Skip to content

Commit

Permalink
seg6: bpf: fix skb checksum in bpf_push_seg6_encap()
Browse files Browse the repository at this point in the history
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: fe94cc2 ("bpf: Add IPv6 Segment Routing helpers")
Signed-off-by: Andrea Mayer <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
  • Loading branch information
skorpion17 authored and Paolo Abeni committed Jul 14, 2022
1 parent f048880 commit 4889fbd
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion net/core/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -6158,7 +6158,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);
Expand Down

0 comments on commit 4889fbd

Please sign in to comment.