arptables: Fix parsing of inverted 'arp operation' match
Phil Sutter
reviewerPATCH 1/3 arptables: Fix parsing of inverted 'arp operation' match
The wrong bit was set in 'invflags', probably due to copy'n'paste from the previous case.
--- iptables/nft-arp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
iptables/nft-arp.c +1 -1
@@ -244,7 +244,7 @@ static void nft_arp_parse_payload(struct nft_xt_ctx *ctx, fw->arp.arhln = ar_hln; fw->arp.arhln_mask =0xff ;if (inv) - fw->arp.invflags |=IPT_INV_ARPOP ; + fw->arp.invflags |=IPT_INV_ARPHLN ;break ;case offsetof(struct arphdr , ar_pln):get_cmp_data (e, &ar_pln,sizeof (ar_pln), &inv);
Signature · 1 line
2.40.0
Phil Sutter
reviewerPATCH 2/3 arptables: Don't omit standard matches if inverted
Inverted --h-len and --h-type matches were omitted from output by accident if they matched on their standard value.
--- iptables/nft-arp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
iptables/nft-arp.c +4 -2
@@ -408,7 +408,8 @@ static void nft_arp_print_rule_details(const struct iptables_command_state *cs, after_devdst: -if (fw->arp.arhln_mask !=255 || fw->arp.arhln !=6 ) { +if (fw->arp.arhln_mask !=255 || fw->arp.arhln !=6 || + fw->arp.invflags &IPT_INV_ARPHLN ) {printf ("%s%s" , sep, fw->arp.invflags &IPT_INV_ARPHLN ?"! " :"" );printf ("--h-length %d" , fw->arp.arhln);
@@ -432,7 +433,8 @@ static void nft_arp_print_rule_details(const struct iptables_command_state *cs, sep =" " ; } -if (fw->arp.arhrd_mask !=65535 || fw->arp.arhrd !=htons (1 )) { +if (fw->arp.arhrd_mask !=65535 || fw->arp.arhrd !=htons (1 ) || + fw->arp.invflags &IPT_INV_ARPHRD ) {uint16_t tmp =ntohs (fw->arp.arhrd); printf("%s%s", sep, fw->arp.invflags & IPT_INV_ARPHRD
Signature · 1 line
2.40.0
Phil Sutter
reviewerPATCH 3/3 xshared: Fix parsing of option arguments in same word
In reply to Phil SutterWhen merging commandline parsers, a decision between 'argv[optind - 1]' and 'optarg' had to be made in some spots. While the implementation of check_inverse() required the former, use of the latter allows for the common syntax of '--opt=arg' or even '-oarg' as 'optarg' will point at the suffix while 'argv[optind - 1]' will just point at the following option.
Fix the mess by making check_inverse() update optarg pointer if needed so calling code may refer to and always correct 'optarg'.
--- extensions/libarpt_standard.t | 2 ++ extensions/libxt_standard.t | 3 ++ iptables/xshared.c | 61 +++++++++++++++++------------------ 3 files changed, 35 insertions(+), 31 deletions(-)
extensions/libarpt_standard.t +2 -0
@@ -12,3 +12,5 @@ -i lo --destination-mac 11:22:33:44:55:66;-i lo --dst-mac 11:22:33:44:55:66;OK --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
extensions/libxt_standard.t +3 -0
@@ -21,3 +21,6 @@ -s 10.11.12.13/255.128.0.0;-s 10.0.0.0/9;OK -s 10.11.12.13/255.0.255.0;-s 10.0.12.0/255.0.255.0;OK -s 10.11.12.13/255.0.12.0;-s 10.0.12.0/255.0.12.0;OK +:FORWARD +--protocol=tcp --source=1.2.3.4 --destination=5.6.7.8/32 --in-interface=eth0 --out-interface=eth1 --jump=ACCEPT;-s 1.2.3.4/32 -d 5.6.7.8/32 -i eth0 -o eth1 -p tcp -j ACCEPT;OK +-ptcp -s1.2.3.4 -d5.6.7.8/32 -ieth0 -oeth1 -jACCEPT;-s 1.2.3.4/32 -d 5.6.7.8/32 -i eth0 -o eth1 -p tcp -j ACCEPT;OK
iptables/xshared.c +30 -31
153 lines not on this page · raw message
Signature · 1 line
2.40.0
Phil Sutter
reviewerQuoted 5 lines · Phil Sutter
The wrong bit was set in 'invflags', probably due to copy'n'paste from the previous case.
Fixes 84909d171585d ("xtables: bootstrap ARP compatibility layer for nftables")Signed-off-by Phil Sutter <[email protected]>
Series applied.