diff options
author | Tom Gundersen <teg@jklm.no> | 2015-11-16 19:05:27 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-11-17 13:26:51 +0100 |
commit | 6506063f8f68f589040cfcc138d3f61269fb2a63 (patch) | |
tree | 62d378f3a29268c86959c90ba4794be33757c132 /src | |
parent | 62379e884e8a30cabbad994095c76e2f44b8f425 (diff) |
sd-dhcp6-client: allow multiple clients on host
We need to enable SO_REUSEADDR in order for several sockets to be allowed
to bind to the same port (even on different links).
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd-network/dhcp6-network.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/libsystemd-network/dhcp6-network.c b/src/libsystemd-network/dhcp6-network.c index 318ee9c4b4..ec601cbc6a 100644 --- a/src/libsystemd-network/dhcp6-network.c +++ b/src/libsystemd-network/dhcp6-network.c @@ -45,16 +45,13 @@ int dhcp6_network_bind_udp_socket(int index, struct in6_addr *local_address) { int r, off = 0, on = 1; if (local_address) - memcpy(&src.in6.sin6_addr, local_address, - sizeof(src.in6.sin6_addr)); + src.in6.sin6_addr = *local_address; - s = socket(AF_INET6, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, - IPPROTO_UDP); + s = socket(AF_INET6, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, IPPROTO_UDP); if (s < 0) return -errno; - r = setsockopt(s, IPPROTO_IPV6, IPV6_PKTINFO, &pktinfo, - sizeof(pktinfo)); + r = setsockopt(s, IPPROTO_IPV6, IPV6_PKTINFO, &pktinfo, sizeof(pktinfo)); if (r < 0) return -errno; @@ -66,6 +63,10 @@ int dhcp6_network_bind_udp_socket(int index, struct in6_addr *local_address) { if (r < 0) return -errno; + r = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); + if (r < 0) + return -errno; + r = bind(s, &src.sa, sizeof(src.in6)); if (r < 0) return -errno; |