All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: akashavkin@gmail.com
Subject: [PATCH nft 2/2] parser_bison: turn redudant ip option type field match into boolean
Date: Fri, 31 Jan 2025 11:47:16 +0100	[thread overview]
Message-ID: <20250131104716.492246-2-pablo@netfilter.org> (raw)
In-Reply-To: <20250131104716.492246-1-pablo@netfilter.org>

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.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 doc/payload-expression.txt | 8 ++++----
 src/parser_bison.y         | 3 +++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/doc/payload-expression.txt b/doc/payload-expression.txt
index 7bc24a8a6502..2a155aa87b6f 100644
--- a/doc/payload-expression.txt
+++ b/doc/payload-expression.txt
@@ -808,16 +808,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
diff --git a/src/parser_bison.y b/src/parser_bison.y
index c8714812532d..d15bf212489d 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -5698,6 +5698,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
 			{
-- 
2.30.2


  reply	other threads:[~2025-01-31 10:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-31 10:47 [PATCH nft 1/2] ipopt: use ipv4 address datatype for address field in ip options Pablo Neira Ayuso
2025-01-31 10:47 ` Pablo Neira Ayuso [this message]
2025-02-05 12:29   ` [PATCH nft 2/2] parser_bison: turn redudant ip option type field match into boolean Alexey Kashavkin
2025-02-06 11:55     ` Pablo Neira Ayuso
2025-02-06 12:02       ` Alexey Kashavkin
2025-02-06 12:44         ` Pablo Neira Ayuso

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=20250131104716.492246-2-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=akashavkin@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.