Change the control socket to ospfd.sock.<rdomain>.
authorremi <remi@openbsd.org>
Wed, 11 Jul 2018 12:09:34 +0000 (12:09 +0000)
committerremi <remi@openbsd.org>
Wed, 11 Jul 2018 12:09:34 +0000 (12:09 +0000)
ok friehm@ jca@

usr.sbin/ospfctl/ospfctl.c
usr.sbin/ospfd/ospfd.c

index 4d0f051..9ee92aa 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ospfctl.c,v 1.64 2016/12/05 22:39:25 jca Exp $ */
+/*     $OpenBSD: ospfctl.c,v 1.65 2018/07/11 12:09:34 remi Exp $ */
 
 /*
  * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -89,13 +89,16 @@ main(int argc, char *argv[])
        struct parse_result     *res;
        struct imsg              imsg;
        unsigned int             ifidx = 0;
-       int                      ctl_sock;
+       int                      ctl_sock, r;
        int                      done = 0;
        int                      n, verbose = 0;
        int                      ch;
        char                    *sockname;
 
-       sockname = OSPFD_SOCKET;
+       r = getrtable();
+       if (asprintf(&sockname, "%s.%d", OSPFD_SOCKET, r) == -1)
+               err(1, "asprintf");
+
        while ((ch = getopt(argc, argv, "s:")) != -1) {
                switch (ch) {
                case 's':
index b3a9172..378bc2b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ospfd.c,v 1.98 2018/07/09 13:19:46 remi Exp $ */
+/*     $OpenBSD: ospfd.c,v 1.99 2018/07/11 12:09:34 remi Exp $ */
 
 /*
  * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -115,11 +115,10 @@ main(int argc, char *argv[])
        int                      ipforwarding;
        int                      mib[4];
        size_t                   len;
-       char                    *sockname;
+       char                    *sockname = NULL;
 
        conffile = CONF_FILE;
        ospfd_process = PROC_MAIN;
-       sockname = OSPFD_SOCKET;
 
        log_init(1, LOG_DAEMON);        /* log to stderr until daemonized */
        log_procinit(log_procnames[ospfd_process]);
@@ -185,6 +184,13 @@ main(int argc, char *argv[])
                kif_clear();
                exit(1);
        }
+
+       if (sockname == NULL) {
+               if (asprintf(&sockname, "%s.%d", OSPFD_SOCKET,
+                   ospfd_conf->rdomain) == -1)
+                       err(1, "asprintf");
+       }
+
        ospfd_conf->csock = sockname;
 
        if (ospfd_conf->opts & OSPFD_OPT_NOACTION) {