public inbox for netfilter-devel@vger.kernel.org
 help / color / mirror / Atom feed
* [nft PATCH 0/2] A bit of non-constant binop follow-up
@ 2026-04-02 18:43 Phil Sutter
  2026-04-02 18:43 ` [nft PATCH 1/2] parser_json: Accept non-RHS expressions in binop RHS Phil Sutter
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Phil Sutter @ 2026-04-02 18:43 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel, Dion Bosschieter

When asked about how to translate ebtables' --arp-gratuitous match, I
noticed that basically everything is there already but the parser
rejects it.

While we can't do a simple 'arp saddr ip == arp daddr ip' because cmp
expression requires for one side of the equation to be constant, using
XOR on LHS we can work around this limitation:

arp saddr ip ^ arp daddr ip == 0.0.0.0

Thanks to Jeremy's work on bitwise expression (which one might want to
repeat for cmp), the above is possible in VM code:

[ payload load 4b @ network header + 14 => reg 1 ]
[ payload load 4b @ network header + 24 => reg 2 ]
[ bitwise reg 1 = ( reg 1 ^ reg 2 ) ]
[ cmp eq reg 1 0x00000000 ]

Patch 2 of this series relaxes the parser so it accepts the input.
Basically it undoes an old workaround needed before we introduced start
conditions.

Patch 1 removes a similar restriction in JSON parser. It is needed at
least to accept the JSON equivalent of above match (conversion to JSON
on output was already correct).

Phil Sutter (2):
  parser_json: Accept non-RHS expressions in binop RHS
  parser_bison: Accept non-constant binop on LHS of relationals

 doc/payload-expression.txt        |  6 ++++
 src/parser_bison.y                | 16 +++++-----
 src/parser_json.c                 |  2 +-
 src/scanner.l                     |  2 +-
 tests/py/arp/arp.t                |  4 +++
 tests/py/arp/arp.t.json           | 51 +++++++++++++++++++++++++++++++
 tests/py/arp/arp.t.payload        | 14 +++++++++
 tests/py/arp/arp.t.payload.netdev | 18 +++++++++++
 8 files changed, 104 insertions(+), 9 deletions(-)

-- 
2.51.0


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

end of thread, other threads:[~2026-04-04  9:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02 18:43 [nft PATCH 0/2] A bit of non-constant binop follow-up Phil Sutter
2026-04-02 18:43 ` [nft PATCH 1/2] parser_json: Accept non-RHS expressions in binop RHS Phil Sutter
2026-04-02 18:43 ` [nft PATCH 2/2] parser_bison: Accept non-constant binop on LHS of relationals Phil Sutter
2026-04-03 15:53 ` [nft PATCH 0/2] A bit of non-constant binop follow-up Jeremy Sowden
2026-04-04  9:32   ` Phil Sutter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox