Revert "scanner: remove saddr/daddr from initial state"
Phil Sutter
reviewerPATCH v2 1/1 Revert "scanner: remove saddr/daddr from initial state"
This reverts commit df4ee3171f3e3c0e85dd45d555d7d06e8c1647c5 as it breaks ipsec expression if preceeded by a counter statement:
| Error: syntax error, unexpected string, expecting saddr or daddr | add rule ip ipsec-ip4 ipsec-forw counter ipsec out ip daddr 192.168.1.2 | ^^^^^
Signed-off-by Phil Sutter <[email protected]>
---
Changes since v1:
- Fold the two patches into one.
--- src/scanner.l | 6 ++---- tests/py/inet/ipsec.t | 2 ++ tests/py/inet/ipsec.t.json | 21 +++++++++++++++++++++ tests/py/inet/ipsec.t.payload | 6 ++++++ 4 files changed, 31 insertions(+), 4 deletions(-)
src/scanner.l +2 -4
@@ -464,10 +464,8 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr}) "bridge" { return BRIDGE; } "ether" { scanner_push_start_cond(yyscanner, SCANSTATE_ETH); return ETHER; } -<SCANSTATE_ARP,SCANSTATE_CT,SCANSTATE_ETH,SCANSTATE_IP,SCANSTATE_IP6,SCANSTATE_EXPR_FIB,SCANSTATE_EXPR_IPSEC>{ - "saddr" { return SADDR; } - "daddr" { return DADDR; } -} +"saddr" { return SADDR; } +"daddr" { return DADDR; } "type" { scanner_push_start_cond(yyscanner, SCANSTATE_TYPE); return TYPE; } "typeof" { return TYPEOF; }
tests/py/inet/ipsec.t +2 -0
@@ -19,3 +19,5 @@ ipsec in ip6 daddr dead::beef;ok ipsec out ip6 saddr dead::feed;ok ipsec in spnum 256 reqid 1;fail + +counter ipsec out ip daddr 192.168.1.2;ok
tests/py/inet/ipsec.t.json +21 -0
@@ -134,3 +134,24 @@ } } ] + +# counter ipsec out ip daddr 192.168.1.2 +[ + { + "counter": null + }, + { + "match": { + "left": { + "ipsec": { + "dir": "out", + "family": "ip", + "key": "daddr", + "spnum": 0 + } + }, + "op": "==", + "right": "192.168.1.2" + } + } +]
tests/py/inet/ipsec.t.payload +6 -0
@@ -37,3 +37,9 @@ ip ipsec-ip4 ipsec-forw [ xfrm load out 0 saddr6 => reg 1 ] [ cmp eq reg 1 0x0000adde 0x00000000 0x00000000 0xedfe0000 ] +# counter ipsec out ip daddr 192.168.1.2 +ip ipsec-ip4 ipsec-forw + [ counter pkts 0 bytes 0 ] + [ xfrm load out 0 daddr4 => reg 1 ] + [ cmp eq reg 1 0x0201a8c0 ] +
Signature · 1 line
2.34.1
Florian Westphal
maintainerQuoted 11 lines · Phil Sutter
This reverts commit
df4ee3171f3e3c0e85dd45d555d7d06e8c1647c5as it breaks ipsec expression if preceeded by a counter statement:| Error: syntax error, unexpected string, expecting saddr or daddr | add rule ip ipsec-ip4 ipsec-forw counter ipsec out ip daddr 192.168.1.2 | ^^^^^Signed-off-by Phil Sutter <[email protected]>---
Changes since v1:
- Fold the two patches into one.
Please hold back a bit, I think this is a bug in the scoping code on nft side, not a flex or bison limitation.
I've applied the test case locally and will report back on alternate fix for this bug.