lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] udp_send: space for IP header is not being allocated?


From: Robin Iddon
Subject: Re: [lwip-users] udp_send: space for IP header is not being allocated?
Date: Fri, 13 Jul 2007 18:27:58 +0100
User-agent: Thunderbird 1.5.0.12 (Windows/20070509)

I might be barking up the wrong tree here, but when you allocate the pbuf for your user data you pass in a flag that says "TRANSPORT" and this means that when the pbuf is allocated the transport header space is pre-allocated. Now, if you're using UDP raw interface, I am not sure in what way that is different from the normal udp_send().

Hope this helps,
Robin

David Baird wrote:
Hi,

I think I found a bug, but wanted to check with people on the mailing
list before reporting it (since it seems like others are using UDP
without any problem, I wonder why it is that I am having a problem?).

Space for IP header (IP_HLEN) is not properly allocated when using the
UDP RAW API.  The problem seems to be constrained to one of these
functions:

- udp_send (in src/core/udp.c)
- ip_output_if (in src/core/ipv4/ip.c)

The problem is that no function is assuming the responsibility of
allocating sufficient memory for the IP header (e.g. by calling
``pbuf_alloc`` and ``pbuf_chain``).  Neither ``ip_output_if`` nor
``udp_send`` allocate any memory (pbufs) for the IP header.

However, ``udp_send`` does allocate enough memory for the UDP header
(but not the IP header).  Looking at other code (``raw_send_to`` in
``src/core/raw.c``) seems to indicate that space for the IP header
must be allocated *before* calling ``ip_output_if`` which means that
``udp_send`` has a bug (because it does not allocate space for the IP
header).  In either case, it seems that someone apparently needs to
allocate a pbuf and call pbuf_chain.

Here are some lines captured when enabling debug output (in
``src/include/lwip/debug.h``) and trying to call ``udp_send`` (NOTE:
this is not captured from the CVS head, but hopefully should follow it
closely enough)::

   udp_send
   pbuf_header: old 0x195aa8 new 0x195aa0 (8)
   udp_send: added header in given pbuf 0x195a88
   udp_send: sending datagram of length 13
   udp_send: UDP packet length 13
   udp_send: UDP checksum 0x0000
   udp_send: ip_output_if (,,,,IP_PROTO_UDP,)
   pbuf_header: failed as 0x195a8c < 0x195a98
   ip_output: not enough room for IP header in pbuf

I am unable to send any UDP packets (even if I try different sizes).
However, if I rewrite ``udp_send`` to force it to call ``pbuf_alloc``
and ``pbuf_chain``, then everything works perfect (i.e. I am able to
send UDP packets).

So, is this a bug?  Or do you think I am missing something important?

-David


_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users







reply via email to

[Prev in Thread] Current Thread [Next in Thread]