From: Florian Westphal <fw@strlen.de>
To: Florian Westphal <fw@strlen.de>
Cc: Brian Davidson <davidson.brian@gmail.com>,
netfilter@vger.kernel.org, pablo@netfilter.org
Subject: Re: ip6 dscp fails map lookup
Date: Fri, 3 Nov 2023 22:59:04 +0100 [thread overview]
Message-ID: <20231103215904.GA23268@breakpoint.cc> (raw)
In-Reply-To: <20231103193704.GI8035@breakpoint.cc>
Florian Westphal <fw@strlen.de> wrote:
> Brian Davidson <davidson.brian@gmail.com> wrote:
> > Using 'ip6 dscp' in a map lookup does not give expected results. It
> > seems to always match the zero value (cs0). It appears in the first
> > rule that the byteorder is not being converted between the two bitwise
> > operations, which is what happens when using ip6 dscp directly in the
> > second rule.
> >
> > # nft -f - <<EOF
> > add table ip6 t
> > add chain ip6 t c
> > add map ip6 t mapv6 { typeof ip6 dscp : meta mark; }
> > EOF
> >
> > # nft -d netlink add rule ip6 t c meta mark set ip6 dscp map @mapv6
> > ip6 t c
> > [ payload load 2b @ network header + 0 => reg 1 ]
> > [ bitwise reg 1 = ( reg 1 & 0x0000c00f ) ^ 0x00000000 ]
> > [ bitwise reg 1 = ( reg 1 >> 0x00000006 ) ]
> > [ lookup reg 1 set mapv6 dreg 1 ]
> > [ meta set mark with reg 1 ]
> >
> > # nft -d netlink add rule ip6 t c meta mark set ip6 dscp
> > ip6 t c
> > [ payload load 2b @ network header + 0 => reg 1 ]
> > [ bitwise reg 1 = ( reg 1 & 0x0000c00f ) ^ 0x00000000 ]
> > [ byteorder reg 1 = ntoh(reg 1, 2, 2) ]
> > [ bitwise reg 1 = ( reg 1 >> 0x00000006 ) ]
> > [ meta set mark with reg 1 ]
>
> Uhm. Pablo, any idea why the byte-swap-or-not logic depends
> on something *other* than if the mask length is > 8 bit or not?
>
> diff --git a/src/evaluate.c b/src/evaluate.c
> --- a/src/evaluate.c
> +++ b/src/evaluate.c
> @@ -545,7 +545,7 @@ static void expr_evaluate_bits(struct eval_ctx *ctx, struct expr **exprp)
> and->len = masklen;
>
> if (shift) {
> - if (ctx->stmt_len > 0 && div_round_up(masklen, BITS_PER_BYTE) > 1) {
> + if (masklen > BITS_PER_BYTE) {
I think this is right but binop xfer
won't remove the inserted byteorder conversion
in case the shift is to be removed by adjusting
a constant right hand side value.
I will have a look.
next prev parent reply other threads:[~2023-11-03 21:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-03 16:18 ip6 dscp fails map lookup Brian Davidson
2023-11-03 19:37 ` Florian Westphal
2023-11-03 21:59 ` Florian Westphal [this message]
2023-11-05 17:15 ` Pablo Neira Ayuso
2023-11-05 17:41 ` Florian Westphal
2023-11-05 17:58 ` Pablo Neira Ayuso
2023-11-05 21:33 ` Pablo Neira Ayuso
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=20231103215904.GA23268@breakpoint.cc \
--to=fw@strlen.de \
--cc=davidson.brian@gmail.com \
--cc=netfilter@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.