From: Jakub Kicinski <kuba@kernel.org>
To: "Maciej Żenczykowski" <maze@google.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org,
martin.lau@linux.dev, daniel@iogearbox.net,
john.fastabend@gmail.com, eddyz87@gmail.com, sdf@fomichev.me,
haoluo@google.com, willemb@google.com,
william.xuanziyang@huawei.com, alan.maguire@oracle.com,
bpf@vger.kernel.org
Subject: Re: [PATCH net] net: clear the dst when changing skb protocol
Date: Thu, 5 Jun 2025 06:22:34 -0700 [thread overview]
Message-ID: <20250605062234.1df7e74a@kernel.org> (raw)
In-Reply-To: <CANP3RGfRaYwve_xgxH6Tp2zenzKn2-DjZ9tg023WVzfdJF3p_w@mail.gmail.com>
On Wed, 4 Jun 2025 23:21:02 +0200 Maciej Żenczykowski wrote:
> > @@ -3550,10 +3557,10 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 off, u32 len_diff,
> > /* Match skb->protocol to new outer l3 protocol */
> > if (skb->protocol == htons(ETH_P_IP) &&
> > flags & BPF_F_ADJ_ROOM_ENCAP_L3_IPV6)
> > - skb->protocol = htons(ETH_P_IPV6);
> > + bpf_skb_change_protocol(skb, ETH_P_IPV6);
> > else if (skb->protocol == htons(ETH_P_IPV6) &&
> > flags & BPF_F_ADJ_ROOM_ENCAP_L3_IPV4)
> > - skb->protocol = htons(ETH_P_IP);
> > + bpf_skb_change_protocol(skb, ETH_P_IP);
>
> I wonder if this shouldn't drop dst even when doing ipv4->ipv4 or
> ipv6->ipv6 -- it's encapping, presumably old dst is irrelevant...
I keep going back and forth on this. You definitely have a point,
but I feel like there are levels to how BPF prog can make the dst
irrelevant:
- change proto
- encap
- adjust room but not set any encap flag
- overwrite the addrs without calling any helpers
First case we have to cover for safety, last we can't possibly cover.
So the question is whether we should draw the line somewhere in
the middle, or leave this patch as is and if the actual use case arrives
- let BPF call skb_dst_drop() as a kfunc. Right now I'm leaning towards
the latter.
Does that make sense? Does anyone else have an opinion?
next prev parent reply other threads:[~2025-06-05 13:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-04 21:06 [PATCH net] net: clear the dst when changing skb protocol Jakub Kicinski
2025-06-04 21:21 ` Maciej Żenczykowski
2025-06-05 13:22 ` Jakub Kicinski [this message]
2025-06-05 13:50 ` Maciej Żenczykowski
2025-06-05 14:01 ` Jakub Kicinski
2025-06-06 0:09 ` Willem de Bruijn
2025-06-06 0:31 ` Jakub Kicinski
2025-06-06 9:40 ` Maciej Żenczykowski
2025-06-06 17:11 ` Jakub Kicinski
2025-06-06 17:36 ` Maciej Żenczykowski
2025-06-06 15:55 ` Willem de Bruijn
2025-06-06 17:09 ` Jakub Kicinski
2025-06-04 21:45 ` Daniel Borkmann
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=20250605062234.1df7e74a@kernel.org \
--to=kuba@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=andrew+netdev@lunn.ch \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=edumazet@google.com \
--cc=haoluo@google.com \
--cc=horms@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=martin.lau@linux.dev \
--cc=maze@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=willemb@google.com \
--cc=william.xuanziyang@huawei.com \
/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).