From: Florian Westphal <fw@strlen.de>
To: Florian Westphal <fw@strlen.de>,
Netfilter Development <netfilter-devel@vger.kernel.org>
Subject: Re: Netfilter queue is unable to mangle fragmented UDP6: bug?
Date: Fri, 27 Oct 2023 12:41:01 +0200 [thread overview]
Message-ID: <20231027104101.GA6174@breakpoint.cc> (raw)
In-Reply-To: <ZTscICNz5aUmLYSr@slk15.local.net>
Duncan Roe <duncan_roe@optusnet.com.au> wrote:
> I expected the netfilter program to see the full UDP datagram as sent. With
> UDP/IPv4 it does see the full datagram, but not with UDP/IPv6.
For INPUT ipv4 stack will defrag before INPUT hooks are called.
From ipv6 point of view, the ipv6 next header protocol value isn't
relevant at that stage, so it doesn't matter if thats IPPROTO_TCP,
IPPROTO_UDP or, in this case, IPPROTO_FRAGMENT.
INPUT hook runs on the arrived packets, then the packets are delivered
to the next handler, i.e. the fragment-collection done by the IPPROTO_FRAGMENT
handlers is done AFTER the INPUT hook.
To get the behaviour you want you need to enable netfilter ipv6 defrag.
There is currently no way to do this standalone, you will need to add
a dummy tproxy or conntrack rule (the latter will enable conntrack too
which might not be what you want).
Or you modify your ruleset to also queue fragments to userspace and
do ipv6 defrag yourself in the nfqueue application.
> > Do you mean "segments"? Its the other way around, with GSO/TSO, stack
> > builds large superpackes, one tcp header with lots of data.
>
> Sorry for the confusion here. I only meant to say that there is no problem with
> TCP.
Yes, because no ipv6 fragmentation takes place.
> IOW kernel delivers to filter program exactly what was in the buffer when the
> remote application did a write(2) (for buffer size up to just under 64KB).
Not really, it depends on the protocols involved and the network, think
e.g. of a traffic policier that enforces some rate limit.
> I don't know what GSO is, only that it's strongly recommended to use it.
https://en.wikipedia.org/wiki/TCP_offload_engine
But if you are talking about F_GSO flag for nfqueue -- it does NOT
enable GSO, on the contrary. It tells the kernel "This program
can handle large packets with "bogus" (to-be-filled-by-hardware)
checksum".
Without the flag, tcp packets need to be splitted in software and their
checksums need to be computed too (i.e. all the data needs to be read).
> This example shows a UDP4 2KB datagram being successfully mangled and a UDP6 2KB
> datagram failing to be mangled.
> >
> > You also removed tcpdump info, I suspect it was "flags [+]"
> > with two fragments for udp:ipv4 too?
>
> There are 2 fragments for both IPv4 and IPv6.
>
> tcpdump does not report any flags:
>
> > 08:16:09.713395 IP6 fe80::1a60:24ff:febb:2d6 > fe80::1ac0:4dff:fe04:75ba: frag (0|1448) 47843 > 1042: UDP, length 2048
> > 08:16:09.713395 IP6 fe80::1a60:24ff:febb:2d6 > fe80::1ac0:4dff:fe04:75ba: frag (1448|608)
> > 08:17:22.924883 IP smallstar.local.net.55288 > dimstar.local.net.1042: UDP, length 2048
> > 08:17:22.924883 IP smallstar.local.net > dimstar.local.net: udp
Forgot to mention: in the future when debugging problems, please use
-vvvv (as many as needed), tcpdump elides a lot of information
otherwise.
prev parent reply other threads:[~2023-10-27 10:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-22 4:24 Netfilter queue is unable to mangle fragmented UDP6: bug? Duncan Roe
2023-10-25 12:32 ` Florian Westphal
2023-10-27 2:10 ` Duncan Roe
2023-10-27 10:41 ` 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=20231027104101.GA6174@breakpoint.cc \
--to=fw@strlen.de \
--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 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).