Skip to content

Commit 2c88668

Browse files
lxingregkh
authored andcommitted
net: support ip generic csum processing in skb_csum_hwoffload_help
[ Upstream commit 62fafcd ] NETIF_F_IP|IPV6_CSUM feature flag indicates UDP and TCP csum offload while NETIF_F_HW_CSUM feature flag indicates ip generic csum offload for HW, which includes not only for TCP/UDP csum, but also for other protocols' csum like GRE's. However, in skb_csum_hwoffload_help() it only checks features against NETIF_F_CSUM_MASK(NETIF_F_HW|IP|IPV6_CSUM). So if it's a non TCP/UDP packet and the features doesn't support NETIF_F_HW_CSUM, but supports NETIF_F_IP|IPV6_CSUM only, it would still return 0 and leave the HW to do csum. This patch is to support ip generic csum processing by checking NETIF_F_HW_CSUM for all protocols, and check (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM) only for TCP and UDP. Note that we're using skb->csum_offset to check if it's a TCP/UDP proctol, this might be fragile. However, as Alex said, for now we only have a few L4 protocols that are requesting Tx csum offload, we'd better fix this until a new protocol comes with a same csum offset. v1->v2: - not extend skb->csum_not_inet, but use skb->csum_offset to tell if it's an UDP/TCP csum packet. v2->v3: - add a note in the changelog, as Willem suggested. Suggested-by: Alexander Duyck <alexander.duyck@gmail.com> Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Stable-dep-of: 04c20a9 ("net: skip offload for NETIF_F_IPV6_CSUM if ipv6 header contains extension") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e8494ac commit 2c88668

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

net/core/dev.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3323,7 +3323,18 @@ int skb_csum_hwoffload_help(struct sk_buff *skb,
33233323
return !!(features & NETIF_F_SCTP_CRC) ? 0 :
33243324
skb_crc32c_csum_help(skb);
33253325

3326-
return !!(features & NETIF_F_CSUM_MASK) ? 0 : skb_checksum_help(skb);
3326+
if (features & NETIF_F_HW_CSUM)
3327+
return 0;
3328+
3329+
if (features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) {
3330+
switch (skb->csum_offset) {
3331+
case offsetof(struct tcphdr, check):
3332+
case offsetof(struct udphdr, check):
3333+
return 0;
3334+
}
3335+
}
3336+
3337+
return skb_checksum_help(skb);
33273338
}
33283339
EXPORT_SYMBOL(skb_csum_hwoffload_help);
33293340

0 commit comments

Comments
 (0)