From: Steven Barth Date: Sun, 29 Mar 2015 13:39:20 +0000 (+0200) Subject: Fix hostname export X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ef74d8ae3d22dc3acba6d583c0de2983ada57f13;p=oweals%2Fodhcpd.git Fix hostname export --- 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;