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

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