]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
arptables: Fix formatting of numeric --h-type output
authorPhil Sutter <phil@nwl.cc>
Wed, 8 Nov 2023 02:58:42 +0000 (03:58 +0100)
committerPhil Sutter <phil@nwl.cc>
Thu, 9 Nov 2023 14:55:16 +0000 (15:55 +0100)
Arptables expects numeric arguments to --h-type option in hexadecimal
form, even if no '0x'-prefix is present. In contrast, it prints such
values in decimal. This is not just inconsistent, but makes it
impossible to save and later restore a ruleset without fixing up the
values in between.

Assuming that the parser side can't be changed for compatibility
reasons, fix the output side instead.

This is a day 1 bug and present in legacy arptables as well, so treat
this as a "feature" of arptables-nft and omit a Fixes: tag.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Florian Westphal <fw@strlen.de>
extensions/libarpt_standard.t
iptables/nft-arp.c

index 007fa2b8335e872341c53930d2210571cc84d54b..a2b0a36a4a6bfd3aba0fe2d59c4e11240af668fb 100644 (file)
@@ -13,4 +13,6 @@
 --source-mac Unicast;--src-mac 00:00:00:00:00:00/01:00:00:00:00:00;OK
 ! --src-mac Multicast;! --src-mac 01:00:00:00:00:00/01:00:00:00:00:00;OK
 --src-mac=01:02:03:04:05:06 --dst-mac=07:08:09:0A:0B:0C --h-length=6 --opcode=Request --h-type=Ethernet --proto-type=ipv4;--src-mac 01:02:03:04:05:06 --dst-mac 07:08:09:0a:0b:0c --opcode 1 --proto-type 0x800;OK
---src-mac ! 01:02:03:04:05:06 --dst-mac ! 07:08:09:0A:0B:0C --h-length ! 6 --opcode ! Request --h-type ! Ethernet --proto-type ! ipv4;! --src-mac 01:02:03:04:05:06 ! --dst-mac 07:08:09:0a:0b:0c ! --h-length 6 ! --opcode 1 ! --h-type 1 ! --proto-type 0x800;OK
+--src-mac ! 01:02:03:04:05:06 --dst-mac ! 07:08:09:0A:0B:0C --h-length ! 6 --opcode ! Request --h-type ! Ethernet --proto-type ! ipv4;! --src-mac 01:02:03:04:05:06 ! --dst-mac 07:08:09:0a:0b:0c ! --h-length 6 ! --opcode 1 ! --h-type 0x1 ! --proto-type 0x800;OK
+--h-type 10;--h-type 0x10;OK
+--h-type 0x10;=;OK
index 8521cc4f15c1dc3e19f9d7273700f400e450fee2..83aec5003004ecb291a3bf7eb70048a6637bc6f0 100644 (file)
@@ -323,9 +323,9 @@ after_devdst:
                if (tmp == 1 && !(format & FMT_NUMERIC))
                        printf("--h-type %s", "Ethernet");
                else
-                       printf("--h-type %u", tmp);
+                       printf("--h-type 0x%x", tmp);
                if (fw->arp.arhrd_mask != 65535)
-                       printf("/%d", ntohs(fw->arp.arhrd_mask));
+                       printf("/0x%x", ntohs(fw->arp.arhrd_mask));
                sep = " ";
        }