summaryrefslogtreecommitdiffstats
path: root/src/cache.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2024-02-06 19:26:57 +0100
committerPhil Sutter <phil@nwl.cc>2024-02-07 19:14:16 +0100
commit674eb7fa2895813b25f6fbfcc9417fc0788fade1 (patch)
treee1413590176c7f434134454e09936c6606853365 /src/cache.c
parent02466e17e8cca5f97757092094c0600cedce09e2 (diff)
cache: Optimize caching for 'list tables' command
No point in fetching anything other than existing tables from kernel: 'list tables' merely prints existing table names, no contents. Also populate filter's family field to reduce overhead when listing tables in one family with many tables in another one. It works without further adjustments because nftnl_nlmsg_build_hdr() will use the value for nfgen_family. Reported-by: anton.khazan@gmail.com Link: https://bugzilla.netfilter.org/show_bug.cgi?id=1735 Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'src/cache.c')
-rw-r--r--src/cache.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cache.c b/src/cache.c
index b7f46c00..97f50cca 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -203,8 +203,12 @@ static unsigned int evaluate_cache_list(struct nft_ctx *nft, struct cmd *cmd,
{
switch (cmd->obj) {
case CMD_OBJ_TABLE:
- if (filter && cmd->handle.table.name) {
+ if (filter)
filter->list.family = cmd->handle.family;
+ if (!cmd->handle.table.name) {
+ flags |= NFT_CACHE_TABLE;
+ break;
+ } else if (filter) {
filter->list.table = cmd->handle.table.name;
}
flags |= NFT_CACHE_FULL;