ip_gre: add csum offload support for gre header
authorXin Long <lucien.xin@gmail.com>
Thu, 28 Jan 2021 09:18:32 +0000 (17:18 +0800)
committerJakub Kicinski <kuba@kernel.org>
Sat, 30 Jan 2021 04:39:14 +0000 (20:39 -0800)
commitefa1a65c7e1946ff174c56d36bf015ff9e11c4a1
treebdc8299195caa5024ff2bb1f5ec26827758d3a0d
parent62fafcd63139920eb25b3fbf154177ce3e6f3232
ip_gre: add csum offload support for gre header

This patch is to add csum offload support for gre header:

On the TX path in gre_build_header(), when CHECKSUM_PARTIAL's set
for inner proto, it will calculate the csum for outer proto, and
inner csum will be offloaded later. Otherwise, CHECKSUM_PARTIAL
and csum_start/offset will be set for outer proto, and the outer
csum will be offloaded later.

On the GSO path in gre_gso_segment(), when CHECKSUM_PARTIAL is
not set for inner proto and the hardware supports csum offload,
CHECKSUM_PARTIAL and csum_start/offset will be set for outer
proto, and outer csum will be offloaded later. Otherwise, it
will do csum for outer proto by calling gso_make_checksum().

Note that SCTP has to do the csum by itself for non GSO path in
sctp_packet_pack(), as gre_build_header() can't handle the csum
with CHECKSUM_PARTIAL set for SCTP CRC csum offload.

v1->v2:
  - remove the SCTP part, as GRE dev doesn't support SCTP CRC CSUM
    and it will always do checksum for SCTP in sctp_packet_pack()
    when it's not a GSO packet.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/gre.h
net/ipv4/gre_offload.c