SO_BINDTODEVICE is not supported on this system

Lambrecht Jürgen J.Lambrecht at
Tue Jul 23 09:09:01 UTC 2013

On 07/22/2013 05:02 AM, Denys Vlasenko wrote:
> On Thursday 18 July 2013 20:59, Matthias Andree wrote:
>> Am 18.07.2013 16:58, schrieb Lambrecht Jürgen:
>>> On 07/18/2013 12:49 PM, Lambrecht Jürgen wrote:
>>>> Hi,
>>>> I am porting the busybox dhcp server to an RTOS (eCos). eCos uses the
>>>> FreeBSD TCP/IP stack.
>>>> I get this message: bb_error_msg("SO_BINDTODEVICE is not supported on
>>>> this system");.
>>>> Why not ignoring this option on systems that do not support it, as long
>>>> as there is only 1 network interface?
> I assume you are concerned with this code in networking/udhcp/socket.c:
> int FAST_FUNC udhcp_listen_socket(/*uint32_t ip,*/ int port, const char *inf)
> {
> ...
>          if (setsockopt_bindtodevice(fd, inf))
>                  xfunc_die(); /* warning is already printed */
> I propose replacing xfunc_die() here with a message
> which explains that there could be problems
> if we run on a multihomed machine.
Indeed, that is what I try to do in my patch, but I try to only print a 
message on a multihomed machine, not if there is only 1 interface.
> On another note, how BSD software does this?
> Surely they have dhcp clients, and they work correctly on multihomed machines?
This is about the dhcp server.
And I am quite sure the busybox dhcp server does not run on FreeBSD, 
because there is no SO_BINDTODEVICE there. So the dhcp server will die 
when run on FreeBSD.
I sent an email to mandree at (found on 
about it, but no reply yet.

>> I'd say that the SO_BINDTODEVICE stuff can be avoided, as sketched
>> below. The plan is:
>> 1. obtain the interface's primary address for the socket's address
>> family with ioctl (socket, SIOCGIFADDR, struct ifreq *something)
>> <>
>> 2. bind(2) to that address.
> This won't work for Lambrecht's purpose of porting dhcp:
> dhcp client does not have an IP address -
> dhcp's purpose is to obtain one :)
No, it is about the dhcp server.
But anyhow, it is a valid point: the dhcp server (read in notes on the 
busybox sources) should also run when the interface has no address!
I will reply to it on the other email.

Kind regards,

Jürgen Lambrecht
R&D Associate
Mobile: +32 499 644 531
Tel: +32 (0)51 303045    Fax: +32 (0)51 310670
Televic Rail NV - Leo Bekaertlaan 1 - 8870 Izegem - Belgium
Company number 0825.539.581 - RPR Kortrijk

More information about the busybox mailing list