summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/dhcp6-network.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-11-16 17:43:08 +0100
committerTom Gundersen <teg@jklm.no>2015-11-17 14:17:41 +0100
commitc601ebf79f0c54be14d3c16f0f484c0335cdeec4 (patch)
treec13fb6b3eb731d5f885bf0bed63935d84bb6fc02 /src/libsystemd-network/dhcp6-network.c
parentfb84d8966e5ce49b0c705768bb4da4956c4e529a (diff)
sd-dhcp6-client: bind to link-local address
This ensures that several DHCPv6 clients can run on separate interfaces simultaneously.
Diffstat (limited to 'src/libsystemd-network/dhcp6-network.c')
-rw-r--r--src/libsystemd-network/dhcp6-network.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/libsystemd-network/dhcp6-network.c b/src/libsystemd-network/dhcp6-network.c
index ec601cbc6a..fd2d60c9d5 100644
--- a/src/libsystemd-network/dhcp6-network.c
+++ b/src/libsystemd-network/dhcp6-network.c
@@ -33,28 +33,23 @@
#include "socket-util.h"
int dhcp6_network_bind_udp_socket(int index, struct in6_addr *local_address) {
- struct in6_pktinfo pktinfo = {
- .ipi6_ifindex = index,
- };
union sockaddr_union src = {
.in6.sin6_family = AF_INET6,
.in6.sin6_port = htobe16(DHCP6_PORT_CLIENT),
- .in6.sin6_addr = IN6ADDR_ANY_INIT,
+ .in6.sin6_scope_id = index,
};
_cleanup_close_ int s = -1;
int r, off = 0, on = 1;
- if (local_address)
- src.in6.sin6_addr = *local_address;
+ assert(index > 0);
+ assert(local_address);
+
+ src.in6.sin6_addr = *local_address;
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));
- if (r < 0)
- return -errno;
-
r = setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));
if (r < 0)
return -errno;