summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2019-05-31 01:55:26 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2019-06-05 01:52:46 +0200
commit43e587c1d10175519f16abe0779cc11f7f789c15 (patch)
treee1f3e442e7455d404327a64dfc61ca562b2b9999
parent*: Convert to using frr_vtydir instead of DAEMON_VTY_DIR (diff)
downloadfrr-43e587c1d10175519f16abe0779cc11f7f789c15.tar.xz
frr-43e587c1d10175519f16abe0779cc11f7f789c15.zip
*: Convert over to all -N namespace to change DAEMON_VTY_DIR
When the user specifies -N namespace allow it to influence the frr_vtydir(DAEMON_VTY_DIR) to have namespace in it's path like so: $frrstate_dir/<namespace> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
-rw-r--r--babeld/babel_main.c2
-rwxr-xr-xconfigure.ac2
-rw-r--r--lib/libfrr.c40
-rw-r--r--lib/libfrr.h6
-rw-r--r--vtysh/vtysh_main.c2
-rw-r--r--watchfrr/watchfrr.c2
6 files changed, 38 insertions, 16 deletions
diff --git a/babeld/babel_main.c b/babeld/babel_main.c
index 6e2d4ecea..a3f2b4e7d 100644
--- a/babeld/babel_main.c
+++ b/babeld/babel_main.c
@@ -68,7 +68,7 @@ const unsigned char ones[16] =
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
-static char state_file[512];
+static char state_file[1024];
unsigned char protocol_group[16]; /* babel's link-local multicast address */
int protocol_port; /* babel's port */
diff --git a/configure.ac b/configure.ac
index 631d847b9..e94cb541e 100755
--- a/configure.ac
+++ b/configure.ac
@@ -2205,7 +2205,7 @@ AC_SUBST([frr_statedir])
AC_DEFINE_UNQUOTED([LDPD_SOCKET], ["$frr_statedir%s%s/ldpd.sock"], [ldpd control socket])
AC_DEFINE_UNQUOTED([ZEBRA_SERV_PATH], ["$frr_statedir%s%s/zserv.api"], [zebra api socket])
AC_DEFINE_UNQUOTED([BFDD_CONTROL_SOCKET], ["$frr_statedir%s%s/bfdd.sock"], [bfdd control socket])
-AC_DEFINE_UNQUOTED([DAEMON_VTY_DIR], ["$frr_statedir"], [daemon vty directory])
+AC_DEFINE_UNQUOTED([DAEMON_VTY_DIR], ["$frr_statedir%s%s"], [daemon vty directory])
AC_DEFINE_UNQUOTED([DAEMON_DB_DIR], ["$frr_statedir"], [daemon database directory])
dnl autoconf does this, but it does it too late...
diff --git a/lib/libfrr.c b/lib/libfrr.c
index ae33609d9..ed784fc73 100644
--- a/lib/libfrr.c
+++ b/lib/libfrr.c
@@ -46,7 +46,7 @@ DEFINE_KOOH(frr_early_fini, (), ())
DEFINE_KOOH(frr_fini, (), ())
const char frr_sysconfdir[] = SYSCONFDIR;
-const char frr_vtydir[] = DAEMON_VTY_DIR;
+char frr_vtydir[256];
#ifdef HAVE_SQLITE3
const char frr_dbdir[] = DAEMON_DB_DIR;
#endif
@@ -57,7 +57,7 @@ char frr_protonameinst[256] = "NONE";
char config_default[512];
char frr_zclientpath[256];
-static char pidfile_default[512];
+static char pidfile_default[1024];
#ifdef HAVE_SQLITE3
static char dbfile_default[512];
#endif
@@ -285,6 +285,11 @@ bool frr_zclient_addr(struct sockaddr_storage *sa, socklen_t *sa_len,
static struct frr_daemon_info *di = NULL;
+void frr_init_vtydir(void)
+{
+ snprintf(frr_vtydir, sizeof(frr_vtydir), DAEMON_VTY_DIR, "", "");
+}
+
void frr_preinit(struct frr_daemon_info *daemon, int argc, char **argv)
{
di = daemon;
@@ -307,10 +312,13 @@ void frr_preinit(struct frr_daemon_info *daemon, int argc, char **argv)
if (di->flags & FRR_DETACH_LATER)
nodetach_daemon = true;
+ frr_init_vtydir();
snprintf(config_default, sizeof(config_default), "%s/%s.conf",
frr_sysconfdir, di->name);
snprintf(pidfile_default, sizeof(pidfile_default), "%s/%s.pid",
frr_vtydir, di->name);
+ snprintf(frr_zclientpath, sizeof(frr_zclientpath),
+ ZEBRA_SERV_PATH, "", "");
#ifdef HAVE_SQLITE3
snprintf(dbfile_default, sizeof(dbfile_default), "%s/%s.db",
frr_dbdir, di->name);
@@ -398,6 +406,10 @@ static int frr_opt(int opt)
errors++;
break;
}
+ if (di->zpathspace)
+ fprintf(stderr,
+ "-N option overriden by -z for zebra named socket path\n");
+
if (strchr(optarg, '/') || strchr(optarg, '.')) {
fprintf(stderr,
"slashes or dots are not permitted in the --pathspace option.\n");
@@ -406,8 +418,13 @@ static int frr_opt(int opt)
}
di->pathspace = optarg;
- snprintf(frr_zclientpath, sizeof(frr_zclientpath),
- ZEBRA_SERV_PATH, "/", di->pathspace);
+ if (!di->zpathspace)
+ snprintf(frr_zclientpath, sizeof(frr_zclientpath),
+ ZEBRA_SERV_PATH, "/", di->pathspace);
+ snprintf(frr_vtydir, sizeof(frr_vtydir), DAEMON_VTY_DIR, "/",
+ di->pathspace);
+ snprintf(pidfile_default, sizeof(pidfile_default), "%s/%s.pid",
+ frr_vtydir, di->name);
break;
#ifdef HAVE_SQLITE3
case OPTION_DB_FILE:
@@ -427,6 +444,10 @@ static int frr_opt(int opt)
di->terminal = 1;
break;
case 'z':
+ di->zpathspace = true;
+ if (di->pathspace)
+ fprintf(stderr,
+ "-z option overrides -N option for zebra named socket path\n");
if (di->flags & FRR_NO_ZCLIENT)
return 1;
strlcpy(frr_zclientpath, optarg, sizeof(frr_zclientpath));
@@ -513,9 +534,6 @@ int frr_getopt(int argc, char *const argv[], int *longindex)
int opt;
int lidx;
- snprintf(frr_zclientpath, sizeof(frr_zclientpath),
- ZEBRA_SERV_PATH, "", "");
-
comb_next_lo->name = NULL;
do {
@@ -599,8 +617,8 @@ struct thread_master *frr_init(void)
snprintf(config_default, sizeof(config_default), "%s%s%s%s.conf",
frr_sysconfdir, p_pathspace, di->name, p_instance);
- snprintf(pidfile_default, sizeof(pidfile_default), "%s/%s%s%s.pid",
- frr_vtydir, p_pathspace, di->name, p_instance);
+ snprintf(pidfile_default, sizeof(pidfile_default), "%s/%s%s.pid",
+ frr_vtydir, di->name, p_instance);
#ifdef HAVE_SQLITE3
snprintf(dbfile_default, sizeof(dbfile_default), "%s/%s%s%s.db",
frr_dbdir, p_pathspace, di->name, p_instance);
@@ -884,9 +902,7 @@ static void frr_vty_serv(void)
const char *dir;
char defvtydir[256];
- snprintf(defvtydir, sizeof(defvtydir), "%s%s%s", frr_vtydir,
- di->pathspace ? "/" : "",
- di->pathspace ? di->pathspace : "");
+ snprintf(defvtydir, sizeof(defvtydir), "%s", frr_vtydir);
dir = di->vty_sock_path ? di->vty_sock_path : defvtydir;
diff --git a/lib/libfrr.h b/lib/libfrr.h
index d17495e04..e2b3db74a 100644
--- a/lib/libfrr.h
+++ b/lib/libfrr.h
@@ -81,7 +81,10 @@ struct frr_daemon_info {
#endif
const char *vty_path;
const char *module_path;
+
const char *pathspace;
+ bool zpathspace;
+
const char *early_logging;
const char *early_loglevel;
@@ -120,6 +123,7 @@ struct frr_daemon_info {
.version = FRR_VERSION, ) \
/* end */
+extern void frr_init_vtydir(void);
extern void frr_preinit(struct frr_daemon_info *daemon, int argc, char **argv);
extern void frr_opt_add(const char *optstr, const struct option *longopts,
const char *helpstr);
@@ -150,7 +154,7 @@ extern void frr_fini(void);
extern char config_default[512];
extern char frr_zclientpath[256];
extern const char frr_sysconfdir[];
-extern const char frr_vtydir[];
+extern char frr_vtydir[256];
extern const char frr_moduledir[];
extern char frr_protoname[];
diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c
index 2e4510a45..966746018 100644
--- a/vtysh/vtysh_main.c
+++ b/vtysh/vtysh_main.c
@@ -332,6 +332,8 @@ int main(int argc, char **argv, char **env)
progname = ((p = strrchr(argv[0], '/')) ? ++p : argv[0]);
strlcpy(sysconfdir, frr_sysconfdir, sizeof(sysconfdir));
+
+ frr_init_vtydir();
strlcpy(vtydir, frr_vtydir, sizeof(vtydir));
/* Option handling. */
diff --git a/watchfrr/watchfrr.c b/watchfrr/watchfrr.c
index f0ce88a5b..1cc7722f4 100644
--- a/watchfrr/watchfrr.c
+++ b/watchfrr/watchfrr.c
@@ -648,7 +648,7 @@ static void daemon_send_ready(int exitcode)
{
FILE *fp;
static int sent = 0;
- char started[512];
+ char started[1024];
if (sent)
return;