]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tcpopt: remove KIND keyword
authorFlorian Westphal <fw@strlen.de>
Sun, 21 Nov 2021 22:32:57 +0000 (23:32 +0100)
committerFlorian Westphal <fw@strlen.de>
Wed, 1 Dec 2021 13:11:39 +0000 (14:11 +0100)
tcp option <foo> kind ... never makes any sense, as "tcp option <foo>"
already tells the kernel to look for the foo <kind>.

"tcp option sack kind 5" matches if the sack option is present; its a
more complicated form of the simpler "tcp option sack exists".

"tcp option sack kind 1" (or any other value than 5) will never match.

So remove this.

Test cases are converted to "exists".

Signed-off-by: Florian Westphal <fw@strlen.de>
doc/payload-expression.txt
src/parser_bison.y
src/scanner.l
tests/py/any/tcpopt.t
tests/py/any/tcpopt.t.json
tests/py/any/tcpopt.t.payload

index 930a18074a6ca8c93198ed7fcd0602b4ae7c3fd1..106ff74ce57ef5503da02d68b9f144685c0eda57 100644 (file)
@@ -614,37 +614,37 @@ Segment Routing Header
 |Keyword| Description | TCP option fields
 |eol|
 End if option list|
-kind
+-
 |nop|
 1 Byte TCP Nop padding option |
-kind
+-
 |maxseg|
 TCP Maximum Segment Size|
-kind, length, size
+length, size
 |window|
 TCP Window Scaling |
-kind, length, count
+length, count
 |sack-perm |
 TCP SACK permitted |
-kind, length
+length
 |sack|
 TCP Selective Acknowledgement (alias of block 0) |
-kind, length, left, right
+length, left, right
 |sack0|
 TCP Selective Acknowledgement (block 0) |
-kind, length, left, right
+length, left, right
 |sack1|
 TCP Selective Acknowledgement (block 1) |
-kind, length, left, right
+length, left, right
 |sack2|
 TCP Selective Acknowledgement (block 2) |
-kind, length, left, right
+length, left, right
 |sack3|
 TCP Selective Acknowledgement (block 3) |
-kind, length, left, right
+length, left, right
 |timestamp|
 TCP Timestamps |
-kind, length, tsval, tsecr
+length, tsval, tsecr
 |============================
 
 TCP option matching also supports raw expression syntax to access arbitrary options:
@@ -673,7 +673,12 @@ type, length, ptr, addr
 
 .finding TCP options
 --------------------
-filter input tcp option sack-perm kind 1 counter
+filter input tcp option sack-perm exists counter
+--------------------
+
+.matching TCP options
+--------------------
+filter input tcp option maxseg size lt 536
 --------------------
 
 .matching IPv6 exthdr
index 81d75ecb2fe8afe6036bf6994f36d05f65633aae..bc5ec2e667b8e0524160781734ef05204d7f58c6 100644 (file)
@@ -412,7 +412,6 @@ int nft_lex(void *, void *, void *);
 %token SACK3                   "sack3"
 %token SACK_PERM               "sack-permitted"
 %token TIMESTAMP               "timestamp"
-%token KIND                    "kind"
 %token COUNT                   "count"
 %token LEFT                    "left"
 %token RIGHT                   "right"
@@ -5526,8 +5525,7 @@ tcp_hdr_option_type       :       EOL             { $$ = TCPOPT_KIND_EOL; }
                        }
                        ;
 
-tcp_hdr_option_field   :       KIND            { $$ = TCPOPT_COMMON_KIND; }
-                       |       LENGTH          { $$ = TCPOPT_COMMON_LENGTH; }
+tcp_hdr_option_field   :       LENGTH          { $$ = TCPOPT_COMMON_LENGTH; }
                        |       SIZE            { $$ = TCPOPT_MAXSEG_SIZE; }
                        |       COUNT           { $$ = TCPOPT_WINDOW_COUNT; }
                        |       LEFT            { $$ = TCPOPT_SACK_LEFT; }
index 6cc7778dd85e1fc285558f238d082b60f5e7be32..455ef99fea8fe10570fdf7f4d5ccc85c51b12a8b 100644 (file)
@@ -481,7 +481,6 @@ addrstring  ({macaddr}|{ip4addr}|{ip6addr})
 "timestamp"            { return TIMESTAMP; }
 "time"                 { return TIME; }
 
-"kind"                 { return KIND; }
 "count"                        { return COUNT; }
 "left"                 { return LEFT; }
 "right"                        { return RIGHT; }
index bcc64eac2e2189d1bbb8a6efa1719927029dafab..d3586eae8399a1a16e025d4ea3ed338ac325cf11 100644 (file)
@@ -4,17 +4,16 @@
 *ip6;test-ip6;input
 *inet;test-inet;input
 
-tcp option eol kind 1;ok
-tcp option nop kind 1;ok
-tcp option maxseg kind 1;ok
+tcp option eol exists;ok
+tcp option nop exists;ok
+tcp option maxseg exists;ok
 tcp option maxseg length 1;ok
 tcp option maxseg size 1;ok
-tcp option window kind 1;ok
 tcp option window length 1;ok
 tcp option window count 1;ok
-tcp option sack-perm kind 1;ok
+tcp option sack-perm exists;ok
 tcp option sack-perm length 1;ok
-tcp option sack kind 1;ok
+tcp option sack exists;ok
 tcp option sack length 1;ok
 tcp option sack left 1;ok
 tcp option sack0 left 1;ok;tcp option sack left 1
@@ -26,7 +25,7 @@ tcp option sack0 right 1;ok;tcp option sack right 1
 tcp option sack1 right 1;ok
 tcp option sack2 right 1;ok
 tcp option sack3 right 1;ok
-tcp option timestamp kind 1;ok
+tcp option timestamp exists;ok
 tcp option timestamp length 1;ok
 tcp option timestamp tsval 1;ok
 tcp option timestamp tsecr 1;ok
index a45b4c8b5c586016e6d02ff7aaf87a487c5dcb6b..5468accb16b40eaa1046cceba28885b8c6a0374b 100644 (file)
@@ -1,47 +1,44 @@
-# tcp option eol kind 1
+# tcp option eol exists
 [
     {
         "match": {
             "left": {
                 "tcp option": {
-                    "field": "kind",
                     "name": "eol"
                 }
             },
             "op": "==",
-            "right": 1
+            "right": true
         }
     }
 ]
 
-# tcp option nop kind 1
+# tcp option nop exists
 [
     {
         "match": {
             "left": {
                 "tcp option": {
-                    "field": "kind",
                     "name": "nop"
                 }
             },
             "op": "==",
-            "right": 1
+            "right": true
         }
     }
 ]
 
-# tcp option maxseg kind 1
+# tcp option maxseg exists
 [
     {
         "match": {
             "left": {
                 "tcp option": {
-                    "field": "kind",
                     "name": "maxseg"
                 }
             },
             "op": "==",
-            "right": 1
+            "right": true
         }
     }
 ]
     }
 ]
 
-# tcp option window kind 1
-[
-    {
-        "match": {
-            "left": {
-                "tcp option": {
-                    "field": "kind",
-                    "name": "window"
-                }
-            },
-            "op": "==",
-            "right": 1
-        }
-    }
-]
-
 # tcp option window length 1
 [
     {
     }
 ]
 
-# tcp option sack-perm kind 1
+# tcp option sack-perm exists
 [
     {
         "match": {
             "left": {
                 "tcp option": {
-                    "field": "kind",
                     "name": "sack-perm"
                 }
             },
             "op": "==",
-            "right": 1
+            "right": true
         }
     }
 ]
     }
 ]
 
-# tcp option sack kind 1
+# tcp option sack exists
 [
     {
         "match": {
             "left": {
                 "tcp option": {
-                    "field": "kind",
                     "name": "sack"
                 }
             },
             "op": "==",
-            "right": 1
+            "right": true
         }
     }
 ]
             "left": {
                 "tcp option": {
                     "field": "left",
-                    "name": "sack0"
+                    "name": "sack"
                 }
             },
             "op": "==",
             "left": {
                 "tcp option": {
                     "field": "right",
-                    "name": "sack0"
+                    "name": "sack"
                 }
             },
             "op": "==",
     }
 ]
 
-# tcp option timestamp kind 1
+# tcp option timestamp exists
 [
     {
         "match": {
             "left": {
                 "tcp option": {
-                    "field": "kind",
                     "name": "timestamp"
                 }
             },
             "op": "==",
-            "right": 1
+            "right": true
         }
     }
 ]
     }
 ]
 
-# tcp option 6 exists
+# tcp option 255 missing
 [
     {
         "match": {
             "left": {
                 "tcp option": {
-                    "base": 6,
+                    "base": 255,
                     "len": 8,
                     "offset": 0
                 }
             },
             "op": "==",
-            "right": true
+            "right": false
         }
     }
 ]
 
-# tcp option 255 missing
+# tcp option 6 exists
 [
     {
         "match": {
             "left": {
                 "tcp option": {
-                    "base": 255,
+                    "base": 6,
                     "len": 8,
                     "offset": 0
                 }
             },
             "op": "==",
-            "right": false
+            "right": true
         }
     }
 ]
         }
     }
 ]
-
index 51f3a75276685b529fed031b90f900850f784701..d88bcd433a10f0667b780745bf4fde8b41c6472a 100644 (file)
@@ -1,16 +1,16 @@
-# tcp option eol kind 1
+# tcp option eol exists
 inet 
-  [ exthdr load tcpopt 1b @ 0 + 0 => reg 1 ]
+  [ exthdr load tcpopt 1b @ 0 + 0 present => reg 1 ]
   [ cmp eq reg 1 0x00000001 ]
 
-# tcp option nop kind 1
+# tcp option nop exists
 inet 
-  [ exthdr load tcpopt 1b @ 1 + 0 => reg 1 ]
+  [ exthdr load tcpopt 1b @ 1 + 0 present => reg 1 ]
   [ cmp eq reg 1 0x00000001 ]
 
-# tcp option maxseg kind 1
+# tcp option maxseg exists
 inet 
-  [ exthdr load tcpopt 1b @ 2 + 0 => reg 1 ]
+  [ exthdr load tcpopt 1b @ 2 + 0 present => reg 1 ]
   [ cmp eq reg 1 0x00000001 ]
 
 # tcp option maxseg length 1
@@ -23,11 +23,6 @@ inet
   [ exthdr load tcpopt 2b @ 2 + 2 => reg 1 ]
   [ cmp eq reg 1 0x00000100 ]
 
-# tcp option window kind 1
-inet 
-  [ exthdr load tcpopt 1b @ 3 + 0 => reg 1 ]
-  [ cmp eq reg 1 0x00000001 ]
-
 # tcp option window length 1
 inet 
   [ exthdr load tcpopt 1b @ 3 + 1 => reg 1 ]
@@ -38,9 +33,9 @@ inet
   [ exthdr load tcpopt 1b @ 3 + 2 => reg 1 ]
   [ cmp eq reg 1 0x00000001 ]
 
-# tcp option sack-perm kind 1
+# tcp option sack-perm exists
 inet 
-  [ exthdr load tcpopt 1b @ 4 + 0 => reg 1 ]
+  [ exthdr load tcpopt 1b @ 4 + 0 present => reg 1 ]
   [ cmp eq reg 1 0x00000001 ]
 
 # tcp option sack-perm length 1
@@ -48,9 +43,9 @@ inet
   [ exthdr load tcpopt 1b @ 4 + 1 => reg 1 ]
   [ cmp eq reg 1 0x00000001 ]
 
-# tcp option sack kind 1
+# tcp option sack exists
 inet 
-  [ exthdr load tcpopt 1b @ 5 + 0 => reg 1 ]
+  [ exthdr load tcpopt 1b @ 5 + 0 present => reg 1 ]
   [ cmp eq reg 1 0x00000001 ]
 
 # tcp option sack length 1
@@ -108,9 +103,9 @@ inet
   [ exthdr load tcpopt 4b @ 5 + 30 => reg 1 ]
   [ cmp eq reg 1 0x01000000 ]
 
-# tcp option timestamp kind 1
+# tcp option timestamp exists
 inet 
-  [ exthdr load tcpopt 1b @ 8 + 0 => reg 1 ]
+  [ exthdr load tcpopt 1b @ 8 + 0 present => reg 1 ]
   [ cmp eq reg 1 0x00000001 ]
 
 # tcp option timestamp length 1