From: Jeremy Sowden <jeremy@azazel.net>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Netfilter Devel <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH nft v3 0/9] bitwise shift support
Date: Sun, 2 Feb 2020 22:28:12 +0000 [thread overview]
Message-ID: <20200202222812.GC136286@azazel.net> (raw)
In-Reply-To: <20200201123223.GA136286@azazel.net>
[-- Attachment #1: Type: text/plain, Size: 2256 bytes --]
On 2020-02-01, at 12:32:23 +0000, Jeremy Sowden wrote:
> On 2020-01-28, at 20:09:45 +0100, Pablo Neira Ayuso wrote:
> > On Sun, Jan 19, 2020 at 10:57:01PM +0000, Jeremy Sowden wrote:
> > > The kernel supports bitwise shift operations. This patch-set adds
> > > the support to nft. There are a few preliminary housekeeping
> > > patches.
> >
> > Actually, this batch goes in the direction of adding the basic
> > lshift/right support.
> >
> > # nft --debug=netlink add rule x y tcp dport set tcp dport lshift 1
> > ip x y
> > [ meta load l4proto => reg 1 ]
> > [ cmp eq reg 1 0x00000006 ]
> > [ payload load 2b @ transport header + 2 => reg 1 ]
> > [ byteorder reg 1 = ntoh(reg 1, 2, 2) ]
> > [ bitwise reg 1 = ( reg 1 << 0x00000001 ) ]
> > [ payload write reg 1 => 2b @ transport header + 2 csum_type 1
> > csum_off 16 csum_flags 0x0 ]
> >
> > I'm applying patches 1, 2, 3, 4, 7 and 8.
> >
> > Regarding patch 5, it would be good to restore the parens when
> > listing.
>
> Will do.
This is already handled by the same code that does it for the other
parenthesized expressions (src/expression.c, ll. 600ff.):
static void binop_arg_print(const struct expr *op, const struct expr *arg,
struct output_ctx *octx)
{
bool prec = false;
if (arg->etype == EXPR_BINOP &&
expr_binop_precedence[op->op] != 0 &&
expr_binop_precedence[op->op] < expr_binop_precedence[arg->op])
prec = 1;
if (prec)
nft_print(octx, "(");
expr_print(arg, octx);
if (prec)
nft_print(octx, ")");
}
> > Patch 6, I guess it will break something else. Did you run tests/py
> > to check this?
>
> I did and I got the same results before and after applying it. I'll
> take another look.
Evaluation of the shift expression inserts a byte-order conversion if
necessary to enforce host endianness, so by changing it we just avoid
the addition of the extra operation. I've rewritten the commit message.
> > Patch 9, I'm skipping until 5 and 6 are sorted out.
I've tweaked the shell test-cases to include a parenthesized expression,
and added some matching Python ones.
I'll send a new version out soon.
J.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
prev parent reply other threads:[~2020-02-02 22:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-19 22:57 [PATCH nft v3 0/9] bitwise shift support Jeremy Sowden
2020-01-19 22:57 ` [PATCH nft v3 1/9] Update gitignore Jeremy Sowden
2020-01-19 22:57 ` [PATCH nft v3 2/9] src: white-space fixes Jeremy Sowden
2020-01-19 22:57 ` [PATCH nft v3 3/9] netlink_delinearize: fix typo Jeremy Sowden
2020-01-19 22:57 ` [PATCH nft v3 4/9] netlink_delinearize: remove commented out pr_debug statement Jeremy Sowden
2020-01-19 22:57 ` [PATCH nft v3 5/9] parser: add parenthesized statement expressions Jeremy Sowden
2020-01-19 22:57 ` [PATCH nft v3 6/9] evaluate: change shift byte-order to host-endian Jeremy Sowden
2020-01-19 22:57 ` [PATCH nft v3 7/9] include: update nf_tables.h Jeremy Sowden
2020-01-19 22:57 ` [PATCH nft v3 8/9] netlink: add support for handling shift expressions Jeremy Sowden
2020-01-19 22:57 ` [PATCH nft v3 9/9] tests: shell: add bit-shift tests Jeremy Sowden
2020-01-28 19:20 ` Pablo Neira Ayuso
2020-02-01 12:32 ` Jeremy Sowden
2020-01-28 19:09 ` [PATCH nft v3 0/9] bitwise shift support Pablo Neira Ayuso
2020-02-01 12:32 ` Jeremy Sowden
2020-02-02 22:28 ` Jeremy Sowden [this message]
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=20200202222812.GC136286@azazel.net \
--to=jeremy@azazel.net \
--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).