A bit of non-constant binop follow-up
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 2 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | parser_json: Accept non-RHS expressions in binop RHSsrc/ | +1 | 0 replies | |
| 2/2 | parser_bison: Accept non-constant binop on LHS of relationalsdoc/ src/ src/ +4 more | +103 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [nft PATCH 0/2] A bit of non-constant binop follow-up
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(-)
Signature · 1 line
2.51.0