summaryrefslogtreecommitdiff
path: root/usr.sbin/eigrpd
diff options
context:
space:
mode:
authorRenato Westphal <renato@cvs.openbsd.org>2016-09-02 16:23:51 +0000
committerRenato Westphal <renato@cvs.openbsd.org>2016-09-02 16:23:51 +0000
commit156601b8486994bb37a07fc8a95f7ecae4eb7d42 (patch)
tree8288541c8ac05d63559b142167025c58dac7f46f /usr.sbin/eigrpd
parent668559c106c6c3e1be9e4e2add61f463108adef0 (diff)
Fix broken pipe teardown.
* Add missing close() calls to actually close the pipes, calling just msgbuf_clean() is not enough; * Bring back some NOTREACHED lint comments. style(9) says they can be removed but in some cases they are useful to humans too; * Add __dead to the shutdown functions; * Some other minor changes to make eigrpd(8) more similar to the other routing daemons.
Diffstat (limited to 'usr.sbin/eigrpd')
-rw-r--r--usr.sbin/eigrpd/eigrpd.c18
-rw-r--r--usr.sbin/eigrpd/eigrpe.c19
-rw-r--r--usr.sbin/eigrpd/rde.c14
3 files changed, 32 insertions, 19 deletions
diff --git a/usr.sbin/eigrpd/eigrpd.c b/usr.sbin/eigrpd/eigrpd.c
index 8fe08c35cdc..e129fdd3676 100644
--- a/usr.sbin/eigrpd/eigrpd.c
+++ b/usr.sbin/eigrpd/eigrpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eigrpd.c,v 1.17 2016/08/08 21:38:42 renato Exp $ */
+/* $OpenBSD: eigrpd.c,v 1.18 2016/09/02 16:23:50 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -69,6 +69,7 @@ main_sig_handler(int sig, short event, void *arg)
case SIGTERM:
case SIGINT:
eigrpd_shutdown();
+ /* NOTREACHED */
case SIGHUP:
if (eigrp_reload() == -1)
log_warnx("configuration reload failed");
@@ -272,6 +273,8 @@ main(int argc, char *argv[])
event_dispatch();
eigrpd_shutdown();
+ /* NOTREACHED */
+ return (0);
}
__dead void
@@ -280,16 +283,16 @@ eigrpd_shutdown(void)
pid_t pid;
int status;
+ /* close pipes */
msgbuf_clear(&iev_eigrpe->ibuf.w);
- free(iev_eigrpe);
- iev_eigrpe = NULL;
+ close(iev_eigrpe->ibuf.fd);
msgbuf_clear(&iev_rde->ibuf.w);
- free(iev_rde);
- iev_rde = NULL;
+ close(iev_rde->ibuf.fd);
- config_clear(eigrpd_conf);
kr_shutdown();
+ config_clear(eigrpd_conf);
+ log_debug("waiting for children to terminate");
do {
pid = wait(&status);
if (pid == -1) {
@@ -301,6 +304,9 @@ eigrpd_shutdown(void)
"eigrp engine", WTERMSIG(status));
} while (pid != -1 || (pid == -1 && errno == EINTR));
+ free(iev_eigrpe);
+ free(iev_rde);
+
log_info("terminating");
exit(0);
}
diff --git a/usr.sbin/eigrpd/eigrpe.c b/usr.sbin/eigrpd/eigrpe.c
index 56b290884b1..e76361c218c 100644
--- a/usr.sbin/eigrpd/eigrpe.c
+++ b/usr.sbin/eigrpd/eigrpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eigrpe.c,v 1.25 2016/08/08 16:48:53 renato Exp $ */
+/* $OpenBSD: eigrpe.c,v 1.26 2016/09/02 16:23:50 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -36,7 +36,7 @@
#include "log.h"
void eigrpe_sig_handler(int, short, void *);
-void eigrpe_shutdown(void);
+__dead void eigrpe_shutdown(void);
static struct event ev4;
static struct event ev6;
@@ -173,11 +173,18 @@ eigrpe(int debug, int verbose, char *sockname)
return (0);
}
-void
+__dead void
eigrpe_shutdown(void)
{
- control_cleanup(global.csock);
+ /* close pipes */
+ msgbuf_write(&iev_rde->ibuf.w);
+ msgbuf_clear(&iev_rde->ibuf.w);
+ close(iev_rde->ibuf.fd);
+ msgbuf_write(&iev_main->ibuf.w);
+ msgbuf_clear(&iev_main->ibuf.w);
+ close(iev_main->ibuf.fd);
+ control_cleanup(global.csock);
config_clear(econf);
event_del(&ev4);
@@ -186,11 +193,7 @@ eigrpe_shutdown(void)
close(global.eigrp_socket_v6);
/* clean up */
- msgbuf_write(&iev_rde->ibuf.w);
- msgbuf_clear(&iev_rde->ibuf.w);
free(iev_rde);
- msgbuf_write(&iev_main->ibuf.w);
- msgbuf_clear(&iev_main->ibuf.w);
free(iev_main);
free(pkt_ptr);
diff --git a/usr.sbin/eigrpd/rde.c b/usr.sbin/eigrpd/rde.c
index bb9d32b9631..5390d9f565c 100644
--- a/usr.sbin/eigrpd/rde.c
+++ b/usr.sbin/eigrpd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.18 2016/08/08 16:48:53 renato Exp $ */
+/* $OpenBSD: rde.c,v 1.19 2016/09/02 16:23:50 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -34,7 +34,7 @@
#include "rde.h"
void rde_sig_handler(int sig, short, void *);
-void rde_shutdown(void);
+__dead void rde_shutdown(void);
void rde_dispatch_imsg(int, short, void *);
void rde_dispatch_parent(int, short, void *);
@@ -131,14 +131,18 @@ rde(int debug, int verbose)
return (0);
}
-void
+__dead void
rde_shutdown(void)
{
+ /* close pipes */
+ msgbuf_clear(&iev_eigrpe->ibuf.w);
+ close(iev_eigrpe->ibuf.fd);
+ msgbuf_clear(&iev_main->ibuf.w);
+ close(iev_main->ibuf.fd);
+
config_clear(rdeconf);
- msgbuf_clear(&iev_eigrpe->ibuf.w);
free(iev_eigrpe);
- msgbuf_clear(&iev_main->ibuf.w);
free(iev_main);
log_info("route decision engine exiting");