This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

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)
  • Loading branch information...
hrs-allbsd committed Jul 26, 2013
1 parent 2969ec6 commit 5ede9da9b79aa87f07fa875c04dd1b9961ee1f0a
Showing with 120 additions and 51 deletions.
  1. +81 −40 etc/network.subr
  2. +17 −0 etc/rc.subr
  3. +9 −9 lib/libc/gen/sysctl.3
  4. +13 −2 sys/net/rtsock.c
View
@@ -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,29 +739,49 @@ 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
# Helper function for ifalias_expand_addr(). Handles IPv4.
#
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).
View
@@ -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}.
View
@@ -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 in the message header.
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
View
@@ -1811,14 +1811,25 @@ 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;
name ++;
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,

0 comments on commit 5ede9da

Please sign in to comment.