From c7313d446b21b771ba3fd22246e54ee30430b023 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 1 Aug 2021 09:07:03 +0000 Subject: [PATCH] Do not abuse the IMSG_CTL_SEND_REQUEST imsg to transition to REBOOTING. There will be a few more cases internal to dhcpleased that have nothing to do with the control socket. While here move requesting a new lease via a call to dhclient under ifndef SMALL, nothing on the ramdisk uses this. --- sbin/dhcpleased/control.c | 4 ++-- sbin/dhcpleased/dhcpleased.h | 5 +++-- sbin/dhcpleased/engine.c | 4 ++-- sbin/dhcpleased/frontend.c | 9 ++++++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/sbin/dhcpleased/control.c b/sbin/dhcpleased/control.c index 9a713cb9913..d29e3fb1639 100644 --- a/sbin/dhcpleased/control.c +++ b/sbin/dhcpleased/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.3 2021/07/26 09:26:36 florian Exp $ */ +/* $OpenBSD: control.c,v 1.4 2021/08/01 09:07:03 florian Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -280,7 +280,7 @@ control_dispatch_imsg(int fd, short event, void *bula) if (IMSG_DATA_SIZE(imsg) != sizeof(uint32_t)) break; c->iev.ibuf.pid = imsg.hdr.pid; - frontend_imsg_compose_engine(imsg.hdr.type, 0, + frontend_imsg_compose_engine(IMSG_REQUEST_REBOOT, 0, imsg.hdr.pid, imsg.data, IMSG_DATA_SIZE(imsg)); break; default: diff --git a/sbin/dhcpleased/dhcpleased.h b/sbin/dhcpleased/dhcpleased.h index c436558bc82..7f6ec87ad19 100644 --- a/sbin/dhcpleased/dhcpleased.h +++ b/sbin/dhcpleased/dhcpleased.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpleased.h,v 1.9 2021/07/28 07:57:10 anton Exp $ */ +/* $OpenBSD: dhcpleased.h,v 1.10 2021/08/01 09:07:03 florian Exp $ */ /* * Copyright (c) 2017, 2021 Florian Obser @@ -190,6 +190,7 @@ enum imsg_type { #ifndef SMALL IMSG_CTL_LOG_VERBOSE, IMSG_CTL_SHOW_INTERFACE_INFO, + IMSG_CTL_SEND_REQUEST, IMSG_CTL_RELOAD, IMSG_CTL_END, IMSG_RECONF_CONF, @@ -198,7 +199,6 @@ enum imsg_type { IMSG_RECONF_C_ID, IMSG_RECONF_END, #endif /* SMALL */ - IMSG_CTL_SEND_REQUEST, IMSG_SEND_DISCOVER, IMSG_SEND_REQUEST, IMSG_SOCKET_IPC, @@ -217,6 +217,7 @@ enum imsg_type { IMSG_PROPOSE_RDNS, IMSG_WITHDRAW_RDNS, IMSG_REPROPOSE_RDNS, + IMSG_REQUEST_REBOOT, }; #ifndef SMALL diff --git a/sbin/dhcpleased/engine.c b/sbin/dhcpleased/engine.c index 060d0de5a2c..79ea38c8d22 100644 --- a/sbin/dhcpleased/engine.c +++ b/sbin/dhcpleased/engine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: engine.c,v 1.22 2021/07/26 09:26:36 florian Exp $ */ +/* $OpenBSD: engine.c,v 1.23 2021/08/01 09:07:03 florian Exp $ */ /* * Copyright (c) 2017, 2021 Florian Obser @@ -317,7 +317,7 @@ engine_dispatch_frontend(int fd, short event, void *bula) memcpy(&if_index, imsg.data, sizeof(if_index)); engine_showinfo_ctl(&imsg, if_index); break; - case IMSG_CTL_SEND_REQUEST: + case IMSG_REQUEST_REBOOT: if (IMSG_DATA_SIZE(imsg) != sizeof(if_index)) fatalx("%s: IMSG_CTL_SEND_DISCOVER wrong " "length: %lu", __func__, diff --git a/sbin/dhcpleased/frontend.c b/sbin/dhcpleased/frontend.c index bf33e6e5e48..249c6718cf5 100644 --- a/sbin/dhcpleased/frontend.c +++ b/sbin/dhcpleased/frontend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: frontend.c,v 1.15 2021/07/27 18:17:37 florian Exp $ */ +/* $OpenBSD: frontend.c,v 1.16 2021/08/01 09:07:03 florian Exp $ */ /* * Copyright (c) 2017, 2021 Florian Obser @@ -761,7 +761,9 @@ handle_route_message(struct rt_msghdr *rtm, struct sockaddr **rti_info) log_debug("RTP_PROPOSAL_SOLICIT"); frontend_imsg_compose_engine(IMSG_REPROPOSE_RDNS, 0, 0, NULL, 0); - } else if (rtm->rtm_flags & RTF_PROTO3) { + } +#ifndef SMALL + else if (rtm->rtm_flags & RTF_PROTO3) { uint32_t if_index; char ifnamebuf[IF_NAMESIZE], *if_name; @@ -769,9 +771,10 @@ handle_route_message(struct rt_msghdr *rtm, struct sockaddr **rti_info) if_name = if_indextoname(if_index, ifnamebuf); log_warnx("\"dhclient %s\" ran, requesting new lease", if_name != NULL ? if_name : "(unknown)"); - frontend_imsg_compose_engine(IMSG_CTL_SEND_REQUEST, + frontend_imsg_compose_engine(IMSG_REQUEST_REBOOT, 0, 0, &if_index, sizeof(if_index)); } +#endif /* SMALL */ break; default: log_debug("unexpected RTM: %d", rtm->rtm_type); -- 2.20.1