diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2019-06-06 14:09:45 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2019-06-07 11:14:32 +0200 |
commit | 9eb52029d5a34825a0c6b731a1a07001f8293f3e (patch) | |
tree | 90a094bbc2a8c6aa7fbad241972d3998ff715287 | |
parent | 8951c655e95b790ead4ff73a98b6c8027df876de (diff) |
rule: ensure cache consistency
Check for generation ID after the cache is populated. In case of
interference, release the inconsistent cache and retry.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | src/rule.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -251,7 +251,7 @@ int cache_update(struct nft_ctx *nft, enum cmd_ops cmd, struct list_head *msgs) .nft = nft, }; struct nft_cache *cache = &nft->cache; - uint32_t genid; + uint32_t genid, genid_stop; int ret; replay: ctx.seqnum = cache->seqnum++; @@ -272,6 +272,13 @@ replay: } return -1; } + + genid_stop = mnl_genid_get(&ctx); + if (genid != genid_stop) { + cache_release(cache); + goto replay; + } + cache->genid = genid; cache->cmd = cmd; return 0; |