Blame SOURCES/0049-parser-merge-sack-perm-sack-permitted-and-maxseg-mss.patch

0341a5
From f87960ecc2ed04c803b27bb6a9c42ecd0ba0bc96 Mon Sep 17 00:00:00 2001
0341a5
From: Phil Sutter <psutter@redhat.com>
0341a5
Date: Mon, 12 Jul 2021 17:44:08 +0200
0341a5
Subject: [PATCH] parser: merge sack-perm/sack-permitted and maxseg/mss
0341a5
0341a5
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1979334
0341a5
Upstream Status: nftables commit 2a9aea6f2dfb6
0341a5
0341a5
commit 2a9aea6f2dfb6ee61528809af98860e06b38762b
0341a5
Author: Florian Westphal <fw@strlen.de>
0341a5
Date:   Mon Nov 2 00:27:04 2020 +0100
0341a5
0341a5
    parser: merge sack-perm/sack-permitted and maxseg/mss
0341a5
0341a5
    One was added by the tcp option parsing ocde, the other by synproxy.
0341a5
0341a5
    So we have:
0341a5
    synproxy ... sack-perm
0341a5
    synproxy ... mss
0341a5
0341a5
    and
0341a5
0341a5
    tcp option maxseg
0341a5
    tcp option sack-permitted
0341a5
0341a5
    This kills the extra tokens on the scanner/parser side,
0341a5
    so sack-perm and sack-permitted can both be used.
0341a5
0341a5
    Likewise, 'synproxy maxseg' and 'tcp option mss size 42' will work too.
0341a5
    On the output side, the shorter form is now preferred, i.e. sack-perm
0341a5
    and mss.
0341a5
0341a5
    Signed-off-by: Florian Westphal <fw@strlen.de>
0341a5
---
0341a5
 doc/payload-expression.txt    |  8 ++++----
0341a5
 src/parser_bison.y            | 12 +++++-------
0341a5
 src/scanner.l                 |  8 ++++----
0341a5
 src/tcpopt.c                  |  2 +-
0341a5
 tests/py/any/tcpopt.t         |  4 ++--
0341a5
 tests/py/any/tcpopt.t.json    |  8 ++++----
0341a5
 tests/py/any/tcpopt.t.payload | 12 ++++++------
0341a5
 7 files changed, 26 insertions(+), 28 deletions(-)
0341a5
0341a5
diff --git a/doc/payload-expression.txt b/doc/payload-expression.txt
0341a5
index dba42fd..3d7057c 100644
0341a5
--- a/doc/payload-expression.txt
0341a5
+++ b/doc/payload-expression.txt
0341a5
@@ -525,13 +525,13 @@ nftables currently supports matching (finding) a given ipv6 extension header, TC
0341a5
 *dst* {*nexthdr* | *hdrlength*}
0341a5
 *mh* {*nexthdr* | *hdrlength* | *checksum* | *type*}
0341a5
 *srh* {*flags* | *tag* | *sid* | *seg-left*}
0341a5
-*tcp option* {*eol* | *noop* | *maxseg* | *window* | *sack-permitted* | *sack* | *sack0* | *sack1* | *sack2* | *sack3* | *timestamp*} 'tcp_option_field'
0341a5
+*tcp option* {*eol* | *noop* | *maxseg* | *window* | *sack-perm* | *sack* | *sack0* | *sack1* | *sack2* | *sack3* | *timestamp*} 'tcp_option_field'
0341a5
 *ip option* { lsrr | ra | rr | ssrr } 'ip_option_field'
0341a5
 
0341a5
 The following syntaxes are valid only in a relational expression with boolean type on right-hand side for checking header existence only:
0341a5
 [verse]
0341a5
 *exthdr* {*hbh* | *frag* | *rt* | *dst* | *mh*}
0341a5
-*tcp option* {*eol* | *noop* | *maxseg* | *window* | *sack-permitted* | *sack* | *sack0* | *sack1* | *sack2* | *sack3* | *timestamp*}
0341a5
+*tcp option* {*eol* | *noop* | *maxseg* | *window* | *sack-perm* | *sack* | *sack0* | *sack1* | *sack2* | *sack3* | *timestamp*}
0341a5
 *ip option* { lsrr | ra | rr | ssrr }
0341a5
 
0341a5
 .IPv6 extension headers
0341a5
@@ -568,7 +568,7 @@ kind, length, size
0341a5
 |window|
0341a5
 TCP Window Scaling |
0341a5
 kind, length, count
0341a5
-|sack-permitted|
0341a5
+|sack-perm |
0341a5
 TCP SACK permitted |
0341a5
 kind, length
0341a5
 |sack|
0341a5
@@ -611,7 +611,7 @@ type, length, ptr, addr
0341a5
 
0341a5
 .finding TCP options
0341a5
 --------------------
0341a5
-filter input tcp option sack-permitted kind 1 counter
0341a5
+filter input tcp option sack-perm kind 1 counter
0341a5
 --------------------
0341a5
 
0341a5
 .matching IPv6 exthdr
0341a5
diff --git a/src/parser_bison.y b/src/parser_bison.y
0341a5
index 4cca31b..56d26e3 100644
0341a5
--- a/src/parser_bison.y
0341a5
+++ b/src/parser_bison.y
0341a5
@@ -221,7 +221,6 @@ int nft_lex(void *, void *, void *);
0341a5
 %token SYNPROXY			"synproxy"
0341a5
 %token MSS			"mss"
0341a5
 %token WSCALE			"wscale"
0341a5
-%token SACKPERM			"sack-perm"
0341a5
 
0341a5
 %token HOOK			"hook"
0341a5
 %token DEVICE			"device"
0341a5
@@ -385,14 +384,13 @@ int nft_lex(void *, void *, void *);
0341a5
 %token OPTION			"option"
0341a5
 %token ECHO			"echo"
0341a5
 %token EOL			"eol"
0341a5
-%token MAXSEG			"maxseg"
0341a5
 %token NOOP			"noop"
0341a5
 %token SACK			"sack"
0341a5
 %token SACK0			"sack0"
0341a5
 %token SACK1			"sack1"
0341a5
 %token SACK2			"sack2"
0341a5
 %token SACK3			"sack3"
0341a5
-%token SACK_PERMITTED		"sack-permitted"
0341a5
+%token SACK_PERM		"sack-permitted"
0341a5
 %token TIMESTAMP		"timestamp"
0341a5
 %token KIND			"kind"
0341a5
 %token COUNT			"count"
0341a5
@@ -2889,7 +2887,7 @@ synproxy_arg		:	MSS	NUM
0341a5
 			{
0341a5
 				$<stmt>0->synproxy.flags |= NF_SYNPROXY_OPT_TIMESTAMP;
0341a5
 			}
0341a5
-			|	SACKPERM
0341a5
+			|	SACK_PERM
0341a5
 			{
0341a5
 				$<stmt>0->synproxy.flags |= NF_SYNPROXY_OPT_SACK_PERM;
0341a5
 			}
0341a5
@@ -2944,7 +2942,7 @@ synproxy_ts		:	/* empty */	{ $$ = 0; }
0341a5
 			;
0341a5
 
0341a5
 synproxy_sack		:	/* empty */	{ $$ = 0; }
0341a5
-			|	SACKPERM
0341a5
+			|	SACK_PERM
0341a5
 			{
0341a5
 				$$ = NF_SYNPROXY_OPT_SACK_PERM;
0341a5
 			}
0341a5
@@ -4736,9 +4734,9 @@ tcp_hdr_field		:	SPORT		{ $$ = TCPHDR_SPORT; }
0341a5
 
0341a5
 tcp_hdr_option_type	:	EOL		{ $$ = TCPOPTHDR_EOL; }
0341a5
 			|	NOOP		{ $$ = TCPOPTHDR_NOOP; }
0341a5
-			|	MAXSEG		{ $$ = TCPOPTHDR_MAXSEG; }
0341a5
+			|	MSS  	  	{ $$ = TCPOPTHDR_MAXSEG; }
0341a5
 			|	WINDOW		{ $$ = TCPOPTHDR_WINDOW; }
0341a5
-			|	SACK_PERMITTED	{ $$ = TCPOPTHDR_SACK_PERMITTED; }
0341a5
+			|	SACK_PERM	{ $$ = TCPOPTHDR_SACK_PERMITTED; }
0341a5
 			|	SACK		{ $$ = TCPOPTHDR_SACK0; }
0341a5
 			|	SACK0		{ $$ = TCPOPTHDR_SACK0; }
0341a5
 			|	SACK1		{ $$ = TCPOPTHDR_SACK1; }
0341a5
diff --git a/src/scanner.l b/src/scanner.l
0341a5
index 7daf5c1..a369802 100644
0341a5
--- a/src/scanner.l
0341a5
+++ b/src/scanner.l
0341a5
@@ -419,14 +419,16 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
0341a5
 
0341a5
 "echo"			{ return ECHO; }
0341a5
 "eol"			{ return EOL; }
0341a5
-"maxseg"		{ return MAXSEG; }
0341a5
+"maxseg"		{ return MSS; }
0341a5
+"mss"			{ return MSS; }
0341a5
 "noop"			{ return NOOP; }
0341a5
 "sack"			{ return SACK; }
0341a5
 "sack0"			{ return SACK0; }
0341a5
 "sack1"			{ return SACK1; }
0341a5
 "sack2"			{ return SACK2; }
0341a5
 "sack3"			{ return SACK3; }
0341a5
-"sack-permitted"	{ return SACK_PERMITTED; }
0341a5
+"sack-permitted"	{ return SACK_PERM; }
0341a5
+"sack-perm"		{ return SACK_PERM; }
0341a5
 "timestamp"		{ return TIMESTAMP; }
0341a5
 "time"			{ return TIME; }
0341a5
 
0341a5
@@ -562,9 +564,7 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
0341a5
 "osf"			{ return OSF; }
0341a5
 
0341a5
 "synproxy"		{ return SYNPROXY; }
0341a5
-"mss"			{ return MSS; }
0341a5
 "wscale"		{ return WSCALE; }
0341a5
-"sack-perm"		{ return SACKPERM; }
0341a5
 
0341a5
 "notrack"		{ return NOTRACK; }
0341a5
 
0341a5
diff --git a/src/tcpopt.c b/src/tcpopt.c
0341a5
index ec305d9..6dbaa9e 100644
0341a5
--- a/src/tcpopt.c
0341a5
+++ b/src/tcpopt.c
0341a5
@@ -55,7 +55,7 @@ static const struct exthdr_desc tcpopt_window = {
0341a5
 };
0341a5
 
0341a5
 static const struct exthdr_desc tcpopt_sack_permitted = {
0341a5
-	.name		= "sack-permitted",
0341a5
+	.name		= "sack-perm",
0341a5
 	.type		= TCPOPT_SACK_PERMITTED,
0341a5
 	.templates	= {
0341a5
 		[TCPOPTHDR_FIELD_KIND]		= PHT("kind",   0, 8),
0341a5
diff --git a/tests/py/any/tcpopt.t b/tests/py/any/tcpopt.t
0341a5
index 08b1dcb..5f21d49 100644
0341a5
--- a/tests/py/any/tcpopt.t
0341a5
+++ b/tests/py/any/tcpopt.t
0341a5
@@ -12,8 +12,8 @@ tcp option maxseg size 1;ok
0341a5
 tcp option window kind 1;ok
0341a5
 tcp option window length 1;ok
0341a5
 tcp option window count 1;ok
0341a5
-tcp option sack-permitted kind 1;ok
0341a5
-tcp option sack-permitted length 1;ok
0341a5
+tcp option sack-perm kind 1;ok
0341a5
+tcp option sack-perm length 1;ok
0341a5
 tcp option sack kind 1;ok
0341a5
 tcp option sack length 1;ok
0341a5
 tcp option sack left 1;ok
0341a5
diff --git a/tests/py/any/tcpopt.t.json b/tests/py/any/tcpopt.t.json
0341a5
index 48eb339..2c6236a 100644
0341a5
--- a/tests/py/any/tcpopt.t.json
0341a5
+++ b/tests/py/any/tcpopt.t.json
0341a5
@@ -126,14 +126,14 @@
0341a5
     }
0341a5
 ]
0341a5
 
0341a5
-# tcp option sack-permitted kind 1
0341a5
+# tcp option sack-perm kind 1
0341a5
 [
0341a5
     {
0341a5
         "match": {
0341a5
             "left": {
0341a5
                 "tcp option": {
0341a5
                     "field": "kind",
0341a5
-                    "name": "sack-permitted"
0341a5
+                    "name": "sack-perm"
0341a5
                 }
0341a5
             },
0341a5
             "op": "==",
0341a5
@@ -142,14 +142,14 @@
0341a5
     }
0341a5
 ]
0341a5
 
0341a5
-# tcp option sack-permitted length 1
0341a5
+# tcp option sack-perm length 1
0341a5
 [
0341a5
     {
0341a5
         "match": {
0341a5
             "left": {
0341a5
                 "tcp option": {
0341a5
                     "field": "length",
0341a5
-                    "name": "sack-permitted"
0341a5
+                    "name": "sack-perm"
0341a5
                 }
0341a5
             },
0341a5
             "op": "==",
0341a5
diff --git a/tests/py/any/tcpopt.t.payload b/tests/py/any/tcpopt.t.payload
0341a5
index 63751cf..f63076a 100644
0341a5
--- a/tests/py/any/tcpopt.t.payload
0341a5
+++ b/tests/py/any/tcpopt.t.payload
0341a5
@@ -166,42 +166,42 @@ inet
0341a5
   [ exthdr load tcpopt 1b @ 3 + 2 => reg 1 ]
0341a5
   [ cmp eq reg 1 0x00000001 ]
0341a5
 
0341a5
-# tcp option sack-permitted kind 1
0341a5
+# tcp option sack-perm kind 1
0341a5
 ip 
0341a5
   [ meta load l4proto => reg 1 ]
0341a5
   [ cmp eq reg 1 0x00000006 ]
0341a5
   [ exthdr load tcpopt 1b @ 4 + 0 => reg 1 ]
0341a5
   [ cmp eq reg 1 0x00000001 ]
0341a5
 
0341a5
-# tcp option sack-permitted kind 1
0341a5
+# tcp option sack-perm kind 1
0341a5
 ip6 
0341a5
   [ meta load l4proto => reg 1 ]
0341a5
   [ cmp eq reg 1 0x00000006 ]
0341a5
   [ exthdr load tcpopt 1b @ 4 + 0 => reg 1 ]
0341a5
   [ cmp eq reg 1 0x00000001 ]
0341a5
 
0341a5
-# tcp option sack-permitted kind 1
0341a5
+# tcp option sack-perm kind 1
0341a5
 inet 
0341a5
   [ meta load l4proto => reg 1 ]
0341a5
   [ cmp eq reg 1 0x00000006 ]
0341a5
   [ exthdr load tcpopt 1b @ 4 + 0 => reg 1 ]
0341a5
   [ cmp eq reg 1 0x00000001 ]
0341a5
 
0341a5
-# tcp option sack-permitted length 1
0341a5
+# tcp option sack-perm length 1
0341a5
 ip 
0341a5
   [ meta load l4proto => reg 1 ]
0341a5
   [ cmp eq reg 1 0x00000006 ]
0341a5
   [ exthdr load tcpopt 1b @ 4 + 1 => reg 1 ]
0341a5
   [ cmp eq reg 1 0x00000001 ]
0341a5
 
0341a5
-# tcp option sack-permitted length 1
0341a5
+# tcp option sack-perm length 1
0341a5
 ip6 
0341a5
   [ meta load l4proto => reg 1 ]
0341a5
   [ cmp eq reg 1 0x00000006 ]
0341a5
   [ exthdr load tcpopt 1b @ 4 + 1 => reg 1 ]
0341a5
   [ cmp eq reg 1 0x00000001 ]
0341a5
 
0341a5
-# tcp option sack-permitted length 1
0341a5
+# tcp option sack-perm length 1
0341a5
 inet 
0341a5
   [ meta load l4proto => reg 1 ]
0341a5
   [ cmp eq reg 1 0x00000006 ]
0341a5
-- 
0341a5
2.31.1
0341a5