parser: move qualified meta expression parsing to flex/bison
Florian Westphal
maintainerPATCH 1/1 parser: move qualified meta expression parsing to flex/bison
The meta keyword currently accepts 'STRING' arguments.
This was originally done to avoid pollution the global token namespace.
However, nowadays we do have flex scopes to avoid this. Add the tokens currently handled implciitly via STRING within META flex scope.
SECPATH is a compatibility alias, map this to IPSEC token. IBRPORT/OBRPORT are also compatibility aliases, remove those tokens and handle this directly in scanner.l.
This also avoids nft from printing tokens in help texts that are only there for compatibility with old rulesets.
meta_key_parse() is retained for json input parser.
--- doc/libnftables-json.adoc | 2 +- src/parser_bison.y | 54 +++++++++++++++------------------------ src/scanner.l | 19 ++++++++++++-- 3 files changed, 39 insertions(+), 36 deletions(-)
doc/libnftables-json.adoc +1 -1
@@ -1269,7 +1269,7 @@ ____ 'META_KEY' := *"length"* | *"protocol"* | *"priority"* | *"random"* | *"mark"* | *"iif"* | *"iifname"* | *"iiftype"* | *"oif"* | *"oifname"* | *"oiftype"* | *"skuid"* | *"skgid"* | *"nftrace"* | - *"rtclassid"* | *"ibriport"* | *"obriport"* | *"ibridgename"* | + *"rtclassid"* | *"ibrname"* | *"obrname"* | *"ibridgename"* | *"obridgename"* | *"pkttype"* | *"cpu"* | *"iifgroup"* | *"oifgroup"* | *"cgroup"* | *"nfproto"* | *"l4proto"* | *"secpath"*
src/parser_bison.y +21 -33
90 lines not on this page · raw message
src/scanner.l +17 -2
@@ -754,15 +754,30 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr}) "skgid" { return SKGID; } "nftrace" { return NFTRACE; } "rtclassid" { return RTCLASSID; } -"ibriport" { return IBRIPORT; } +"ibriport" { return IBRIDGENAME; } /* backwards compat */ "ibrname" { return IBRIDGENAME; } -"obriport" { return OBRIPORT; } +"obriport" { return OBRIDGENAME; } /* backwards compat */ "obrname" { return OBRIDGENAME; } "pkttype" { return PKTTYPE; } "cpu" { return CPU; } "iifgroup" { return IIFGROUP; } "oifgroup" { return OIFGROUP; } "cgroup" { return CGROUP; } +<SCANSTATE_META>{ + "nfproto" { return NFPROTO; } + "l4proto" { return L4PROTO; } + "iifkind" { return IIFKIND; } + "oifkind" { return OIFKIND; } + "ibrpvid" { return IBRPVID; } + "ibrvproto" { return IBRVPROTO; } + "sdif" { return SDIF; } + "sdifname" { return SDIFNAME; } + "broute" { return BROUTE; } + "ibrhwaddr" { return BRIFHWADDR; } + + /* backwards compat */ + "secpath" { scanner_push_start_cond(yyscanner, SCANSTATE_EXPR_IPSEC); return IPSEC; } +} <SCANSTATE_EXPR_RT>{ "nexthop" { return NEXTHOP; }
Signature · 1 line
2.52.0
Quoted 11 lines · Florian Westphal
The meta keyword currently accepts 'STRING' arguments.
This was originally done to avoid pollution the global token namespace.However, nowadays we do have flex scopes to avoid this. Add the tokens currently handled implciitly via STRING within META flex scope.
SECPATH is a compatibility alias, map this to IPSEC token. IBRPORT/OBRPORT are also compatibility aliases, remove those tokens and handle this directly in scanner.l.
Quoted 6 lines
This also avoids nft from printing tokens in help texts that are only there for compatibility with old rulesets.
meta_key_parse()is retained for json input parser.Signed-off-by Florian Westphal <[email protected]>