add SO_BINDTODEVICE support
authorJohn Crispin <blogic@openwrt.org>
Tue, 2 Sep 2014 18:20:10 +0000 (20:20 +0200)
committerJohn Crispin <blogic@openwrt.org>
Tue, 2 Sep 2014 18:20:10 +0000 (20:20 +0200)
Signed-off-by: John Crispin <blogic@openwrt.org>
interface.c

index 1584c24..6651fd8 100644 (file)
@@ -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");