From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: phil@nwl.cc, fw@strlen.de
Subject: [PATCH nft] rule: ensure cache consistency
Date: Thu, 6 Jun 2019 14:11:53 +0200 [thread overview]
Message-ID: <20190606121153.3777-1-pablo@netfilter.org> (raw)
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>
---
src/rule.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/rule.c b/src/rule.c
index 1e081c8fe862..cb5bd2162c02 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -244,8 +244,6 @@ static bool cache_is_updated(struct nft_cache *cache, uint16_t genid)
int cache_update(struct nft_ctx *nft, enum cmd_ops cmd, struct list_head *msgs)
{
- uint16_t genid;
- int ret;
struct netlink_ctx ctx = {
.list = LIST_HEAD_INIT(ctx.list),
.nft = nft,
@@ -253,7 +251,8 @@ int cache_update(struct nft_ctx *nft, enum cmd_ops cmd, struct list_head *msgs)
.nft = nft,
};
struct nft_cache *cache = &nft->cache;
-
+ uint16_t genid, genid_stop;
+ int ret;
replay:
ctx.seqnum = cache->seqnum++;
genid = mnl_genid_get(&ctx);
@@ -273,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;
--
2.11.0
reply other threads:[~2019-06-06 12:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190606121153.3777-1-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=phil@nwl.cc \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).