[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: Wed, 20 Apr 2011 16:38:33 +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

Follow-up Comment #3, bug #33128 (project lwip):

Sorry, I don't have a reference, so possibly it's not supposed to work.

The destination is not on the same subnet as any of the device interfaces, so
the selected interface must be used so that the correct gateway will be used.

So for example, suppose we have 2 interfaces on the device: and Both have a netmask of We open a UDP socket bound to
each interface.

>From the socket bound to, we want to send to This works
fine because ip_route() finds the correct interface.

>From the socket bound to, we want to send to We would
expect that the packet would be sent to the gateway for the interface
( in this case), and the gateway would then route the packet

The main issue with the way it currently works is that the packet actually
never gets sent at all if the incorrect interface is selected. The reason is
that there is a check to see if the packet's source address is equal to the
netif's address (around line 560 in udp.c, if (!ip_addr_cmp(&(pcb->local_ip),
&(netif->ip_addr))) { ... ). This means that whenever the interface selected
is not the same one as what the socket was bound to, the packet will not get
sent. This happens for all the packets destined for over the interface. I think this is a general issue?

The current behaviour is to use the default interface (since the destination
IP is not on any interface's subnet), and then send to whatever the gateway is
for the default interface. So it would (for example) choose the
interface to send over, and then the packet would get sent to that interface's
gateway ( This would be bad because the gateway is not
connected to the internet (for example). This could just be an issue for us
because of our crazy network setup (since only one gateway can actually route
to the destination).


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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