From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Weiming Shi" <bestswngs@gmail.com>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"John Fastabend" <john.fastabend@gmail.com>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Ihor Solodrai" <ihor.solodrai@linux.dev>,
"David S . Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Simon Horman" <horms@kernel.org>,
"Shuah Khan" <shuah@kernel.org>
Cc: linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
"Toke Høiland-Jørgensen" <toke@redhat.com>,
"Peter Oskolkov" <posk@google.com>, "Xiang Mei" <xmei5@asu.edu>,
stable@vger.kernel.org
Subject: Re: [PATCH v3 2/3] bpf: clear stale IPv4 options after LWT encapsulation
Date: Sun, 20 Sep 2026 17:06:47 +0000 [thread overview]
Message-ID: <DLKB3T7PYCND.3FLS0I8UEX9NL@gmail.com> (raw)
In-Reply-To: <20260920163211.795547-3-bestswngs@gmail.com>
On Mon, Sep 21, 2026 at 12:32 AM Weiming Shi <bestswngs@gmail.com> wrote:
> Select the reset layout from the protocol callback which consumes the
> packet: the original family for BPF_OK and unsupported redirects, or the
> new family for supported reroute and redirect paths. Preserve the ingress
> interface and L3-slave state from the restored original control block and
> initialize the IPv6 next-header offset when needed. Save and restore the
> marker around nested LWT runs.
What Daniel sketched in v2 was 20 lines. This is still an overkill.
[...]
> +static void bpf_lwt_reset_cb(struct sk_buff *skb, __be16 orig_proto,
> + bool use_new_proto)
> +{
> + __be16 cb_proto = use_new_proto ? skb->protocol : orig_proto;
> + int iif = skb->skb_iif;
> + bool l3slave = false;
> +
> + /* VRF may have replaced skb_iif with the master device index. */
> + if (orig_proto == htons(ETH_P_IP)) {
> + iif = IPCB(skb)->iif;
> + l3slave = ipv4_l3mdev_skb(IPCB(skb)->flags);
When the family doesn't change only IPCB(skb)->opt is stale.
Clear just that like ip_tunnel_xmit() and udp_tunnel_xmit_skb() do.
iif and flags stay as they are and the VRF special casing goes away.
When the family changes do what seg6_do_srh_encap() does.
[...]
> + use_new_proto = (ret == BPF_LWT_REROUTE &&
> + lwt->prog->type != BPF_PROG_TYPE_LWT_OUT) ||
> + (ret == BPF_REDIRECT && can_redirect);
> + if (lwt_ip_encap)
> + bpf_lwt_reset_cb(skb, orig_proto, use_new_proto);
Not needed. BPF_OK after the prog changed the family is broken no
matter which layout the cb has. bpf_xmit() drops such skb and
bpf_input() hands a v6 packet to ip_forward().
Use skb->protocol.
pw-bot: cr
next prev parent reply other threads:[~2026-09-20 17:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-20 16:32 [PATCH v3 0/3] bpf: clear stale IPv4 options after LWT encapsulation Weiming Shi
2026-09-20 16:32 ` [PATCH v3 1/3] bpf: propagate cb_access from freplace programs Weiming Shi
2026-09-20 17:06 ` Alexei Starovoitov
2026-09-20 17:07 ` Alexei Starovoitov
2026-09-20 16:32 ` [PATCH v3 2/3] bpf: clear stale IPv4 options after LWT encapsulation Weiming Shi
2026-09-20 17:06 ` Alexei Starovoitov [this message]
2026-09-20 16:32 ` [PATCH v3 3/3] selftests/bpf: cover stale CB after LWT IP encapsulation Weiming Shi
2026-09-20 17:06 ` 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=DLKB3T7PYCND.3FLS0I8UEX9NL@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bestswngs@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=edumazet@google.com \
--cc=emil@etsalapatis.com \
--cc=horms@kernel.org \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=posk@google.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=stable@vger.kernel.org \
--cc=toke@redhat.com \
--cc=xmei5@asu.edu \
--cc=yonghong.song@linux.dev \
/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.