diff options
author | Steven Barth <steven@midlink.org> | 2015-03-29 15:39:20 +0200 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2015-03-29 15:39:20 +0200 |
commit | ef74d8ae3d22dc3acba6d583c0de2983ada57f13 (patch) | |
tree | b215de5956036eb7a149e614e41ebb9d0e251b15 | |
parent | 7103b67707aac1a44b64211b45eca9c5c54bef2d (diff) |
Fix hostname export
-rw-r--r-- | src/dhcpv6-ia.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c index c97a079..ffcb6df 100644 --- a/src/dhcpv6-ia.c +++ b/src/dhcpv6-ia.c @@ -254,11 +254,15 @@ void dhcpv6_write_statefile(void) struct in6_addr addr; struct odhcpd_ipaddr *addrs = (c->managed) ? c->managed : iface->ia_addr; size_t addrlen = (c->managed) ? (size_t)c->managed_size : iface->ia_addr_len; + size_t mostpref = 0; + + for (size_t i = 0; i < addrlen; ++i) + if (addrs[i].preferred > addrs[mostpref].preferred) + mostpref = i; for (size_t i = 0; i < addrlen; ++i) { - if (addrs[i].prefix > 96) - continue; - if (c->valid_until <= now) + if (addrs[i].prefix > 96 || c->valid_until <= now || + (iface->managed < RELAYD_MANAGED_NO_AFLAG && i != mostpref)) continue; addr = addrs[i].addr; |