All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH nft v3 00/18] Support for boolean binops with variable RHS operands.
@ 2020-03-03  9:48 Jeremy Sowden
  2020-03-03  9:48 ` [PATCH nft v3 01/18] evaluate: add separate variables for lshift and xor binops Jeremy Sowden
                   ` (18 more replies)
  0 siblings, 19 replies; 27+ messages in thread
From: Jeremy Sowden @ 2020-03-03  9:48 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Florian Westphal; +Cc: Netfilter Devel

Kernel support for passing mask and xor values for bitwise boolean
operations via registers allows us to support boolean binop's with
variable RHS operands: XOR expressions pass the xor value in a register;
AND expressions pass the mask value in a register; OR expressions pass
both mask and xor values in registers.

NB, OR expressions are converted to `(a & (b ^ 1)) ^ b` during
linearization (in patch 9), because it makes both linearization and
delinearization a lot simpler.  However, it involves rearranging and
allocating expressions after the evaluation phase.  Since nothing else
does this, AFAICS, I'm not sure whether it's the right thing to do.

The patch-set comprises four parts:

   1 -  7: some tidying and bug-fixes;
   8 - 10: support for variable RHS operands;
  11 - 15: updates to linearization and delinearization of payload
           expressions to work correctly with variable RHS operands;
  16 - 18: some new shell and Python test-cases.

Changes since v2:

  * patch 11 updated to stop binop length being clobbered during
    evaluation, instead of working around it during linearization.

Changes since v1:

  * patch 05 updated to treat short values as constant, rather than
    doing nothing with them.

Jeremy Sowden (18):
  evaluate: add separate variables for lshift and xor binops.
  evaluate: simplify calculation of payload size.
  evaluate: don't evaluate payloads twice.
  evaluate: convert the byte-order of payload statement arguments.
  evaluate: no need to swap byte-order for values of fewer than 16 bits.
  netlink_delinearize: set shift RHS byte-order.
  src: fix leaks.
  include: update nf_tables.h.
  src: support (de)linearization of bitwise op's with variable right
    operands.
  evaluate: allow boolean binop expressions with variable righthand
    arguments.
  evaluate: don't clobber binop bitmask lengths.
  netlink_delinearize: fix typo.
  netlink_delinearize: refactor stmt_payload_binop_postprocess.
  netlink_delinearize: add support for processing variable payload
    statement arguments.
  netlink_delinearize: add postprocessing for payload binops.
  tests: shell: remove stray debug flag.
  tests: shell: add variable binop RHS tests.
  tests: py: add variable binop RHS tests.

 include/expression.h                          |   1 +
 include/linux/netfilter/nf_tables.h           |   4 +
 src/evaluate.c                                |  77 ++--
 src/netlink_delinearize.c                     | 370 +++++++++++++-----
 src/netlink_linearize.c                       |  95 ++++-
 tests/py/any/ct.t                             |   1 +
 tests/py/any/ct.t.json                        |  37 ++
 tests/py/any/ct.t.payload                     |  33 ++
 tests/py/any/meta.t.payload                   |   4 -
 tests/py/inet/tcp.t                           |   2 +
 tests/py/inet/tcp.t.json                      |  46 ++-
 tests/py/inet/tcp.t.payload                   |  68 ++++
 tests/py/ip/ip.t                              |   3 +
 tests/py/ip/ip.t.json                         |  66 ++++
 tests/py/ip/ip.t.payload                      |  26 ++
 tests/py/ip/ip.t.payload.bridge               |  30 ++
 tests/py/ip/ip.t.payload.inet                 |  30 ++
 tests/py/ip/ip.t.payload.netdev               |  30 ++
 tests/shell/testcases/chains/0040mark_shift_0 |   2 +-
 tests/shell/testcases/chains/0040mark_shift_2 |  11 +
 .../testcases/chains/0041payload_variable_0   |  11 +
 .../testcases/chains/0041payload_variable_1   |  11 +
 .../testcases/chains/0041payload_variable_2   |  11 +
 .../testcases/chains/0041payload_variable_3   |  11 +
 .../chains/dumps/0040mark_shift_2.nft         |   6 +
 .../chains/dumps/0041payload_variable_0.nft   |   6 +
 .../chains/dumps/0041payload_variable_1.nft   |   6 +
 .../chains/dumps/0041payload_variable_2.nft   |   6 +
 .../chains/dumps/0041payload_variable_3.nft   |   6 +
 29 files changed, 873 insertions(+), 137 deletions(-)
 create mode 100755 tests/shell/testcases/chains/0040mark_shift_2
 create mode 100755 tests/shell/testcases/chains/0041payload_variable_0
 create mode 100755 tests/shell/testcases/chains/0041payload_variable_1
 create mode 100755 tests/shell/testcases/chains/0041payload_variable_2
 create mode 100755 tests/shell/testcases/chains/0041payload_variable_3
 create mode 100644 tests/shell/testcases/chains/dumps/0040mark_shift_2.nft
 create mode 100644 tests/shell/testcases/chains/dumps/0041payload_variable_0.nft
 create mode 100644 tests/shell/testcases/chains/dumps/0041payload_variable_1.nft
 create mode 100644 tests/shell/testcases/chains/dumps/0041payload_variable_2.nft
 create mode 100644 tests/shell/testcases/chains/dumps/0041payload_variable_3.nft

-- 
2.25.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2020-03-11 20:53 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-03  9:48 [PATCH nft v3 00/18] Support for boolean binops with variable RHS operands Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 01/18] evaluate: add separate variables for lshift and xor binops Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 02/18] evaluate: simplify calculation of payload size Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 03/18] evaluate: don't evaluate payloads twice Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 04/18] evaluate: convert the byte-order of payload statement arguments Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 05/18] evaluate: no need to swap byte-order for values of fewer than 16 bits Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 06/18] netlink_delinearize: set shift RHS byte-order Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 07/18] src: fix leaks Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 08/18] include: update nf_tables.h Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 09/18] src: support (de)linearization of bitwise op's with variable right operands Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 10/18] evaluate: allow boolean binop expressions with variable righthand arguments Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 11/18] evaluate: don't clobber binop bitmask lengths Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 12/18] netlink_delinearize: fix typo Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 13/18] netlink_delinearize: refactor stmt_payload_binop_postprocess Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 14/18] netlink_delinearize: add support for processing variable payload statement arguments Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 15/18] netlink_delinearize: add postprocessing for payload binops Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 16/18] tests: shell: remove stray debug flag Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 17/18] tests: shell: add variable binop RHS tests Jeremy Sowden
2020-03-03  9:48 ` [PATCH nft v3 18/18] tests: py: " Jeremy Sowden
2020-03-10  2:39   ` Pablo Neira Ayuso
2020-03-10  9:30     ` Jeremy Sowden
2020-03-11 13:26       ` Pablo Neira Ayuso
2020-03-11 14:35         ` Jeremy Sowden
2020-03-11 17:17           ` Pablo Neira Ayuso
2020-03-11 20:54             ` Jeremy Sowden
2020-03-05 10:53 ` [PATCH nft v3 00/18] Support for boolean binops with variable RHS operands Florian Westphal
2020-03-05 11:36   ` Jeremy Sowden

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.