]> git.proxmox.com Git - mirror_ovs.git/commit
csum: Fix csum_continue() on big endian with an odd number of bytes.
authorDaniele Di Proietto <diproiettod@vmware.com>
Thu, 8 Dec 2016 19:35:30 +0000 (11:35 -0800)
committerDaniele Di Proietto <diproiettod@vmware.com>
Fri, 9 Dec 2016 19:34:04 +0000 (11:34 -0800)
commit23b2a1baa6285838b9ae33ae0ac2759ef46e494f
tree44ef612769a012cccaabcdfa57d386129969bd80
parent1dea14357f9b9c1ce273538dd0cb36ba2a1993dd
csum: Fix csum_continue() on big endian with an odd number of bytes.

Even though it reads 16 bits at a time, csum_continue() is almost
neutral to endianness (see RFC 1071 1.2 (B), "Byte Order Independence").

Consider a buffer like the following:

00000000: XX YY XX YY XX YY XX YY ZZ

Each couple of bytes is interpreted on little endian as:

*data = 0xYYXX

while on big endian

*data = 0xXXYY

The last byte "ZZ" should be treated as the two bytes "ZZ 00"
little endian:

*data = 0x00ZZ

big endian:

*data = 0xZZ00

which means that the last byte (for odd buffers) should be left shifted
by 8 bits on big endian platforms.

This fixes a couple of connection tracking tests in userspace for big
endian platforms.

I guess RFC1071 4.1 (implementation example of the checksum in C), would
manifest the same problem on big endian.

Reported-at: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=840770
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
lib/csum.c