SO_BINDTODEVICE is not supported on this system

Denys Vlasenko vda.linux at
Mon Jul 22 03:02:38 UTC 2013

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.

On another note, how BSD software does this?
Surely they have dhcp clients, and they work correctly on multihomed machines?

> 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 :)

More information about the busybox mailing list