[Top][All Lists]

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

[lwip-devel] [bug #33128] Socket send() and sendto() do not use bound in

From: Ken MacKay
Subject: [lwip-devel] [bug #33128] Socket send() and sendto() do not use bound interface.
Date: Tue, 19 Apr 2011 20:33:53 +0000
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27


                 Summary: Socket send() and sendto() do not use bound
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: kmackay
            Submitted on: Tue 19 Apr 2011 08:33:53 PM GMT
                Category: sockets
                Severity: 3 - Normal
              Item Group: Faulty Behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: 
            lwIP version: CVS Head



This is an issue we have noted with UDP sockets, but I believe it applies to
all socket types. We have multiple IP interfaces on our device, and we open
one socket per interface (and bind the socket to the interface). When we call
sendto() on a socket, we expect that the packet will be sent over the
interface that we bound the socket to. However, since udp_sendto() (called by
the sockets API) uses ip_route() to find an interface, the packet will always
be sent either over the first netif with a matching address/netmask, or the
default netif if there is no match.

We have fixed this by adding a 'struct netif *bound_if' to the struct netconn.
This is set to NULL by default in netconn_alloc(). Then, in do_bind(), we
added code to iterate through all netifs and set the bound_if member to the
netif with the matching IP address (if any). Finally, in do_send(), we check
to see if msg->conn->bound_if is non-NULL; if so, we call
udp_sendto_if()/udp_sendto_if_chksum() instead.

You could do a similar thing for TCP sockets but there was no convenient
interface-specific functions to call (and TCP is not required for our
application). I guess you would need to use the bound netif on connect, and
then also on write.


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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