netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nft 05/12] scanner: add ether scope
Date: Thu, 11 Mar 2021 14:23:06 +0100	[thread overview]
Message-ID: <20210311132313.24403-6-fw@strlen.de> (raw)
In-Reply-To: <20210311132313.24403-1-fw@strlen.de>

just like previous change: useless as-is, but prepares
for removal of saddr/daddr from INITIAL scope.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 include/parser.h   |  1 +
 src/parser_bison.y | 11 ++++++-----
 src/scanner.l      |  3 ++-
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/include/parser.h b/include/parser.h
index e338713dad32..cdc5fd094af5 100644
--- a/include/parser.h
+++ b/include/parser.h
@@ -29,6 +29,7 @@ struct parser_state {
 enum startcond_type {
 	PARSER_SC_BEGIN,
 	PARSER_SC_CT,
+	PARSER_SC_ETH,
 	PARSER_SC_IP,
 	PARSER_SC_IP6,
 	PARSER_SC_EXPR_FIB,
diff --git a/src/parser_bison.y b/src/parser_bison.y
index 74ab69dd8820..9cfa336643e5 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -862,6 +862,7 @@ opt_newline		:	NEWLINE
 			;
 
 close_scope_ct		: { scanner_pop_start_cond(nft->scanner, PARSER_SC_CT); };
+close_scope_eth		: { scanner_pop_start_cond(nft->scanner, PARSER_SC_ETH); };
 close_scope_fib		: { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_FIB); };
 close_scope_hash	: { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_HASH); };
 close_scope_ip		: { scanner_pop_start_cond(nft->scanner, PARSER_SC_IP); };
@@ -3015,7 +3016,7 @@ log_flags		:	TCP	log_flags_tcp
 			{
 				$$ = NF_LOG_UID;
 			}
-			|	ETHER
+			|	ETHER	close_scope_eth
 			{
 				$$ = NF_LOG_MACDECODE;
 			}
@@ -4539,7 +4540,7 @@ boolean_expr		:	boolean_keys
 			}
 			;
 
-keyword_expr		:	ETHER                   { $$ = symbol_value(&@$, "ether"); }
+keyword_expr		:	ETHER   close_scope_eth { $$ = symbol_value(&@$, "ether"); }
 			|	IP	close_scope_ip  { $$ = symbol_value(&@$, "ip"); }
 			|	IP6	close_scope_ip6 { $$ = symbol_value(&@$, "ip6"); }
 			|	VLAN			{ $$ = symbol_value(&@$, "vlan"); }
@@ -5080,7 +5081,7 @@ payload_base_spec	:	LL_HDR		{ $$ = PROTO_BASE_LL_HDR; }
 			|	TRANSPORT_HDR	{ $$ = PROTO_BASE_TRANSPORT_HDR; }
 			;
 
-eth_hdr_expr		:	ETHER	eth_hdr_field
+eth_hdr_expr		:	ETHER	eth_hdr_field	close_scope_eth
 			{
 				$$ = payload_expr_alloc(&@$, &proto_eth, $2);
 			}
@@ -5114,8 +5115,8 @@ arp_hdr_field		:	HTYPE		{ $$ = ARPHDR_HRD; }
 			|	HLEN		{ $$ = ARPHDR_HLN; }
 			|	PLEN		{ $$ = ARPHDR_PLN; }
 			|	OPERATION	{ $$ = ARPHDR_OP; }
-			|	SADDR ETHER	{ $$ = ARPHDR_SADDR_ETHER; }
-			|	DADDR ETHER	{ $$ = ARPHDR_DADDR_ETHER; }
+			|	SADDR ETHER	close_scope_eth	{ $$ = ARPHDR_SADDR_ETHER; }
+			|	DADDR ETHER	close_scope_eth { $$ = ARPHDR_DADDR_ETHER; }
 			|	SADDR IP	close_scope_ip	{ $$ = ARPHDR_SADDR_IP; }
 			|	DADDR IP	close_scope_ip	{ $$ = ARPHDR_DADDR_IP; }
 			;
diff --git a/src/scanner.l b/src/scanner.l
index c78f34b625c2..b1b03b951263 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -197,6 +197,7 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
 %option warn
 %option stack
 %s SCANSTATE_CT
+%s SCANSTATE_ETH
 %s SCANSTATE_IP
 %s SCANSTATE_IP6
 %s SCANSTATE_EXPR_FIB
@@ -393,7 +394,7 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
 
 "bridge"		{ return BRIDGE; }
 
-"ether"			{ return ETHER; }
+"ether"			{ scanner_push_start_cond(yyscanner, SCANSTATE_ETH); return ETHER; }
 "saddr"			{ return SADDR; }
 "daddr"			{ return DADDR; }
 "type"			{ return TYPE; }
-- 
2.26.2


  parent reply	other threads:[~2021-03-11 13:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11 13:23 [PATCH nft 00/12] move more keywords away from initial scope Florian Westphal
2021-03-11 13:23 ` [PATCH nft 01/12] scanner: ct: move to own scope Florian Westphal
2021-03-11 13:23 ` [PATCH nft 02/12] scanner: ip: " Florian Westphal
2021-03-11 13:23 ` [PATCH nft 03/12] scanner: ip6: " Florian Westphal
2021-03-11 13:23 ` [PATCH nft 04/12] scanner: add fib scope Florian Westphal
2021-03-11 13:23 ` Florian Westphal [this message]
2021-03-11 13:23 ` [PATCH nft 06/12] scanner: arp: move to own scope Florian Westphal
2021-03-11 13:23 ` [PATCH nft 07/12] scanner: remove saddr/daddr from initial state Florian Westphal
2021-03-11 13:23 ` [PATCH nft 08/12] scanner: vlan: move to own scope Florian Westphal
2021-03-11 13:23 ` [PATCH nft 09/12] scanner: limit: " Florian Westphal
2021-03-11 13:23 ` [PATCH nft 10/12] scanner: quota: " Florian Westphal
2021-03-11 13:23 ` [PATCH nft 11/12] scanner: move until,over,used keywords away from init state Florian Westphal
2021-03-11 13:23 ` [PATCH nft 12/12] scanner: secmark: move to own scope Florian Westphal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210311132313.24403-6-fw@strlen.de \
    --to=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).