summaryrefslogtreecommitdiff
path: root/usr.sbin/ospfd
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2009-04-07 14:57:34 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2009-04-07 14:57:34 +0000
commit4414bfbcccd0f412374a68c641a98627511adfb9 (patch)
tree526648596a17d2482219d2be34df7f0b6652efd9 /usr.sbin/ospfd
parentf8354bc65dd07aa49ae2f37a946696e83a1d82ef (diff)
allow to specify an alternate control socket instead of /var/run/ospfd.sock.
this is required to run multiple instances of ospfd. ok claudio@
Diffstat (limited to 'usr.sbin/ospfd')
-rw-r--r--usr.sbin/ospfd/control.c22
-rw-r--r--usr.sbin/ospfd/control.h6
-rw-r--r--usr.sbin/ospfd/ospfd.87
-rw-r--r--usr.sbin/ospfd/ospfd.c15
-rw-r--r--usr.sbin/ospfd/ospfd.h3
-rw-r--r--usr.sbin/ospfd/ospfe.c4
6 files changed, 34 insertions, 23 deletions
diff --git a/usr.sbin/ospfd/control.c b/usr.sbin/ospfd/control.c
index f3e0d1665e1..d4269f8d518 100644
--- a/usr.sbin/ospfd/control.c
+++ b/usr.sbin/ospfd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.22 2009/02/25 17:09:55 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.23 2009/04/07 14:57:33 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -41,7 +41,7 @@ struct ctl_conn *control_connbypid(pid_t);
void control_close(int);
int
-control_init(void)
+control_init(char *path)
{
struct sockaddr_un sun;
int fd;
@@ -54,28 +54,28 @@ control_init(void)
bzero(&sun, sizeof(sun));
sun.sun_family = AF_UNIX;
- strlcpy(sun.sun_path, OSPFD_SOCKET, sizeof(sun.sun_path));
+ strlcpy(sun.sun_path, path, sizeof(sun.sun_path));
- if (unlink(OSPFD_SOCKET) == -1)
+ if (unlink(path) == -1)
if (errno != ENOENT) {
- log_warn("control_init: unlink %s", OSPFD_SOCKET);
+ log_warn("control_init: unlink %s", path);
close(fd);
return (-1);
}
old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH);
if (bind(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) {
- log_warn("control_init: bind: %s", OSPFD_SOCKET);
+ log_warn("control_init: bind: %s", path);
close(fd);
umask(old_umask);
return (-1);
}
umask(old_umask);
- if (chmod(OSPFD_SOCKET, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) == -1) {
+ if (chmod(path, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) == -1) {
log_warn("control_init: chmod");
close(fd);
- (void)unlink(OSPFD_SOCKET);
+ (void)unlink(path);
return (-1);
}
@@ -102,10 +102,10 @@ control_listen(void)
}
void
-control_cleanup(void)
+control_cleanup(char *path)
{
-
- unlink(OSPFD_SOCKET);
+ if (path)
+ unlink(path);
}
/* ARGSUSED */
diff --git a/usr.sbin/ospfd/control.h b/usr.sbin/ospfd/control.h
index 91816e2ecf5..732005f6dd4 100644
--- a/usr.sbin/ospfd/control.h
+++ b/usr.sbin/ospfd/control.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.h,v 1.2 2005/05/25 13:41:43 claudio Exp $ */
+/* $OpenBSD: control.h,v 1.3 2009/04/07 14:57:33 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -38,12 +38,12 @@ struct ctl_conn {
struct imsgbuf ibuf;
};
-int control_init(void);
+int control_init(char *);
int control_listen(void);
void control_accept(int, short, void *);
void control_dispatch_imsg(int, short, void *);
int control_imsg_relay(struct imsg *);
-void control_cleanup(void);
+void control_cleanup(char *);
void session_socket_blockmode(int, enum blockmodes);
diff --git a/usr.sbin/ospfd/ospfd.8 b/usr.sbin/ospfd/ospfd.8
index 7bde9c44d7e..c41eaffca5f 100644
--- a/usr.sbin/ospfd/ospfd.8
+++ b/usr.sbin/ospfd/ospfd.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ospfd.8,v 1.22 2009/01/31 19:37:12 sobrado Exp $
+.\" $OpenBSD: ospfd.8,v 1.23 2009/04/07 14:57:33 reyk Exp $
.\"
.\" Copyright (c) 2004, 2005, 2007 Esben Norby <norby@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: January 31 2009 $
+.Dd $Mdocdate: April 7 2009 $
.Dt OSPFD 8
.Os
.Sh NAME
@@ -27,6 +27,7 @@
.Fl D Ar macro Ns = Ns Ar value Oc
.Xc
.Op Fl f Ar file
+.Op Fl s Ar socket
.Sh DESCRIPTION
.Nm
is an Open Shortest Path First
@@ -143,6 +144,8 @@ Specify an alternative configuration file.
.It Fl n
Configtest mode.
Only check the configuration file for validity.
+.It Fl s Ar socket
+Use an alternate location for the default control socket.
.It Fl v
Produce more verbose output.
.El
diff --git a/usr.sbin/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c
index 6cbd094358a..f11e4b3a0b7 100644
--- a/usr.sbin/ospfd/ospfd.c
+++ b/usr.sbin/ospfd/ospfd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.c,v 1.63 2009/03/27 14:37:26 michele Exp $ */
+/* $OpenBSD: ospfd.c,v 1.64 2009/04/07 14:57:33 reyk Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -116,7 +116,8 @@ usage(void)
{
extern char *__progname;
- fprintf(stderr, "usage: %s [-cdnv] [-D macro=value] [-f file]\n",
+ fprintf(stderr, "usage: %s [-cdnv] [-D macro=value]"
+ " [-f file] [-s socket]\n",
__progname);
exit(1);
}
@@ -131,13 +132,15 @@ main(int argc, char *argv[])
int ipforwarding;
int mib[4];
size_t len;
+ char *sockname;
conffile = CONF_FILE;
ospfd_process = PROC_MAIN;
+ sockname = OSPFD_SOCKET;
log_init(1); /* log to stderr until daemonized */
- while ((ch = getopt(argc, argv, "cdD:f:nv")) != -1) {
+ while ((ch = getopt(argc, argv, "cdD:f:ns:v")) != -1) {
switch (ch) {
case 'c':
opts |= OSPFD_OPT_FORCE_DEMOTE;
@@ -156,6 +159,9 @@ main(int argc, char *argv[])
case 'n':
opts |= OSPFD_OPT_NOACTION;
break;
+ case 's':
+ sockname = optarg;
+ break;
case 'v':
if (opts & OSPFD_OPT_VERBOSE)
opts |= OSPFD_OPT_VERBOSE2;
@@ -196,6 +202,7 @@ main(int argc, char *argv[])
kr_shutdown();
exit(1);
}
+ ospfd_conf->csock = sockname;
if (ospfd_conf->opts & OSPFD_OPT_NOACTION) {
if (ospfd_conf->opts & OSPFD_OPT_VERBOSE)
@@ -307,7 +314,7 @@ ospfd_shutdown(void)
if (rde_pid)
kill(rde_pid, SIGTERM);
- control_cleanup();
+ control_cleanup(ospfd_conf->csock);
kr_shutdown();
carp_demote_shutdown();
diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h
index 397c94a76b0..f8b98780055 100644
--- a/usr.sbin/ospfd/ospfd.h
+++ b/usr.sbin/ospfd/ospfd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.h,v 1.76 2009/03/04 12:51:01 claudio Exp $ */
+/* $OpenBSD: ospfd.h,v 1.77 2009/04/07 14:57:33 reyk Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -408,6 +408,7 @@ struct ospfd_conf {
u_int8_t rfc1583compat;
u_int8_t border;
u_int8_t redistribute;
+ char *csock;
};
/* kroute */
diff --git a/usr.sbin/ospfd/ospfe.c b/usr.sbin/ospfd/ospfe.c
index 80e37e6ba42..26af67020ba 100644
--- a/usr.sbin/ospfd/ospfe.c
+++ b/usr.sbin/ospfd/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.63 2009/03/04 12:51:01 claudio Exp $ */
+/* $OpenBSD: ospfe.c,v 1.64 2009/04/07 14:57:33 reyk Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -89,7 +89,7 @@ ospfe(struct ospfd_conf *xconf, int pipe_parent2ospfe[2], int pipe_ospfe2rde[2],
}
/* create ospfd control socket outside chroot */
- if (control_init() == -1)
+ if (control_init(xconf->csock) == -1)
fatalx("control socket setup failed");
/* create the raw ip socket */