svn commit: r253683 - in stable/9: etc lib/libc/gen sys/net
Hiroki Sato
hrs at FreeBSD.org
Fri Jul 26 18:27:14 UTC 2013
Author: hrs
Date: Fri Jul 26 18:27:13 2013
New Revision: 253683
URL: http://svnweb.freebsd.org/changeset/base/253683
Log:
MFC 253262, 253318, 243184, 253444, 253505, 253520:
- Add a leaf node CTL_NET.PF_ROUTE.0.AF.NET_RT_DUMP.0.FIB. This returns
routing table with the specified FIB number, not td->td_proc->p_fibnum.
- Add check_namevarlist() to check if ${name}_var is reserved in
rc.subr or not.
- Fix a bug in ipv6_prefix_IF. It did not work with the 64-bit prefix
notation like 2001:db8:1:1.
- Use eui64 flag in ifconfig(8) instead of network6_getladdr()[*] for
interface indentifier part.
- Fix address range specification with ifconfig(8) options such as:
* inet 192.0.2.1-10 netmask 255.255.255.0 (inet range spec + ifconfig options)
* inet6 2001:db8:1::1-f prefixlen 60 (inet6 range spec + ifconfig options)
If prefixlen or netmask option is specified with CIDR notation at
the same time, the option is used.
- Do not set ND6_IFF_ACCEPT_RTADV on if_bridge(4) interfaces when
ipv6_enable=yes.
Approved by: re (marius)
Modified:
stable/9/etc/network.subr
stable/9/etc/rc.subr
stable/9/lib/libc/gen/sysctl.3
stable/9/sys/net/rtsock.c
Directory Properties:
stable/9/etc/ (props changed)
stable/9/lib/libc/ (props changed)
stable/9/sys/ (props changed)
Modified: stable/9/etc/network.subr
==============================================================================
--- stable/9/etc/network.subr Fri Jul 26 18:20:52 2013 (r253682)
+++ stable/9/etc/network.subr Fri Jul 26 18:27:13 2013 (r253683)
@@ -113,9 +113,18 @@ ifconfig_up()
# backward compatibility: $ipv6_enable
case $ipv6_enable in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
- if ! checkyesno ipv6_gateway_enable; then
- _ipv6_opts="${_ipv6_opts} accept_rtadv"
- fi
+ case $1 in
+ bridge[0-9]*)
+ # No accept_rtadv by default on if_bridge(4)
+ # to avoid a conflict with the member
+ # interfaces.
+ ;;
+ *)
+ if ! checkyesno ipv6_gateway_enable; then
+ _ipv6_opts="${_ipv6_opts} accept_rtadv"
+ fi
+ ;;
+ esac
;;
esac
@@ -550,9 +559,18 @@ ipv6_autoconfif()
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
if checkyesno ipv6_gateway_enable; then
return 1
- else
- return 0
fi
+ case $1 in
+ bridge[0-9]*)
+ # No accept_rtadv by default on if_bridge(4)
+ # to avoid a conflict with the member
+ # interfaces.
+ return 1
+ ;;
+ *)
+ return 0
+ ;;
+ esac
;;
esac
@@ -721,9 +739,14 @@ ifalias()
#
ifalias_expand_addr()
{
+ local _af _action
+
+ _af=$1
+ _action=$2
+ shift 2
- afexists $1 || return
- ifalias_expand_addr_$1 $2 $3
+ afexists $_af || return
+ ifalias_expand_addr_$_af $_action $*
}
# ifalias_expand_addr_inet action addr
@@ -731,19 +754,34 @@ ifalias_expand_addr()
#
ifalias_expand_addr_inet()
{
- local _action _arg _cidr _cidr_addr
+ local _action _arg _cidr _cidr_addr _exargs
local _ipaddr _plen _range _iphead _iptail _iplow _iphigh _ipcount
local _retstr _c
_action=$1
_arg=$2
+ shift 2
+ _exargs=$*
_retstr=
- case $_action:$_arg in
- *:*--*) return ;; # invalid
- tmp:*) echo $_arg && return ;; # already expanded
- tmp:*-*) _action="alias" ;; # to be expanded
- *:*-*) ;; # to be expanded
- *:*) echo inet $_arg && return ;; # already expanded
+ case $_action:$_arg:$_exargs in
+ *:*--*) return ;; # invalid
+ tmp:*[0-9]-[0-9]*:*) # to be expanded
+ _action="alias"
+ ;;
+ *:*[0-9]-[0-9]*:*) # to be expanded
+ ;;
+ tmp:*:*netmask*) # already expanded w/ netmask option
+ echo ${_arg%/[0-9]*} $_exargs && return
+ ;;
+ tmp:*:*) # already expanded w/o netmask option
+ echo $_arg $_exargs && return
+ ;;
+ *:*:*netmask*) # already expanded w/ netmask option
+ echo inet ${_arg%/[0-9]*} $_exargs && return
+ ;;
+ *:*:*) # already expanded w/o netmask option
+ echo inet $_arg $_exargs && return
+ ;;
esac
for _cidr in $_arg; do
@@ -796,7 +834,7 @@ ifalias_expand_addr_inet()
done
for _c in $_retstr; do
- ifalias_expand_addr_inet $_action $_c
+ ifalias_expand_addr_inet $_action $_c $_exargs
done
}
@@ -805,20 +843,35 @@ ifalias_expand_addr_inet()
#
ifalias_expand_addr_inet6()
{
- local _action _arg _cidr _cidr_addr
+ local _action _arg _cidr _cidr_addr _exargs
local _ipaddr _plen _ipleft _ipright _iplow _iphigh _ipcount
local _ipv4part
local _retstr _c
_action=$1
_arg=$2
+ shift 2
+ _exargs=$*
_retstr=
- case $_action:$_arg in
- *:*--*) return ;; # invalid
- tmp:*) echo $_arg && return ;;
- tmp:*-*) _action="alias" ;;
- *:*-*) ;;
- *:*) echo inet6 $_arg && return ;;
+ case $_action:$_arg:$_exargs in
+ *:*--*:*) return ;; # invalid
+ tmp:*[0-9a-zA-Z]-[0-9a-zA-Z]*:*)# to be expanded
+ _action="alias"
+ ;;
+ *:*[0-9a-zA-Z]-[0-9a-zA-Z]*:*) # to be expanded
+ ;;
+ tmp:*:*prefixlen*) # already expanded w/ prefixlen option
+ echo ${_arg%/[0-9]*} $_exargs && return
+ ;;
+ tmp:*:*) # already expanded w/o prefixlen option
+ echo $_arg $_exargs && return
+ ;;
+ *:*:*prefixlen*) # already expanded w/ prefixlen option
+ echo inet6 ${_arg%/[0-9]*} $_exargs && return
+ ;;
+ *:*:*) # already expanded w/o prefixlen option
+ echo inet6 $_arg $_exargs && return
+ ;;
esac
for _cidr in $_arg; do
@@ -872,7 +925,7 @@ ifalias_expand_addr_inet6()
fi
for _c in $_retstr; do
- ifalias_expand_addr_inet6 $_action $_c
+ ifalias_expand_addr_inet6 $_action $_c $_exargs
done
else
# v4mapped/v4compat should handle as an IPv4 alias
@@ -888,7 +941,7 @@ ifalias_expand_addr_inet6()
_retstr=`ifalias_expand_addr_inet \
tmp ${_ipv4part}${_plen:+/}${_plen}`
for _c in $_retstr; do
- ifalias_expand_addr_inet $_action $_c
+ ifalias_expand_addr_inet $_action $_c $_exargs
done
fi
done
@@ -1052,16 +1105,12 @@ ifalias_af_common()
#
ipv6_prefix_hostid_addr_common()
{
- local _if _action prefix laddr hostid j address
+ local _if _action prefix j
_if=$1
_action=$2
prefix=`get_if_var ${_if} ipv6_prefix_IF`
if [ -n "${prefix}" ]; then
- laddr=`network6_getladdr ${_if}`
- hostid=${laddr#fe80::}
- hostid=${hostid%\%*}
-
for j in ${prefix}; do
# The default prefixlen is 64.
plen=${j#*/}
@@ -1071,18 +1120,10 @@ ipv6_prefix_hostid_addr_common()
esac
# Normalize the last part by removing ":"
- j=${j%:*}
+ j=${j%::*}
j=${j%:}
- OIFS=$IFS; IFS=":"; set -- $j; nj=$#; IFS=$OIFS
- OIFS=$IFS; IFS=":"; set -- $hostid; nh=$#; IFS=$OIFS
- if [ $(($nj + $nh)) -eq 8 ]; then
- address=$j\:$hostid
- else
- address=$j\::$hostid
- fi
-
- ${IFCONFIG_CMD} ${_if} inet6 ${address} \
- prefixlen $plen ${_action}
+ ${IFCONFIG_CMD} ${_if} inet6 $j:: \
+ prefixlen $plen eui64 ${_action}
# if I am a router, add subnet router
# anycast address (RFC 2373).
Modified: stable/9/etc/rc.subr
==============================================================================
--- stable/9/etc/rc.subr Fri Jul 26 18:20:52 2013 (r253682)
+++ stable/9/etc/rc.subr Fri Jul 26 18:27:13 2013 (r253683)
@@ -1774,6 +1774,23 @@ check_kern_features()
fi
}
+# check_namevarlist var
+# Return "0" if ${name}_var is reserved in rc.subr.
+
+_rc_namevarlist="program chroot chdir flags fib nice user group groups"
+check_namevarlist()
+{
+ local _v
+
+ for _v in $_rc_namevarlist; do
+ case $1 in
+ $_v) return 0 ;;
+ esac
+ done
+
+ return 1
+}
+
# _echoonce var msg mode
# mode=0: Echo $msg if ${$var} is empty.
# After doing echo, a string is set to ${$var}.
Modified: stable/9/lib/libc/gen/sysctl.3
==============================================================================
--- stable/9/lib/libc/gen/sysctl.3 Fri Jul 26 18:20:52 2013 (r253682)
+++ stable/9/lib/libc/gen/sysctl.3 Fri Jul 26 18:27:13 2013 (r253683)
@@ -28,7 +28,7 @@
.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95
.\" $FreeBSD$
.\"
-.Dd February 11, 2012
+.Dd May 17, 2013
.Dt SYSCTL 3
.Os
.Sh NAME
@@ -547,14 +547,14 @@ The length of each message is contained
The third level name is a protocol number, which is currently always 0.
The fourth level name is an address family, which may be set to 0 to
select all address families.
-The fifth and sixth level names are as follows:
-.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
-.It Sy "Fifth level name Sixth level is:"
-.It "NET_RT_FLAGS rtflags"
-.It "NET_RT_DUMP None"
-.It "NET_RT_IFLIST 0 or if_index"
-.It "NET_RT_IFMALIST 0 or if_index"
-.It "NET_RT_IFLISTL 0 or if_index"
+The fifth, sixth, and seventh level names are as follows:
+.Bl -column -offset indent "Fifth level Sixth level" "Seventh level"
+.It Sy "Fifth level Sixth level" Ta Sy "Seventh level"
+.It "NET_RT_FLAGS rtflags" Ta "None"
+.It "NET_RT_DUMP None" Ta "None or fib number"
+.It "NET_RT_IFLIST 0 or if_index" Ta None
+.It "NET_RT_IFMALIST 0 or if_index" Ta None
+.It "NET_RT_IFLISTL 0 or if_index" Ta None
.El
.Pp
The
Modified: stable/9/sys/net/rtsock.c
==============================================================================
--- stable/9/sys/net/rtsock.c Fri Jul 26 18:20:52 2013 (r253682)
+++ stable/9/sys/net/rtsock.c Fri Jul 26 18:27:13 2013 (r253683)
@@ -1811,6 +1811,7 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS)
u_int namelen = arg2;
struct radix_node_head *rnh = NULL; /* silence compiler. */
int i, lim, error = EINVAL;
+ int fib = 0;
u_char af;
struct walkarg w;
@@ -1818,7 +1819,17 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS)
namelen--;
if (req->newptr)
return (EPERM);
- if (namelen != 3)
+ if (name[1] == NET_RT_DUMP) {
+ if (namelen == 3)
+ fib = req->td->td_proc->p_fibnum;
+ else if (namelen == 4)
+ fib = (name[3] == -1) ?
+ req->td->td_proc->p_fibnum : name[3];
+ else
+ return ((namelen < 3) ? EISDIR : ENOTDIR);
+ if (fib < 0 || fib >= rt_numfibs)
+ return (EINVAL);
+ } else if (namelen != 3)
return ((namelen < 3) ? EISDIR : ENOTDIR);
af = name[0];
if (af > AF_MAX)
@@ -1857,7 +1868,7 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS)
* take care of routing entries
*/
for (error = 0; error == 0 && i <= lim; i++) {
- rnh = rt_tables_get_rnh(req->td->td_proc->p_fibnum, i);
+ rnh = rt_tables_get_rnh(fib, i);
if (rnh != NULL) {
RADIX_NODE_HEAD_RLOCK(rnh);
error = rnh->rnh_walktree(rnh,
More information about the svn-src-stable-9
mailing list