]> git.ipfire.org Git - thirdparty/nftables.git/commit
cache: add hashtable cache for sets
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 2 Apr 2021 18:26:15 +0000 (20:26 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sat, 3 Apr 2021 17:41:02 +0000 (19:41 +0200)
commitdf48e56e987f84bb32ea53dfe98569dfe3fb7e37
tree945f098ec9d185504435f31cfe792b734e1efd0b
parent6b7b7d5d219dca4465390f4a69096383d17782d3
cache: add hashtable cache for sets

This patch adds a hashtable for set lookups.

This patch also splits table->sets in two:

- Sets that reside in the cache are stored in the new
  tables->cache_set and tables->cache_set_ht.

- Set that defined via command line / ruleset file reside in
  tables->set.

Sets in the cache (already in the kernel) are not placed in the
table->sets list.

By keeping separated lists, sets defined via command line / ruleset file
can be added to cache.

Adding 10000 sets, before:

 # time nft -f x
 real    0m6,415s
 user    0m3,126s
 sys     0m3,284s

After:

 # time nft -f x
 real    0m3,949s
 user    0m0,743s
 sys     0m3,205s

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/cache.h
include/netlink.h
include/rule.h
src/cache.c
src/evaluate.c
src/json.c
src/monitor.c
src/netlink.c
src/netlink_delinearize.c
src/rule.c