]> git.ipfire.org Git - thirdparty/nftables.git/commit
evaluate: support for bitfield payload statement with binary operation
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 27 Feb 2025 17:36:16 +0000 (18:36 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 7 Mar 2025 12:56:47 +0000 (13:56 +0100)
commitee32bc90b80f329822b1dd3ee35f2eb98ae7f260
tree026e60bac7b91350d9705d5ea0072d8349de39a3
parentde447e248cce3ca3fd7040c386ac798c35721415
evaluate: support for bitfield payload statement with binary operation

Update bitfield payload statement support to allow for bitwise
and/or/xor updates. Adjust payload expression to fetch 16-bits for
mangling while leaving unmodified bits intact.

 # nft --debug=netlink add rule x y ip dscp set ip dscp or 0x1
 ip x y
   [ payload load 2b @ network header + 0 => reg 1 ]
   [ bitwise reg 1 = ( reg 1 & 0x0000fbff ) ^ 0x00000400 ]
   [ payload write reg 1 => 2b @ network header + 0 csum_type 1 csum_off 10 csum_flags 0x0 ]

Skip expr_evaluate_bits() transformation since these are only useful
for payload matching and set lookups.

Listing still shows a raw expression:

  # nft list ruleset
    ...
                    @nh,8,5 set 0x0

The follow up patch completes it:

  ("netlink_delinearize: support for bitfield payload statement with binary operation")

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1698
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/evaluate.c