Discussion:
Bug#284729: libnet1: UDP checksums are bogus in odd sized packets
Domenico Andreoli
2004-12-08 22:18:14 UTC
Permalink
hi Mike, hi all,

here is a bug reported to libnet debian package. full log is available
at http://bugs.debian.org/284729.

i saw similar bug has been reported few days ago against tcp checksum.
is this the same bug? could you please hand me the solution in order
to let me fix the debian package? that's because i don't know if you'll
release the next version in time for sarge ;)

cheers
domenico

----- Forwarded message from Ulisses <***@unavarra.es> -----

Date: Wed, 08 Dec 2004 13:06:06 +0100
To: Debian Bug Tracking System <***@bugs.debian.org>
Subject: Bug#284729: libnet1: UDP checksums are bogus in odd sized packets

...

If I send UDP packets using libnet and I let libnet to checksum them I
found that the checksums are wrong. I have verified this with
tethereal -V.

Using the same procedure with packets having an even size are always ok.

Please note that:

+ I have used tcpdump and tcpdump doesn't report udp checksum errors.
+ Using my own udp checksum routine and capturing packets from
the network, odd sized packets from the network are ok but capturing
libnet generated packets gives wrong udp checksums.

So I think both libnet and tcpdump are wrong and my routine and
tethereal's are right.

I hope this helps

Ulisses

----- End forwarded message -----


-----[ Domenico Andreoli, aka cavok
--[ http://people.debian.org/~cavok/gpgkey.asc
---[ 3A0F 2F80 F79C 678A 8936 4FEE 0677 9033 A20E BC50
Frédéric Raynal
2004-12-09 13:08:49 UTC
Permalink
Hi,
hi, thank you for the fast response :)
Here is a replacement function for libnet_in_cksum() (file
libnet/src/libnet_checksum.c) Several fix have been proposed on
libnet's ML, and that the one _I_ prefer, but I dont know if that is
the one Mike kept.
i'm leaving few days to Mike to comment the thread, then i'll use
your fix.
Note that I did not said it was my fix, but the one I adopted. We had
long discussion on libnet's ML, and that fix have been proposed by Wu
Yongwei.

Cheers,

Fred

int
libnet_in_cksum(u_int16_t *addr, size_t len)
{
int sum;
u_int16_t last_byte;

sum = 0;
last_byte = 0;
while (len > 1)
{
sum += *addr++;
len -= 2;
}
if (len == 1)
{
*(u_int8_t*)&last_byte = *(u_int8_t*)addr;
sum += last_byte;
}
return sum;
}
Domenico Andreoli
2004-12-09 12:06:59 UTC
Permalink
Hi,
hi, thank you for the fast response :)
Here is a replacement function for libnet_in_cksum() (file
libnet/src/libnet_checksum.c) Several fix have been proposed on
libnet's ML, and that the one _I_ prefer, but I dont know if that is
the one Mike kept.
i'm leaving few days to Mike to comment the thread, then i'll use
your fix.

cheers
domenico

-----[ Domenico Andreoli, aka cavok
--[ http://people.debian.org/~cavok/gpgkey.asc
---[ 3A0F 2F80 F79C 678A 8936 4FEE 0677 9033 A20E BC50

Loading...