summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2018-07-11 19:05:26 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2018-07-11 19:05:26 +0000
commit03059594d64f77ef3546db846da55bd7451921ca (patch)
tree626a0faf09af613f7c3251030c4d07c42f40a35b /usr.sbin
parent84ebbe0014e68b30d0c0f23289dead83907ebdc7 (diff)
cleanly shutdown by sending advertisement with lifetime 0
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/rad/engine.c5
-rw-r--r--usr.sbin/rad/frontend.c8
-rw-r--r--usr.sbin/rad/rad.c12
-rw-r--r--usr.sbin/rad/rad.h3
4 files changed, 23 insertions, 5 deletions
diff --git a/usr.sbin/rad/engine.c b/usr.sbin/rad/engine.c
index 4f568e37ee7..9ecb93da44b 100644
--- a/usr.sbin/rad/engine.c
+++ b/usr.sbin/rad/engine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: engine.c,v 1.5 2018/07/11 17:32:05 florian Exp $ */
+/* $OpenBSD: engine.c,v 1.6 2018/07/11 19:05:25 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -239,6 +239,9 @@ engine_dispatch_frontend(int fd, short event, void *bula)
memcpy(&verbose, imsg.data, sizeof(verbose));
log_setverbose(verbose);
break;
+ case IMSG_SHUTDOWN:
+ engine_imsg_compose_frontend(IMSG_SHUTDOWN, 0, NULL, 0);
+ break;
default:
log_debug("%s: unexpected imsg %d", __func__,
imsg.hdr.type);
diff --git a/usr.sbin/rad/frontend.c b/usr.sbin/rad/frontend.c
index e3bc5376b7f..536822bd439 100644
--- a/usr.sbin/rad/frontend.c
+++ b/usr.sbin/rad/frontend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frontend.c,v 1.4 2018/07/11 17:32:05 florian Exp $ */
+/* $OpenBSD: frontend.c,v 1.5 2018/07/11 19:05:25 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -411,6 +411,9 @@ frontend_dispatch_main(int fd, short event, void *bula)
fatal("pledge");
frontend_startup();
break;
+ case IMSG_SHUTDOWN:
+ frontend_imsg_compose_engine(IMSG_SHUTDOWN, 0, NULL, 0);
+ break;
default:
log_debug("%s: error handling imsg %d", __func__,
imsg.hdr.type);
@@ -478,6 +481,9 @@ frontend_dispatch_engine(int fd, short event, void *bula)
free_ra_iface(ra_iface);
}
break;
+ case IMSG_SHUTDOWN:
+ frontend_imsg_compose_main(IMSG_SHUTDOWN, 0, NULL, 0);
+ break;
default:
log_debug("%s: error handling imsg %d", __func__,
imsg.hdr.type);
diff --git a/usr.sbin/rad/rad.c b/usr.sbin/rad/rad.c
index 2339050b71c..96aa5532989 100644
--- a/usr.sbin/rad/rad.c
+++ b/usr.sbin/rad/rad.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rad.c,v 1.3 2018/07/11 14:01:44 florian Exp $ */
+/* $OpenBSD: rad.c,v 1.4 2018/07/11 19:05:25 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -83,6 +83,8 @@ uint32_t cmd_opts;
void
main_sig_handler(int sig, short event, void *arg)
{
+ struct rad_conf empty_conf;
+
/*
* Normal signal handler rules don't apply because libevent
* decouples for us.
@@ -91,7 +93,10 @@ main_sig_handler(int sig, short event, void *arg)
switch (sig) {
case SIGTERM:
case SIGINT:
- main_shutdown();
+ memset(&empty_conf, 0, sizeof(empty_conf));
+ (void)main_imsg_send_config(&empty_conf);
+ (void)main_imsg_compose_frontend(IMSG_SHUTDOWN, 0, NULL, 0);
+ break;
case SIGHUP:
if (main_reload() == -1)
log_warnx("configuration reload failed");
@@ -414,6 +419,9 @@ main_dispatch_frontend(int fd, short event, void *bula)
memcpy(&verbose, imsg.data, sizeof(verbose));
log_setverbose(verbose);
break;
+ case IMSG_SHUTDOWN:
+ shut = 1;
+ break;
default:
log_debug("%s: error handling imsg %d", __func__,
imsg.hdr.type);
diff --git a/usr.sbin/rad/rad.h b/usr.sbin/rad/rad.h
index ee9b32dc86a..cb1d8c8aa71 100644
--- a/usr.sbin/rad/rad.h
+++ b/usr.sbin/rad/rad.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rad.h,v 1.5 2018/07/11 17:32:05 florian Exp $ */
+/* $OpenBSD: rad.h,v 1.6 2018/07/11 19:05:25 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -63,6 +63,7 @@ enum imsg_type {
IMSG_SEND_RA,
IMSG_UPDATE_IF,
IMSG_REMOVE_IF,
+ IMSG_SHUTDOWN,
IMSG_SOCKET_IPC
};