Skip to content

Commit f023ad9

Browse files
committed
packet-solutions: Fix checksum folding helper
As reported by @mwiget - the csum_fold_helper() was missing a round of folding. Fixes #130. Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
1 parent 84e667a commit f023ad9

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packet-solutions/xdp_prog_kern_03.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ struct bpf_map_def SEC("maps") redirect_params = {
3232

3333
static __always_inline __u16 csum_fold_helper(__u32 csum)
3434
{
35-
return ~((csum & 0xffff) + (csum >> 16));
35+
__u32 sum;
36+
sum = (csum >> 16) + (csum & 0xffff);
37+
sum += (sum >> 16);
38+
return ~sum;
3639
}
3740

3841
/*

0 commit comments

Comments
 (0)