]> git.baikalelectronics.ru Git - kernel.git/commit
seg6: fix skb checksum evaluation in SRH encapsulation/insertion
authorAndrea Mayer <andrea.mayer@uniroma2.it>
Tue, 12 Jul 2022 17:58:35 +0000 (19:58 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 14 Jul 2022 08:15:15 +0000 (10:15 +0200)
commita3e7e9dc5a76c97311a8288062caf7b8f2d5495e
tree917bfd337a6285b45b9af3b63b4e9ed7da21ff26
parentadb0d9c552bd6410b2ba4f8b6be6ee3ad63a1799
seg6: fix skb checksum evaluation in SRH encapsulation/insertion

Support for SRH encapsulation and insertion was introduced with
commit 7ab7a75aa79e ("ipv6: sr: add support for SRH encapsulation and
injection with lwtunnels"), through the seg6_do_srh_encap() and
seg6_do_srh_inline() functions, respectively.
The former encapsulates the packet in an outer IPv6 header along with
the SRH, while the latter inserts the SRH between the IPv6 header and
the payload. Then, the headers are initialized/updated according to the
operating mode (i.e., encap/inline).
Finally, the skb checksum is calculated to reflect the changes applied
to the headers.

The IPv6 payload length ('payload_len') is not initialized
within seg6_do_srh_{inline,encap}() but is deferred in seg6_do_srh(), i.e.
the caller of seg6_do_srh_{inline,encap}().
However, this operation invalidates the skb checksum, since the
'payload_len' is updated only after the checksum is evaluated.

To solve this issue, the initialization of the IPv6 payload length is
moved from seg6_do_srh() directly into the seg6_do_srh_{inline,encap}()
functions and before the skb checksum update takes place.

Fixes: 7ab7a75aa79e ("ipv6: sr: add support for SRH encapsulation and injection with lwtunnels")
Reported-by: Paolo Abeni <pabeni@redhat.com>
Link: https://lore.kernel.org/all/20220705190727.69d532417be7438b15404ee1@uniroma2.it
Signed-off-by: Andrea Mayer <andrea.mayer@uniroma2.it>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/ipv6/seg6_iptunnel.c