Skip to contentSkip to conversation

tests: py: remove verdict from closing end interval

PATCH New Pablo Neira Ayuso 1 participant 2 messages Nov 4, 2021 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/2 tests: py: remove verdict from closing end interval

Kernel does not allow for NFT_SET_ELEM_INTERVAL_END flag and NFTA_SET_ELEM_DATA. The closing end interval represents a mismatch, therefore, no verdict can be applied. The existing payload files show the drop verdict when this is unset (because NF_DROP=0).

This update is required to fix payload warnings in tests/py after libnftnl's ("set: use NFTNL_SET_ELEM_VERDICT to print verdict").

Fixes 6671d9d137f6 ("mnl: Set NFTNL_SET_DATA_TYPE before dumping set elements")
---
 tests/py/ip/ip.t.payload           | 2 +-
 tests/py/ip/ip.t.payload.bridge    | 2 +-
 tests/py/ip/ip.t.payload.inet      | 2 +-
 tests/py/ip/ip.t.payload.netdev    | 2 +-
 tests/py/ip6/vmap.t.payload.inet   | 2 +-
 tests/py/ip6/vmap.t.payload.ip6    | 2 +-
 tests/py/ip6/vmap.t.payload.netdev | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)
tests/py/ip/ip.t.payload +1 -1
index 49d1a0fb03e8..b9fcb5158e9d 100644
@@ -430,7 +430,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  : drop 0 [end]	element 00000005  : accept 0 [end]	element 00000006  : continue 0 [end]	element 00000007  : drop 1 [end]
+	element 00000000  : drop 0 [end]	element 00000005  : accept 0 [end]	element 00000006  : continue 0 [end]	element 00000007  : 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 +1 -1
index dac8654395f4..c6f8d4e5575b 100644
@@ -566,7 +566,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  : drop 0 [end]	element 00000005  : accept 0 [end]	element 00000006  : continue 0 [end]	element 00000007  : drop 1 [end]
+	element 00000000  : drop 0 [end]	element 00000005  : accept 0 [end]	element 00000006  : continue 0 [end]	element 00000007  : 1 [end]
 bridge test-bridge input 
   [ meta load protocol => reg 1 ]
   [ cmp eq reg 1 0x00000008 ]
tests/py/ip/ip.t.payload.inet +1 -1
index 64371650480f..e26d0dac47be 100644
@@ -566,7 +566,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  : drop 0 [end]	element 00000005  : accept 0 [end]	element 00000006  : continue 0 [end]	element 00000007  : drop 1 [end]
+	element 00000000  : drop 0 [end]	element 00000005  : accept 0 [end]	element 00000006  : continue 0 [end]	element 00000007  : 1 [end]
 inet test-inet input 
   [ meta load nfproto => reg 1 ]
   [ cmp eq reg 1 0x00000002 ]
tests/py/ip/ip.t.payload.netdev +1 -1
index 65f8c96a9470..de990f5bba12 100644
@@ -465,7 +465,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  : drop 0 [end]	element 00000005  : accept 0 [end]	element 00000006  : continue 0 [end]	element 00000007  : drop 1 [end]
+	element 00000000  : drop 0 [end]	element 00000005  : accept 0 [end]	element 00000006  : continue 0 [end]	element 00000007  : 1 [end]
 netdev test-netdev ingress 
   [ meta load protocol => reg 1 ]
   [ cmp eq reg 1 0x00000008 ]
tests/py/ip6/vmap.t.payload.inet +1 -1
index 522564a31044..931cc6bd75a7 100644
@@ -371,7 +371,7 @@ inet test-inet input
 # ip6 saddr vmap { ::/64 : accept}
 __map%d test-inet f
 __map%d test-inet 0
-	element 00000000 00000000 00000000 00000000  : accept 0 [end]	element 00000000 01000000 00000000 00000000  : drop 1 [end]
+	element 00000000 00000000 00000000 00000000  : accept 0 [end]	element 00000000 01000000 00000000 00000000  : 1 [end]
 inet test-inet input
   [ meta load nfproto => reg 1 ]
   [ cmp eq reg 1 0x0000000a ]
tests/py/ip6/vmap.t.payload.ip6 +1 -1
index 3850a7c58fd1..6e077b27a5f0 100644
@@ -297,7 +297,7 @@ ip6 test-ip6 input
 # ip6 saddr vmap { ::/64 : accept}
 __map%d test-ip6 f
 __map%d test-ip6 0
-	element 00000000 00000000 00000000 00000000  : accept 0 [end]	element 00000000 01000000 00000000 00000000  : drop 1 [end]
+	element 00000000 00000000 00000000 00000000  : accept 0 [end]	element 00000000 01000000 00000000 00000000  : 1 [end]
 ip6 test-ip6 input
   [ payload load 16b @ network header + 8 => reg 1 ]
   [ lookup reg 1 set __map%d dreg 0 ]
tests/py/ip6/vmap.t.payload.netdev +1 -1
index d9cbad5877ae..45f2c0b01e9c 100644
@@ -371,7 +371,7 @@ netdev test-netdev ingress
 # ip6 saddr vmap { ::/64 : accept}
 __map%d test-netdev f
 __map%d test-netdev 0
-	element 00000000 00000000 00000000 00000000  : accept 0 [end]	element 00000000 01000000 00000000 00000000  : drop 1 [end]
+	element 00000000 00000000 00000000 00000000  : accept 0 [end]	element 00000000 01000000 00000000 00000000  : 1 [end]
 netdev test-netdev ingress 
   [ meta load protocol => reg 1 ]
   [ cmp eq reg 1 0x0000dd86 ]
Signature · 1 line
2.30.2
author maintainer
#1 lore raw

PATCH 2/2 mnl: do not build nftnl_set element list

Do not call alloc_setelem_cache() to build the set element list in nftnl_set. Instead, translate one single set element expression to nftnl_set_elem object at a time and use this object to build the netlink header.

This is reduce userspace memory consumption, using a huge test set containing 1.1 million element blocklist, this patch is reducing userspace memory consumption by 40%.

---
 include/netlink.h |   2 +
 src/mnl.c         | 112 ++++++++++++++++++++++++++++++++++++----------
 src/netlink.c     |   4 +-
 3 files changed, 93 insertions(+), 25 deletions(-)
include/netlink.h +2 -0
index 2467ff82a520..c1d7d3189455 100644
@@ -72,6 +72,8 @@ struct netlink_ctx {
 
 extern struct nftnl_expr *alloc_nft_expr(const char *name);
 extern void alloc_setelem_cache(const struct expr *set, struct nftnl_set *nls);
+struct nftnl_set_elem *alloc_nftnl_setelem(const struct expr *set,
+					   const struct expr *expr);
 
 extern struct nftnl_table *netlink_table_alloc(const struct nlmsghdr *nlh);
 extern struct nftnl_chain *netlink_chain_alloc(const struct nlmsghdr *nlh);
src/mnl.c +89 -23

145 lines not on this page · raw message

src/netlink.c +2 -2
index 28a5514ad873..f63f2bd1bd60 100644
@@ -100,8 +100,8 @@ struct nftnl_expr *alloc_nft_expr(const char *name)
 void __netlink_gen_data(const struct expr *expr,
 			struct nft_data_linearize *data, bool expand);
 
-static struct nftnl_set_elem *alloc_nftnl_setelem(const struct expr *set,
-						  const struct expr *expr)
+struct nftnl_set_elem *alloc_nftnl_setelem(const struct expr *set,
+					   const struct expr *expr)
 {
 	const struct expr *elem, *data;
 	struct nftnl_set_elem *nlse;
Signature · 1 line
2.30.2