]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
ebtables: Fix MAC address match translation
authorPhil Sutter <phil@nwl.cc>
Thu, 1 Dec 2022 12:03:49 +0000 (13:03 +0100)
committerPhil Sutter <phil@nwl.cc>
Fri, 2 Dec 2022 00:47:32 +0000 (01:47 +0100)
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
iptables/nft-bridge.c

index d7ddf6a39762e9808652f9a1a2f1355e49cce58e..c24ed1568884b8c638a2416819fce6b7fcddbc3f 100644 (file)
@@ -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'
index 8d002c17b53d36d329a439d4d671162b881c3e42..e223d19765f90a054c73eacd983aa40550c80478 100644 (file)
@@ -866,17 +866,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);
        }
 }