From 0498f8969d2a024d6f3534258c1cd4344a5838a7 Mon Sep 17 00:00:00 2001 From: florian Date: Thu, 11 Jul 2024 10:48:51 +0000 Subject: [PATCH] Be a bit more noisy in syslog on what is going on. So far dhcp6leased(8) has been completely silent. Prodding by Brian Conway. --- sbin/dhcp6leased/engine.c | 31 +++++++++++++++++++++++++------ sbin/dhcp6leased/frontend.c | 27 +++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/sbin/dhcp6leased/engine.c b/sbin/dhcp6leased/engine.c index f1202dfc622..e410a5a465d 100644 --- a/sbin/dhcp6leased/engine.c +++ b/sbin/dhcp6leased/engine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: engine.c,v 1.23 2024/07/11 10:38:57 florian Exp $ */ +/* $OpenBSD: engine.c,v 1.24 2024/07/11 10:48:51 florian Exp $ */ /* * Copyright (c) 2017, 2021, 2024 Florian Obser @@ -1279,9 +1279,10 @@ configure_interfaces(struct dhcp6leased_iface *iface) struct iface_ia_conf *ia_conf; struct iface_pd_conf *pd_conf; struct imsg_lease_info imsg_lease_info; + uint32_t i; + char ntopbuf[INET6_ADDRSTRLEN]; char ifnamebuf[IF_NAMESIZE], *if_name; - if ((if_name = if_indextoname(iface->if_index, ifnamebuf)) == NULL) { log_debug("%s: unknown interface %d", __func__, iface->if_index); @@ -1294,6 +1295,14 @@ configure_interfaces(struct dhcp6leased_iface *iface) return; } + for (i = 0; i < iface_conf->ia_count; i++) { + struct prefix *pd = &iface->new_pds[i]; + + log_info("prefix delegation #%d %s/%d received on %s from " + "server %s", i, inet_ntop(AF_INET6, &pd->prefix, ntopbuf, + INET6_ADDRSTRLEN), pd->prefix_len, if_name, + dhcp_duid2str(iface->serverid_len, iface->serverid)); + } SIMPLEQ_FOREACH(ia_conf, &iface_conf->iface_ia_list, entry) { struct prefix *pd = &iface->new_pds[ia_conf->id]; @@ -1304,10 +1313,9 @@ configure_interfaces(struct dhcp6leased_iface *iface) } if (prefixcmp(iface->pds, iface->new_pds, iface_conf->ia_count) != 0) { - uint32_t i; - char ntopbuf[INET6_ADDRSTRLEN]; - - log_warnx("IA_PDs changed"); + log_info("Prefix delegations on %s from server %s changed", + if_name, dhcp_duid2str(iface->serverid_len, + iface->serverid)); for (i = 0; i < iface_conf->ia_count; i++) { log_debug("%s: iface->pds [%d]: %s/%d", __func__, i, inet_ntop(AF_INET6, &iface->pds[i].prefix, ntopbuf, @@ -1336,6 +1344,8 @@ deconfigure_interfaces(struct dhcp6leased_iface *iface) struct iface_conf *iface_conf; struct iface_ia_conf *ia_conf; struct iface_pd_conf *pd_conf; + uint32_t i; + char ntopbuf[INET6_ADDRSTRLEN]; char ifnamebuf[IF_NAMESIZE], *if_name; @@ -1351,6 +1361,15 @@ deconfigure_interfaces(struct dhcp6leased_iface *iface) return; } + for (i = 0; i < iface_conf->ia_count; i++) { + struct prefix *pd = &iface->pds[i]; + + log_info("Prefix delegation #%d %s/%d expired on %s from " + "server %s", i, inet_ntop(AF_INET6, &pd->prefix, ntopbuf, + INET6_ADDRSTRLEN), pd->prefix_len, if_name, + dhcp_duid2str(iface->serverid_len, iface->serverid)); + } + SIMPLEQ_FOREACH(ia_conf, &iface_conf->iface_ia_list, entry) { struct prefix *pd = &iface->pds[ia_conf->id]; diff --git a/sbin/dhcp6leased/frontend.c b/sbin/dhcp6leased/frontend.c index 716ccfdb00f..88552f53a22 100644 --- a/sbin/dhcp6leased/frontend.c +++ b/sbin/dhcp6leased/frontend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: frontend.c,v 1.12 2024/06/19 07:42:44 florian Exp $ */ +/* $OpenBSD: frontend.c,v 1.13 2024/07/11 10:48:51 florian Exp $ */ /* * Copyright (c) 2017, 2021, 2024 Florian Obser @@ -873,8 +873,8 @@ build_packet(uint8_t message_type, struct iface *iface, char *if_name) void send_packet(uint8_t message_type, struct iface *iface) { - ssize_t pkt_len; - char ifnamebuf[IF_NAMESIZE], *if_name; + ssize_t pkt_len; + char ifnamebuf[IF_NAMESIZE], *if_name, *message_name; if (!event_initialized(&iface->udpev)) { iface->send_solicit = 1; @@ -887,7 +887,26 @@ send_packet(uint8_t message_type, struct iface *iface) == NULL) return; /* iface went away, nothing to do */ - log_debug("%s on %s", dhcp_message_type2str(message_type), if_name); + switch (message_type) { + case DHCPSOLICIT: + message_name = "Soliciting"; + break; + case DHCPREQUEST: + message_name = "Requesting"; + break; + case DHCPRENEW: + message_name = "Renewing"; + break; + case DHCPREBIND: + message_name = "Rebinding"; + break; + default: + message_name = NULL; + break; + } + + if (message_name) + log_info("%s lease on %s", message_name, if_name); pkt_len = build_packet(message_type, iface, if_name); -- 2.20.1