diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2020-08-06 12:52:00 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2020-08-06 13:05:13 +0200 |
commit | 407c54f712554d1055c43e8a7d731a765564c16b (patch) | |
tree | 124c53d61b4e004c69539144389c8279fd560631 /src/rule.c | |
parent | 455709effa095c6e986385974a0cf702dad8491c (diff) |
src: cache gets out of sync in interactive mode
Since 94a945ffa81b ("libnftables: Get rid of explicit cache flushes"),
the cache logic checks for the generation number to refresh the cache.
This breaks interactive mode when listing stateful objects though. This
patch adds a new flag to force a cache refresh when the user requests a
ruleset listing.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/rule.c')
-rw-r--r-- | src/rule.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -237,6 +237,11 @@ static bool cache_is_complete(struct nft_cache *cache, unsigned int flags) return (cache->flags & flags) == flags; } +static bool cache_needs_refresh(struct nft_cache *cache) +{ + return cache->flags & NFT_CACHE_REFRESH; +} + static bool cache_is_updated(struct nft_cache *cache, uint16_t genid) { return genid && genid == cache->genid; @@ -261,7 +266,8 @@ int cache_update(struct nft_ctx *nft, unsigned int flags, struct list_head *msgs replay: ctx.seqnum = cache->seqnum++; genid = mnl_genid_get(&ctx); - if (cache_is_complete(cache, flags) && + if (!cache_needs_refresh(cache) && + cache_is_complete(cache, flags) && cache_is_updated(cache, genid)) return 0; |