94 lines
2.6 KiB
Diff
94 lines
2.6 KiB
Diff
|
From 5009b467a06a86f5dcc3218fb860cd81bc5e067f Mon Sep 17 00:00:00 2001
|
||
|
From: Phil Sutter <phil@nwl.cc>
|
||
|
Date: Tue, 4 May 2021 13:06:32 +0200
|
||
|
Subject: [PATCH] scanner: sctp: Move to own scope
|
||
|
|
||
|
This isolates only "vtag" token for now.
|
||
|
|
||
|
Signed-off-by: Phil Sutter <phil@nwl.cc>
|
||
|
Reviewed-by: Florian Westphal <fw@strlen.de>
|
||
|
(cherry picked from commit 0925d7e214825628e7db4a86d5ebbad578ab0777)
|
||
|
|
||
|
Conflicts:
|
||
|
include/parser.h
|
||
|
src/parser_bison.y
|
||
|
src/scanner.l
|
||
|
-> Context changes due to missing other scopes.
|
||
|
---
|
||
|
include/parser.h | 1 +
|
||
|
src/parser_bison.y | 5 +++--
|
||
|
src/scanner.l | 8 ++++++--
|
||
|
3 files changed, 10 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/include/parser.h b/include/parser.h
|
||
|
index b2ebd7aa226c5..4e7b4ef430966 100644
|
||
|
--- a/include/parser.h
|
||
|
+++ b/include/parser.h
|
||
|
@@ -28,6 +28,7 @@ struct parser_state {
|
||
|
|
||
|
enum startcond_type {
|
||
|
PARSER_SC_BEGIN,
|
||
|
+ PARSER_SC_SCTP,
|
||
|
PARSER_SC_EXPR_HASH,
|
||
|
PARSER_SC_EXPR_NUMGEN,
|
||
|
};
|
||
|
diff --git a/src/parser_bison.y b/src/parser_bison.y
|
||
|
index da3fafcd1eeb1..383908fa3742f 100644
|
||
|
--- a/src/parser_bison.y
|
||
|
+++ b/src/parser_bison.y
|
||
|
@@ -859,6 +859,7 @@ opt_newline : NEWLINE
|
||
|
|
||
|
close_scope_hash : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_HASH); };
|
||
|
close_scope_numgen : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_NUMGEN); };
|
||
|
+close_scope_sctp : { scanner_pop_start_cond(nft->scanner, PARSER_SC_SCTP); };
|
||
|
|
||
|
common_block : INCLUDE QUOTED_STRING stmt_separator
|
||
|
{
|
||
|
@@ -4620,7 +4621,7 @@ primary_rhs_expr : symbol_expr { $$ = $1; }
|
||
|
BYTEORDER_HOST_ENDIAN,
|
||
|
sizeof(data) * BITS_PER_BYTE, &data);
|
||
|
}
|
||
|
- | SCTP
|
||
|
+ | SCTP close_scope_sctp
|
||
|
{
|
||
|
uint8_t data = IPPROTO_SCTP;
|
||
|
$$ = constant_expr_alloc(&@$, &inet_protocol_type,
|
||
|
@@ -5345,7 +5346,7 @@ dccp_hdr_field : SPORT { $$ = DCCPHDR_SPORT; }
|
||
|
| TYPE { $$ = DCCPHDR_TYPE; }
|
||
|
;
|
||
|
|
||
|
-sctp_hdr_expr : SCTP sctp_hdr_field
|
||
|
+sctp_hdr_expr : SCTP sctp_hdr_field close_scope_sctp
|
||
|
{
|
||
|
$$ = payload_expr_alloc(&@$, &proto_sctp, $2);
|
||
|
}
|
||
|
diff --git a/src/scanner.l b/src/scanner.l
|
||
|
index ec8f252fbc8c8..c8e74e685f3d7 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_SCTP
|
||
|
%s SCANSTATE_EXPR_HASH
|
||
|
%s SCANSTATE_EXPR_NUMGEN
|
||
|
|
||
|
@@ -491,8 +492,11 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr})
|
||
|
|
||
|
"dccp" { return DCCP; }
|
||
|
|
||
|
-"sctp" { return SCTP; }
|
||
|
-"vtag" { return VTAG; }
|
||
|
+"sctp" { scanner_push_start_cond(yyscanner, SCANSTATE_SCTP); return SCTP; }
|
||
|
+
|
||
|
+<SCANSTATE_SCTP>{
|
||
|
+ "vtag" { return VTAG; }
|
||
|
+}
|
||
|
|
||
|
"rt" { return RT; }
|
||
|
"rt0" { return RT0; }
|
||
|
--
|
||
|
2.33.0
|
||
|
|