diff options
| author | Roy Marples <roy@marples.name> | 2017-10-25 14:56:23 +0100 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2017-10-25 14:56:23 +0100 |
| commit | ef53a17e01fc25aea22717373afcfcd9e35c85b5 (patch) | |
| tree | a06b6c7ba2ffad61a9ebb3bfd791cc315802a82c /src/ipv6.c | |
| parent | b15dcccc636637b767adbb14305a1e304b00c347 (diff) | |
| download | dhcpcd-ef53a17e01fc25aea22717373afcfcd9e35c85b5.tar.xz | |
DHCPv6: listen on all IPv6 addresses for active interface
Simplify the process of selecting addresses to listen for DHCPv6
replies on by listening on all addresses for active interfaces
when not in master mode.
Always send from a socket not bound to an address to ensure
unicast in non master mode works fine. The downside of this approach
is that we no longer send from the DHCPv6 client port, but this
seems to work fine, at least with ISC DHCPd.
Diffstat (limited to 'src/ipv6.c')
| -rw-r--r-- | src/ipv6.c | 28 |
1 files changed, 5 insertions, 23 deletions
@@ -1103,26 +1103,10 @@ ipv6_handleifa(struct dhcpcd_ctx *ctx, break; case RTM_NEWADDR: if (ia == NULL) { - char buf[INET6_ADDRSTRLEN]; - const char *cbp; - - if ((ia = calloc(1, sizeof(*ia))) == NULL) { - logerr(__func__); - break; - } + ia = ipv6_newaddr(ifp, addr, prefix_len, 0); #ifdef ALIAS_ADDR strlcpy(ia->alias, ifname, sizeof(ia->alias)); #endif - ia->iface = ifp; - ia->addr = *addr; - ia->prefix_len = prefix_len; - ipv6_makeprefix(&ia->prefix, &ia->addr, - ia->prefix_len); - cbp = inet_ntop(AF_INET6, &addr->s6_addr, - buf, sizeof(buf)); - if (cbp) - snprintf(ia->saddr, sizeof(ia->saddr), - "%s/%d", cbp, prefix_len); if (if_getlifetime6(ia) == -1) { /* No support or address vanished. * Either way, just set a deprecated @@ -1190,10 +1174,8 @@ ipv6_handleifa(struct dhcpcd_ctx *ctx, } if (ia != NULL) { - if (!IN6_IS_ADDR_LINKLOCAL(&ia->addr)) { - ipv6nd_handleifa(cmd, ia); - dhcp6_handleifa(cmd, ia); - } + ipv6nd_handleifa(cmd, ia); + dhcp6_handleifa(cmd, ia); /* Done with the ia now, so free it. */ if (cmd == RTM_DELADDR) @@ -1453,8 +1435,8 @@ ipv6_tryaddlinklocal(struct interface *ifp) } struct ipv6_addr * -ipv6_newaddr(struct interface *ifp, struct in6_addr *addr, uint8_t prefix_len, - unsigned int flags) +ipv6_newaddr(struct interface *ifp, const struct in6_addr *addr, + uint8_t prefix_len, unsigned int flags) { struct ipv6_addr *ia; char buf[INET6_ADDRSTRLEN]; |
