[olsr-dev] Problems checsuming with UDP+IPv6

Andreas T√łnnesen (spam-protected)
Wed Jan 11 20:40:10 CET 2006


Hi,

First of all, kudos to you guys for creating such an easy to use
yet powerfull lib!

Now for my little story:
After experiencing some IPv6 problems with the olsr.org routing daemon,
that the standard socket API could not fix(in a platform independent
manner) we decided to give libnet a shot. I was not 100% sure about
the IPv6 support in libnet but as the API provided ipv6 counterparts
to all ip functions I figured it should work. So question one is:
Is IPv6 "officialy" supported?

At first I implemented use of libnet for IPv4 mode and there was no
problems at all, but when I started out on the IPv6 part trouble
came visiting. OLSR uses UDP for transport, but after building a UDP
frame and adding the IPv6 header glibc detects a free call on an
erronous block when libnet_write is called and the application is 
terminated:
*** glibc detected *** free(): invalid next size (normal): 0x0807ab88 ***
Avbrutt (SIGABRT)

After seeing this I tried the usual "build a simple application to get
rid of all the possible traps" So I did, and it still crashed. The next
step in this highly scientific process is "try with every possible
different combination of parameters" :-) And finally, when I tried
adding my own checksum in the libnet_build_udp call it no longer
crashed.
Looking at the checksum calculation in libnet_checksum.c it turned out
that IP version was never set correctly when dealing with IPv6/UDP.
It seems the buf pointer passed on from libnet_pblock_coalesce is way
off. Now I have not studyed the code very much, but it looks like the
q->ip_offset is always zero in the IPv6/UDP case, leading to the offset
beeing == l->total_size (at least in my case) which gives a messed up
buffer pointer. I have not investigated any further.
Now the question is: Has anybody ever sucessfully generated and
transmitted a IPv6/UDP frame with automatic UDP checksum using libnet?
I'm using the stock debian 1.1.2.1 libnet version, but I have also tried
with a self-compiled 1.1.3 with the same result.

The source of a small app that produces the crash can be found at:
http://www.olsr.org/files/libnet_crash.c
Here you can also check if I am doing anything wrong ;-)

Thanks for you time,
Andreas T





More information about the Olsr-dev mailing list