]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net: Clear the dst when performing encap / decap
authorJakub Kicinski <kuba@kernel.org>
Sun, 29 Mar 2026 18:04:27 +0000 (11:04 -0700)
committerMartin KaFai Lau <martin.lau@kernel.org>
Mon, 30 Mar 2026 22:28:21 +0000 (15:28 -0700)
commit699f47e616fed11d5074e7bbee2f4f920028c4a2
tree6ae48de319f5cfc94b8050b2c322c0715068d934
parentcf0d9080c6f795bc6be08babbffa29b62c06e9b0
net: Clear the dst when performing encap / decap

Commit ba9db6f907ac ("net: clear the dst when changing skb protocol")
added dst clearing when a BPF program changes the skb protocol
(e.g. IPv4 to IPv6). Since that was a fix we only cleared the dst when
the L3 protocol actually changes to keep it minimal. As suggested during
the discussion (see Link) encap or decap operation which wraps or unwraps
a same-protocol header may also render the existing dst incorrect - even
if that doesn't result in a crash, just the wrong route for the now-outermost
IP dst.

Make dropping dst unconditional for bpf_skb_change_proto() and all
L3 encap / decap ops.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/CANP3RGfRaYwve_xgxH6Tp2zenzKn2-DjZ9tg023WVzfdJF3p_w@mail.gmail.com
Link: https://patch.msgid.link/20260329180428.2657785-1-kuba@kernel.org
net/core/filter.c