* [PATCH nf-next] netfilter: nft_lookup: only cancel tracking for clobbered dregs
@ 2022-03-11 10:53 Florian Westphal
0 siblings, 0 replies; only message in thread
From: Florian Westphal @ 2022-03-11 10:53 UTC (permalink / raw)
To: netfilter-devel; +Cc: Florian Westphal
In most cases, nft_lookup will be read-only, i.e. won't clobber
registers. In case of map, we need to cancel the registers that will
see stores.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/nft_lookup.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/net/netfilter/nft_lookup.c b/net/netfilter/nft_lookup.c
index 90becbf5bff3..f2242fb08bca 100644
--- a/net/netfilter/nft_lookup.c
+++ b/net/netfilter/nft_lookup.c
@@ -253,6 +253,26 @@ static int nft_lookup_validate(const struct nft_ctx *ctx,
return 0;
}
+static bool nft_lookup_reduce(struct nft_regs_track *track,
+ const struct nft_expr *expr)
+{
+ const struct nft_lookup *priv = nft_expr_priv(expr);
+
+ if (priv->set->flags & NFT_SET_MAP) {
+ unsigned int regcount, i, dreg = priv->dreg;
+
+ regcount = DIV_ROUND_UP(priv->set->dlen, NFT_REG32_SIZE);
+
+ /* reset registers that were clobbered */
+ for (i = 0; i < regcount; i++, dreg++) {
+ track->regs[dreg].selector = NULL;
+ track->regs[dreg].bitwise = NULL;
+ }
+ }
+
+ return false;
+}
+
static const struct nft_expr_ops nft_lookup_ops = {
.type = &nft_lookup_type,
.size = NFT_EXPR_SIZE(sizeof(struct nft_lookup)),
@@ -263,6 +283,7 @@ static const struct nft_expr_ops nft_lookup_ops = {
.destroy = nft_lookup_destroy,
.dump = nft_lookup_dump,
.validate = nft_lookup_validate,
+ .reduce = nft_lookup_reduce,
};
struct nft_expr_type nft_lookup_type __read_mostly = {
--
2.34.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-11 10:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-11 10:53 [PATCH nf-next] netfilter: nft_lookup: only cancel tracking for clobbered dregs Florian Westphal
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).