From: John Crispin Date: Tue, 2 Sep 2014 18:20:10 +0000 (+0200) Subject: add SO_BINDTODEVICE support X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c05c2fd3c8fd3a2bc5be41ee0fb35c5bae14a3cb;p=oweals%2Fmdnsd.git add SO_BINDTODEVICE support Signed-off-by: John Crispin --- diff --git a/interface.c b/interface.c index 1584c24..6651fd8 100644 --- a/interface.c +++ b/interface.c @@ -378,6 +378,9 @@ reconnect_socket4(struct uloop_timeout *timeout) goto retry; } + if (setsockopt(iface->fd.fd, SOL_SOCKET, SO_BINDTODEVICE, iface->name, strlen(iface->name) < 0)) + fprintf(stderr, "ioctl failed: SO_BINDTODEVICE\n"); + if (setsockopt(iface->fd.fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) fprintf(stderr, "ioctl failed: SO_REUSEADDR\n"); @@ -419,6 +422,9 @@ reconnect_socket6(struct uloop_timeout *timeout) goto retry; } + if (setsockopt(iface->fd.fd, SOL_SOCKET, SO_BINDTODEVICE, iface->name, strlen(iface->name) < 0)) + fprintf(stderr, "ioctl failed: SO_BINDTODEVICE\n"); + if (setsockopt(iface->fd.fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl)) < 0) fprintf(stderr, "ioctl failed: IPV6_UNICAST_HOPS\n");