summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/etc/frr/daemons67
-rwxr-xr-xtools/frrcommon.sh.in28
2 files changed, 66 insertions, 29 deletions
diff --git a/tools/etc/frr/daemons b/tools/etc/frr/daemons
index b1526888ed..860c4980b6 100644
--- a/tools/etc/frr/daemons
+++ b/tools/etc/frr/daemons
@@ -58,30 +58,61 @@ fabricd_options="-A 127.0.0.1"
vrrpd_options=" -A 127.0.0.1"
pathd_options=" -A 127.0.0.1"
+
+# If you want to pass a common option to all daemons, you can use the
+# "frr_global_options" variable.
+#
+#frr_global_options=""
+
+
+# The list of daemons to watch is automatically generated by the init script.
+# This variable can be used to pass options to watchfrr that will be passed
+# prior to the daemon list.
+#
+# To make watchfrr create/join the specified netns, add the the "--netns"
+# option here. It will only have an effect in /etc/frr/<somename>/daemons, and
+# you need to start FRR with "/usr/lib/frr/frrinit.sh start <somename>".
+#
+#watchfrr_options=""
+
+
# configuration profile
#
#frr_profile="traditional"
#frr_profile="datacenter"
+
+# This is the maximum number of FD's that will be available. Upon startup this
+# is read by the control files and ulimit is called. Uncomment and use a
+# reasonable value for your setup if you are expecting a large number of peers
+# in say BGP.
#
-# This is the maximum number of FD's that will be available.
-# Upon startup this is read by the control files and ulimit
-# is called. Uncomment and use a reasonable value for your
-# setup if you are expecting a large number of peers in
-# say BGP.
#MAX_FDS=1024
-# 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"
-# or you can use "all_wrap" for all daemons, e.g. to use perf record:
-# all_wrap="/usr/bin/perf record --call-graph -"
-# the normal daemon command is added to this at the end.
+# For any daemon, you can specify a "wrap" command to start instead of starting
+# the daemon directly. This will simply be prepended to the daemon invocation.
+# These variables have the form daemon_wrap, where 'daemon' is the name of the
+# daemon (the same pattern as the daemon_options variables).
+#
+# Note that when daemons are started, they are told to daemonize with the `-d`
+# option. This has several implications. For one, the init script expects that
+# when it invokes a daemon, the invocation returns immediately. If you add a
+# wrap command here, it must comply with this expectation and daemonize as
+# well, or the init script will never return. Furthermore, because daemons are
+# themselves daemonized with -d, you must ensure that your wrapper command is
+# capable of following child processes after a fork() if you need it to do so.
+#
+# If your desired wrapper does not support daemonization, you can wrap it with
+# a utility program that daemonizes programs, such as 'daemonize'. An example
+# of this might look like:
+#
+# bgpd_wrap="/usr/bin/daemonize /usr/bin/mywrapper"
+#
+# This is particularly useful for programs which record processes but lack
+# daemonization options, such as perf and rr.
+#
+# If you wish to wrap all daemons in the same way, you may set the "all_wrap"
+# variable.
+#
+#all_wrap=""
diff --git a/tools/frrcommon.sh.in b/tools/frrcommon.sh.in
index e5286d14f6..c168edc50d 100755
--- a/tools/frrcommon.sh.in
+++ b/tools/frrcommon.sh.in
@@ -52,7 +52,7 @@ is_user_root () {
debug() {
[ -n "$watchfrr_debug" ] || return 0
- printf '%s %s(%s):' "`date +%Y-%m-%dT%H:%M:%S.%N`" "$0" $$ >&2
+ printf '%s %s(%s):' "$(date +%Y-%m-%dT%H:%M:%S.%N)" "$0" $$ >&2
# this is to show how arguments are split regarding whitespace & co.
# (e.g. for use with `debug "message" "$@"`)
while [ $# -gt 0 ]; do
@@ -73,12 +73,16 @@ chownfrr() {
vtysh_b () {
[ "$1" = "watchfrr" ] && return 0
- [ -r "$C_PATH/frr.conf" ] || return 0
- if [ -n "$1" ]; then
- "$VTYSH" `echo $nsopt` -b -d "$1"
- else
- "$VTYSH" `echo $nsopt` -b
+ if [ -r "$C_PATH/frr.conf" ]; then
+ log_warning_msg "$C_PATH/frr.conf does not exist; skipping config apply"
+ return 0
fi
+
+ cmd="$VTYSH $nsopt -b"
+ [ -n "$1" ] && cmd="${cmd} -d $1"
+
+ log_success_msg "Sending config with '$cmd'"
+ eval "$cmd"
}
daemon_inst() {
@@ -164,7 +168,7 @@ daemon_start() {
daemon_inst "$1"
- ulimit -n $MAX_FDS > /dev/null 2> /dev/null
+ [ "$MAX_FDS" != "" ] && ulimit -n "$MAX_FDS" > /dev/null 2> /dev/null
daemon_prep "$daemon" "$inst" || return 1
if test ! -d "$V_PATH"; then
mkdir -p "$V_PATH"
@@ -176,7 +180,9 @@ daemon_start() {
instopt="${inst:+-n $inst}"
eval args="\$${daemon}_options"
- if eval "$all_wrap $wrap $bin $nsopt -d $frr_global_options $instopt $args"; then
+ cmd="$all_wrap $wrap $bin $nsopt -d $frr_global_options $instopt $args"
+ log_success_msg "Starting $daemon with command: '$cmd'"
+ if eval "$cmd"; then
log_success_msg "Started $dmninst"
if $all; then
debug "Skipping startup of vtysh until all have started"
@@ -202,7 +208,7 @@ daemon_stop() {
[ -r "$pidfile" ] || fail="pid file not found"
$all && [ -n "$fail" ] && return 0
- [ -z "$fail" ] && pid="`cat \"$pidfile\"`"
+ [ -z "$fail" ] && pid="$(cat \"$pidfile\")"
[ -z "$fail" -a -z "$pid" ] && fail="pid file is empty"
[ -n "$fail" ] || kill -0 "$pid" 2>/dev/null || fail="pid $pid not running"
@@ -236,7 +242,7 @@ daemon_status() {
pidfile="$V_PATH/$daemon${inst:+-$inst}.pid"
[ -r "$pidfile" ] || return 3
- pid="`cat \"$pidfile\"`"
+ pid="$(cat \"$pidfile\")"
[ -z "$pid" ] && return 1
kill -0 "$pid" 2>/dev/null || return 1
return 0
@@ -360,7 +366,7 @@ frrcommon_main() {
cmd="$1"
shift
- if [ "$1" = "all" -o -z "$1" ]; then
+ if [ "$1" = "all" ] || [ -z "$1" ]; then
case "$cmd" in
start) all_start;;
stop) all_stop;;