netfilter.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Niklas Beierl <niklasbeierl@posteo.net>
Cc: netfilter@vger.kernel.org
Subject: Re: TCPOPTSTROP can be repalced with undocumented "reset tcp option opt"
Date: Mon, 14 Jul 2025 17:00:34 +0200	[thread overview]
Message-ID: <aHUbkoEEVmK9dw-_@strlen.de> (raw)
In-Reply-To: <4c0c089d-cc53-4375-bb01-c34a858809bf@posteo.net>

Niklas Beierl <niklasbeierl@posteo.net> wrote:
> I found myself in the situation of needing the behavior from the legacy  
> TCPOPTSTRIP target. On the netfilter wiki, this target is listed under 
> "Unsupported extensions" with the very brief comment "consider native 
> interface, need to extend nft_exthdr.c".
> 
> https://wiki.nftables.org/wiki-nftables/index.php/Supported_features_compared_to_xtables#TCPOPTSTRIP

I've removed this bit, its outdated.

> reset tcp option OPT
> 
> which seems to turn the selected option into NOPs. To my understanding 
> this is equivalent to  "-p tcp -j TCPOPTSTRIP --strip-options OPT".

It is.

> I think this should be mentioned in the wiki on the Mangling packet 
> headers page and also with regards to replacing TCPOPTRESET. How can I 
> make this happen? Can I get credentials to the wiki somehow? Should I 
> instead write it up and send it to someone?

You could send a patch for iptables, specifically
extensions/libxt_TCPOPTSTRIP.c and add ".xlate" support together with a
libxt_TCPOPTSTRIP.txlate file (with tests).

Then the wiki could link to that just like it does for other supported
extensions.

> Furthermore, I would like to understand (and document) the general 
> syntax for setting tcp options. I am especially curious whether tcp 
> options can also be set if the field is not known to the netfilter code.

Whats your use case?

You can do
tcp option @255,8,8 255

(locate option 255, offset 8 bit, fetch 8 bits), then compare to 255.
Same syntax as raw payload expressions.

> I guess there are issues with encoding the cli-passed value 
> appropriately in the header field?
> 
> Lastly I was wondering whether it is also possible to add or entirely 
> remove option fields from tcp headers - as opposed to just NOPing them?

Not at this time, its more expensive since data needs to be moved.
NOPing is much simpler.

      reply	other threads:[~2025-07-14 15:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-14 10:48 TCPOPTSTROP can be repalced with undocumented "reset tcp option opt" Niklas Beierl
2025-07-14 15:00 ` Florian Westphal [this message]

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=aHUbkoEEVmK9dw-_@strlen.de \
    --to=fw@strlen.de \
    --cc=netfilter@vger.kernel.org \
    --cc=niklasbeierl@posteo.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).