diff --git a/bpf/xdp_udp.bpf.c b/bpf/xdp_udp.bpf.c index a513933..a49e0d1 100644 --- a/bpf/xdp_udp.bpf.c +++ b/bpf/xdp_udp.bpf.c @@ -55,7 +55,6 @@ static __always_inline __u16 udp_checksum(struct iphdr *ip, struct udphdr * udp, // So we can overflow a bit make this __u32 __u32 csum_total = 0; - __u16 csum; __u16 *buf = (void *)udp; csum_total += (__u16)ip->saddr; @@ -86,11 +85,7 @@ static __always_inline __u16 udp_checksum(struct iphdr *ip, struct udphdr * udp, csum_total += (*(__u8 *)buf); } - // Add any cksum overflow back into __u16 - csum = (__u16)csum_total + (__u16)(csum_total >> 16); - - csum = ~csum; - return csum; + return csum_fold_helper(csum_total); } struct backend { diff --git a/userspace-go/bpf_bpfeb.o b/userspace-go/bpf_bpfeb.o index 965a33b..816372b 100644 Binary files a/userspace-go/bpf_bpfeb.o and b/userspace-go/bpf_bpfeb.o differ diff --git a/userspace-go/bpf_bpfel.o b/userspace-go/bpf_bpfel.o index d31f382..3dec66e 100644 Binary files a/userspace-go/bpf_bpfel.o and b/userspace-go/bpf_bpfel.o differ diff --git a/userspace-go/userspace-go b/userspace-go/userspace-go index a74ee32..c576959 100755 Binary files a/userspace-go/userspace-go and b/userspace-go/userspace-go differ diff --git a/userspace-go/xdp_udp.go b/userspace-go/xdp_udp.go index 144b659..de147d6 100644 --- a/userspace-go/xdp_udp.go +++ b/userspace-go/xdp_udp.go @@ -68,7 +68,7 @@ func main() { Shwaddr: hwaddr2bytes("06:56:87:ec:fd:1f"), // Container-Side Veth Mac Dhwaddr: hwaddr2bytes("86:ad:33:29:ff:5e"), - Nocksum: 1, + Nocksum: 0, Ifindex: 8, }