-/* $OpenBSD: dhclient.c,v 1.446 2017/06/24 10:09:26 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.447 2017/06/24 23:32:57 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
routehandler(struct interface_info *ifi)
{
char ntoabuf[INET_ADDRSTRLEN];
- struct in_addr a, b;
+ struct in_addr a;
struct sockaddr *sa;
struct ifa_msghdr *ifam;
struct ether_addr hw;
/* Tell the priv process active_addr is gone. */
log_warnx("Active address (%s) deleted; exiting",
inet_ntoa(ifi->active->address));
- memset(&b, 0, sizeof(b));
- add_address(b, b);
- /* No need to write resolv.conf now. */
- ifi->flags &= ~IFI_IS_RESPONSIBLE;
- quit = INTERNALSIG;
- break;
+ sendhup();
+ goto done;
}
if (deleting.s_addr != INADDR_ANY) {
strlcpy(ntoabuf, inet_ntoa(a), sizeof(ntoabuf));
get_hw_address(ifi);
if (memcmp(&hw, &ifi->hw_address, sizeof(hw))) {
log_warnx("LLADDR changed; restarting");
- quit = SIGHUP;
+ sendhup();
goto done;
}
}
void
fork_privchld(struct interface_info *ifi, int fd, int fd2)
{
- struct imsg_hup imsg;
struct pollfd pfd[1];
struct imsgbuf *priv_ibuf;
ssize_t n;
* routes, possibly preventing NFS from properly shutting down.
*/
if (quit != SIGTERM) {
- memset(&imsg, 0, sizeof(imsg));
- imsg.addr = active_addr;
- priv_cleanup(ifi, &imsg);
+ priv_cleanup(ifi);
}
if (quit == SIGHUP) {
-/* $OpenBSD: dhcpd.h,v 1.194 2017/06/24 10:09:26 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.195 2017/06/24 23:32:57 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
int interface_status(struct interface_info *);
int get_rdomain(char *);
void get_hw_address(struct interface_info *);
+void sendhup(void);
/* tables.c */
extern const struct option dhcp_options[256];
-/* $OpenBSD: dispatch.c,v 1.126 2017/06/21 15:24:34 krw Exp $ */
+/* $OpenBSD: dispatch.c,v 1.127 2017/06/24 23:32:57 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
void packethandler(struct interface_info *ifi);
-void sendhup(struct client_lease *);
void
get_hw_address(struct interface_info *ifi)
time_t cur_time, howlong;
void (*func)(struct interface_info *);
- while (quit == 0) {
+ while (quit == 0 || quit == SIGHUP) {
+ if (quit == SIGHUP) {
+ log_warnx("%s; restarting", strsignal(quit));
+ sendhup();
+ }
+
if (ifi->timeout_func) {
time(&cur_time);
if (ifi->timeout <= cur_time) {
}
}
- if (quit == SIGHUP) {
- /* Tell [priv] process that HUP has occurred. */
- sendhup(ifi->active);
- log_warnx("%s; restarting", strsignal(quit));
- exit (0);
- } else if (quit != INTERNALSIG) {
+ if (quit != INTERNALSIG)
fatalx("%s", strsignal(quit));
- }
}
void
}
/*
- * Inform the [priv] process a HUP was received and it should restart.
+ * Inform the [priv] process a HUP was received.
*/
void
-sendhup(struct client_lease *active)
+sendhup(void)
{
- struct imsg_hup imsg;
int rslt;
- if (active)
- imsg.addr = active->address;
- else
- imsg.addr.s_addr = INADDR_ANY;
-
- rslt = imsg_compose(unpriv_ibuf, IMSG_HUP, 0, 0, -1,
- &imsg, sizeof(imsg));
+ rslt = imsg_compose(unpriv_ibuf, IMSG_HUP, 0, 0, -1, NULL, 0);
if (rslt == -1)
log_warn("sendhup: imsg_compose");
-/* $OpenBSD: kroute.c,v 1.92 2017/06/23 15:40:56 krw Exp $ */
+/* $OpenBSD: kroute.c,v 1.93 2017/06/24 23:32:57 krw Exp $ */
/*
* Copyright 2012 Kenneth R Westerback <krw@openbsd.org>
* priv_cleanup removes dhclient installed routes and address.
*/
void
-priv_cleanup(struct interface_info *ifi, struct imsg_hup *imsg)
+priv_cleanup(struct interface_info *ifi)
{
struct imsg_flush_routes fimsg;
struct imsg_delete_address dimsg;
fimsg.zapzombies = 0; /* Only zapzombies when binding a lease. */
priv_flush_routes(ifi, &fimsg);
- if (imsg->addr.s_addr == INADDR_ANY)
+ if (active_addr.s_addr == INADDR_ANY)
return;
- dimsg.addr = imsg->addr;
+ dimsg.addr = active_addr;
priv_delete_address(ifi, &dimsg);
}
-/* $OpenBSD: privsep.c,v 1.49 2017/06/24 10:09:26 krw Exp $ */
+/* $OpenBSD: privsep.c,v 1.50 2017/06/24 23:32:57 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
break;
case IMSG_HUP:
- if (imsg.hdr.len != IMSG_HEADER_SIZE +
- sizeof(struct imsg_hup))
+ if (imsg.hdr.len != IMSG_HEADER_SIZE)
log_warnx("bad IMSG_HUP");
else {
imsg_free(&imsg);
-/* $OpenBSD: privsep.h,v 1.37 2017/06/24 10:09:26 krw Exp $ */
+/* $OpenBSD: privsep.h,v 1.38 2017/06/24 23:32:57 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
IMSG_WRITE_RESOLV_CONF
};
-struct imsg_hup {
- struct in_addr addr;
-};
-
struct imsg_delete_address {
struct in_addr addr;
};
void priv_set_interface_mtu(struct interface_info *,
struct imsg_set_interface_mtu *);
-void priv_cleanup(struct interface_info *, struct imsg_hup *);
+void priv_cleanup(struct interface_info *);