Skip to content

Commit

Permalink
udp:nat:vxlan tx after nat should recsum if vxlan tx offload on
Browse files Browse the repository at this point in the history
    If vxlan-dev enable tx csum offload, there are two case of CHECKSUM_PARTIAL,
    but udp->check donot have the both meanings.

    1. vxlan-dev disable tx csum offload, udp->check is just pseudo hdr.
    2. vxlan-dev enable tx csum offload, udp->check is pseudo hdr and
       csum from outter l4 to innner l4.

    Unfortunately if there is a nat process after vxlan tx,udp_manip_pkt just use
    CSUM_PARTIAL to re csum PKT, which is just right on vxlan tx csum disable offload.

    This patch use skb->csum_local flag to identify two case, which will csum lco_csum if valid.

Signed-off-by: chenwei.0515 <chenwei.0515@bytedance.com>
  • Loading branch information
chenwei.0515 authored and intel-lab-lkp committed Apr 1, 2023
1 parent 7b50567 commit 58c404c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/skbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,7 @@ struct sk_buff {
__u8 slow_gro:1;
__u8 csum_not_inet:1;
__u8 scm_io_uring:1;
__u8 csum_local:1;

#ifdef CONFIG_NET_SCHED
__u16 tc_index; /* traffic control index */
Expand Down
1 change: 1 addition & 0 deletions net/ipv4/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,7 @@ void udp_set_csum(bool nocheck, struct sk_buff *skb,
uh->check = udp_v4_check(len, saddr, daddr, lco_csum(skb));
if (uh->check == 0)
uh->check = CSUM_MANGLED_0;
skb->csum_local = 1;
} else {
skb->ip_summed = CHECKSUM_PARTIAL;
skb->csum_start = skb_transport_header(skb) - skb->head;
Expand Down
9 changes: 9 additions & 0 deletions net/netfilter/nf_nat_proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <net/ip6_route.h>
#include <net/xfrm.h>
#include <net/ipv6.h>
#include <net/udp.h>

#include <net/netfilter/nf_conntrack_core.h>
#include <net/netfilter/nf_conntrack.h>
Expand Down Expand Up @@ -75,6 +76,14 @@ static bool udp_manip_pkt(struct sk_buff *skb,
hdr = (struct udphdr *)(skb->data + hdroff);
__udp_manip_pkt(skb, iphdroff, hdr, tuple, maniptype, !!hdr->check);

if (skb->csum_local) {
hdr->check = 0;
hdr->check = udp_v4_check(htons(hdr->len), tuple->src.u3.ip, tuple->dst.u3.ip,
lco_csum(skb));
if (hdr->check == 0)
hdr->check = CSUM_MANGLED_0;
}

return true;
}

Expand Down

0 comments on commit 58c404c

Please sign in to comment.