Blame SOURCES/0058-scanner-sctp-Move-to-own-scope.patch

cf8614
From 595e79b1ccdfa6b11cd6c2b1c8eda0161b58d22a Mon Sep 17 00:00:00 2001
cf8614
From: Phil Sutter <psutter@redhat.com>
cf8614
Date: Tue, 13 Jul 2021 13:54:12 +0200
cf8614
Subject: [PATCH] scanner: sctp: Move to own scope
cf8614
cf8614
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1979334
cf8614
Upstream Status: nftables commit 0925d7e214825
cf8614
Conflicts: Context change due to missing other scopes.
cf8614
cf8614
commit 0925d7e214825628e7db4a86d5ebbad578ab0777
cf8614
Author: Phil Sutter <phil@nwl.cc>
cf8614
Date:   Tue May 4 13:06:32 2021 +0200
cf8614
cf8614
    scanner: sctp: Move to own scope
cf8614
cf8614
    This isolates only "vtag" token for now.
cf8614
cf8614
    Signed-off-by: Phil Sutter <phil@nwl.cc>
cf8614
    Reviewed-by: Florian Westphal <fw@strlen.de>
cf8614
---
cf8614
 include/parser.h   | 1 +
cf8614
 src/parser_bison.y | 5 +++--
cf8614
 src/scanner.l      | 8 ++++++--
cf8614
 3 files changed, 10 insertions(+), 4 deletions(-)
cf8614
cf8614
diff --git a/include/parser.h b/include/parser.h
cf8614
index 1d293f5..2e6ef4d 100644
cf8614
--- a/include/parser.h
cf8614
+++ b/include/parser.h
cf8614
@@ -30,6 +30,7 @@ struct parser_state {
cf8614
 
cf8614
 enum startcond_type {
cf8614
 	PARSER_SC_BEGIN,
cf8614
+	PARSER_SC_SCTP,
cf8614
 	PARSER_SC_EXPR_HASH,
cf8614
 	PARSER_SC_EXPR_NUMGEN,
cf8614
 };
cf8614
diff --git a/src/parser_bison.y b/src/parser_bison.y
cf8614
index 9a9447f..beb5995 100644
cf8614
--- a/src/parser_bison.y
cf8614
+++ b/src/parser_bison.y
cf8614
@@ -842,6 +842,7 @@ opt_newline		:	NEWLINE
cf8614
 
cf8614
 close_scope_hash	: { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_HASH); };
cf8614
 close_scope_numgen	: { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_NUMGEN); };
cf8614
+close_scope_sctp	: { scanner_pop_start_cond(nft->scanner, PARSER_SC_SCTP); };
cf8614
 
cf8614
 common_block		:	INCLUDE		QUOTED_STRING	stmt_separator
cf8614
 			{
cf8614
@@ -4059,7 +4060,7 @@ primary_rhs_expr	:	symbol_expr		{ $$ = $1; }
cf8614
 							 BYTEORDER_HOST_ENDIAN,
cf8614
 							 sizeof(data) * BITS_PER_BYTE, &data);
cf8614
 			}
cf8614
-			|	SCTP
cf8614
+			|	SCTP	close_scope_sctp
cf8614
 			{
cf8614
 				uint8_t data = IPPROTO_SCTP;
cf8614
 				$$ = constant_expr_alloc(&@$, &inet_protocol_type,
cf8614
@@ -4782,7 +4783,7 @@ dccp_hdr_field		:	SPORT		{ $$ = DCCPHDR_SPORT; }
cf8614
 			|	TYPE		{ $$ = DCCPHDR_TYPE; }
cf8614
 			;
cf8614
 
cf8614
-sctp_hdr_expr		:	SCTP	sctp_hdr_field
cf8614
+sctp_hdr_expr		:	SCTP	sctp_hdr_field	close_scope_sctp
cf8614
 			{
cf8614
 				$$ = payload_expr_alloc(&@$, &proto_sctp, $2);
cf8614
 			}
cf8614
diff --git a/src/scanner.l b/src/scanner.l
cf8614
index 68fe988..b79ae55 100644
cf8614
--- a/src/scanner.l
cf8614
+++ b/src/scanner.l
cf8614
@@ -196,6 +196,7 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
cf8614
 %option nodefault
cf8614
 %option warn
cf8614
 %option stack
cf8614
+%s SCANSTATE_SCTP
cf8614
 %s SCANSTATE_EXPR_HASH
cf8614
 %s SCANSTATE_EXPR_NUMGEN
cf8614
 
cf8614
@@ -488,8 +489,11 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
cf8614
 
cf8614
 "dccp"			{ return DCCP; }
cf8614
 
cf8614
-"sctp"			{ return SCTP; }
cf8614
-"vtag"			{ return VTAG; }
cf8614
+"sctp"			{ scanner_push_start_cond(yyscanner, SCANSTATE_SCTP); return SCTP; }
cf8614
+
cf8614
+<SCANSTATE_SCTP>{
cf8614
+	"vtag"			{ return VTAG; }
cf8614
+}
cf8614
 
cf8614
 "rt"			{ return RT; }
cf8614
 "rt0"			{ return RT0; }
cf8614
-- 
cf8614
2.31.1
cf8614