From: Andrea Mayer Date: Tue, 12 Jul 2022 17:58:37 +0000 (+0200) Subject: seg6: bpf: fix skb checksum in bpf_push_seg6_encap() X-Git-Tag: Ubuntu-5.15.0-49.55~364 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=7a729af6a1dae13170f103f5a786c23ef5a47160;p=mirror_ubuntu-jammy-kernel.git seg6: bpf: fix skb checksum in bpf_push_seg6_encap() BugLink: https://bugs.launchpad.net/bugs/1988351 [ Upstream commit 4889fbd98deaf243c3baadc54e296d71c6af1eb0 ] Both helper functions bpf_lwt_seg6_action() and bpf_lwt_push_encap() use the bpf_push_seg6_encap() to encapsulate the packet in an IPv6 with Segment Routing Header (SRH) or insert an SRH between the IPv6 header and the payload. To achieve this result, such helper functions rely on bpf_push_seg6_encap() which, in turn, leverages seg6_do_srh_{encap,inline}() to perform the required operation (i.e. encap/inline). This patch removes the initialization of the IPv6 header payload length from bpf_push_seg6_encap(), as it is now handled properly by seg6_do_srh_{encap,inline}() to prevent corruption of the skb checksum. Fixes: fe94cc290f53 ("bpf: Add IPv6 Segment Routing helpers") Signed-off-by: Andrea Mayer Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Signed-off-by: Kamal Mostafa Signed-off-by: Stefan Bader --- diff --git a/net/core/filter.c b/net/core/filter.c index d1e2ef77ce4c..8b2bc855714b 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -5851,7 +5851,6 @@ static int bpf_push_seg6_encap(struct sk_buff *skb, u32 type, void *hdr, u32 len if (err) return err; - ipv6_hdr(skb)->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); skb_set_transport_header(skb, sizeof(struct ipv6hdr)); return seg6_lookup_nexthop(skb, NULL, 0);