]> git.puffer.fish Git - matthieu/frr.git/commitdiff
watchfrr: Allow an integrated config to work within a namespace
authorDonald Sharp <sharpd@nvidia.com>
Tue, 5 Oct 2021 00:32:25 +0000 (20:32 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Wed, 6 Oct 2021 16:21:56 +0000 (12:21 -0400)
Since watchfrr invokes vtysh to gather the show run output and
write the data, if we are operating inside of a namespace FRR
must also pass this in.

Yes. This seems hacky.  I don't fully understand why vtysh
is invoked this way.

New output:

sharpd@eva:~/frr3$ sudo vtysh -N one

Hello, this is FRRouting (version 8.1-dev).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

eva# wr mem
Note: this version of vtysh never writes vtysh.conf
% Can't open configuration file /etc/frr/one/vtysh.conf due to 'No such file or directory'.
Building Configuration...
Integrated configuration saved to /etc/frr/one/frr.conf
[OK]
eva#

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
watchfrr/watchfrr.c
watchfrr/watchfrr.h
watchfrr/watchfrr_vty.c

index 40749e8fc26293c833846f33e0fd9e58e0e90bf9..b09d0924588467e1678bd027675f5c08f90c7305 100644 (file)
@@ -68,6 +68,7 @@ DEFINE_MTYPE_STATIC(WATCHFRR, WATCHFRR_DAEMON, "watchfrr daemon entry");
 struct thread_master *master;
 
 static bool watch_only = false;
+const char *pathspace;
 
 typedef enum {
        PHASE_NONE = 0,
@@ -1513,8 +1514,15 @@ int main(int argc, char **argv)
        else
                unsetenv("FRR_PATHSPACE");
 
+       /*
+        * when watchfrr_di.pathspace is read, if it is not specified
+        * pathspace is NULL as expected
+        */
+       pathspace = watchfrr_di.pathspace;
+
        if (netns_en && !netns)
                netns = watchfrr_di.pathspace;
+
        if (netns_en && netns && netns[0])
                netns_setup(netns);
 
index 4df1bf74afb78857464704100b9f958c584e6980..4987a932c03c484dee4dd62db085839a32e38510 100644 (file)
 
 DECLARE_MGROUP(WATCHFRR);
 
+/*
+ * This is the name of the pathspace we are in `-N XXX`
+ * If the default then this is NULL
+ */
+extern const char *pathspace;
+
 extern void watchfrr_vty_init(void);
 
 extern pid_t integrated_write_pid;
index eda4f5d516bf3785ea2ca174ddad88bb64e62d0e..1492ee37b600073b443cf3d2aea8eba5e39657a2 100644 (file)
@@ -105,7 +105,10 @@ DEFUN(config_write_integrated,
 
        /* don't allow the user to pass parameters, we're root here!
         * should probably harden vtysh at some point too... */
-       execl(VTYSH_BIN_PATH, "vtysh", "-w", NULL);
+       if (pathspace)
+               execl(VTYSH_BIN_PATH, "vtysh", "-N", pathspace, "-w", NULL);
+       else
+               execl(VTYSH_BIN_PATH, "vtysh", "-w", NULL);
 
        /* unbuffered write; we just messed with stdout... */
        char msg[512];