From ef74d8ae3d22dc3acba6d583c0de2983ada57f13 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Sun, 29 Mar 2015 15:39:20 +0200 Subject: [PATCH] Fix hostname export --- src/dhcpv6-ia.c | 10 +++++++--- 1 file 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; -- 2.25.1