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

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