]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: rename ibrportname, obrportname
authorFlorian Westphal <fw@strlen.de>
Fri, 13 Apr 2018 12:36:32 +0000 (14:36 +0200)
committerFlorian Westphal <fw@strlen.de>
Tue, 17 Apr 2018 21:23:06 +0000 (23:23 +0200)
For bridge, iifname is the port name, whereas 'ibrport' is the
logical name of the bridge ("br0") the port ("iifname") is enslaved to.

So, 'ibrport' is a misnomer.

libnftl calls these 'bri_iifname' and 'bri_oifname', which is good
but using 'briiifname' in nft is rather ugly, so use 'ibridgename'
and 'obridgename' instead.

Old names are still recognized, listing shows the new names.

Signed-off-by: Florian Westphal <fw@strlen.de>
doc/nft.xml
src/meta.c
src/parser_bison.y
src/scanner.l
tests/py/bridge/meta.t [new file with mode: 0644]
tests/py/bridge/meta.t.payload [new file with mode: 0644]
tests/py/inet/meta.t
tests/py/ip/meta.t

index 88d39415820c0a2c29290069102399532d15b23c..47e106900d3563a548436d6e3ea0fd029d7100e5 100644 (file)
@@ -2738,8 +2738,8 @@ filter output icmpv6 type { echo-request, echo-reply }
                                                <arg>skgid</arg>
                                                <arg>nftrace</arg>
                                                <arg>rtclassid</arg>
-                                               <arg>ibriport</arg>
-                                               <arg>obriport</arg>
+                                               <arg>ibridgename</arg>
+                                               <arg>obridgename</arg>
                                                <arg>pkttype</arg>
                                                <arg>cpu</arg>
                                                <arg>iifgroup</arg>
@@ -2853,12 +2853,12 @@ filter output icmpv6 type { echo-request, echo-reply }
                                                                <entry>realm</entry>
                                                        </row>
                                                        <row>
-                                                               <entry>ibriport</entry>
+                                                               <entry>ibridgename</entry>
                                                                <entry>Input bridge interface name</entry>
                                                                <entry>ifname</entry>
                                                        </row>
                                                        <row>
-                                                               <entry>obriport</entry>
+                                                               <entry>obridgename</entry>
                                                                <entry>Output bridge interface name</entry>
                                                                <entry>ifname</entry>
                                                        </row>
index 11de2dab8b9be6cb588730f7ea7459d164f43306..f8010964175714da3a7ea4f7d50b56741b8e51aa 100644 (file)
@@ -413,10 +413,10 @@ static const struct meta_template meta_templates[] = {
                                                1    , BYTEORDER_HOST_ENDIAN),
        [NFT_META_RTCLASSID]    = META_TEMPLATE("rtclassid", &realm_type,
                                                4 * 8, BYTEORDER_HOST_ENDIAN),
-       [NFT_META_BRI_IIFNAME]  = META_TEMPLATE("ibriport",  &ifname_type,
+       [NFT_META_BRI_IIFNAME]  = META_TEMPLATE("ibridgename",  &ifname_type,
                                                IFNAMSIZ * BITS_PER_BYTE,
                                                BYTEORDER_HOST_ENDIAN),
-       [NFT_META_BRI_OIFNAME]  = META_TEMPLATE("obriport",  &ifname_type,
+       [NFT_META_BRI_OIFNAME]  = META_TEMPLATE("obridgename",  &ifname_type,
                                                IFNAMSIZ * BITS_PER_BYTE,
                                                BYTEORDER_HOST_ENDIAN),
        [NFT_META_PKTTYPE]      = META_TEMPLATE("pkttype",   &pkttype_type,
@@ -451,6 +451,8 @@ static bool meta_key_is_qualified(enum nft_meta_keys key)
        case NFT_META_PRIORITY:
        case NFT_META_PRANDOM:
        case NFT_META_SECPATH:
+       case NFT_META_BRI_IIFNAME:
+       case NFT_META_BRI_OIFNAME:
                return true;
        default:
                return false;
@@ -652,6 +654,15 @@ struct error_record *meta_key_parse(const struct location *loc,
                return NULL;
        }
 
+       /* Backwards compat hack */
+       if (strcmp(str, "ibriport") == 0) {
+               *value = NFT_META_BRI_IIFNAME;
+               return NULL;
+       } else if (strcmp(str, "obriport") == 0) {
+               *value = NFT_META_BRI_OIFNAME;
+               return NULL;
+       }
+
        len = (int)sizeof(buf);
        size = sizeof(buf);
 
index e2440be15aa2f13228e2d83cb353785d4adfe585..b948c66ce2258f660e6851fec64ba0bc09259ee9 100644 (file)
@@ -394,6 +394,8 @@ int nft_lex(void *, void *, void *);
 %token RTCLASSID               "rtclassid"
 %token IBRIPORT                        "ibriport"
 %token OBRIPORT                        "obriport"
+%token IBRIDGENAME             "ibridgename"
+%token OBRIDGENAME             "obridgename"
 %token PKTTYPE                 "pkttype"
 %token CPU                     "cpu"
 %token IIFGROUP                        "iifgroup"
index f3544ce5e7709652420efa398c419a5ac3f0c8f4..9e8fe00bdc3bf476de2d8081f3490b6979aa538b 100644 (file)
@@ -486,7 +486,9 @@ addrstring  ({macaddr}|{ip4addr}|{ip6addr})
 "nftrace"              { return NFTRACE; }
 "rtclassid"            { return RTCLASSID; }
 "ibriport"             { return IBRIPORT; }
+"ibridgename"          { return IBRIDGENAME; }
 "obriport"             { return OBRIPORT; }
+"obridgename"          { return OBRIDGENAME; }
 "pkttype"              { return PKTTYPE; }
 "cpu"                  { return CPU; }
 "iifgroup"             { return IIFGROUP; }
diff --git a/tests/py/bridge/meta.t b/tests/py/bridge/meta.t
new file mode 100644 (file)
index 0000000..ed37367
--- /dev/null
@@ -0,0 +1,6 @@
+:input;type filter hook input priority 0
+
+*bridge;test-bridge;input
+
+meta obridgename "br0";ok;meta obridgename "br0"
+meta ibridgename "br0";ok;meta ibridgename "br0"
diff --git a/tests/py/bridge/meta.t.payload b/tests/py/bridge/meta.t.payload
new file mode 100644 (file)
index 0000000..2728c0a
--- /dev/null
@@ -0,0 +1,10 @@
+# meta obridgename "br0"
+bridge test-bridge input
+  [ meta load bri_oifname => reg 1 ]
+  [ cmp eq reg 1 0x00307262 0x00000000 0x00000000 0x00000000 ]
+
+# meta ibridgename "br0"
+bridge test-bridge input
+  [ meta load bri_iifname => reg 1 ]
+  [ cmp eq reg 1 0x00307262 0x00000000 0x00000000 0x00000000 ]
+
index d68896dc0b9ecf271d28828e454f9dc607c03fcf..cfde9f32babe0351c2c191a3d258cfaef24ac868 100644 (file)
@@ -14,3 +14,5 @@ meta nfproto ipv6 meta l4proto tcp;ok;meta nfproto ipv6 meta l4proto 6
 meta nfproto ipv4 counter ip saddr 1.2.3.4;ok
 meta secpath exists;ok
 meta secpath missing;ok
+meta ibridgename "br0";fail
+meta obridgename "br0";fail
index d0682adf1366c749270fc257b9654b5ba91fe51a..c3afae79314c5ece94c7faca8f0eb8b947217109 100644 (file)
@@ -7,3 +7,6 @@ meta l4proto icmp icmp type echo-request;ok;icmp type echo-request
 meta l4proto ipv6-icmp icmpv6 type nd-router-advert;ok;icmpv6 type nd-router-advert
 meta l4proto 58 icmpv6 type nd-router-advert;ok;icmpv6 type nd-router-advert
 icmpv6 type nd-router-advert;ok
+
+meta ibridgename "br0";fail
+meta obridgename "br0";fail