diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2014-10-30 12:30:32 +0100 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2014-10-30 14:05:41 +0100 |
commit | d94b406eeba27af2a6abff333dc16e82d28ed636 (patch) | |
tree | 5590f9d3345e51c1c8f6c881da30896fdc2b29fc /src/router.c | |
parent | b461334ab277b6e8fd1622ab7c8a655363bd3f6c (diff) |
Fix IPv6 DNS server adddress selection
Fix selection of IPv6 DNS address in DHCPv6 and RA overwrite as an address could be selected
with preferred lifetime zero while IPv6 addresses are in use with non zero preferred
lifetimes.
Fix tries to pick the IPv6 address with the longest preferred lifetime now.
Fixes also the issue an IPv6 address with preferred lifetime zero could be returned in DHCPv6
DNS server option while an IPv6 address with non zero preferred lifetime is returned as DNS
recursive RA option for the same set of available IPv6 addresses.
Diffstat (limited to 'src/router.c')
-rw-r--r-- | src/router.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/router.c b/src/router.c index 0b15dac..3d26c58 100644 --- a/src/router.c +++ b/src/router.c @@ -537,7 +537,6 @@ static void forward_router_advertisement(uint8_t *data, size_t len) struct sockaddr_in6 all_nodes = {AF_INET6, 0, 0, ALL_IPV6_NODES, 0}; struct iovec iov = {data, len}; - struct odhcpd_ipaddr addr; struct interface *iface; list_for_each_entry(iface, &interfaces, head) { if (iface->ra != RELAYD_RELAY || iface->master) @@ -550,13 +549,14 @@ static void forward_router_advertisement(uint8_t *data, size_t len) // If we have to rewrite DNS entries if (iface->always_rewrite_dns && dns_ptr && dns_count > 0) { const struct in6_addr *rewrite = iface->dns; + struct in6_addr addr; size_t rewrite_cnt = iface->dns_cnt; if (rewrite_cnt == 0) { - if (odhcpd_get_interface_addresses(iface->ifindex, &addr, 1) < 1) + if (odhcpd_get_preferred_interface_address(iface->ifindex, &addr) < 1) continue; // Unable to comply - rewrite = &addr.addr; + rewrite = &addr; rewrite_cnt = 1; } |