summaryrefslogtreecommitdiff
path: root/usr.sbin/ospfd/ospfd.c
diff options
context:
space:
mode:
authorremi <remi@cvs.openbsd.org>2018-08-29 08:43:18 +0000
committerremi <remi@cvs.openbsd.org>2018-08-29 08:43:18 +0000
commit86b5e77220f6d28cc9f30875ad27bfd1b14b329e (patch)
treeeebaa0f6db13d91e4b3c46a2bad33868eb2eef13 /usr.sbin/ospfd/ospfd.c
parent12500a136200ea749fcd410f3deb512a51b3941e (diff)
Prevent ospfd from starting if another ospfd is already using the same
socket. The check on the control socket happens early so that the rc scripts detect a failure. OK claudio@ florian@
Diffstat (limited to 'usr.sbin/ospfd/ospfd.c')
-rw-r--r--usr.sbin/ospfd/ospfd.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/usr.sbin/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c
index 378bc2bfbb0..df80b65733e 100644
--- a/usr.sbin/ospfd/ospfd.c
+++ b/usr.sbin/ospfd/ospfd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.c,v 1.99 2018/07/11 12:09:34 remi Exp $ */
+/* $OpenBSD: ospfd.c,v 1.100 2018/08/29 08:43:17 remi Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -116,6 +116,7 @@ main(int argc, char *argv[])
int mib[4];
size_t len;
char *sockname = NULL;
+ int control_fd;
conffile = CONF_FILE;
ospfd_process = PROC_MAIN;
@@ -213,6 +214,9 @@ main(int argc, char *argv[])
log_init(debug, LOG_DAEMON);
log_setverbose(ospfd_conf->opts & OSPFD_OPT_VERBOSE);
+ if ((control_check(ospfd_conf->csock)) == -1)
+ fatalx("control socket check failed");
+
if (!debug)
daemon(1, 0);
@@ -270,6 +274,10 @@ main(int argc, char *argv[])
iev_rde->handler, iev_rde);
event_add(&iev_rde->ev, NULL);
+ if ((control_fd = control_init(ospfd_conf->csock)) == -1)
+ fatalx("control socket setup failed");
+ main_imsg_compose_ospfe_fd(IMSG_CONTROLFD, 0, control_fd);
+
if (kr_init(!(ospfd_conf->flags & OSPFD_FLAG_NO_FIB_UPDATE),
ospfd_conf->rdomain, ospfd_conf->redist_label_or_prefix) == -1)
fatalx("kr_init failed");
@@ -486,6 +494,13 @@ main_imsg_compose_ospfe(int type, pid_t pid, void *data, u_int16_t datalen)
}
void
+main_imsg_compose_ospfe_fd(int type, pid_t pid, int fd)
+{
+ if (iev_ospfe)
+ imsg_compose_event(iev_ospfe, type, 0, pid, fd, NULL, 0);
+}
+
+void
main_imsg_compose_rde(int type, pid_t pid, void *data, u_int16_t datalen)
{
if (iev_rde)