conf/132483: [rc.subr] [patch] setfib(1) support for rc.subr
Sergey Matveychuk
sem at FreeBSD.org
Mon Mar 9 12:50:09 PDT 2009
>Number: 132483
>Category: conf
>Synopsis: [rc.subr] [patch] setfib(1) support for rc.subr
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Mar 09 19:50:06 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator: Sergey Matveychuk
>Release: CURRENT
>Organization:
>Environment:
>Description:
Add support setfib(1) for rc.subr.
If ${name}_fib specified and the number less then configured FIBs number, command will runned with setfib(1).
>How-To-Repeat:
>Fix:
Patch attached with submission follows:
--- etc/rc.subr.orig 2009-03-09 21:34:36.000000000 +0300
+++ etc/rc.subr 2009-03-09 22:15:33.000000000 +0300
@@ -58,6 +58,7 @@
IDCMD="if [ -x $ID ]; then $ID -un; fi"
PS="/bin/ps -ww"
JID=`$PS -p $$ -o jid=`
+SETFIB="/usr/sbin/setfib"
case ${OSTYPE} in
FreeBSD)
@@ -422,6 +423,8 @@
# ${name}_chdir n Directory to cd to before running ${command}
# (if not using ${name}_chroot).
#
+# ${name}_fib n A FIB number for setfib(1).
+#
# ${name}_flags n Arguments to call ${command} with.
# NOTE: $flags from the parent environment
# can be used to override this.
@@ -581,6 +584,12 @@
_pidcmd=
_procname=${procname:-${command}}
+ eval _fib=\$${name}_fib
+ _setfibcmd=
+ if [ -n "$_fib" -a -x $SETFIB -a $_fib -lt `$SYSCTL_N net.fibs` ]; then
+ _setfibcmd="/usr/sbin/setfib -F $_fib"
+ fi
+
# setup pid check command
if [ -n "$_procname" ]; then
if [ -n "$pidfile" ]; then
@@ -644,7 +653,7 @@
if [ -n "$_cmd" ]; then
_run_rc_precmd || return 1
- _run_rc_doit "$_cmd $rc_extra_args" || return 1
+ _run_rc_doit "$_setfibcmd $_cmd $rc_extra_args" || return 1
_run_rc_postcmd
return $_return
fi
@@ -683,13 +692,13 @@
[ -z "${rc_quiet}" ] && echo "Starting ${name}."
if [ -n "$_chroot" ]; then
_doit="\
-${_nice:+nice -n $_nice }\
+${_nice:+nice -n $_nice } $_setfibcmd\
chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\
$_chroot $command $rc_flags $command_args"
else
_doit="\
${_chdir:+cd $_chdir && }\
-$command $rc_flags $command_args"
+$_setfibcmd $command $rc_flags $command_args"
if [ -n "$_user" ]; then
_doit="su -m $_user -c 'sh -c \"$_doit\"'"
fi
--- share/man/man8/rc.subr.8.orig 2009-03-09 22:31:26.000000000 +0300
+++ share/man/man8/rc.subr.8 2009-03-09 22:31:31.000000000 +0300
@@ -587,6 +587,12 @@
Only supported after
.Pa /usr
is mounted.
+.It Va ${name}_fib
+If the number is less than configured FIBs number,
+.Va command
+will be runned with setfib(1). Only supported after
+.Pa /usr
+is mounted.
.It Va ${name}_flags
Arguments to call
.Va command
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list