summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2021-03-11 14:23:07 +0100
committerFlorian Westphal <fw@strlen.de>2021-03-16 23:59:42 +0100
commit7ae67aafa8a86b9a66bf9cb102ea551e33d243cf (patch)
tree35163e5cd42d213ef1e787f326c3a2bd17ab5619
parent8e006bb06f1bf07fb042b8d52ae6ae5bb54f38ae (diff)
scanner: arp: move to own scope
allows to move the arp specific tokens out of the INITIAL scope. Signed-off-by: Florian Westphal <fw@strlen.de>
-rw-r--r--include/parser.h1
-rw-r--r--src/parser_bison.y7
-rw-r--r--src/scanner.l15
3 files changed, 14 insertions, 9 deletions
diff --git a/include/parser.h b/include/parser.h
index cdc5fd09..38039677 100644
--- a/include/parser.h
+++ b/include/parser.h
@@ -28,6 +28,7 @@ struct parser_state {
enum startcond_type {
PARSER_SC_BEGIN,
+ PARSER_SC_ARP,
PARSER_SC_CT,
PARSER_SC_ETH,
PARSER_SC_IP,
diff --git a/src/parser_bison.y b/src/parser_bison.y
index 9cfa3366..a22f61c4 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -861,6 +861,7 @@ opt_newline : NEWLINE
| /* empty */
;
+close_scope_arp : { scanner_pop_start_cond(nft->scanner, PARSER_SC_ARP); };
close_scope_ct : { scanner_pop_start_cond(nft->scanner, PARSER_SC_CT); };
close_scope_eth : { scanner_pop_start_cond(nft->scanner, PARSER_SC_ETH); };
close_scope_fib : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_FIB); };
@@ -2431,7 +2432,7 @@ family_spec : /* empty */ { $$ = NFPROTO_IPV4; }
family_spec_explicit : IP close_scope_ip { $$ = NFPROTO_IPV4; }
| IP6 close_scope_ip6 { $$ = NFPROTO_IPV6; }
| INET { $$ = NFPROTO_INET; }
- | ARP { $$ = NFPROTO_ARP; }
+ | ARP close_scope_arp { $$ = NFPROTO_ARP; }
| BRIDGE { $$ = NFPROTO_BRIDGE; }
| NETDEV { $$ = NFPROTO_NETDEV; }
;
@@ -4544,7 +4545,7 @@ keyword_expr : ETHER close_scope_eth { $$ = symbol_value(&@$, "ether"); }
| IP close_scope_ip { $$ = symbol_value(&@$, "ip"); }
| IP6 close_scope_ip6 { $$ = symbol_value(&@$, "ip6"); }
| VLAN { $$ = symbol_value(&@$, "vlan"); }
- | ARP { $$ = symbol_value(&@$, "arp"); }
+ | ARP close_scope_arp { $$ = symbol_value(&@$, "arp"); }
| DNAT { $$ = symbol_value(&@$, "dnat"); }
| SNAT { $$ = symbol_value(&@$, "snat"); }
| ECN { $$ = symbol_value(&@$, "ecn"); }
@@ -5104,7 +5105,7 @@ vlan_hdr_field : ID { $$ = VLANHDR_VID; }
| TYPE { $$ = VLANHDR_TYPE; }
;
-arp_hdr_expr : ARP arp_hdr_field
+arp_hdr_expr : ARP arp_hdr_field close_scope_arp
{
$$ = payload_expr_alloc(&@$, &proto_arp, $2);
}
diff --git a/src/scanner.l b/src/scanner.l
index b1b03b95..509b1b0d 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -196,6 +196,7 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr})
%option nodefault
%option warn
%option stack
+%s SCANSTATE_ARP
%s SCANSTATE_CT
%s SCANSTATE_ETH
%s SCANSTATE_IP
@@ -405,12 +406,14 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr})
"cfi" { return CFI; }
"pcp" { return PCP; }
-"arp" { return ARP; }
-"htype" { return HTYPE; }
-"ptype" { return PTYPE; }
-"hlen" { return HLEN; }
-"plen" { return PLEN; }
-"operation" { return OPERATION; }
+"arp" { scanner_push_start_cond(yyscanner, SCANSTATE_ARP); return ARP; }
+<SCANSTATE_ARP>{
+ "htype" { return HTYPE; }
+ "ptype" { return PTYPE; }
+ "hlen" { return HLEN; }
+ "plen" { return PLEN; }
+ "operation" { return OPERATION; }
+}
"ip" { scanner_push_start_cond(yyscanner, SCANSTATE_IP); return IP; }
"version" { return HDRVERSION; }