diff options
-rw-r--r-- | usr.sbin/ospfctl/ospfctl.8 | 16 | ||||
-rw-r--r-- | usr.sbin/ospfctl/ospfctl.c | 28 | ||||
-rw-r--r-- | usr.sbin/ospfd/control.c | 22 | ||||
-rw-r--r-- | usr.sbin/ospfd/control.h | 6 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfd.8 | 7 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfd.c | 15 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfd.h | 3 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfe.c | 4 |
8 files changed, 71 insertions, 30 deletions
diff --git a/usr.sbin/ospfctl/ospfctl.8 b/usr.sbin/ospfctl/ospfctl.8 index 8bc7c2ed269..18a64881602 100644 --- a/usr.sbin/ospfctl/ospfctl.8 +++ b/usr.sbin/ospfctl/ospfctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ospfctl.8,v 1.18 2008/12/06 13:18:12 sobrado Exp $ +.\" $OpenBSD: ospfctl.8,v 1.19 2009/04/07 14:57:33 reyk Exp $ .\" .\" Copyright (c) 2004, 2005 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: December 6 2008 $ +.Dd $Mdocdate: April 7 2009 $ .Dt OSPFCTL 8 .Os .Sh NAME @@ -22,6 +22,7 @@ .Nd control the Open Shortest Path First daemon .Sh SYNOPSIS .Nm +.Op Fl s Ar socket .Ar command .Op Ar argument ... .Sh DESCRIPTION @@ -31,6 +32,17 @@ program controls the .Xr ospfd 8 daemon. .Pp +The following option is available: +.Bl -tag -width Ds +.It Fl s Ar socket +Use +.Ar socket +instead of the default +.Pa /var/run/ospfd.sock +to communicate with +.Xr ospfd 8 . +.El +.Pp The following commands are available: .Bl -tag -width Ds .It Cm fib couple diff --git a/usr.sbin/ospfctl/ospfctl.c b/usr.sbin/ospfctl/ospfctl.c index 53a8bf870bd..dbfdbb386f8 100644 --- a/usr.sbin/ospfctl/ospfctl.c +++ b/usr.sbin/ospfctl/ospfctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfctl.c,v 1.45 2009/01/30 12:43:18 norby Exp $ */ +/* $OpenBSD: ospfctl.c,v 1.46 2009/04/07 14:57:33 reyk Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -76,7 +76,8 @@ usage(void) { extern char *__progname; - fprintf(stderr, "usage: %s command [argument ...]\n", __progname); + fprintf(stderr, "usage: %s [-s socket] command [argument ...]\n", + __progname); exit(1); } @@ -97,9 +98,25 @@ main(int argc, char *argv[]) int ctl_sock; int done = 0; int n; + int ch; + char *sockname; + + sockname = OSPFD_SOCKET; + while ((ch = getopt(argc, argv, "s:")) != -1) { + switch (ch) { + case 's': + sockname = optarg; + break; + default: + usage(); + /* NOTREACHED */ + } + } + argc -= optind; + argv += optind; /* parse options */ - if ((res = parse(argc - 1, argv + 1)) == NULL) + if ((res = parse(argc, argv)) == NULL) exit(1); /* connect to ospfd control socket */ @@ -108,9 +125,10 @@ main(int argc, char *argv[]) bzero(&sun, sizeof(sun)); sun.sun_family = AF_UNIX; - strlcpy(sun.sun_path, OSPFD_SOCKET, sizeof(sun.sun_path)); + + strlcpy(sun.sun_path, sockname, sizeof(sun.sun_path)); if (connect(ctl_sock, (struct sockaddr *)&sun, sizeof(sun)) == -1) - err(1, "connect: %s", OSPFD_SOCKET); + err(1, "connect: %s", sockname); if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); 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 */ |