All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Sowden <jeremy@azazel.net>
To: Pablo Neira Ayuso <pablo@netfilter.org>, Florian Westphal <fw@strlen.de>
Cc: Netfilter Devel <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH nft v2 11/18] netlink_linearize: round binop bitmask length up.
Date: Tue, 3 Mar 2020 09:33:34 +0000	[thread overview]
Message-ID: <20200303093334.GA2265@azazel.net> (raw)
In-Reply-To: <20200302221916.1005019-12-jeremy@azazel.net>

[-- Attachment #1: Type: text/plain, Size: 1171 bytes --]

On 2020-03-02, at 22:19:09 +0000, Jeremy Sowden wrote:
> In this example:
>
> nft --debug=netlink add rule ip t c ip dscp set ip dscp
> ip t c
>   [ payload load 2b @ network header + 0 => reg 1 ]
>   [ bitwise reg 1 = (reg=1 & 0x000003ff ) ^ 0x00000000 ]
>   [ payload load 1b @ network header + 1 => reg 2 ]
>   [ bitwise reg 2 = (reg=2 & 0x0000003c ) ^ 0x00000000 ]
>   [ bitwise reg 2 = ( reg 2 >> 0x00000002 ) ]
>   [ bitwise reg 2 = ( reg 2 << 0x00000002 ) ]
>   [ bitwise reg 1 = (reg=1 & 0x0000ffff ) ^ reg 2 ]
>   [ payload write reg 1 => 2b @ network header + 0 csum_type 1 csum_off 10 csum_flags 0x0 ]
>
> The mask at line 4 should be 0xfc, not 0x3c.
>
> Evaluation of the payload expression munges it from `ip dscp` to
> `(ip dscp & 0xfc) >> 2`.  When this AND expression is evaluated, its
> length is set to 6, the length of `ip dscp`.  When the bitwise netlink
> expression is generated, the length of the AND is used to generate the
> mask, 0x3f, used in combining the binop's.  The upshot of this is that
> the original mask gets mangled to 0x3c.  We can fix this by rounding
> the length of the mask to the nearest byte.

This is the wrong solution.

J.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

  reply	other threads:[~2020-03-03  9:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-02 22:18 [PATCH nft v2 00/18] Support for boolean binops with variable RHS operands Jeremy Sowden
2020-03-02 22:18 ` [PATCH nft v2 01/18] evaluate: add separate variables for lshift and xor binops Jeremy Sowden
2020-03-02 22:19 ` [PATCH nft v2 02/18] evaluate: simplify calculation of payload size Jeremy Sowden
2020-03-02 22:19 ` [PATCH nft v2 03/18] evaluate: don't evaluate payloads twice Jeremy Sowden
2020-03-02 22:19 ` [PATCH nft v2 04/18] evaluate: convert the byte-order of payload statement arguments Jeremy Sowden
2020-03-02 22:19 ` [PATCH nft v2 05/18] evaluate: no need to swap byte-order for values of fewer than 16 bits Jeremy Sowden
2020-03-02 22:19 ` [PATCH nft v2 06/18] netlink_delinearize: set shift RHS byte-order Jeremy Sowden
2020-03-02 22:19 ` [PATCH nft v2 07/18] src: fix leaks Jeremy Sowden
2020-03-02 22:19 ` [PATCH nft v2 08/18] include: update nf_tables.h Jeremy Sowden
2020-03-02 22:19 ` [PATCH nft v2 09/18] src: support (de)linearization of bitwise op's with variable right operands Jeremy Sowden
2020-03-02 22:19 ` [PATCH nft v2 10/18] evaluate: allow boolean binop expressions with variable righthand arguments Jeremy Sowden
2020-03-02 22:19 ` [PATCH nft v2 11/18] netlink_linearize: round binop bitmask length up Jeremy Sowden
2020-03-03  9:33   ` Jeremy Sowden [this message]
2020-03-02 22:19 ` [PATCH nft v2 12/18] netlink_delinearize: fix typo Jeremy Sowden
2020-03-02 22:19 ` [PATCH nft v2 13/18] netlink_delinearize: refactor stmt_payload_binop_postprocess Jeremy Sowden
2020-03-02 22:19 ` [PATCH nft v2 14/18] netlink_delinearize: add support for processing variable payload statement arguments Jeremy Sowden
2020-03-02 22:19 ` [PATCH nft v2 15/18] netlink_delinearize: add postprocessing for payload binops Jeremy Sowden
2020-03-02 22:19 ` [PATCH nft v2 16/18] tests: shell: remove stray debug flag Jeremy Sowden
2020-03-02 22:19 ` [PATCH nft v2 17/18] tests: shell: add variable binop RHS tests Jeremy Sowden
2020-03-02 22:19 ` [PATCH nft v2 18/18] tests: py: " Jeremy Sowden

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=20200303093334.GA2265@azazel.net \
    --to=jeremy@azazel.net \
    --cc=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 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.