Skip to content

Commit

Permalink
netfilter: nf_nat_snmp: fix checksum calculation (v4)
Browse files Browse the repository at this point in the history
Fix checksum calculation in nf_nat_snmp_basic.

Based on patches by Clark Wang <wtweeker@163.com> and
Stephen Hemminger <shemminger@vyatta.com>.

https://bugzilla.kernel.org/show_bug.cgi?id=17622

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Patrick McHardy authored and David S. Miller committed Sep 22, 2010
1 parent 15cdead commit d6120b8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/ipv4/netfilter/nf_nat_snmp_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,13 +893,15 @@ static void fast_csum(__sum16 *csum,
unsigned char s[4];

if (offset & 1) {
s[0] = s[2] = 0;
s[0] = ~0;
s[1] = ~*optr;
s[2] = 0;
s[3] = *nptr;
} else {
s[1] = s[3] = 0;
s[0] = ~*optr;
s[1] = ~0;
s[2] = *nptr;
s[3] = 0;
}

*csum = csum_fold(csum_partial(s, 4, ~csum_unfold(*csum)));
Expand Down

0 comments on commit d6120b8

Please sign in to comment.