From 66dd6fdbdd6fbe578314c5e2760086b0b7645e44 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 10 Feb 2016 08:15:42 -0500 Subject: [PATCH] *: Modify protocols to have systemd integration Modify the daemons to integrate with systemd, if it is enabled via configure, and to notify systemd that they are running/stopping and to send watch notifications. Signed-off-by: Donald Sharp --- babeld/babel_main.c | 4 ++++ bgpd/bgp_main.c | 3 +++ isisd/isis_main.c | 4 ++++ ospf6d/ospf6_main.c | 4 ++++ ospfd/ospf_main.c | 3 +++ ospfd/ospfd.c | 7 ++++++- ripd/rip_main.c | 4 ++++ ripngd/ripng_main.c | 1 + zebra/main.c | 4 ++++ 9 files changed, 33 insertions(+), 1 deletion(-) diff --git a/babeld/babel_main.c b/babeld/babel_main.c index ff9d2ad804..21b2513d70 100644 --- a/babeld/babel_main.c +++ b/babeld/babel_main.c @@ -49,6 +49,7 @@ THE SOFTWARE. #include "command.h" #include "vty.h" #include "memory.h" +#include "systemd.h" #include "babel_main.h" #include "babeld.h" @@ -271,6 +272,7 @@ babel_init(int argc, char **argv) exit (1); }; + systemd_send_started (master); /* init some quagga's dependencies, and babeld's commands */ babeld_quagga_init(); /* init zebra client's structure and it's commands */ @@ -304,6 +306,7 @@ babel_get_progname(char *argv_0) { static void babel_fail(void) { + systemd_send_stopping (); exit(1); } @@ -462,6 +465,7 @@ babel_exit_properly(void) unlink(pidfile); debugf(BABEL_DEBUG_COMMON, "Done."); + systemd_send_stopping (); exit(0); } diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index 8d15b34612..02dc3110fe 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -38,6 +38,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "stream.h" #include "queue.h" #include "vrf.h" +#include "systemd.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_attr.h" @@ -297,6 +298,7 @@ bgp_exit (int status) if (zlog_default) closezlog (zlog_default); + systemd_send_stopping (); exit (status); } @@ -433,6 +435,7 @@ main (int argc, char **argv) /* Process ID file creation. */ pid_output (pid_file); + systemd_send_started (bm->master); /* Make bgp vty socket. */ vty_serv_sock (vty_addr, vty_port, BGP_VTYSH_PATH); diff --git a/isisd/isis_main.c b/isisd/isis_main.c index e28846bf6f..55bc2a7344 100644 --- a/isisd/isis_main.c +++ b/isisd/isis_main.c @@ -36,6 +36,7 @@ #include "filter.h" #include "zclient.h" #include "vrf.h" +#include "systemd.h" #include "isisd/dict.h" #include "include-netbsd/iso.h" @@ -167,6 +168,7 @@ reload () static __attribute__((__noreturn__)) void terminate (int i) { + systemd_send_stopping (); exit (i); } @@ -365,6 +367,8 @@ main (int argc, char **argv, char **envp) if (pid_file[0] != '\0') pid_output (pid_file); + systemd_send_started (master); + /* Make isis vty socket. */ vty_serv_sock (vty_addr, vty_port, ISIS_VTYSH_PATH); diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index af48d1fe4c..4eb22c15a3 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -37,6 +37,7 @@ #include "sigevent.h" #include "zclient.h" #include "vrf.h" +#include "systemd.h" #include "ospf6d.h" #include "ospf6_top.h" @@ -165,6 +166,7 @@ ospf6_exit (int status) if (zlog_default) closezlog (zlog_default); + systemd_send_stopping (); exit (status); } @@ -346,6 +348,8 @@ main (int argc, char *argv[], char *envp[]) /* pid file create */ pid_output (pid_file); + systemd_send_started (master); + /* Make ospf6 vty socket. */ if (!vty_port) vty_port = OSPF6_VTY_PORT; diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index 4e67b20bba..f86f834b4f 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -40,6 +40,7 @@ #include "sigevent.h" #include "zclient.h" #include "vrf.h" +#include "systemd.h" #include "ospfd/ospfd.h" #include "ospfd/ospf_interface.h" @@ -366,6 +367,8 @@ main (int argc, char **argv) } /* Process id file create. */ pid_output (pid_file); + + systemd_send_started (master); vty_serv_sock (vty_addr, vty_port, vty_path); /* Print banner. */ diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index 5957918c9c..8fbecee050 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -34,6 +34,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "zclient.h" #include "plist.h" #include "sockopt.h" +#include "systemd.h" #include "ospfd/ospfd.h" #include "ospfd/ospf_network.h" @@ -395,7 +396,10 @@ ospf_deferred_shutdown_finish (struct ospf *ospf) /* ospfd being shut-down? If so, was this the last ospf instance? */ if (CHECK_FLAG (om->options, OSPF_MASTER_SHUTDOWN) && (listcount (om->ospf) == 0)) - exit (0); + { + systemd_send_stopping (); + exit (0); + } return; } @@ -462,6 +466,7 @@ ospf_terminate (void) SET_FLAG (om->options, OSPF_MASTER_SHUTDOWN); + systemd_send_stopping (); /* exit immediately if OSPF not actually running */ if (listcount(om->ospf) == 0) exit(0); diff --git a/ripd/rip_main.c b/ripd/rip_main.c index a5ea36a1f1..6cd23c8300 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -34,6 +34,7 @@ #include "sigevent.h" #include "zclient.h" #include "vrf.h" +#include "systemd.h" #include "ripd/ripd.h" @@ -155,6 +156,7 @@ sigint (void) if (! retain_mode) rip_clean (); + systemd_send_stopping (); exit (0); } @@ -303,6 +305,8 @@ main (int argc, char **argv) exit (1); } + systemd_send_started (master); + /* Pid file create. */ pid_output (pid_file); diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c index c05da0c9ef..6fb0d00abd 100644 --- a/ripngd/ripng_main.c +++ b/ripngd/ripng_main.c @@ -35,6 +35,7 @@ #include "privs.h" #include "sigevent.h" #include "vrf.h" +#include "systemd.h" #include "ripngd/ripngd.h" diff --git a/zebra/main.c b/zebra/main.c index ad7a020e62..0666de9784 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -33,6 +33,7 @@ #include "privs.h" #include "sigevent.h" #include "vrf.h" +#include "systemd.h" #include "zebra/rib.h" #include "zebra/zserv.h" @@ -184,6 +185,7 @@ sigint (void) #endif zebra_ptm_finish(); + systemd_send_stopping(); exit (0); } @@ -513,12 +515,14 @@ main (int argc, char **argv) if (daemon_mode && daemon (0, 0) < 0) { zlog_err("Zebra daemon failed: %s", strerror(errno)); + systemd_send_stopping (); exit (1); } /* Output pid of zebra. */ pid_output (pid_file); + systemd_send_started (zebrad.master); /* After we have successfully acquired the pidfile, we can be sure * about being the only copy of zebra process, which is submitting * changes to the FIB. -- 2.39.5