[nft PATCH 09/26] scanner: comp: Move to own scope.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Isolates only 'cpi' keyword for now.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 include/parser.h   | 1 +
 src/parser_bison.y | 5 +++--
 src/scanner.l      | 7 +++++--
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/include/parser.h b/include/parser.h
index 0e75bad482075..c16f210121040 100644
--- a/include/parser.h
+++ b/include/parser.h
@@ -45,6 +45,7 @@ enum startcond_type {
 	PARSER_SC_TCP,
 	PARSER_SC_VLAN,
 	PARSER_SC_CMD_LIST,
+	PARSER_SC_EXPR_COMP,
 	PARSER_SC_EXPR_FIB,
 	PARSER_SC_EXPR_HASH,
 	PARSER_SC_EXPR_IPSEC,
diff --git a/src/parser_bison.y b/src/parser_bison.y
index 937bb410fa779..7a02eaf88a58f 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -927,6 +927,7 @@ opt_newline		:	NEWLINE
 			;
 
 close_scope_arp		: { scanner_pop_start_cond(nft->scanner, PARSER_SC_ARP); };
+close_scope_comp	: { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_COMP); };
 close_scope_ct		: { scanner_pop_start_cond(nft->scanner, PARSER_SC_CT); };
 close_scope_counter	: { scanner_pop_start_cond(nft->scanner, PARSER_SC_COUNTER); };
 close_scope_eth		: { scanner_pop_start_cond(nft->scanner, PARSER_SC_ETH); };
@@ -4813,7 +4814,7 @@ primary_rhs_expr	:	symbol_expr		{ $$ = $1; }
 							 BYTEORDER_HOST_ENDIAN,
 							 sizeof(data) * BITS_PER_BYTE, &data);
 			}
-			|	COMP
+			|	COMP	close_scope_comp
 			{
 				uint8_t data = IPPROTO_COMP;
 				$$ = constant_expr_alloc(&@$, &inet_protocol_type,
@@ -5464,7 +5465,7 @@ esp_hdr_field		:	SPI		{ $$ = ESPHDR_SPI; }
 			|	SEQUENCE	{ $$ = ESPHDR_SEQUENCE; }
 			;
 
-comp_hdr_expr		:	COMP	comp_hdr_field
+comp_hdr_expr		:	COMP	comp_hdr_field	close_scope_comp
 			{
 				$$ = payload_expr_alloc(&@$, &proto_comp, $2);
 			}
diff --git a/src/scanner.l b/src/scanner.l
index 01cb501cb8cb3..a27df6c7e3915 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -211,6 +211,7 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
 %s SCANSTATE_TCP
 %s SCANSTATE_VLAN
 %s SCANSTATE_CMD_LIST
+%s SCANSTATE_EXPR_COMP
 %s SCANSTATE_EXPR_FIB
 %s SCANSTATE_EXPR_HASH
 %s SCANSTATE_EXPR_IPSEC
@@ -544,9 +545,11 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
 
 "esp"			{ return ESP; }
 
-"comp"			{ return COMP; }
+"comp"			{ scanner_push_start_cond(yyscanner, SCANSTATE_EXPR_COMP); return COMP; }
+<SCANSTATE_EXPR_COMP>{
+	"cpi"			{ return CPI; }
+}
 "flags"			{ return FLAGS; }
-"cpi"			{ return CPI; }
 
 "udp"			{ return UDP; }
 "udplite"		{ return UDPLITE; }
-- 
2.34.1




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux