From: florian Date: Thu, 11 Jul 2024 10:38:57 +0000 (+0000) Subject: Write lease after we configured prefixes. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=cc3e93c233c03e53ea7d0df5a38e9fa0fea55c8f;p=openbsd Write lease after we configured prefixes. While here, do not claim we have a ::/0 lease, it confuses the parser. --- diff --git a/sbin/dhcp6leased/dhcp6leased.c b/sbin/dhcp6leased/dhcp6leased.c index 61fbd182a59..8c2fb7e5543 100644 --- a/sbin/dhcp6leased/dhcp6leased.c +++ b/sbin/dhcp6leased/dhcp6leased.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcp6leased.c,v 1.11 2024/06/05 16:15:47 florian Exp $ */ +/* $OpenBSD: dhcp6leased.c,v 1.12 2024/07/11 10:38:57 florian Exp $ */ /* * Copyright (c) 2017, 2021, 2024 Florian Obser @@ -913,6 +913,9 @@ write_lease_file(struct imsg_lease_info *imsg_lease_info) rem = sizeof(lease_buf); for (i = 0; i < iface_conf->ia_count; i++) { + if (imsg_lease_info->pds[i].prefix_len == 0) + continue; + len = snprintf(p, rem, "%s%d %s %d\n", LEASE_IA_PD_PREFIX, i, inet_ntop(AF_INET6, &imsg_lease_info->pds[i].prefix, ntopbuf, INET6_ADDRSTRLEN), diff --git a/sbin/dhcp6leased/engine.c b/sbin/dhcp6leased/engine.c index f58ae94929f..f1202dfc622 100644 --- a/sbin/dhcp6leased/engine.c +++ b/sbin/dhcp6leased/engine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: engine.c,v 1.22 2024/07/11 10:37:47 florian Exp $ */ +/* $OpenBSD: engine.c,v 1.23 2024/07/11 10:38:57 florian Exp $ */ /* * Copyright (c) 2017, 2021, 2024 Florian Obser @@ -1294,11 +1294,6 @@ configure_interfaces(struct dhcp6leased_iface *iface) return; } - memset(&imsg_lease_info, 0, sizeof(imsg_lease_info)); - imsg_lease_info.if_index = iface->if_index; - memcpy(imsg_lease_info.pds, iface->new_pds, sizeof(iface->new_pds)); - engine_imsg_compose_main(IMSG_WRITE_LEASE, 0, &imsg_lease_info, - sizeof(imsg_lease_info)); SIMPLEQ_FOREACH(ia_conf, &iface_conf->iface_ia_list, entry) { struct prefix *pd = &iface->new_pds[ia_conf->id]; @@ -1327,6 +1322,12 @@ configure_interfaces(struct dhcp6leased_iface *iface) memcpy(iface->pds, iface->new_pds, sizeof(iface->pds)); memset(iface->new_pds, 0, sizeof(iface->new_pds)); + + memset(&imsg_lease_info, 0, sizeof(imsg_lease_info)); + imsg_lease_info.if_index = iface->if_index; + memcpy(imsg_lease_info.pds, iface->pds, sizeof(iface->pds)); + engine_imsg_compose_main(IMSG_WRITE_LEASE, 0, &imsg_lease_info, + sizeof(imsg_lease_info)); } void