From: Florian Westphal <fw@strlen.de>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Florian Westphal <fw@strlen.de>, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft 2/7] netlink_delinearize: postprocess binary ands in set expressions
Date: Mon, 1 Aug 2022 13:28:35 +0200 [thread overview]
Message-ID: <20220801112835.GB29493@breakpoint.cc> (raw)
In-Reply-To: <YuekXoqvZkGdQJRJ@salvia>
Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> Hi Florian,
>
> On Wed, Jul 27, 2022 at 01:19:58PM +0200, Florian Westphal wrote:
> [..]
> > diff --git a/include/netlink.h b/include/netlink.h
> > index e8e0f68ae1a4..2d5532387c0c 100644
> > --- a/include/netlink.h
> > +++ b/include/netlink.h
> [...]
> > @@ -2569,6 +2582,24 @@ static void expr_postprocess(struct rule_pp_ctx *ctx, struct expr **exprp)
> > expr_set_type(expr->right, &integer_type,
> > BYTEORDER_HOST_ENDIAN);
> > break;
> > + case OP_AND:
> > + expr_set_type(expr->right, expr->left->dtype,
> > + expr->left->byteorder);
> > +
> > + /* Only process OP_AND if we are inside a concatenation.
> > + *
> > + * Else, we remove it too early, for normal contect OP_AND
> > + * removal needs to be performed as part of the relational
> > + * operation because the RHS constant might need to be adjusted
> > + * (shifted).
> > + */
> > + if ((ctx->flags & RULE_PP_IN_CONCATENATION) &&
> > + expr->left->etype == EXPR_PAYLOAD &&
> > + expr->right->etype == EXPR_VALUE) {
> > + __binop_postprocess(ctx, expr, expr->left, expr->right, exprp);
> > + return;
> > + }
> > + break;
>
> Not sure this flag is enough. If I load this ruleset
>
> table netdev nt {
> set macset {
> typeof vlan id
> size 1024
> flags dynamic,timeout
> }
> chain y {
> }
> }
> add rule netdev nt y update @macset { vlan id timeout 5s }
>
> listing still shows the raw expression:
>
> table netdev nt {
> set macset {
> typeof vlan id
> size 1024
> flags dynamic,timeout
> }
>
> chain y {
> update @macset { @ll,112,16 & 0xfff timeout 5s }
> }
> }
>
> looks like the problem is related to expressions in set statements?
Good catch, I added a patch to the series that also enabled OP_AND
removal for the set elem key case.
I took the above and added it to the test case.
next prev parent reply other threads:[~2022-08-01 11:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-27 11:19 [PATCH nft 0/7] really handle stacked l2 headers Florian Westphal
2022-07-27 11:19 ` [PATCH nft 1/7] netlink_delinearize: allow postprocessing on concatenated elements Florian Westphal
2022-07-27 11:19 ` [PATCH nft 2/7] netlink_delinearize: postprocess binary ands in set expressions Florian Westphal
2022-08-01 10:01 ` Pablo Neira Ayuso
2022-08-01 11:28 ` Florian Westphal [this message]
2022-07-27 11:19 ` [PATCH nft 3/7] proto: track full stack of seen l2 protocols, not just cumulative offset Florian Westphal
2022-07-27 11:20 ` [PATCH nft 4/7] debug: dump the l2 protocol stack Florian Westphal
2022-07-27 11:20 ` [PATCH nft 5/7] tests: add a test case for ether and vlan listing Florian Westphal
2022-07-27 11:20 ` [PATCH nft 6/7] evaluate: search stacked header list for matching payload dep Florian Westphal
2022-07-27 11:20 ` [PATCH nft 7/7] src: allow anon set concatenation with ether and vlan Florian Westphal
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=20220801112835.GB29493@breakpoint.cc \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/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).