]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
parser_bison: turn redundant ip option type field match into boolean
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 31 Jan 2025 10:14:22 +0000 (11:14 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 17 Jun 2025 09:26:13 +0000 (11:26 +0200)
commit f9a48ce2f9c252bf74d98d10412b1f72585a45ec upstream.

The ip option expression allows for non-sense matching like:

ip option lsrr type 1

because 'lsrr' already provides the type field, this never results in a
matching.

Turn this expression into:

ip option lsrr exists

And update documentation to hide this redundant type field.

Fixes: 226a0e072d5c ("exthdr: add support for matching IPv4 options")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
doc/payload-expression.txt
src/parser_bison.y

index 9a761b71769ee40074170ed29cbe105b53908d36..9112fa0a1d8b46bc8fb5d556ca8631c53f962595 100644 (file)
@@ -669,16 +669,16 @@ TCP option matching also supports raw expression syntax to access arbitrary opti
 |Keyword| Description | IP option fields
 |lsrr|
 Loose Source Route |
-type, length, ptr, addr
+length, ptr, addr
 |ra|
 Router Alert |
-type, length, value
+length, value
 |rr|
 Record Route |
-type, length, ptr, addr
+length, ptr, addr
 |ssrr|
 Strict Source Route |
-type, length, ptr, addr
+length, ptr, addr
 |============================
 
 .finding TCP options
index 3258c7e632c0966ef74a2679a1bb36525bf6738d..526285dace0fb2f0903312284cd646fda837409d 100644 (file)
@@ -5556,6 +5556,9 @@ ip_hdr_expr               :       IP      ip_hdr_field    close_scope_ip
                                        erec_queue(error(&@1, "unknown ip option type/field"), state->msgs);
                                        YYERROR;
                                }
+
+                               if ($4 == IPOPT_FIELD_TYPE)
+                                       $$->exthdr.flags = NFT_EXTHDR_F_PRESENT;
                        }
                        |       IP      OPTION  ip_option_type close_scope_ip
                        {