Skip to content

mark statement support for non-constant expression

Pablo Neira Ayuso netfilter-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest12 patches 2 repliesIn review
  2. v28 patches 0 repliesSuperseded
  3. v19 patches 0 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12netlink_delinearize: correct type and byte-order of shiftssrc/netlink_delinearize.c+11 -20 replies
2/12evaluate: support shifts larger than the width of the left operandinclude/rule.h src/evaluate.c src/netlink_delinearize.c+47 -200 replies
3/12evaluate: don't eval unary argumentssrc/evaluate.c+2 -40 replies
4/12evaluate: relax type-checking for integer arguments in mark statementssrc/evaluate.c tests/py/ip/meta.t tests/py/ip/meta.t.json +1 more+41 -20 replies
5/12evaluate: set up integer type to shift expressionsrc/evaluate.c+1 -01 reply
6/12evaluate: honor statement length in integer evaluationsrc/evaluate.c+8 -20 replies
7/12evaluate: honor statement length in bitwise evaluationsrc/evaluate.c+23 -41 reply
8/12netlink_delinerize: incorrect byteorder in mark statement listingsrc/netlink_delinearize.c+14 -40 replies
9/12tests: py: add test-cases for ct and packet mark payload expressionstests/py/ip/ct.t tests/py/ip/ct.t.json tests/py/ip/ct.t.payload +9 more+483 -00 replies
10/12tests: shell: rename and move bitwise test-casestests/shell/testcases/bitwise/0040mark_binop_0 tests/shell/testcases/bitwise/0040mark_binop_1 tests/shell/testcases/bitwise/dumps/0040mark_binop_0.nft +1 more+4 -40 replies
11/12tests: shell: add test-cases for ct and packet mark payload expressionstests/shell/testcases/bitwise/0040mark_binop_2 tests/shell/testcases/bitwise/0040mark_binop_3 tests/shell/testcases/bitwise/0040mark_binop_4 +13 more+136 -00 replies
12/12tests: py: extend test-cases for mark statements with bitwise expressionstests/py/ip/ct.t tests/py/ip/ct.t.json tests/py/ip/ct.t.payload +3 more+234 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH nft,v3 00/12] mark statement support for non-constant expression

Hi,

This is v3 of the following patchset:

https://marc.info/?l=netfilter-devel&m=167904710124404&w=2

this takes over the initial effort from Jeremy Sowden to enhance mark statements support for variable expression.

This round emphasizes on the support for bitwise expression (not only shift).

No kernel updates are required in this batch.

Patch #1 no changes.

Patch #2 changes to sets ctx->stmt_len for meta and ct only, reset

	 ctx->stmt_len in expr_evaluate_map() to avoid interference
	 with map evaluation.

Patch #3 no changes.

Patch #4 no changes.

Patch #5 new in this series, missing type in shift evaluation.

	 This is required to evaluate constant shift, eg. 1 << 1
         which is reduced at evaluation step to 0x2.

Patch #6 disable lhs maximum length cap when ctx->stmt_len is available.

	 This allows for: meta mark set ip dscp | 0xff000000

Patch #7 honor ctx->stmt_len in bitwise evaluation, otherwise evaluation
results in incorrect bytecode. This assumes host byteorder for the statement, which is fine at this stage since only ct and meta statement are supported.

Patch #8 adjust byteorder in delinearize path if bitwise length hints
that it refers to the statement length. This assumes host byteorder, in this future, when this support is generalized this requires to infer the byteorder from the statement that has been used.

Patch #9-#12 tests already posted in the previous batch and new ones.

Jeremy Sowden (5):
netlink_delinearize: correct type and byte-order of shifts
evaluate: don't eval unary arguments
tests: py: add test-cases for ct and packet mark payload expressions
tests: shell: rename and move bitwise test-cases
tests: shell: add test-cases for ct and packet mark payload expressions

Pablo Neira Ayuso (7):
evaluate: support shifts larger than the width of the left operand
evaluate: relax type-checking for integer arguments in mark statements
evaluate: set up integer type to shift expression
evaluate: honor statement length in integer evaluation
evaluate: honor statement length in bitwise evaluation
netlink_delinerize: incorrect byteorder in mark statement listing
tests: py: extend test-cases for mark statements with bitwise expressions

 include/rule.h                                |   1 +
 src/evaluate.c                                | 119 +++++--
 src/netlink_delinearize.c                     |  35 ++-
 tests/py/ip/ct.t                              |   6 +
 tests/py/ip/ct.t.json                         | 154 +++++++++
 tests/py/ip/ct.t.payload                      |  50 +++
 tests/py/ip/meta.t                            |   5 +
 tests/py/ip/meta.t.json                       |  78 +++++
 tests/py/ip/meta.t.payload                    |  25 ++
 tests/py/ip6/ct.t                             |   9 +
 tests/py/ip6/ct.t.json                        | 293 ++++++++++++++++++
 tests/py/ip6/ct.t.payload                     |  46 +++
 tests/py/ip6/meta.t                           |   3 +
 tests/py/ip6/meta.t.json                      |  58 ++++
 tests/py/ip6/meta.t.payload                   |  20 ++
 .../0040mark_binop_0}                         |   2 +-
 .../0040mark_binop_1}                         |   2 +-
 .../shell/testcases/bitwise/0040mark_binop_2  |  11 +
 .../shell/testcases/bitwise/0040mark_binop_3  |  11 +
 .../shell/testcases/bitwise/0040mark_binop_4  |  11 +
 .../shell/testcases/bitwise/0040mark_binop_5  |  11 +
 .../shell/testcases/bitwise/0040mark_binop_6  |  11 +
 .../shell/testcases/bitwise/0040mark_binop_7  |  11 +
 .../shell/testcases/bitwise/0040mark_binop_8  |  11 +
 .../shell/testcases/bitwise/0040mark_binop_9  |  11 +
 .../dumps/0040mark_binop_0.nft}               |   2 +-
 .../dumps/0040mark_binop_1.nft}               |   2 +-
 .../bitwise/dumps/0040mark_binop_2.nft        |   6 +
 .../bitwise/dumps/0040mark_binop_3.nft        |   6 +
 .../bitwise/dumps/0040mark_binop_4.nft        |   6 +
 .../bitwise/dumps/0040mark_binop_5.nft        |   6 +
 .../bitwise/dumps/0040mark_binop_6.nft        |   6 +
 .../bitwise/dumps/0040mark_binop_7.nft        |   6 +
 .../bitwise/dumps/0040mark_binop_8.nft        |   6 +
 .../bitwise/dumps/0040mark_binop_9.nft        |   6 +
 35 files changed, 1004 insertions(+), 42 deletions(-)
 create mode 100644 tests/py/ip6/ct.t
 create mode 100644 tests/py/ip6/ct.t.json
 create mode 100644 tests/py/ip6/ct.t.payload
 rename tests/shell/testcases/{chains/0040mark_shift_0 => bitwise/0040mark_binop_0} (68%)
 rename tests/shell/testcases/{chains/0040mark_shift_1 => bitwise/0040mark_binop_1} (70%)
 create mode 100755 tests/shell/testcases/bitwise/0040mark_binop_2
 create mode 100755 tests/shell/testcases/bitwise/0040mark_binop_3
 create mode 100755 tests/shell/testcases/bitwise/0040mark_binop_4
 create mode 100755 tests/shell/testcases/bitwise/0040mark_binop_5
 create mode 100755 tests/shell/testcases/bitwise/0040mark_binop_6
 create mode 100755 tests/shell/testcases/bitwise/0040mark_binop_7
 create mode 100755 tests/shell/testcases/bitwise/0040mark_binop_8
 create mode 100755 tests/shell/testcases/bitwise/0040mark_binop_9
 rename tests/shell/testcases/{chains/dumps/0040mark_shift_0.nft => bitwise/dumps/0040mark_binop_0.nft} (58%)
 rename tests/shell/testcases/{chains/dumps/0040mark_shift_1.nft => bitwise/dumps/0040mark_binop_1.nft} (64%)
 create mode 100644 tests/shell/testcases/bitwise/dumps/0040mark_binop_2.nft
 create mode 100644 tests/shell/testcases/bitwise/dumps/0040mark_binop_3.nft
 create mode 100644 tests/shell/testcases/bitwise/dumps/0040mark_binop_4.nft
 create mode 100644 tests/shell/testcases/bitwise/dumps/0040mark_binop_5.nft
 create mode 100644 tests/shell/testcases/bitwise/dumps/0040mark_binop_6.nft
 create mode 100644 tests/shell/testcases/bitwise/dumps/0040mark_binop_7.nft
 create mode 100644 tests/shell/testcases/bitwise/dumps/0040mark_binop_8.nft
 create mode 100644 tests/shell/testcases/bitwise/dumps/0040mark_binop_9.nft
Signature · 1 line
2.30.2