]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
proto: replace vlan ether type with 8021q
authorFlorian Westphal <fw@strlen.de>
Fri, 2 Apr 2021 10:54:53 +0000 (12:54 +0200)
committerFlorian Westphal <fw@strlen.de>
Sat, 3 Apr 2021 11:55:53 +0000 (13:55 +0200)
Previous patches added "8021ad" mnemonic for IEEE 802.1AD frame type.
This adds the 8021q shorthand for the existing 'vlan' frame type.

nft will continue to recognize 'ether type vlan', but listing
will now print 8021q.

Adjust all test cases accordingly.

Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
17 files changed:
src/proto.c
src/scanner.l
tests/py/any/meta.t
tests/py/any/meta.t.json
tests/py/any/meta.t.json.output
tests/py/any/meta.t.payload
tests/py/bridge/meta.t
tests/py/bridge/meta.t.json
tests/py/bridge/reject.t
tests/py/bridge/reject.t.json
tests/py/bridge/reject.t.json.output
tests/py/bridge/reject.t.payload
tests/py/bridge/vlan.t
tests/py/bridge/vlan.t.json
tests/py/bridge/vlan.t.json.output
tests/py/bridge/vlan.t.payload
tests/py/bridge/vlan.t.payload.netdev

index 67c519be1382716111148469ca83ac0a164a75c5..63727605a20a829f52f219aa738797e24db357fc 100644 (file)
@@ -1057,8 +1057,11 @@ static const struct symbol_table ethertype_tbl = {
                SYMBOL("ip",            __constant_htons(ETH_P_IP)),
                SYMBOL("arp",           __constant_htons(ETH_P_ARP)),
                SYMBOL("ip6",           __constant_htons(ETH_P_IPV6)),
-               SYMBOL("vlan",          __constant_htons(ETH_P_8021Q)),
+               SYMBOL("8021q",         __constant_htons(ETH_P_8021Q)),
                SYMBOL("8021ad",        __constant_htons(ETH_P_8021AD)),
+
+               /* for compatibility with older versions */
+               SYMBOL("vlan",          __constant_htons(ETH_P_8021Q)),
                SYMBOL_LIST_END
        },
 };
index 9eb79d2d24545bf0a5022a586b1752e8431df434..a9232db8978e7fcb462473b48173bcc04ce862b0 100644 (file)
@@ -423,6 +423,7 @@ addrstring  ({macaddr}|{ip4addr}|{ip6addr})
        "pcp"           { return PCP; }
 }
 "8021ad"               { yylval->string = xstrdup(yytext); return STRING; }
+"8021q"                        { yylval->string = xstrdup(yytext); return STRING; }
 
 "arp"                  { scanner_push_start_cond(yyscanner, SCANSTATE_ARP); return ARP; }
 <SCANSTATE_ARP>{
index 7b5825051c8afaf5b509fef92d2d617ac84d481f..0b894cce19c8a00217c5a8e304346c2ea622e80c 100644 (file)
@@ -20,8 +20,8 @@ meta length != { 33, 55, 67, 88};ok
 meta length { 33-55, 66-88};ok
 meta length != { 33-55, 66-88};ok
 
-meta protocol { ip, arp, ip6, vlan };ok;meta protocol { ip6, ip, vlan, arp}
-meta protocol != {ip, arp, ip6, vlan};ok
+meta protocol { ip, arp, ip6, vlan };ok;meta protocol { ip6, ip, 8021q, arp}
+meta protocol != {ip, arp, ip6, 8021q};ok
 meta protocol ip;ok
 meta protocol != ip;ok
 
index 47dc0724d0b88ea1fb02daf22419dc10e5877104..1a98843c7b0e558efef404719f17b9952fa66a05 100644 (file)
     }
 ]
 
-# meta protocol != {ip, arp, ip6, vlan}
+# meta protocol != {ip, arp, ip6, 8021q}
 [
     {
         "match": {
                     "ip",
                     "arp",
                     "ip6",
-                    "vlan"
+                    "8021q"
                 ]
             }
         }
index 74b934b8483934489e9654acb768320b69385404..4e9e669fdbc3b23aedfe94dc7cfd7dc702fadb07 100644 (file)
@@ -10,7 +10,7 @@
                 "set": [
                     "ip",
                     "arp",
-                    "vlan",
+                    "8021q",
                     "ip6"
                 ]
             }
@@ -18,7 +18,7 @@
     }
 ]
 
-# meta protocol != {ip, arp, ip6, vlan}
+# meta protocol != {ip, arp, ip6, 8021q}
 [
     {
         "match": {
@@ -30,7 +30,7 @@
                 "set": [
                     "ip",
                     "arp",
-                    "vlan",
+                    "8021q",
                     "ip6"
                 ]
             }
index 99aab29c54b229fbc03c415ed378fb021fed8ffe..4e43905e309465008e8079ac9eb2f66aeec4822f 100644 (file)
@@ -68,7 +68,7 @@ ip test-ip4 input
   [ meta load protocol => reg 1 ]
   [ lookup reg 1 set __set%d ]
 
-# meta protocol != {ip, arp, ip6, vlan}
+# meta protocol != {ip, arp, ip6, 8021q}
 __set%d test-ip4 3
 __set%d test-ip4 0
        element 00000008  : 0 [end]     element 00000608  : 0 [end]     element 0000dd86  : 0 [end]     element 00000081  : 0 [end]
index 94525f2944ce5f40525e94db26babfb1c68d0186..eda7082f02b4a3c91281187253ba9045772257ba 100644 (file)
@@ -4,5 +4,5 @@
 
 meta obrname "br0";ok
 meta ibrname "br0";ok
-meta ibrvproto vlan;ok
+meta ibrvproto vlan;ok;meta ibrvproto 8021q
 meta ibrpvid 100;ok
index a7a180c29aa600cdf3893c703ff936d4c4524f2d..3122774eba8c2b2874aaa3626d482515c9dbd968 100644 (file)
@@ -32,7 +32,7 @@
                 "meta": { "key": "ibrvproto" }
             },
            "op": "==",
-            "right": "vlan"
+            "right": "8021q"
         }
     }
 ]
index ee33af77eab6bf58b19aa5560e031c4c8353abbb..b242eef49a2b7d9adccb55faca42571ba7e18d65 100644 (file)
@@ -30,13 +30,13 @@ reject with icmpx type port-unreachable;ok;reject
 ether type ipv6 reject with icmp type host-unreachable;fail
 ether type ip6 reject with icmp type host-unreachable;fail
 ether type ip reject with icmpv6 type no-route;fail
-ether type vlan reject;ok
+ether type vlan reject;ok;ether type 8021q reject
 ether type arp reject;fail
-ether type vlan reject with tcp reset;ok;meta l4proto 6 ether type vlan reject with tcp reset
+ether type vlan reject with tcp reset;ok;meta l4proto 6 ether type 8021q reject with tcp reset
 ether type arp reject with tcp reset;fail
 ip protocol udp reject with tcp reset;fail
 
 ether type ip reject with icmpx type admin-prohibited;ok
 ether type ip6 reject with icmpx type admin-prohibited;ok
-ether type vlan reject with icmpx type admin-prohibited;ok
+ether type 8021q reject with icmpx type admin-prohibited;ok
 ether type arp reject with icmpx type admin-prohibited;fail
index aea871f70907e230f8d80e730a17cc8a0b38bbe7..fe21734d0ae3aa815f6bc6a303d4d1948513d7f8 100644 (file)
                 }
             },
             "op": "==",
-            "right": "vlan"
+            "right": "8021q"
         }
     },
     {
     }
 ]
 
-# ether type vlan reject with icmpx type admin-prohibited
+# ether type 8021q reject with icmpx type admin-prohibited
 [
     {
         "match": {
                 }
             },
             "op": "==",
-            "right": "vlan"
+            "right": "8021q"
         }
     },
     {
index e01a63af5a354bc2f886613f66e46204170842c4..b8a44f0eeb02e405da1996f9a029b5f27d8e19ce 100644 (file)
@@ -71,7 +71,7 @@
                 }
             },
             "op": "==",
-            "right": "vlan"
+            "right": "8021q"
         }
     },
     {
@@ -81,4 +81,3 @@
         }
     }
 ]
-
index 7deb6fbf5facd0bddf30ba37127b1fafa2a83f2a..22569877c428b53435d3147cb8ea8fecb1e7a895 100644 (file)
@@ -132,7 +132,7 @@ bridge
   [ cmp eq reg 1 0x00000081 ]
   [ reject type 1 code 0 ]
 
-# ether type vlan reject with icmpx type admin-prohibited
+# ether type 8021q reject with icmpx type admin-prohibited
 bridge
   [ payload load 2b @ link header + 12 => reg 1 ]
   [ cmp eq reg 1 0x00000081 ]
index 8553ba56351d77792c2c97c17223af0253898226..f67b8180996e4aa886ff7541e5ad564d26098a7f 100644 (file)
@@ -32,12 +32,12 @@ ether type vlan vlan id 1 ip saddr 10.0.0.0/23 udp dport 53;ok;vlan id 1 ip sadd
 vlan id { 1, 2, 4, 100, 4095 } vlan pcp 1-3;ok
 vlan id { 1, 2, 4, 100, 4096 };fail
 
-ether type vlan ip protocol 1 accept;ok
+ether type vlan ip protocol 1 accept;ok;ether type 8021q ip protocol 1 accept
 
 # IEEE 802.1AD
 ether type 8021ad vlan id 1 ip protocol 6 accept;ok
-ether type 8021ad vlan id 1 vlan type vlan vlan id 2 vlan type ip counter;ok
-ether type 8021ad vlan id 1 vlan type vlan vlan id 2 vlan type ip ip protocol 6;ok;ether type 8021ad vlan id 1 vlan type vlan vlan id 2 ip protocol 6
+ether type 8021ad vlan id 1 vlan type 8021q vlan id 2 vlan type ip counter;ok
+ether type 8021ad vlan id 1 vlan type 8021q vlan id 2 vlan type ip ip protocol 6;ok;ether type 8021ad vlan id 1 vlan type 8021q vlan id 2 ip protocol 6
 
 # illegal dependencies
 ether type ip vlan id 1;fail
index 8eab271d790bcc88aae12ccef38dcc9deaba1a4e..2a4b64f2279f18c7aac228da0f6419874ea0d1e1 100644 (file)
     }
 ]
 
-# ether type 8021ad vlan id 1 vlan type vlan vlan id 2 vlan type ip counter
+# ether type 8021ad vlan id 1 vlan type 8021q vlan id 2 vlan type ip counter
 [
     {
         "match": {
                 }
             },
             "op": "==",
-            "right": "vlan"
+            "right": "8021q"
         }
     },
     {
     }
 ]
 
-# ether type 8021ad vlan id 1 vlan type vlan vlan id 2 vlan type ip ip protocol 6
+# ether type 8021ad vlan id 1 vlan type 8021q vlan id 2 vlan type ip ip protocol 6
 [
     {
         "match": {
                 }
             },
             "op": "==",
-            "right": "vlan"
+            "right": "8021q"
         }
     },
     {
index a2cc212ea3146369e18eacf888256a1a74bb964b..2f90c8ffd1e710bbe09cb5bf74327560728e0d3b 100644 (file)
@@ -9,7 +9,7 @@
                 }
             },
             "op": "==",
-            "right": "vlan"
+            "right": "8021q"
         }
     },
     {
@@ -72,7 +72,7 @@
     }
 ]
 
-# ether type 8021ad vlan id 1 vlan type vlan vlan id 2 vlan type ip counter
+# ether type 8021ad vlan id 1 vlan type 8021q vlan id 2 vlan type ip counter
 [
     {
         "match": {
                 }
             },
             "op": "==",
-            "right": "vlan"
+            "right": "8021q"
         }
     },
     {
     }
 ]
 
-# ether type 8021ad vlan id 1 vlan type vlan vlan id 2 vlan type ip ip protocol 6
+# ether type 8021ad vlan id 1 vlan type 8021q vlan id 2 vlan type ip ip protocol 6
 [
     {
         "match": {
                 }
             },
             "op": "==",
-            "right": "vlan"
+            "right": "8021q"
         }
     },
     {
index f60c752de401bbca1bdf2dd0013e8cf5d019e189..a78f294671dfa87e6ef3c8a304db9c491a517158 100644 (file)
@@ -222,7 +222,7 @@ bridge
   [ cmp eq reg 1 0x00000006 ]
   [ immediate reg 0 accept ]
 
-# ether type 8021ad vlan id 1 vlan type vlan vlan id 2 vlan type ip counter
+# ether type 8021ad vlan id 1 vlan type 8021q vlan id 2 vlan type ip counter
 bridge
   [ payload load 2b @ link header + 12 => reg 1 ]
   [ cmp eq reg 1 0x0000a888 ]
@@ -238,7 +238,7 @@ bridge
   [ cmp eq reg 1 0x00000008 ]
   [ counter pkts 0 bytes 0 ]
 
-# ether type 8021ad vlan id 1 vlan type vlan vlan id 2 vlan type ip ip protocol 6
+# ether type 8021ad vlan id 1 vlan type 8021q vlan id 2 vlan type ip ip protocol 6
 bridge
   [ payload load 2b @ link header + 12 => reg 1 ]
   [ cmp eq reg 1 0x0000a888 ]
index 94ca6867c271fe9a2ca4244743e27e88db1084be..22e244e2e791c864f6f7b37b6264f61d60e48f64 100644 (file)
@@ -260,7 +260,7 @@ netdev
   [ cmp eq reg 1 0x00000006 ]
   [ immediate reg 0 accept ]
 
-# ether type 8021ad vlan id 1 vlan type vlan vlan id 2 vlan type ip counter
+# ether type 8021ad vlan id 1 vlan type 8021q vlan id 2 vlan type ip counter
 netdev
   [ meta load iiftype => reg 1 ]
   [ cmp eq reg 1 0x00000001 ]
@@ -278,7 +278,7 @@ netdev
   [ cmp eq reg 1 0x00000008 ]
   [ counter pkts 0 bytes 0 ]
 
-# ether type 8021ad vlan id 1 vlan type vlan vlan id 2 vlan type ip ip protocol 6
+# ether type 8021ad vlan id 1 vlan type 8021q vlan id 2 vlan type ip ip protocol 6
 netdev
   [ meta load iiftype => reg 1 ]
   [ cmp eq reg 1 0x00000001 ]