From: Edward Cree <ecree.xilinx@gmail.com>
To: Daniel Xu <dxu@dxuuu.xyz>,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
netdev@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 0/8] Support defragmenting IPv(4|6) packets in BPF
Date: Mon, 27 Feb 2023 20:38:41 +0000 [thread overview]
Message-ID: <cf49a091-9b14-05b8-6a79-00e56f3019e1@gmail.com> (raw)
In-Reply-To: <cover.1677526810.git.dxu@dxuuu.xyz>
On 27/02/2023 19:51, Daniel Xu wrote:
> However, when policy is enforced through BPF, the prog is run before the
> kernel reassembles fragmented packets. This leaves BPF developers in a
> awkward place: implement reassembly (possibly poorly) or use a stateless
> method as described above.
Just out of curiosity - what stops BPF progs using the middle ground of
stateful validation? I'm thinking of something like:
First-frag: run the usual checks on L4 headers etc, if we PASS then save
IPID and maybe expected next frag-offset into a map. But don't try to
stash the packet contents anywhere for later reassembly, just PASS it.
Subsequent frags: look up the IPID in the map. If we find it, validate
and update the frag-offset in the map; if this is the last fragment then
delete the map entry. If the frag-offset was bogus or the IPID wasn't
found in the map, DROP; otherwise PASS.
(If re-ordering is prevalent then use something more sophisticated than
just expected next frag-offset, but the principle is the same. And of
course you might want to put in timers for expiry etc.)
So this avoids the need to stash the packet data and modify/consume SKBs,
because you're not actually doing reassembly; the down-side is that the
BPF program can't so easily make decisions about the application-layer
contents of the fragmented datagram, but for the common case (we just
care about the 5-tuple) it's simple enough.
But I haven't actually tried it, so maybe there's some obvious reason why
it can't work this way.
-ed
next prev parent reply other threads:[~2023-02-27 20:38 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-27 19:51 [PATCH bpf-next v2 0/8] Support defragmenting IPv(4|6) packets in BPF Daniel Xu
2023-02-27 19:51 ` [PATCH bpf-next v2 1/8] ip: frags: Return actual error codes from ip_check_defrag() Daniel Xu
2023-02-27 19:51 ` [PATCH bpf-next v2 3/8] bpf, net, frags: Add bpf_ip_check_defrag() kfunc Daniel Xu
2023-02-28 19:37 ` Stanislav Fomichev
2023-02-28 22:00 ` Daniel Xu
2023-02-28 22:18 ` Stanislav Fomichev
2023-02-27 19:51 ` [PATCH bpf-next v2 4/8] net: ipv6: Factor ipv6_frag_rcv() to take netns and user Daniel Xu
2023-02-27 19:51 ` [PATCH bpf-next v2 5/8] bpf: net: ipv6: Add bpf_ipv6_frag_rcv() kfunc Daniel Xu
2023-02-28 8:15 ` kernel test robot
2023-02-28 9:37 ` kernel test robot
2023-02-27 20:38 ` Edward Cree [this message]
2023-02-27 22:04 ` [PATCH bpf-next v2 0/8] Support defragmenting IPv(4|6) packets in BPF Daniel Xu
2023-02-27 22:58 ` Edward Cree
2023-03-01 16:24 ` Daniel Xu
2023-02-27 23:03 ` Alexei Starovoitov
[not found] ` <20230228015712.clq6kyrsd7rrklbz@kashmir.localdomain>
2023-02-28 4:56 ` Alexei Starovoitov
2023-02-28 13:43 ` Daniel Borkmann
2023-02-28 23:17 ` Daniel Xu
2023-03-07 4:17 ` Alexei Starovoitov
2023-03-07 19:48 ` Daniel Xu
2023-03-07 20:11 ` Florian Westphal
2023-03-07 21:18 ` Alexei Starovoitov
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=cf49a091-9b14-05b8-6a79-00e56f3019e1@gmail.com \
--to=ecree.xilinx@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=dxu@dxuuu.xyz \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@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).