]> git.puffer.fish Git - mirror/frr.git/commitdiff
*: Modify protocols to have systemd integration
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 10 Feb 2016 13:15:42 +0000 (08:15 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 10 Feb 2016 20:07:05 +0000 (15:07 -0500)
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 <sharpd@cumulusnetworks.com>
babeld/babel_main.c
bgpd/bgp_main.c
isisd/isis_main.c
ospf6d/ospf6_main.c
ospfd/ospf_main.c
ospfd/ospfd.c
ripd/rip_main.c
ripngd/ripng_main.c
zebra/main.c

index ff9d2ad80497ffb49e6bfdcfd18c87f122825e64..21b2513d70110d22934311796a8b3938f1d797c9 100644 (file)
@@ -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);
 }
 
index 8d15b34612eeaaa3025baa4245adb8274d1ef0dc..02dc3110febc0f6d9556eeddb58570eaba7fe7e9 100644 (file)
@@ -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);
 
index e28846bf6fb64845eaaac8baf97e64f9c2bbd1de..55bc2a734485990035c45ebca17642d9485cba83 100644 (file)
@@ -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);
 
index af48d1fe4cfeb98d60cc178763eac9ca1d5898d3..4eb22c15a3312f35c15da32fbee24fac582067b5 100644 (file)
@@ -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;
index 4e67b20bbade75d47b5f2df708af608be4dc97bc..f86f834b4fa72f1d5b94f36b2a221103d2ed7cfc 100644 (file)
@@ -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. */
index 5957918c9cb678ce7f91393d595c876cd1a79189..8fbecee0507261a2942d2afd3dfd2cf55532087c 100644 (file)
@@ -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);
index a5ea36a1f1b70c5112f17425b13d2a7387a31f55..6cd23c830094246c6233d185d54e9624f4d2dcb1 100644 (file)
@@ -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);
 
index c05da0c9ef84c4dbb8d2a07cb084a9d97795f0d9..6fb0d00abde063b33a5f4c7c2022b08e0567c3e7 100644 (file)
@@ -35,6 +35,7 @@
 #include "privs.h"
 #include "sigevent.h"
 #include "vrf.h"
+#include "systemd.h"
 
 #include "ripngd/ripngd.h"
 
index ad7a020e62f46f010dd8f76d4fe78a33c64d172b..0666de97846f01e60ce31b6858c9a7461663d28a 100644 (file)
@@ -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.