meta: add ibrpvid and ibrvproto support
PATCH v4 1/1 meta: add ibrpvid and ibrvproto support
From: wenxu <[email protected]>
This allows you to match the bridge pvid and vlan protocol, for instance:
nft add rule bridge firewall zones meta ibrvproto 0x8100 nft add rule bridge firewall zones meta ibrpvid 100
Signed-off-by wenxu <[email protected]>
--- src/meta.c | 6 ++++++ tests/py/bridge/meta.t | 2 ++ tests/py/bridge/meta.t.json | 26 ++++++++++++++++++++++++++ tests/py/bridge/meta.t.payload | 9 +++++++++ 4 files changed, 43 insertions(+)
src/meta.c +6 -0
@@ -442,6 +442,12 @@ const struct meta_template meta_templates[] = { [NFT_META_OIFKIND ] =META_TEMPLATE ("oifkind" , &ifname_type,IFNAMSIZ *BITS_PER_BYTE , BYTEORDER_HOST_ENDIAN), + [NFT_META_BRI_IIFPVID ] =META_TEMPLATE ("ibrpvid" , &integer_type, +2 *BITS_PER_BYTE , + BYTEORDER_HOST_ENDIAN), + [NFT_META_BRI_IIFVPROTO ] =META_TEMPLATE ("ibrvproto" , &integer_type, +2 *BITS_PER_BYTE , + BYTEORDER_HOST_ENDIAN), };static bool meta_key_is_unqualified (enum nft_meta_keys key)
tests/py/bridge/meta.t +2 -0
@@ -4,3 +4,5 @@ meta obrname "br0";ok meta ibrname "br0";ok +meta ibrvproto 33024;ok +meta ibrpvid 100;ok
tests/py/bridge/meta.t.json +26 -0
@@ -23,3 +23,29 @@ } } ] + +# meta ibrvproto 33024 +[ + { + "match": { + "left": { + "meta": { "key": "ibrvproto" } + }, + "op": "==", + "right": 33024 + } + } +] + +# meta ibrpvid 100 +[ + { + "match": { + "left": { + "meta": { "key": "ibrpvid" } + }, + "op": "==", + "right": 100 + } + } +]
tests/py/bridge/meta.t.payload +9 -0
@@ -8,3 +8,12 @@ bridge test-bridge input [ meta load bri_iifname => reg 1 ] [ cmp eq reg 1 0x00307262 0x00000000 0x00000000 0x00000000 ] +# meta ibrvproto 33024 +bridge test-bridge input + [ meta load bri_iifvproto => reg 1 ] + [ cmp eq reg 1 0x00008100 ] + +# meta ibrpvid 100 +bridge test-bridge input + [ meta load bri_iifpvid => reg 1 ] + [ cmp eq reg 1 0x00000064 ]
Signature · 1 line
2.15.1
Pablo Neira Ayuso
maintainerQuoted 21 lines · On Wed, Aug 21, 2019 at 06:10:38PM +0800, [email protected] wrote:
From: wenxu <[email protected]>
This allows you to match the bridge pvid and vlan protocol, for instance:
nft add rule bridge firewall zones meta ibrvproto
0x8100nft add rule bridge firewall zones meta ibrpvid 100Signed-off-by wenxu <[email protected]>--- src/meta.c | 6 ++++++ tests/py/bridge/meta.t | 2 ++ tests/py/bridge/meta.t.json | 26 ++++++++++++++++++++++++++ tests/py/bridge/meta.t.payload | 9 +++++++++ 4 files changed, 43 insertions(+)src/meta.c +0
-0
src/meta.c const struct meta_template meta_templates[] = { · line 445
Quoted 4 lines
src/meta.c +1
-0@@ -442,6 +442,12 @@ const struct meta_template meta_templates[] = { [NFT_META_OIFKIND] = META_TEMPLATE("oifkind", &ifname_type,IFNAMSIZ *BITS_PER_BYTE , BYTEORDER_HOST_ENDIAN), + [NFT_META_BRI_IIFPVID] = META_TEMPLATE("ibrpvid", &integer_type,
Just notices another nitpick: I think if you use etheraddr_type instead of integer_type here, you would get a nicer output.