Blame SOURCES/0048-Revert-ebtables-use-extrapositioned-negation-consist.patch

1dc35b
From af890b239555d52c269d224ada6382381320585d Mon Sep 17 00:00:00 2001
8cce6c
From: Phil Sutter <phil@nwl.cc>
8cce6c
Date: Tue, 5 Feb 2019 18:18:02 +0100
8cce6c
Subject: [PATCH] Revert "ebtables: use extrapositioned negation consistently"
8cce6c
8cce6c
This reverts commit 5f508b76a0cebaf91965ffa678089222e2d47964.
8cce6c
8cce6c
While attempts at unifying syntax between arp-, eb- and iptables-nft
8cce6c
increase the opportunity for more code-sharing, they are problematic
8cce6c
when it comes to compatibility. Accepting the old syntax on input helps,
8cce6c
but due to the fact that neither arptables nor ebtables support --check
8cce6c
command we must expect for users to test existence of a rule by
8cce6c
comparing input with output. If that happens in a script, deviating from
8cce6c
the old syntax in output has a high chance of breaking it.
8cce6c
8cce6c
Therefore revert Florian's patch changing inversion character position
8cce6c
in output and review the old code for consistency - the only thing
8cce6c
changed on top of the actual revert is ebtables' own copy of
8cce6c
print_iface() to make it adhere to the intrapositioned negation scheme
8cce6c
used throughout ebtables.
8cce6c
8cce6c
Added extension tests by the reverted commit have been kept.
8cce6c
8cce6c
Signed-off-by: Phil Sutter <phil@nwl.cc>
8cce6c
Signed-off-by: Florian Westphal <fw@strlen.de>
8cce6c
(cherry picked from commit 35b22e82fa62e10950d8e0fa53a755d4abadf346)
8cce6c
Signed-off-by: Phil Sutter <psutter@redhat.com>
8cce6c
---
1dc35b
 extensions/libebt_802_3.c    |  4 ++--
1dc35b
 extensions/libebt_802_3.t    |  2 +-
1dc35b
 extensions/libebt_arp.c      | 14 +++++++-------
1dc35b
 extensions/libebt_arp.t      |  8 ++++----
1dc35b
 extensions/libebt_ip.c       | 16 ++++++++--------
1dc35b
 extensions/libebt_ip.t       |  6 +++---
1dc35b
 extensions/libebt_ip6.c      | 14 +++++++-------
1dc35b
 extensions/libebt_ip6.t      |  6 +++---
1dc35b
 extensions/libebt_mark_m.c   |  2 +-
1dc35b
 extensions/libebt_mark_m.t   |  4 ++--
1dc35b
 extensions/libebt_pkttype.c  |  5 +----
1dc35b
 extensions/libebt_pkttype.t  | 13 +++++++------
1dc35b
 extensions/libebt_standard.t |  4 ++--
1dc35b
 extensions/libebt_stp.c      |  5 ++---
1dc35b
 extensions/libebt_vlan.c     | 13 ++++---------
1dc35b
 extensions/libebt_vlan.t     | 10 +++++-----
1dc35b
 iptables/nft-bridge.c        |  6 +++---
1dc35b
 17 files changed, 62 insertions(+), 70 deletions(-)
8cce6c
8cce6c
diff --git a/extensions/libebt_802_3.c b/extensions/libebt_802_3.c
8cce6c
index 9e91d05262591..f05d02ead5a4a 100644
8cce6c
--- a/extensions/libebt_802_3.c
8cce6c
+++ b/extensions/libebt_802_3.c
8cce6c
@@ -98,15 +98,15 @@ static void br802_3_print(const void *ip, const struct xt_entry_match *match,
8cce6c
 	struct ebt_802_3_info *info = (struct ebt_802_3_info *)match->data;
8cce6c
 
8cce6c
 	if (info->bitmask & EBT_802_3_SAP) {
8cce6c
+		printf("--802_3-sap ");
8cce6c
 		if (info->invflags & EBT_802_3_SAP)
8cce6c
 			printf("! ");
8cce6c
-		printf("--802_3-sap ");
8cce6c
 		printf("0x%.2x ", info->sap);
8cce6c
 	}
8cce6c
 	if (info->bitmask & EBT_802_3_TYPE) {
8cce6c
+		printf("--802_3-type ");
8cce6c
 		if (info->invflags & EBT_802_3_TYPE)
8cce6c
 			printf("! ");
8cce6c
-		printf("--802_3-type ");
8cce6c
 		printf("0x%.4x ", ntohs(info->type));
8cce6c
 	}
8cce6c
 }
1dc35b
diff --git a/extensions/libebt_802_3.t b/extensions/libebt_802_3.t
1dc35b
index 61081bd6983a8..ddfb2f0a72baf 100644
1dc35b
--- a/extensions/libebt_802_3.t
1dc35b
+++ b/extensions/libebt_802_3.t
1dc35b
@@ -1,3 +1,3 @@
1dc35b
 :INPUT,FORWARD,OUTPUT
1dc35b
-! --802_3-sap 0x0a -j CONTINUE;=;OK
1dc35b
+--802_3-sap ! 0x0a -j CONTINUE;=;OK
1dc35b
 --802_3-type 0x000a -j RETURN;=;OK
8cce6c
diff --git a/extensions/libebt_arp.c b/extensions/libebt_arp.c
8cce6c
index c1b0ab1db0cf1..a062b7e7e5864 100644
8cce6c
--- a/extensions/libebt_arp.c
8cce6c
+++ b/extensions/libebt_arp.c
8cce6c
@@ -338,51 +338,51 @@ static void brarp_print(const void *ip, const struct xt_entry_match *match, int
8cce6c
 
8cce6c
 	if (arpinfo->bitmask & EBT_ARP_OPCODE) {
8cce6c
 		int opcode = ntohs(arpinfo->opcode);
8cce6c
+		printf("--arp-op ");
8cce6c
 		if (arpinfo->invflags & EBT_ARP_OPCODE)
8cce6c
 			printf("! ");
8cce6c
-		printf("--arp-op ");
8cce6c
 		if (opcode > 0 && opcode <= ARRAY_SIZE(opcodes))
8cce6c
 			printf("%s ", opcodes[opcode - 1]);
8cce6c
 		else
8cce6c
 			printf("%d ", opcode);
8cce6c
 	}
8cce6c
 	if (arpinfo->bitmask & EBT_ARP_HTYPE) {
8cce6c
+		printf("--arp-htype ");
8cce6c
 		if (arpinfo->invflags & EBT_ARP_HTYPE)
8cce6c
 			printf("! ");
8cce6c
-		printf("--arp-htype ");
8cce6c
 		printf("%d ", ntohs(arpinfo->htype));
8cce6c
 	}
8cce6c
 	if (arpinfo->bitmask & EBT_ARP_PTYPE) {
8cce6c
+		printf("--arp-ptype ");
8cce6c
 		if (arpinfo->invflags & EBT_ARP_PTYPE)
8cce6c
 			printf("! ");
8cce6c
-		printf("--arp-ptype ");
8cce6c
 		printf("0x%x ", ntohs(arpinfo->ptype));
8cce6c
 	}
8cce6c
 	if (arpinfo->bitmask & EBT_ARP_SRC_IP) {
8cce6c
+		printf("--arp-ip-src ");
8cce6c
 		if (arpinfo->invflags & EBT_ARP_SRC_IP)
8cce6c
 			printf("! ");
8cce6c
-		printf("--arp-ip-src ");
8cce6c
 		printf("%s%s ", xtables_ipaddr_to_numeric((const struct in_addr*) &arpinfo->saddr),
8cce6c
 		       xtables_ipmask_to_numeric((const struct in_addr*)&arpinfo->smsk));
8cce6c
 	}
8cce6c
 	if (arpinfo->bitmask & EBT_ARP_DST_IP) {
8cce6c
+		printf("--arp-ip-dst ");
8cce6c
 		if (arpinfo->invflags & EBT_ARP_DST_IP)
8cce6c
 			printf("! ");
8cce6c
-		printf("--arp-ip-dst ");
8cce6c
 		printf("%s%s ", xtables_ipaddr_to_numeric((const struct in_addr*) &arpinfo->daddr),
8cce6c
 		       xtables_ipmask_to_numeric((const struct in_addr*)&arpinfo->dmsk));
8cce6c
 	}
8cce6c
 	if (arpinfo->bitmask & EBT_ARP_SRC_MAC) {
8cce6c
+		printf("--arp-mac-src ");
8cce6c
 		if (arpinfo->invflags & EBT_ARP_SRC_MAC)
8cce6c
 			printf("! ");
8cce6c
-		printf("--arp-mac-src ");
8cce6c
 		xtables_print_mac_and_mask(arpinfo->smaddr, arpinfo->smmsk);
8cce6c
 		printf(" ");
8cce6c
 	}
8cce6c
 	if (arpinfo->bitmask & EBT_ARP_DST_MAC) {
8cce6c
+		printf("--arp-mac-dst ");
8cce6c
 		if (arpinfo->invflags & EBT_ARP_DST_MAC)
8cce6c
 			printf("! ");
8cce6c
-		printf("--arp-mac-dst ");
8cce6c
 		xtables_print_mac_and_mask(arpinfo->dmaddr, arpinfo->dmmsk);
8cce6c
 		printf(" ");
8cce6c
 	}
1dc35b
diff --git a/extensions/libebt_arp.t b/extensions/libebt_arp.t
1dc35b
index a05ab12dc566f..14ff0f097cfd8 100644
1dc35b
--- a/extensions/libebt_arp.t
1dc35b
+++ b/extensions/libebt_arp.t
1dc35b
@@ -1,11 +1,11 @@
1dc35b
 :INPUT,FORWARD,OUTPUT
1dc35b
 -p ARP --arp-op Request;=;OK
1dc35b
--p ARP ! --arp-htype 1;=;OK
1dc35b
+-p ARP --arp-htype ! 1;=;OK
1dc35b
 -p ARP --arp-ptype 0x2;=;OK
1dc35b
 -p ARP --arp-ip-src 1.2.3.4;=;OK
1dc35b
--p ARP ! --arp-ip-dst 1.2.3.4;=;OK
1dc35b
--p ARP ! --arp-ip-src 0.0.0.0;=;OK
1dc35b
--p ARP ! --arp-ip-dst 0.0.0.0/8;=;OK
1dc35b
+-p ARP ! --arp-ip-dst 1.2.3.4;-p ARP --arp-ip-dst ! 1.2.3.4 -j CONTINUE;OK
1dc35b
+-p ARP --arp-ip-src ! 0.0.0.0;=;OK
1dc35b
+-p ARP --arp-ip-dst ! 0.0.0.0/8;=;OK
1dc35b
 -p ARP --arp-mac-src 00:de:ad:be:ef:00;=;OK
1dc35b
 -p ARP --arp-mac-dst de:ad:be:ef:00:00/ff:ff:ff:ff:00:00;=;OK
1dc35b
 -p ARP --arp-gratuitous;=;OK
8cce6c
diff --git a/extensions/libebt_ip.c b/extensions/libebt_ip.c
8cce6c
index d48704fe1c802..acb9bfcdbbd9f 100644
8cce6c
--- a/extensions/libebt_ip.c
8cce6c
+++ b/extensions/libebt_ip.c
8cce6c
@@ -472,35 +472,35 @@ static void brip_print(const void *ip, const struct xt_entry_match *match,
8cce6c
 	struct in_addr *addrp, *maskp;
8cce6c
 
8cce6c
 	if (info->bitmask & EBT_IP_SOURCE) {
8cce6c
+		printf("--ip-src ");
8cce6c
 		if (info->invflags & EBT_IP_SOURCE)
8cce6c
 			printf("! ");
8cce6c
-		printf("--ip-src ");
8cce6c
 		addrp = (struct in_addr *)&info->saddr;
8cce6c
 		maskp = (struct in_addr *)&info->smsk;
8cce6c
 		printf("%s%s ", xtables_ipaddr_to_numeric(addrp),
8cce6c
 		       xtables_ipmask_to_numeric(maskp));
8cce6c
 	}
8cce6c
 	if (info->bitmask & EBT_IP_DEST) {
8cce6c
+		printf("--ip-dst ");
8cce6c
 		if (info->invflags & EBT_IP_DEST)
8cce6c
 			printf("! ");
8cce6c
-		printf("--ip-dst ");
8cce6c
 		addrp = (struct in_addr *)&info->daddr;
8cce6c
 		maskp = (struct in_addr *)&info->dmsk;
8cce6c
 		printf("%s%s ", xtables_ipaddr_to_numeric(addrp),
8cce6c
 		       xtables_ipmask_to_numeric(maskp));
8cce6c
 	}
8cce6c
 	if (info->bitmask & EBT_IP_TOS) {
8cce6c
+		printf("--ip-tos ");
8cce6c
 		if (info->invflags & EBT_IP_TOS)
8cce6c
 			printf("! ");
8cce6c
-		printf("--ip-tos ");
8cce6c
 		printf("0x%02X ", info->tos);
8cce6c
 	}
8cce6c
 	if (info->bitmask & EBT_IP_PROTO) {
8cce6c
 		struct protoent *pe;
8cce6c
 
8cce6c
+		printf("--ip-proto ");
8cce6c
 		if (info->invflags & EBT_IP_PROTO)
8cce6c
 			printf("! ");
8cce6c
-		printf("--ip-proto ");
8cce6c
 		pe = getprotobynumber(info->protocol);
8cce6c
 		if (pe == NULL) {
8cce6c
 			printf("%d ", info->protocol);
8cce6c
@@ -509,28 +509,28 @@ static void brip_print(const void *ip, const struct xt_entry_match *match,
8cce6c
 		}
8cce6c
 	}
8cce6c
 	if (info->bitmask & EBT_IP_SPORT) {
8cce6c
+		printf("--ip-sport ");
8cce6c
 		if (info->invflags & EBT_IP_SPORT)
8cce6c
 			printf("! ");
8cce6c
-		printf("--ip-sport ");
8cce6c
 		print_port_range(info->sport);
8cce6c
 	}
8cce6c
 	if (info->bitmask & EBT_IP_DPORT) {
8cce6c
+		printf("--ip-dport ");
8cce6c
 		if (info->invflags & EBT_IP_DPORT)
8cce6c
 			printf("! ");
8cce6c
-		printf("--ip-dport ");
8cce6c
 		print_port_range(info->dport);
8cce6c
 	}
8cce6c
 	if (info->bitmask & EBT_IP_ICMP) {
8cce6c
+		printf("--ip-icmp-type ");
8cce6c
 		if (info->invflags & EBT_IP_ICMP)
8cce6c
 			printf("! ");
8cce6c
-		printf("--ip-icmp-type ");
8cce6c
 		ebt_print_icmp_type(icmp_codes, ARRAY_SIZE(icmp_codes),
8cce6c
 				    info->icmp_type, info->icmp_code);
8cce6c
 	}
8cce6c
 	if (info->bitmask & EBT_IP_IGMP) {
8cce6c
+		printf("--ip-igmp-type ");
8cce6c
 		if (info->invflags & EBT_IP_IGMP)
8cce6c
 			printf("! ");
8cce6c
-		printf("--ip-igmp-type ");
8cce6c
 		ebt_print_icmp_type(igmp_types, ARRAY_SIZE(igmp_types),
8cce6c
 				    info->igmp_type, NULL);
8cce6c
 	}
1dc35b
diff --git a/extensions/libebt_ip.t b/extensions/libebt_ip.t
1dc35b
index 01a91a7385fcc..8be5dfbb22309 100644
1dc35b
--- a/extensions/libebt_ip.t
1dc35b
+++ b/extensions/libebt_ip.t
1dc35b
@@ -1,13 +1,13 @@
1dc35b
 :INPUT,FORWARD,OUTPUT
1dc35b
--p ip --ip-src ! 192.168.0.0/24 -j ACCEPT;-p IPv4 ! --ip-src 192.168.0.0/24 -j ACCEPT;OK
1dc35b
+-p ip --ip-src ! 192.168.0.0/24 -j ACCEPT;-p IPv4 --ip-src ! 192.168.0.0/24 -j ACCEPT;OK
1dc35b
 -p IPv4 --ip-dst 10.0.0.1;=;OK
1dc35b
 -p IPv4 --ip-tos 0xFF;=;OK
1dc35b
--p IPv4 ! --ip-tos 0xFF;=;OK
1dc35b
+-p IPv4 --ip-tos ! 0xFF;=;OK
1dc35b
 -p IPv4 --ip-proto tcp --ip-dport 22;=;OK
1dc35b
 -p IPv4 --ip-proto udp --ip-sport 1024:65535;=;OK
1dc35b
 -p IPv4 --ip-proto 253;=;OK
1dc35b
 -p IPv4 --ip-proto icmp --ip-icmp-type echo-request;=;OK
1dc35b
 -p IPv4 --ip-proto icmp --ip-icmp-type 1/1;=;OK
1dc35b
--p ip --ip-protocol icmp --ip-icmp-type ! 1:10;-p IPv4 --ip-proto icmp ! --ip-icmp-type 1:10/0:255 -j CONTINUE;OK
1dc35b
+-p ip --ip-protocol icmp --ip-icmp-type ! 1:10;-p IPv4 --ip-proto icmp --ip-icmp-type ! 1:10/0:255 -j CONTINUE;OK
1dc35b
 --ip-proto icmp --ip-icmp-type 1/1;=;FAIL
1dc35b
 ! -p ip --ip-proto icmp --ip-icmp-type 1/1;=;FAIL
8cce6c
diff --git a/extensions/libebt_ip6.c b/extensions/libebt_ip6.c
8cce6c
index b727764903ffa..b8a5a5d8c3a92 100644
8cce6c
--- a/extensions/libebt_ip6.c
8cce6c
+++ b/extensions/libebt_ip6.c
8cce6c
@@ -399,31 +399,31 @@ static void brip6_print(const void *ip, const struct xt_entry_match *match,
8cce6c
 	struct ebt_ip6_info *ipinfo = (struct ebt_ip6_info *)match->data;
8cce6c
 
8cce6c
 	if (ipinfo->bitmask & EBT_IP6_SOURCE) {
8cce6c
+		printf("--ip6-src ");
8cce6c
 		if (ipinfo->invflags & EBT_IP6_SOURCE)
8cce6c
 			printf("! ");
8cce6c
-		printf("--ip6-src ");
8cce6c
 		printf("%s", xtables_ip6addr_to_numeric(&ipinfo->saddr));
8cce6c
 		printf("%s ", xtables_ip6mask_to_numeric(&ipinfo->smsk));
8cce6c
 	}
8cce6c
 	if (ipinfo->bitmask & EBT_IP6_DEST) {
8cce6c
+		printf("--ip6-dst ");
8cce6c
 		if (ipinfo->invflags & EBT_IP6_DEST)
8cce6c
 			printf("! ");
8cce6c
-		printf("--ip6-dst ");
8cce6c
 		printf("%s", xtables_ip6addr_to_numeric(&ipinfo->daddr));
8cce6c
 		printf("%s ", xtables_ip6mask_to_numeric(&ipinfo->dmsk));
8cce6c
 	}
8cce6c
 	if (ipinfo->bitmask & EBT_IP6_TCLASS) {
8cce6c
+		printf("--ip6-tclass ");
8cce6c
 		if (ipinfo->invflags & EBT_IP6_TCLASS)
8cce6c
 			printf("! ");
8cce6c
-		printf("--ip6-tclass ");
8cce6c
 		printf("0x%02X ", ipinfo->tclass);
8cce6c
 	}
8cce6c
 	if (ipinfo->bitmask & EBT_IP6_PROTO) {
8cce6c
 		struct protoent *pe;
8cce6c
 
8cce6c
+		printf("--ip6-proto ");
8cce6c
 		if (ipinfo->invflags & EBT_IP6_PROTO)
8cce6c
 			printf("! ");
8cce6c
-		printf("--ip6-proto ");
8cce6c
 		pe = getprotobynumber(ipinfo->protocol);
8cce6c
 		if (pe == NULL) {
8cce6c
 			printf("%d ", ipinfo->protocol);
8cce6c
@@ -432,21 +432,21 @@ static void brip6_print(const void *ip, const struct xt_entry_match *match,
8cce6c
 		}
8cce6c
 	}
8cce6c
 	if (ipinfo->bitmask & EBT_IP6_SPORT) {
8cce6c
+		printf("--ip6-sport ");
8cce6c
 		if (ipinfo->invflags & EBT_IP6_SPORT)
8cce6c
 			printf("! ");
8cce6c
-		printf("--ip6-sport ");
8cce6c
 		print_port_range(ipinfo->sport);
8cce6c
 	}
8cce6c
 	if (ipinfo->bitmask & EBT_IP6_DPORT) {
8cce6c
+		printf("--ip6-dport ");
8cce6c
 		if (ipinfo->invflags & EBT_IP6_DPORT)
8cce6c
 			printf("! ");
8cce6c
-		printf("--ip6-dport ");
8cce6c
 		print_port_range(ipinfo->dport);
8cce6c
 	}
8cce6c
 	if (ipinfo->bitmask & EBT_IP6_ICMP6) {
8cce6c
+		printf("--ip6-icmp-type ");
8cce6c
 		if (ipinfo->invflags & EBT_IP6_ICMP6)
8cce6c
 			printf("! ");
8cce6c
-		printf("--ip6-icmp-type ");
8cce6c
 		print_icmp_type(ipinfo->icmpv6_type, ipinfo->icmpv6_code);
8cce6c
 	}
8cce6c
 }
1dc35b
diff --git a/extensions/libebt_ip6.t b/extensions/libebt_ip6.t
1dc35b
index 6b3221ea58f62..fa1038af25649 100644
1dc35b
--- a/extensions/libebt_ip6.t
1dc35b
+++ b/extensions/libebt_ip6.t
1dc35b
@@ -1,15 +1,15 @@
1dc35b
 :INPUT,FORWARD,OUTPUT
1dc35b
--p ip6 ! --ip6-src dead::beef/64 -j ACCEPT;-p IPv6 ! --ip6-src dead::/64 -j ACCEPT;OK
1dc35b
+-p ip6 --ip6-src ! dead::beef/64 -j ACCEPT;-p IPv6 --ip6-src ! dead::/64 -j ACCEPT;OK
1dc35b
 -p IPv6 --ip6-dst dead:beef::/64 -j ACCEPT;=;OK
1dc35b
 -p IPv6 --ip6-dst f00:ba::;=;OK
1dc35b
 -p IPv6 --ip6-tclass 0xFF;=;OK
1dc35b
 -p IPv6 --ip6-proto tcp --ip6-dport 22;=;OK
1dc35b
--p IPv6 --ip6-proto tcp ! --ip6-dport 22;=;OK
1dc35b
+-p IPv6 --ip6-proto tcp --ip6-dport ! 22;=;OK
1dc35b
 -p IPv6 --ip6-proto udp --ip6-sport 1024:65535;=;OK
1dc35b
 -p IPv6 --ip6-proto 253;=;OK
1dc35b
 -p IPv6 --ip6-proto ipv6-icmp --ip6-icmp-type echo-request -j CONTINUE;=;OK
1dc35b
 -p IPv6 --ip6-proto ipv6-icmp --ip6-icmp-type echo-request;=;OK
1dc35b
 -p ip6 --ip6-protocol icmpv6 --ip6-icmp-type 1/1;-p IPv6 --ip6-proto ipv6-icmp --ip6-icmp-type communication-prohibited -j CONTINUE;OK
1dc35b
--p IPv6 --ip6-proto ipv6-icmp ! --ip6-icmp-type 1:10/0:255;=;OK
1dc35b
+-p IPv6 --ip6-proto ipv6-icmp --ip6-icmp-type ! 1:10/0:255;=;OK
1dc35b
 --ip6-proto ipv6-icmp ! --ip6-icmp-type 1:10/0:255;=;FAIL
1dc35b
 ! -p IPv6 --ip6-proto ipv6-icmp ! --ip6-icmp-type 1:10/0:255;=;FAIL
8cce6c
diff --git a/extensions/libebt_mark_m.c b/extensions/libebt_mark_m.c
8cce6c
index 64ad926f19959..2462d0af7d0bc 100644
8cce6c
--- a/extensions/libebt_mark_m.c
8cce6c
+++ b/extensions/libebt_mark_m.c
8cce6c
@@ -86,9 +86,9 @@ static void brmark_m_print(const void *ip, const struct xt_entry_match *match,
8cce6c
 {
8cce6c
 	struct ebt_mark_m_info *info = (struct ebt_mark_m_info *)match->data;
8cce6c
 
8cce6c
+	printf("--mark ");
8cce6c
 	if (info->invert)
8cce6c
 		printf("! ");
8cce6c
-	printf("--mark ");
8cce6c
 	if (info->bitmask == EBT_MARK_OR)
8cce6c
 		printf("/0x%lx ", info->mask);
8cce6c
 	else if (info->mask != 0xffffffff)
1dc35b
diff --git a/extensions/libebt_mark_m.t b/extensions/libebt_mark_m.t
1dc35b
index 9ad41704fbb82..00035427f8b6e 100644
1dc35b
--- a/extensions/libebt_mark_m.t
1dc35b
+++ b/extensions/libebt_mark_m.t
1dc35b
@@ -1,6 +1,6 @@
1dc35b
 :INPUT,FORWARD,OUTPUT
1dc35b
 --mark 42;--mark 0x2a;OK
1dc35b
---mark ! 42;! --mark 0x2a;OK
1dc35b
+--mark ! 42;--mark ! 0x2a;OK
1dc35b
 --mark 42/0xff;--mark 0x2a/0xff;OK
1dc35b
-! --mark 0x1/0xff;=;OK
1dc35b
+--mark ! 0x1/0xff;=;OK
1dc35b
 --mark /0x2;=;OK
8cce6c
diff --git a/extensions/libebt_pkttype.c b/extensions/libebt_pkttype.c
8cce6c
index 265674d19bde6..4e2d19de7983b 100644
8cce6c
--- a/extensions/libebt_pkttype.c
8cce6c
+++ b/extensions/libebt_pkttype.c
8cce6c
@@ -75,10 +75,7 @@ static void brpkttype_print(const void *ip, const struct xt_entry_match *match,
8cce6c
 {
8cce6c
 	struct ebt_pkttype_info *pt = (struct ebt_pkttype_info *)match->data;
8cce6c
 
8cce6c
-	if (pt->invert)
8cce6c
-		printf("! ");
8cce6c
-
8cce6c
-	printf("--pkttype-type ");
8cce6c
+	printf("--pkttype-type %s", pt->invert ? "! " : "");
8cce6c
 
8cce6c
 	if (pt->pkt_type < ARRAY_SIZE(classes))
8cce6c
 		printf("%s ", classes[pt->pkt_type]);
1dc35b
diff --git a/extensions/libebt_pkttype.t b/extensions/libebt_pkttype.t
1dc35b
index f870f5c7f05c4..e3b95ded4903e 100644
1dc35b
--- a/extensions/libebt_pkttype.t
1dc35b
+++ b/extensions/libebt_pkttype.t
1dc35b
@@ -1,13 +1,14 @@
1dc35b
 :INPUT,FORWARD,OUTPUT
1dc35b
+! --pkttype-type host;--pkttype-type ! host -j CONTINUE;OK
1dc35b
 --pkttype-type host;=;OK
1dc35b
-! --pkttype-type host;=;OK
1dc35b
+--pkttype-type ! host;=;OK
1dc35b
 --pkttype-type broadcast;=;OK
1dc35b
-! --pkttype-type broadcast;=;OK
1dc35b
+--pkttype-type ! broadcast;=;OK
1dc35b
 --pkttype-type multicast;=;OK
1dc35b
-! --pkttype-type multicast;=;OK
1dc35b
+--pkttype-type ! multicast;=;OK
1dc35b
 --pkttype-type otherhost;=;OK
1dc35b
-! --pkttype-type otherhost;=;OK
1dc35b
+--pkttype-type ! otherhost;=;OK
1dc35b
 --pkttype-type outgoing;=;OK
1dc35b
-! --pkttype-type outgoing;=;OK
1dc35b
+--pkttype-type ! outgoing;=;OK
1dc35b
 --pkttype-type loopback;=;OK
1dc35b
-! --pkttype-type loopback;=;OK
1dc35b
+--pkttype-type ! loopback;=;OK
1dc35b
diff --git a/extensions/libebt_standard.t b/extensions/libebt_standard.t
1dc35b
index 72081fd6575a0..0d678fb23c439 100644
1dc35b
--- a/extensions/libebt_standard.t
1dc35b
+++ b/extensions/libebt_standard.t
1dc35b
@@ -6,6 +6,6 @@
1dc35b
 -d de:ad:be:ef:00:00 -j CONTINUE;=;OK
1dc35b
 -d de:ad:be:ef:0:00/ff:ff:ff:ff:0:0 -j DROP;-d de:ad:be:ef:00:00/ff:ff:ff:ff:00:00 -j DROP;OK
1dc35b
 -p ARP -j ACCEPT;=;OK
1dc35b
-! -p ARP -j ACCEPT;=;OK
1dc35b
+-p ! ARP -j ACCEPT;=;OK
1dc35b
 -p 0 -j ACCEPT;=;FAIL
1dc35b
-! -p 0 -j ACCEPT;=;FAIL
1dc35b
+-p ! 0 -j ACCEPT;=;FAIL
8cce6c
diff --git a/extensions/libebt_stp.c b/extensions/libebt_stp.c
8cce6c
index 33e4c8d9c615d..06cf93b8d8449 100644
8cce6c
--- a/extensions/libebt_stp.c
8cce6c
+++ b/extensions/libebt_stp.c
8cce6c
@@ -307,9 +307,8 @@ static void brstp_print(const void *ip, const struct xt_entry_match *match,
8cce6c
 	for (i = 0; i < STP_NUMOPS; i++) {
8cce6c
 		if (!(stpinfo->bitmask & (1 << i)))
8cce6c
 			continue;
8cce6c
-		if (stpinfo->invflags & (1 << i))
8cce6c
-			printf("! ");
8cce6c
-		printf("--%s ", brstp_opts[i].name);
8cce6c
+		printf("--%s %s", brstp_opts[i].name,
8cce6c
+		       (stpinfo->invflags & (1 << i)) ? "! " : "");
8cce6c
 		if (EBT_STP_TYPE == (1 << i)) {
8cce6c
 			if (stpinfo->type == BPDU_TYPE_CONFIG)
8cce6c
 				printf("%s", BPDU_TYPE_CONFIG_STRING);
8cce6c
diff --git a/extensions/libebt_vlan.c b/extensions/libebt_vlan.c
8cce6c
index 4a2eb7126895e..a2a9dcce531ce 100644
8cce6c
--- a/extensions/libebt_vlan.c
8cce6c
+++ b/extensions/libebt_vlan.c
8cce6c
@@ -108,19 +108,14 @@ static void brvlan_print(const void *ip, const struct xt_entry_match *match,
8cce6c
 	struct ebt_vlan_info *vlaninfo = (struct ebt_vlan_info *) match->data;
8cce6c
 
8cce6c
 	if (vlaninfo->bitmask & EBT_VLAN_ID) {
8cce6c
-		if (vlaninfo->invflags & EBT_VLAN_ID)
8cce6c
-			printf("! ");
8cce6c
-		printf("--vlan-id %d ", vlaninfo->id);
8cce6c
+		printf("--vlan-id %s%d ", (vlaninfo->invflags & EBT_VLAN_ID) ? "! " : "", vlaninfo->id);
8cce6c
 	}
8cce6c
 	if (vlaninfo->bitmask & EBT_VLAN_PRIO) {
8cce6c
-		if (vlaninfo->invflags & EBT_VLAN_PRIO)
8cce6c
-			printf("! ");
8cce6c
-		printf("--vlan-prio %d ", vlaninfo->prio);
8cce6c
+		printf("--vlan-prio %s%d ", (vlaninfo->invflags & EBT_VLAN_PRIO) ? "! " : "", vlaninfo->prio);
8cce6c
 	}
8cce6c
 	if (vlaninfo->bitmask & EBT_VLAN_ENCAP) {
8cce6c
-		if (vlaninfo->invflags & EBT_VLAN_ENCAP)
8cce6c
-			printf("! ");
8cce6c
-		printf("--vlan-encap %4.4X ", ntohs(vlaninfo->encap));
8cce6c
+		printf("--vlan-encap %s", (vlaninfo->invflags & EBT_VLAN_ENCAP) ? "! " : "");
8cce6c
+		printf("%4.4X ", ntohs(vlaninfo->encap));
8cce6c
 	}
8cce6c
 }
8cce6c
 
1dc35b
diff --git a/extensions/libebt_vlan.t b/extensions/libebt_vlan.t
1dc35b
index 106374cd9cb80..81c795854fca0 100644
1dc35b
--- a/extensions/libebt_vlan.t
1dc35b
+++ b/extensions/libebt_vlan.t
1dc35b
@@ -1,13 +1,13 @@
1dc35b
 :INPUT,FORWARD,OUTPUT
1dc35b
 -p 802_1Q --vlan-id 42;=;OK
1dc35b
--p 802_1Q ! --vlan-id 42;=;OK
1dc35b
+-p 802_1Q --vlan-id ! 42;=;OK
1dc35b
 -p 802_1Q --vlan-prio 1;=;OK
1dc35b
--p 802_1Q ! --vlan-prio 1;=;OK
1dc35b
+-p 802_1Q --vlan-prio ! 1;=;OK
1dc35b
 -p 802_1Q --vlan-encap ip;-p 802_1Q --vlan-encap 0800 -j CONTINUE;OK
1dc35b
 -p 802_1Q --vlan-encap 0800 ;=;OK
1dc35b
--p 802_1Q ! --vlan-encap 0800 ;=;OK
1dc35b
--p 802_1Q --vlan-encap IPv6 ! --vlan-id 1;-p 802_1Q ! --vlan-id 1 --vlan-encap 86DD -j CONTINUE;OK
1dc35b
--p 802_1Q ! --vlan-id 1 --vlan-encap 86DD;=;OK
1dc35b
+-p 802_1Q --vlan-encap ! 0800 ;=;OK
1dc35b
+-p 802_1Q --vlan-encap IPv6 ! --vlan-id 1;-p 802_1Q --vlan-id ! 1 --vlan-encap 86DD -j CONTINUE;OK
1dc35b
+-p 802_1Q --vlan-id ! 1 --vlan-encap 86DD;=;OK
1dc35b
 --vlan-encap ip;=;FAIL
1dc35b
 --vlan-id 2;=;FAIL
1dc35b
 --vlan-prio 1;=;FAIL
8cce6c
diff --git a/iptables/nft-bridge.c b/iptables/nft-bridge.c
8cce6c
index 43b3e3e9649b8..2b79ca951cd92 100644
8cce6c
--- a/iptables/nft-bridge.c
8cce6c
+++ b/iptables/nft-bridge.c
8cce6c
@@ -344,7 +344,7 @@ static void nft_rule_to_ebtables_command_state(const struct nftnl_rule *r,
8cce6c
 static void print_iface(const char *option, const char *name, bool invert)
8cce6c
 {
8cce6c
 	if (*name)
8cce6c
-		printf("%s%s %s ", invert ? "! " : "", option, name);
8cce6c
+		printf("%s%s %s ", option, invert ? " !" : "", name);
8cce6c
 }
8cce6c
 
8cce6c
 static void nft_bridge_print_table_header(const char *tablename)
8cce6c
@@ -389,9 +389,9 @@ static void print_mac(char option, const unsigned char *mac,
8cce6c
 		      const unsigned char *mask,
8cce6c
 		      bool invert)
8cce6c
 {
8cce6c
+	printf("-%c ", option);
8cce6c
 	if (invert)
8cce6c
 		printf("! ");
8cce6c
-	printf("-%c ", option);
8cce6c
 	ebt_print_mac_and_mask(mac, mask);
8cce6c
 	printf(" ");
8cce6c
 }
8cce6c
@@ -406,9 +406,9 @@ static void print_protocol(uint16_t ethproto, bool invert, unsigned int bitmask)
8cce6c
 	if (bitmask & EBT_NOPROTO)
8cce6c
 		return;
8cce6c
 
8cce6c
+	printf("-p ");
8cce6c
 	if (invert)
8cce6c
 		printf("! ");
8cce6c
-	printf("-p ");
8cce6c
 
8cce6c
 	if (bitmask & EBT_802_3) {
8cce6c
 		printf("length ");
8cce6c
-- 
1dc35b
2.21.0
8cce6c