From: Pablo Neira Ayuso Date: Thu, 6 Jun 2019 12:09:45 +0000 (+0200) Subject: rule: ensure cache consistency X-Git-Tag: v0.9.1~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9eb52029d5a34825a0c6b731a1a07001f8293f3e;p=thirdparty%2Fnftables.git 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 --- diff --git a/src/rule.c b/src/rule.c index 651454733..e570238a4 100644 --- a/src/rule.c +++ b/src/rule.c @@ -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;