Skip to contentSkip to conversation

cache: filter out rules by chain

PATCH New Pablo Neira Ayuso 1 participant 1 message Nov 10, 2021 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 cache: filter out rules by chain

With an autogenerated ruleset with ~20k chains.

 # time nft list ruleset &> /dev/null
 real    0m1,712s
 user    0m1,258s
 sys     0m0,454s

Speed up listing of a specific chain:

 # time nft list chain nat MWDG-UGR-234PNG3YBUOTS5QD &> /dev/null
 real    0m0,542s
 user    0m0,251s
 sys     0m0,292s
---
 include/cache.h   |  1 +
 include/netlink.h |  2 --
 src/cache.c       | 84 +++++++++++++++++++++++++++++++++++++++++++++--
 src/netlink.c     | 42 ------------------------
 4 files changed, 82 insertions(+), 47 deletions(-)
include/cache.h +1 -0
index 120a1b8d91b5..e5c509e8510c 100644
@@ -51,6 +51,7 @@ struct nft_cache_filter {
 	struct {
 		uint32_t	family;
 		const char	*table;
+		const char	*chain;
 		const char	*set;
 	} list;
 
include/netlink.h +0 -2
index c1d7d3189455..a692edcdb5bf 100644
@@ -124,8 +124,6 @@ extern struct expr *netlink_alloc_data(const struct location *loc,
 				       const struct nft_data_delinearize *nld,
 				       enum nft_registers dreg);
 
-extern int netlink_list_rules(struct netlink_ctx *ctx, const struct handle *h);
-
 struct netlink_linearize_ctx;
 extern void netlink_linearize_rule(struct netlink_ctx *ctx,
 				   const struct rule *rule,
src/cache.c +81 -3

135 lines not on this page · raw message

src/netlink.c +0 -42

48 lines not on this page · raw message

Signature · 1 line
2.30.2