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

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