summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2019-08-08 19:25:39 +0200
committerDavid Lamparter <equinox@diac24.net>2020-07-22 12:56:04 +0200
commit33606a154753f6f50e711d185ee2728d3a32660e (patch)
tree1426f20ac38fc3b21e82aaaf07892c9177338dcf /tools
parentMerge pull request #6729 from volta-networks/fix_stale_pw_status (diff)
downloadfrr-33606a154753f6f50e711d185ee2728d3a32660e.tar.xz
frr-33606a154753f6f50e711d185ee2728d3a32660e.zip
watchfrr: add (network) namespace support
This adds -N and --netns options to watchfrr, allowing it to start daemons with -N and switching network namespaces respectively. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/etc/frr/daemons5
-rw-r--r--tools/frrcommon.sh.in22
-rw-r--r--tools/frrinit.sh.in5
3 files changed, 23 insertions, 9 deletions
diff --git a/tools/etc/frr/daemons b/tools/etc/frr/daemons
index 8bec3c5bb..0221b0c19 100644
--- a/tools/etc/frr/daemons
+++ b/tools/etc/frr/daemons
@@ -72,6 +72,11 @@ vrrpd_options=" -A 127.0.0.1"
# The list of daemons to watch is automatically generated by the init script.
#watchfrr_options=""
+# To make watchfrr create/join the specified netns, use the following option:
+#watchfrr_options="--netns"
+# This only has an effect in /etc/frr/<somename>/daemons, and you need to
+# start FRR with "/usr/lib/frr/frrinit.sh start <somename>".
+
# for debugging purposes, you can specify a "wrap" command to start instead
# of starting the daemon directly, e.g. to use valgrind on ospfd:
# ospfd_wrap="/usr/bin/valgrind"
diff --git a/tools/frrcommon.sh.in b/tools/frrcommon.sh.in
index 2955f74ce..1203a2fe7 100644
--- a/tools/frrcommon.sh.in
+++ b/tools/frrcommon.sh.in
@@ -16,10 +16,14 @@
#
# This script should be installed in @CFG_SBIN@/frrcommon.sh
+# FRR_PATHSPACE is passed in from watchfrr
+suffix="${FRR_PATHSPACE:+/${FRR_PATHSPACE}}"
+nsopt="${FRR_PATHSPACE:+-N ${FRR_PATHSPACE}}"
+
PATH=/bin:/usr/bin:/sbin:/usr/sbin
D_PATH="@CFG_SBIN@" # /usr/lib/frr
-C_PATH="@CFG_SYSCONF@" # /etc/frr
-V_PATH="@CFG_STATE@" # /var/run/frr
+C_PATH="@CFG_SYSCONF@${suffix}" # /etc/frr
+V_PATH="@CFG_STATE@${suffix}" # /var/run/frr
VTYSH="@vtysh_bin@" # /usr/bin/vtysh
FRR_USER="@enable_user@" # frr
FRR_GROUP="@enable_group@" # frr
@@ -61,9 +65,9 @@ vtysh_b () {
[ "$1" = "watchfrr" ] && return 0
[ -r "$C_PATH/frr.conf" ] || return 0
if [ -n "$1" ]; then
- "$VTYSH" -b -n -d "$1"
+ "$VTYSH" `echo $nsopt` -b -n -d "$1"
else
- "$VTYSH" -b -n
+ "$VTYSH" `echo $nsopt` -b -n
fi
}
@@ -156,7 +160,7 @@ daemon_start() {
instopt="${inst:+-n $inst}"
eval args="\$${daemon}_options"
- if eval "$all_wrap $wrap $bin -d $frr_global_options $instopt $args"; then
+ if eval "$all_wrap $wrap $bin $nsopt -d $frr_global_options $instopt $args"; then
log_success_msg "Started $dmninst"
vtysh_b "$daemon"
else
@@ -292,9 +296,11 @@ load_old_config() {
}
. "$C_PATH/daemons"
-load_old_config "$C_PATH/daemons.conf"
-load_old_config "/etc/default/frr"
-load_old_config "/etc/sysconfig/frr"
+if [ -z "$FRR_PATHSPACE" ]; then
+ load_old_config "$C_PATH/daemons.conf"
+ load_old_config "/etc/default/frr"
+ load_old_config "/etc/sysconfig/frr"
+fi
if { declare -p watchfrr_options 2>/dev/null || true; } | grep -q '^declare \-a'; then
log_warning_msg "watchfrr_options contains a bash array value." \
diff --git a/tools/frrinit.sh.in b/tools/frrinit.sh.in
index 423d6b9b1..539ab7d81 100644
--- a/tools/frrinit.sh.in
+++ b/tools/frrinit.sh.in
@@ -30,6 +30,9 @@ else
}
fi
+# "/usr/lib/frr/frrinit.sh start somenamespace"
+FRR_PATHSPACE="$2"
+
self="`dirname $0`"
if [ -r "$self/frrcommon.sh" ]; then
. "$self/frrcommon.sh"
@@ -105,7 +108,7 @@ reload)
NEW_CONFIG_FILE="${2:-$C_PATH/frr.conf}"
[ ! -r $NEW_CONFIG_FILE ] && log_failure_msg "Unable to read new configuration file $NEW_CONFIG_FILE" && exit 1
- "$RELOAD_SCRIPT" --reload "$NEW_CONFIG_FILE"
+ "$RELOAD_SCRIPT" --reload "$NEW_CONFIG_FILE" `echo $nsopt`
exit $?
;;