udp checksum on raw sockets
Ruslan Ermilov
ru at freebsd.org
Tue Apr 27 12:05:50 PDT 2004
On Tue, Apr 27, 2004 at 06:09:01PM +0200, Mark Santcroos wrote:
> * I'm sending UDP packets on a raw socket.
>
> * iphdr->ip_src.s_addr = INADDR_ANY;
> So I don't know the IP address that will be used as src address.
> So as far as I can see, I have a problem generating the checksum in
> userspace.
>
Yes, that problem is real.
> Suggestion:
>
> Would it make sense that if:
> sysctl net.udp.checksum=1
> and
> udphdr->uh_sum = 0;
> in a UDP packet created on a raw socket, to do the checksum in the kernel
> instead of leaving it zero? If it does, I can create a patch.
>
> Any other hints as how to do the checksum in userland are welcome too. As
> that is the "ultimate" problem I try to fix.
>
Have the raw IP code set csum_flags |= CSUM_UDP (and set csum_data
correctly) in m->m_pkthdr, if ip_p == IPPROTO_UDP && uh_csum == 0.
Do the same thing for IPPROTO_TCP.
Cheers,
--
Ruslan Ermilov
ru at FreeBSD.org
FreeBSD committer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-net/attachments/20040427/71719502/attachment.bin
More information about the freebsd-net
mailing list