netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: netfilter-devel@vger.kernel.org
Cc: Florian Westphal <fw@strlen.de>
Subject: [iptables PATCH 7/7] ebtables: Fix MAC address match translation
Date: Thu,  1 Dec 2022 17:39:16 +0100	[thread overview]
Message-ID: <20221201163916.30808-8-phil@nwl.cc> (raw)
In-Reply-To: <20221201163916.30808-1-phil@nwl.cc>

If a mask was present, ebtables-translate would emit illegal syntax.

Fixes: 5e2b473a64bc7 ("xtables-compat: extend generic tests for masks and wildcards")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 extensions/generic.txlate | 2 +-
 iptables/nft-bridge.c     | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/extensions/generic.txlate b/extensions/generic.txlate
index d7ddf6a39762e..c24ed1568884b 100644
--- a/extensions/generic.txlate
+++ b/extensions/generic.txlate
@@ -65,7 +65,7 @@ ebtables-translate -A FORWARD ! -i iname --logical-in ilogname -o out+ --logical
 nft 'add rule bridge filter FORWARD iifname != "iname" meta ibrname "ilogname" oifname "out*" meta obrname "lout*" ether daddr 01:02:03:04:de:af counter'
 
 ebtables-translate -I INPUT -p ip -d 1:2:3:4:5:6/ff:ff:ff:ff:00:00
-nft 'insert rule bridge filter INPUT ether type 0x800 ether daddr 01:02:03:04:00:00 and ff:ff:ff:ff:00:00 == 01:02:03:04:00:00 counter'
+nft 'insert rule bridge filter INPUT ether type 0x800 ether daddr and ff:ff:ff:ff:00:00 == 01:02:03:04:00:00 counter'
 
 ebtables-translate -I INPUT -p Length
 nft 'insert rule bridge filter INPUT ether type < 0x0600 counter'
diff --git a/iptables/nft-bridge.c b/iptables/nft-bridge.c
index 15dfc585c14ab..8ab21bb54772b 100644
--- a/iptables/nft-bridge.c
+++ b/iptables/nft-bridge.c
@@ -861,17 +861,17 @@ static void nft_bridge_xlate_mac(struct xt_xlate *xl, const char *type, bool inv
 
 	xt_xlate_add(xl, "ether %s %s", type, invert ? "!= " : "");
 
-	xlate_mac(xl, mac);
-
 	if (memcmp(mask, one_msk, ETH_ALEN)) {
 		int i;
-		xt_xlate_add(xl, " and ");
+		xt_xlate_add(xl, "and");
 
 		xlate_mac(xl, mask);
 
 		xt_xlate_add(xl, " == %02x", mac[0] & mask[0]);
 		for (i=1; i < ETH_ALEN; i++)
 			xt_xlate_add(xl, ":%02x", mac[i] & mask[i]);
+	} else {
+		xlate_mac(xl, mac);
 	}
 }
 
-- 
2.38.0


  parent reply	other threads:[~2022-12-01 16:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-01 16:39 [iptables PATCH 0/7] tests: xlate: generic.txlate to pass replay test Phil Sutter
2022-12-01 16:39 ` [iptables PATCH 1/7] ebtables: Implement --check command Phil Sutter
2022-12-08 21:40   ` Pablo Neira Ayuso
2022-12-09  0:41     ` Phil Sutter
2022-12-09 15:23       ` Pablo Neira Ayuso
2022-12-09 16:51         ` Phil Sutter
2022-12-09 20:09           ` Pablo Neira Ayuso
2022-12-01 16:39 ` [iptables PATCH 2/7] tests: xlate: Use --check to verify replay Phil Sutter
2022-12-01 16:39 ` [iptables PATCH 3/7] nft: Fix for comparing ifname matches against nft-generated ones Phil Sutter
2022-12-01 16:39 ` [iptables PATCH 4/7] nft: Fix match generator for '! -i +' Phil Sutter
2022-12-08 12:23   ` Pablo Neira Ayuso
2022-12-08 13:19     ` Phil Sutter
2022-12-08 20:31       ` Pablo Neira Ayuso
2022-12-09  0:25         ` Phil Sutter
2022-12-01 16:39 ` [iptables PATCH 5/7] nft: Recognize INVAL/D interface name Phil Sutter
2022-12-01 16:39 ` [iptables PATCH 6/7] xtables-translate: Fix for interfaces with asterisk mid-string Phil Sutter
2022-12-01 16:39 ` Phil Sutter [this message]
2022-12-02  0:46 ` [iptables PATCH 0/7] tests: xlate: generic.txlate to pass replay test Phil Sutter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221201163916.30808-8-phil@nwl.cc \
    --to=phil@nwl.cc \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).