cleanly shutdown by sending advertisement with lifetime 0
authorflorian <florian@openbsd.org>
Wed, 11 Jul 2018 19:05:25 +0000 (19:05 +0000)
committerflorian <florian@openbsd.org>
Wed, 11 Jul 2018 19:05:25 +0000 (19:05 +0000)
usr.sbin/rad/engine.c
usr.sbin/rad/frontend.c
usr.sbin/rad/rad.c
usr.sbin/rad/rad.h

index 4f568e3..9ecb93d 100644 (file)
@@ -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);
index e3bc537..536822b 100644 (file)
@@ -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);
index 2339050..96aa553 100644 (file)
@@ -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);
index ee9b32d..cb1d8c8 100644 (file)
@@ -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
 };