Skip to contentSkip to conversation

mnl: Set NFTNL_SET_DATA_TYPE before dumping set elements

PATCH New Phil Sutter 1 participant 1 message Mar 8, 2021 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 mnl: Set NFTNL_SET_DATA_TYPE before dumping set elements

In combination with libnftnl's commit "set_elem: Fix printing of verdict map elements", This adds the vmap target to netlink dumps. Adjust dumps in tests/py accordingly.

---
 src/mnl.c                             |  3 +
 tests/py/any/ct.t.payload             |  2 +-
 tests/py/any/meta.t.payload           |  2 +-
 tests/py/inet/fib.t.payload           |  2 +-
 tests/py/inet/tcp.t.payload           |  6 +-
 tests/py/ip/ip.t.payload              |  4 +-
 tests/py/ip/ip.t.payload.bridge       |  4 +-
 tests/py/ip/ip.t.payload.inet         |  4 +-
 tests/py/ip/ip.t.payload.netdev       |  4 +-
 tests/py/ip/masquerade.t.payload      |  2 +-
 tests/py/ip/redirect.t.payload        |  2 +-
 tests/py/ip6/ip6.t.payload.inet       |  4 +-
 tests/py/ip6/ip6.t.payload.ip6        |  4 +-
 tests/py/ip6/masquerade.t.payload.ip6 |  2 +-
 tests/py/ip6/redirect.t.payload.ip6   |  2 +-
 tests/py/ip6/vmap.t.payload.inet      | 84 +++++++++++++--------------
 tests/py/ip6/vmap.t.payload.ip6       | 84 +++++++++++++--------------
 tests/py/ip6/vmap.t.payload.netdev    | 84 +++++++++++++--------------
 18 files changed, 151 insertions(+), 148 deletions(-)
src/mnl.c +3 -0
index 9c965446521c0..deea586f9b002 100644
@@ -1544,6 +1544,9 @@ int mnl_nft_setelem_add(struct netlink_ctx *ctx, const struct set *set,
 	nftnl_set_set_str(nls, NFTNL_SET_NAME, h->set.name);
 	if (h->set_id)
 		nftnl_set_set_u32(nls, NFTNL_SET_ID, h->set_id);
+	if (set_is_datamap(set->flags))
+		nftnl_set_set_u32(nls, NFTNL_SET_DATA_TYPE,
+				  dtype_map_to_kernel(set->data->dtype));
 
 	alloc_setelem_cache(expr, nls);
 	netlink_dump_set(nls, ctx);
tests/py/any/ct.t.payload +1 -1
index a80e5a8d48ffb..733276e196f20 100644
@@ -485,7 +485,7 @@ ip test-ip4 output
 # ct state . ct mark vmap { new . 0x12345678 : drop, established . 0x87654321 : accept}
 __map%d test-ip4 b size 2
 __map%d test-ip4 0
-	element 00000008 12345678  : 0 [end]	element 00000002 87654321  : 0 [end]
+	element 00000008 12345678  : drop 0 [end]	element 00000002 87654321  : accept 0 [end]
 ip test-ip4 output 
   [ ct load state => reg 1 ]
   [ ct load mark => reg 9 ]
tests/py/any/meta.t.payload +1 -1
index c366452514389..99aab29c54b22 100644
@@ -728,7 +728,7 @@ ip test-ip4 output
 # meta iif . meta oif vmap { "lo" . "lo" : drop }
 __map%d test-ip4 b
 __map%d test-ip4 0
-	element 00000001 00000001  : 0 [end]
+	element 00000001 00000001  : drop 0 [end]
 ip test-ip4 output
   [ meta load iif => reg 1 ]
   [ meta load oif => reg 9 ]
tests/py/inet/fib.t.payload +1 -1
index 1d4c3d94aa0bf..050857d96994e 100644
@@ -16,7 +16,7 @@ ip test-ip prerouting
 # fib daddr . iif type vmap { blackhole : drop, prohibit : drop, unicast : accept }
 __map%d test-ip b
 __map%d test-ip 0
-        element 00000006  : 0 [end]     element 00000008  : 0 [end]     element 00000001  : 0 [end]
+	element 00000006  : drop 0 [end]	element 00000008  : drop 0 [end]	element 00000001  : accept 0 [end]
 ip test-ip prerouting
   [ fib daddr . iif type => reg 1 ]
   [ lookup reg 1 set __map%d dreg 0 ]
tests/py/inet/tcp.t.payload +3 -3
index 3b7a4468ca2ca..5eaf4090462db 100644
@@ -81,7 +81,7 @@ inet test-inet input
 # tcp dport vmap { 22 : accept, 23 : drop }
 __map%d test-inet b
 __map%d test-inet 0
-	element 00001600  : 0 [end]	element 00001700  : 0 [end]
+	element 00001600  : accept 0 [end]	element 00001700  : drop 0 [end]
 inet test-inet input
   [ meta load l4proto => reg 1 ]
   [ cmp eq reg 1 0x00000006 ]
@@ -91,7 +91,7 @@ inet test-inet input
 # tcp dport vmap { 25:accept, 28:drop }
 __map%d test-inet b
 __map%d test-inet 0
-	element 00001900  : 0 [end]	element 00001c00  : 0 [end]
+	element 00001900  : accept 0 [end]	element 00001c00  : drop 0 [end]
 inet test-inet input
   [ meta load l4proto => reg 1 ]
   [ cmp eq reg 1 0x00000006 ]
@@ -190,7 +190,7 @@ inet test-inet input
 # tcp sport vmap { 25:accept, 28:drop }
 __map%d test-inet b
 __map%d test-inet 0
-	element 00001900  : 0 [end]	element 00001c00  : 0 [end]
+	element 00001900  : accept 0 [end]	element 00001c00  : drop 0 [end]
 inet test-inet input
   [ meta load l4proto => reg 1 ]
   [ cmp eq reg 1 0x00000006 ]
tests/py/ip/ip.t.payload +2 -2
index 578c8d3705930..bbff508bc604e 100644
@@ -43,7 +43,7 @@ ip test-ip4 input
 # ip dscp vmap { cs1 : continue , cs4 : accept } counter
 __map%d test-ip4 b size 2
 __map%d test-ip4 0
-	element 00000020  : 0 [end]	element 00000080  : 0 [end]
+	element 00000020  : continue 0 [end]	element 00000080  : accept 0 [end]
 ip test-ip4 input 
   [ payload load 1b @ network header + 1 => reg 1 ]
   [ bitwise reg 1 = ( reg 1 & 0x000000fc ) ^ 0x00000000 ]
@@ -526,7 +526,7 @@ ip test-ip4 input
 # ip hdrlength vmap { 0-4 : drop, 5 : accept, 6 : continue } counter
 __map%d test-ip4 f size 4
 __map%d test-ip4 0
-	element 00000000  : 0 [end]	element 00000005  : 0 [end]	element 00000006  : 0 [end]	element 00000007  : 1 [end]
+	element 00000000  : drop 0 [end]	element 00000005  : accept 0 [end]	element 00000006  : continue 0 [end]	element 00000007  : drop 1 [end]
 ip test-ip4 input 
   [ payload load 1b @ network header + 0 => reg 1 ]
   [ bitwise reg 1 = ( reg 1 & 0x0000000f ) ^ 0x00000000 ]
tests/py/ip/ip.t.payload.bridge +2 -2
index 6ac5e74043368..33c9654f1c343 100644
@@ -55,7 +55,7 @@ bridge test-bridge input
 # ip dscp vmap { cs1 : continue , cs4 : accept } counter
 __map%d test-bridge b size 2
 __map%d test-bridge 0
-	element 00000020  : 0 [end]	element 00000080  : 0 [end]
+	element 00000020  : continue 0 [end]	element 00000080  : accept 0 [end]
 bridge test-bridge input 
   [ meta load protocol => reg 1 ]
   [ cmp eq reg 1 0x00000008 ]
@@ -686,7 +686,7 @@ bridge test-bridge input
 # ip hdrlength vmap { 0-4 : drop, 5 : accept, 6 : continue } counter
 __map%d test-bridge f size 4
 __map%d test-bridge 0
-	element 00000000  : 0 [end]	element 00000005  : 0 [end]	element 00000006  : 0 [end]	element 00000007  : 1 [end]
+	element 00000000  : drop 0 [end]	element 00000005  : accept 0 [end]	element 00000006  : continue 0 [end]	element 00000007  : drop 1 [end]
 bridge test-bridge input 
   [ meta load protocol => reg 1 ]
   [ cmp eq reg 1 0x00000008 ]
tests/py/ip/ip.t.payload.inet +2 -2
index 8c778f99b0fa1..0d387da946d2c 100644
@@ -55,7 +55,7 @@ inet test-inet input
 # ip dscp vmap { cs1 : continue , cs4 : accept } counter
 __map%d test-inet b size 2
 __map%d test-inet 0
-	element 00000020  : 0 [end]	element 00000080  : 0 [end]
+	element 00000020  : continue 0 [end]	element 00000080  : accept 0 [end]
 inet test-inet input 
   [ meta load nfproto => reg 1 ]
   [ cmp eq reg 1 0x00000002 ]
@@ -686,7 +686,7 @@ inet test-inet input
 # ip hdrlength vmap { 0-4 : drop, 5 : accept, 6 : continue } counter
 __map%d test-inet f size 4
 __map%d test-inet 0
-	element 00000000  : 0 [end]	element 00000005  : 0 [end]	element 00000006  : 0 [end]	element 00000007  : 1 [end]
+	element 00000000  : drop 0 [end]	element 00000005  : accept 0 [end]	element 00000006  : continue 0 [end]	element 00000007  : drop 1 [end]
 inet test-inet input 
   [ meta load nfproto => reg 1 ]
   [ cmp eq reg 1 0x00000002 ]
tests/py/ip/ip.t.payload.netdev +2 -2
index d4e029b07a8ac..f75f789fe75f9 100644
@@ -585,7 +585,7 @@ netdev test-netdev ingress
 # ip hdrlength vmap { 0-4 : drop, 5 : accept, 6 : continue } counter
 __map%d test-netdev f size 4
 __map%d test-netdev 0
-	element 00000000  : 0 [end]	element 00000005  : 0 [end]	element 00000006  : 0 [end]	element 00000007  : 1 [end]
+	element 00000000  : drop 0 [end]	element 00000005  : accept 0 [end]	element 00000006  : continue 0 [end]	element 00000007  : drop 1 [end]
 netdev test-netdev ingress 
   [ meta load protocol => reg 1 ]
   [ cmp eq reg 1 0x00000008 ]
@@ -686,7 +686,7 @@ netdev test-netdev ingress
 # ip dscp vmap { cs1 : continue , cs4 : accept } counter
 __map%d test-netdev b size 2
 __map%d test-netdev 0
-	element 00000020  : 0 [end]	element 00000080  : 0 [end]
+	element 00000020  : continue 0 [end]	element 00000080  : accept 0 [end]
 netdev test-netdev ingress 
   [ meta load protocol => reg 1 ]
   [ cmp eq reg 1 0x00000008 ]
tests/py/ip/masquerade.t.payload +1 -1
index c4870ab8ae43b..79e52856a22d3 100644
@@ -112,7 +112,7 @@ ip test-ip4 postrouting
 # iifname "eth0" ct state established,new tcp dport vmap {22 : drop, 222 : drop } masquerade
 __map%d test-ip4 b
 __map%d test-ip4 0
-	element 00001600  : 0 [end]	element 0000de00  : 0 [end]
+	element 00001600  : drop 0 [end]	element 0000de00  : drop 0 [end]
 ip test-ip4 postrouting
   [ meta load iifname => reg 1 ]
   [ cmp eq reg 1 0x30687465 0x00000000 0x00000000 0x00000000 ]
tests/py/ip/redirect.t.payload +1 -1
index bdfc6d72d0055..424ad7b4f7ec0 100644
@@ -194,7 +194,7 @@ ip test-ip4 output
 # iifname "eth0" ct state established,new tcp dport vmap {22 : drop, 222 : drop } redirect
 __map%d test-ip4 b
 __map%d test-ip4 0
-	element 00001600  : 0 [end]	element 0000de00  : 0 [end]
+	element 00001600  : drop 0 [end]	element 0000de00  : drop 0 [end]
 ip test-ip4 output
   [ meta load iifname => reg 1 ]
   [ cmp eq reg 1 0x30687465 0x00000000 0x00000000 0x00000000 ]
tests/py/ip6/ip6.t.payload.inet +2 -2
index 11ba34a1bca2b..a107abd7adc82 100644
@@ -44,7 +44,7 @@ inet test-inet input
 # ip6 dscp vmap { 0x04 : accept, 0x3f : continue } counter
 __map%d test-inet b size 2
 __map%d test-inet 0
-	element 00000001  : 0 [end]	element 0000c00f  : 0 [end]
+	element 00000001  : accept 0 [end]	element 0000c00f  : continue 0 [end]
 ip6 test-ip6 input
   [ meta load nfproto => reg 1 ]
   [ cmp eq reg 1 0x0000000a ]
@@ -116,7 +116,7 @@ inet test-inet input
 # ip6 flowlabel vmap { 0 : accept, 2 : continue }
 __map%d test-inet b size 2
 __map%d test-inet 0
-	element 00000000  : 0 [end]	element 00020000  : 0 [end]
+	element 00000000  : accept 0 [end]	element 00020000  : continue 0 [end]
 inet test-inet input 
   [ meta load nfproto => reg 1 ]
   [ cmp eq reg 1 0x0000000a ]
tests/py/ip6/ip6.t.payload.ip6 +2 -2
index 78479253abbdf..6766622085e1f 100644
@@ -34,7 +34,7 @@ ip6 test-ip6 input
 # ip6 dscp vmap { 0x04 : accept, 0x3f : continue } counter
 __map%d test-ip6 b size 2
 __map%d test-ip6 0
-	element 00000001  : 0 [end]	element 0000c00f  : 0 [end]
+	element 00000001  : accept 0 [end]	element 0000c00f  : continue 0 [end]
 ip6 test-ip6 input
   [ payload load 2b @ network header + 0 => reg 1 ]
   [ bitwise reg 1 = ( reg 1 & 0x0000c00f ) ^ 0x00000000 ]
@@ -92,7 +92,7 @@ ip6 test-ip6 input
 # ip6 flowlabel vmap { 0 : accept, 2 : continue }
 __map%d test-ip6 b size 2
 __map%d test-ip6 0
-	element 00000000  : 0 [end]	element 00020000  : 0 [end]
+	element 00000000  : accept 0 [end]	element 00020000  : continue 0 [end]
 ip6 test-ip6 input 
   [ payload load 3b @ network header + 1 => reg 1 ]
   [ bitwise reg 1 = ( reg 1 & 0x00ffff0f ) ^ 0x00000000 ]
tests/py/ip6/masquerade.t.payload.ip6 +1 -1
index d6410b2cf2db3..43ae2ae48244f 100644
@@ -112,7 +112,7 @@ ip6 test-ip6 postrouting
 # iifname "eth0" ct state established,new tcp dport vmap {22 : drop, 222 : drop } masquerade
 __map%d test-ip6 b
 __map%d test-ip6 0
-	element 00001600  : 0 [end]	element 0000de00  : 0 [end]
+	element 00001600  : drop 0 [end]	element 0000de00  : drop 0 [end]
 ip6 test-ip6 postrouting
   [ meta load iifname => reg 1 ]
   [ cmp eq reg 1 0x30687465 0x00000000 0x00000000 0x00000000 ]
tests/py/ip6/redirect.t.payload.ip6 +1 -1
index 20405cea54ef3..e9a2031614856 100644
@@ -178,7 +178,7 @@ ip6 test-ip6 output
 # iifname "eth0" ct state established,new tcp dport vmap {22 : drop, 222 : drop } redirect
 __map%d test-ip6 b
 __map%d test-ip6 0
-	element 00001600  : 0 [end]	element 0000de00  : 0 [end]
+	element 00001600  : drop 0 [end]	element 0000de00  : drop 0 [end]
 ip6 test-ip6 output
   [ meta load iifname => reg 1 ]
   [ cmp eq reg 1 0x30687465 0x00000000 0x00000000 0x00000000 ]
tests/py/ip6/vmap.t.payload.inet +42 -42

336 lines not on this page · raw message

tests/py/ip6/vmap.t.payload.ip6 +42 -42

336 lines not on this page · raw message

tests/py/ip6/vmap.t.payload.netdev +42 -42

336 lines not on this page · raw message

Signature · 1 line
2.30.1