List of Changes =============== Usage: You can control what actions is performed by appending a 4 or a 6 to rc.d/netif commands. For example to start only ipv6 on rl0: # /etc/rc.d/netif start6 rl0 Knobs that have been removed: network_interfaces ipv6_network_interfaces These knobs have been removed at Brooks' suggestion. They denoted whether an interface should be considered for IPv4 and IPv6 configuration, respectively. Instead, now the user should use the NOIPV4 and NOIPV6 keyword in the ifconfig_ variable of interface if it should *not* be considered for v4 or v6 configuration, respectively. Knobs that have changed meaning: ifconfig_ ifconfig_DEFAULT Currently these knobs are intended to be used for both non-IP *and* IPv4 configuration. Going forward they are intended for non-IP related configuration only. The old2new_knobs() subroutine will issue a warning if it detects certain IP related keywords in these knobs. The only IP related keywords allowed in these two variables are: NOIPV4 and NOIPV6. synchronous_dhclient - When set to yes dhclient will be started on DHCP interfaces during general network startup. Currently, this implicitly refers to IPv4 only. Going forward, it refers to both IPv4 and IPv6. In practice, there will be no differnce in behaviour until an IPv6 dhcp client appears in the base system. New knobs: ipv4_enable - similary to ipv6_enable, all IPv4 configuration of interfaces and routing is enabled/disabled by setting this knob to yes or no. Defaults to yes. ipv4_synchronous_dhclient - same as synchronous_dhclient, except it applies only to IPv4 interfaces. ipv6_synchronous_dhclient - same as above except for IPv6 interfaces. Unfortunately, because some knobs (like ifconfig_DEFAULT) have changed meanings, instead of being replaced, it is not possible to have a completely seemless transition. You will have to edit rc.conf(5) in order for your system to work properly after these changes. Having said that, quite a few of the new IP version related knobs can be "automagically" set based on the values of the knobs currently in use. These knobs are: gateway_enable => ipv4_gateway_enable router_enable => ipv4_router_enable router => ipv4_router router_flags => ipv4_router_flags defaultrouter => ipv4_defaultrouter static_routes => ipv4_static_routes static_routes_ => ipv4_static_routes_ route_ => ipv4_route_ dhclient_program => ipv4_dhclient_program dhclient_flags => ipv4_dhclient_flags dhclient_flags_ => ipv4_dhclient_flags_ background_dhclient_ => ipv4_background_dhclient_ The knobs that you will have to examine and modify manually are: ifconfig_ - move IPv4 related configuration (including DHCP keyword) to ipv4_ifconfig_ ifconfig__aliasX - move IPv4 related configuration to ipv4_ifconfig__aliasX ifconfig_DEFAULT - move IPv4 related configuration (including DHCP) to ipv4_ifconfig_DEFAULT network_interfaces - for the interfaces *not* on this list put the NOIPV4 keyword in the respective ifconfig_ variable and delete this knob ipv6_network_interfaces - for the interfaces *not* on this list put the NOIPV6 keyword in the respective ifconfig_ variable and delete this knob ## The following is for the edification of developers who muck about ## in the rc.d code. If you're not interested in the rc.subr/network.subr ## glue you can ignore the rest of this. Some network subroutines have been changed, and some have been split out to reflect their use in IP v4 and v6 configuration. Here's what they look like after the change: [changed] ifconfig_up / ifconfig_down - Non-IP related ifconfig(8) configuration [new] ifconfig_up4 / ifconfig_down4 - IPv4 related ifconfig(8) configuration [new] ifconfig_up6 / ifconfig_down6 - IPv6 related ifconfig(8) configuration [new] dhcpif4 - Returns 0 if the IPv4 address of an interface should be configured automatically by DHCP [new] dhcpif6 - Returns 0 if the IPv6 address of an interface should be configured automatically by DHCP [changed] dhcpif - Returns 0 if either or both IP address versions are configured automatically by DHCP. [new] syncdhcpif4 - Returns 0 if dhclient(8) should be run synchronously for IPv4 in the general network start script. [new] syncdhcpif6 - Same as above except it refers to IPv6 configuration [new] ipv4if - Returns 0 if the interface should be configured for IPv4 [new] ipv6if - Returns 0 if the interface should be configured for IPv6 [new] post_ifconfig_up4 - Configure IPv4 alias knobs and entries in CIDR notation [new] post_ifconfig_down4 - "unconfigure" IPv4 alias and CIDR knobs. [new] post_ifconfig_up6 - configure IPv6 alias knobs [new] ifalias_up4 / ifalias_down4 - Configure IPv4 alias entries. Called by post_ifconfig_up4/down4 routines, respectively. [new] ifalias_up6 - configure IPv6 alias knobs. Called by post_ifconfig_up6(). [new] ifalias_down6 - Currently unused, since delete_addrs6() takes care of this also. [new] delete_addrs6 - remove IPv6 addresses from an interface. Called by ifconfig_down6(). The difference between this and ifalias_down6() is that this deletes all IPv6 address for the interface; whereas, ifalias_down6() deletes only those addresses specified in in an ipv6_ifconfig_IF_aliasX knob. [changed] list_net_interfaces - Lists network interfaces of the following types: - All IPv4 interfaces (legacy behaviour) ipv4 - all IPv4 interfaces ipv6 - all IPv6 interfaces nodhcp - all interfaces, excluding DHCP configured interfaces dhcp - list only DHCP configured interfaces dhcp4 - list only DHCP configured IPv4 interfaces dhcp6 - list only DHCP configured IPv6 interfaces [new] rtsol_up - starts rtsol(8) on an interface stf_up - setup IPv4 to IPv6 mapping faith_up - setup a faith(4) interface default_interface_up - set default IPv6 interface working_ipv6_interfaces - lists valid IPv6 interfaces There are also a bunch of support functions that begin with an underscore '_'. They are meant to be private to network.subr and are called by some of the subroutines listed above. ========== Index: etc/network.subr =================================================================== --- etc/network.subr (.../vendor/FreeBSD/src) (revision 106) +++ etc/network.subr (.../branches/rcd_ipv6) (revision 106) @@ -1,5 +1,5 @@ # -# Copyright (c) 2003 The FreeBSD Project. All rights reserved. +# Copyright (c) 2003-2007 The FreeBSD Project. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -31,36 +31,87 @@ # # ifconfig_up if -# Evaluate ifconfig(8) arguments for interface $if and +# Configure non IPv4 or 6 interface properties. Returns 0 if +# the interface exists and an attempt was made to configure it. +# +ifconfig_up() +{ + local ret ifargs + ret=1 + + if ifexists $1; then + ifargs="`ifconfig_getargs $1`" + if [ -n "${ifargs}" ]; then + ifconfig $1 ${ifargs} + ret=0 + fi + + if wpaif $1; then + if [ $ret -ne 0 ] ; then + ifconfig $1 up + fi + /etc/rc.d/wpa_supplicant start $1 + ret=0 # XXX: not sure this should count + fi + fi + return $ret +} + +# ifconfig_down if +# Returns 0 if the interface $if exists and an attempt was made to +# stop the interface. +# +ifconfig_down() +{ + if ifexists $1; then + if wpaif $1; then + /etc/rc.d/wpa_supplicant stop $1 + fi + ifconfig $1 down + return 0 + fi + return 1 +} + +# _ifconfig_up if ip +# Evaluate ifconfig(8) arguments for interface $if and IP version $ip, +# and run ifconfig(8) with those arguments. It returns 0 if +# arguments were found and executed or 1 if the interface +# had no arguments. +# +_ifconfig_up() +{ + ifconfig_args=`ifconfig_getargs $1 $2` + if [ -n "${ifconfig_args}" ]; then + ifconfig $1 up + case $2 in + [Ii][Pp][Vv]4) + ifconfig $1 ${ifconfig_args} + ;; + [Ii][Pp][Vv]6) + ifconfig $1 inet6 ${ifconfig_args} alias + ;; + esac + return 0 + fi + return 1 +} + +# ifconfig_up4 if +# Evaluate IPv4 ifconfig(8) arguments for interface $if and # run ifconfig(8) with those arguments. It returns 0 if # arguments were found and executed or 1 if the interface # had no arguments. Pseudo arguments DHCP and WPA are handled # here. # -ifconfig_up() +ifconfig_up4() { _cfg=1 - ifconfig_args=`ifconfig_getargs $1` - if [ -n "${ifconfig_args}" ]; then - ifconfig $1 up - ifconfig $1 ${ifconfig_args} - _cfg=0 - fi + _ifconfig_up $1 ipv4 && _cfg=0 || _cfg=1 - if wpaif $1; then - if [ $_cfg -ne 0 ] ; then - ifconfig $1 up - fi - /etc/rc.d/wpa_supplicant start $1 - _cfg=0 # XXX: not sure this should count - fi - - if dhcpif $1; then - if [ $_cfg -ne 0 ] ; then - ifconfig $1 up - fi - if syncdhcpif $1; then + if dhcpif4 $1; then + if syncdhcpif4 $1; then /etc/rc.d/dhclient start $1 fi _cfg=0 @@ -69,30 +120,19 @@ return $_cfg } -# ifconfig_down if -# returns 1 if wpa_supplicant or dhclient was stopped or -# the interface exists. +# ifconfig_down4 if +# returns 1 if wpa_supplicant or dhclient was stopped. # -ifconfig_down() +ifconfig_down4() { [ -z "$1" ] && return 1 _cfg=1 - if wpaif $1; then - /etc/rc.d/wpa_supplicant stop $1 - _cfg=0 - fi - - if dhcpif $1; then + if dhcpif4 $1; then /etc/rc.d/dhclient stop $1 _cfg=0 fi - if ifexists $1; then - ifconfig $1 down - _cfg=0 - fi - return $_cfg } @@ -121,26 +161,61 @@ eval echo \${${prefix}${_if}${suffix}-${_default}} } -# _ifconfig_getargs if -# Echos the arguments for the supplied interface to stdout. -# returns 1 if empty. In general, ifconfig_getargs should be used -# outside this file. +# _ifconfig_getargs if [ip] +# Echoes the arguments for the supplied interface and IP protocol to +# stdout. Returns 1 if empty. In general, ifconfig_getargs should be +# used outside this file. _ifconfig_getargs() { + local dflarg ip + _ifn=$1 if [ -z "$_ifn" ]; then return 1 fi - get_if_var $_ifn ifconfig_IF "$ifconfig_DEFAULT" + case $2 in + [Ii][Pp][Vv]4) + ip=ipv4_ + dflarg="$ipv4_ifconfig_DEFAULT" + ;; + [Ii][Pp][Vv]6) + ip=ipv6_ + dflarg="$ipv6_ifconfig_DEFAULT" + ;; + '') + ip= + dflarg="$ifconfig_DEFAULT" + ;; + *) + return 1 + ;; + esac + + get_if_var $_ifn ${ip}ifconfig_IF "${dflarg}" + return 0 } -# ifconfig_getargs if +# ifconfig_getargs if [ip] # Takes the result from _ifconfig_getargs and removes pseudo # args such as DHCP and WPA. ifconfig_getargs() { - _tmpargs=`_ifconfig_getargs $1` + local ip + + case $2 in + [Ii][Pp][Vv]4) + ip=IPv4;; + [Ii][Pp][Vv]6) + ip=IPv6;; + '') + ip= + ;; + *) + return 1;; + esac + + _tmpargs=`_ifconfig_getargs $1 $ip` if [ $? -eq 1 ]; then return 1 fi @@ -148,6 +223,8 @@ for _arg in $_tmpargs; do case $_arg in + [Nn][Oo][Ii][Pp][Vv]4);; + [Nn][Oo][Ii][Pp][Vv]6);; [Dd][Hh][Cc][Pp]) ;; [Nn][Oo][Aa][Uu][Tt][Oo]) ;; [Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]) ;; @@ -162,12 +239,12 @@ echo $_args } -# autoif -# Returns 0 if the interface should be automaticly configured at -# boot time and 1 otherwise. +# autoif ifn [ip] +# Returns 0 if the interface $ifn should be automaticaly configured for +# IP version $ip at boot time and 1 otherwise. autoif() { - _tmpargs=`_ifconfig_getargs $1` + _tmpargs=`_ifconfig_getargs $1 $2` for _arg in $_tmpargs; do case $_arg in [Nn][Oo][Aa][Uu][Tt][Oo]) @@ -179,11 +256,41 @@ } # dhcpif if -# Returns 0 if the interface is a DHCP interface and 1 otherwise. +# Returns 0 if the interface is configured by DHCP for any IP version. +# Returns 1 otherwise. +# dhcpif() { - _tmpargs=`_ifconfig_getargs $1` - for _arg in $_tmpargs; do + dhcpif4 $1 && return 0 + dhcpif6 $1 && return 0 + return 1 +} + +# dhcpif4 if +# Returns 0 if $if is configured by DHCP for IPv4 or 1 otherwise. +# +dhcpif4() +{ + checkyesno ipv4_enable || return 1 + _dhcpif `_ifconfig_getargs $1 ipv4` && return 0 || return 1 +} + +# dhcpif6 if +# Returns 0 if $if is configured by DHCP for IPv6 or 1 otherwise. +# +dhcpif6() +{ + checkyesno ipv6_enable || return 1 + _dhcpif `_ifconfig_getargs $1 ipv6` && return 0 || return 1 +} + +# _dhcpif args +# Evaluates arg for any DHCP related keywords. Returns 0 if they are +# found or 1 otherwise. +# +_dhcpif() +{ + for _arg in $*; do case $_arg in [Dd][Hh][Cc][Pp]) return 0 @@ -199,13 +306,43 @@ return 1 } -# syncdhcpif -# Returns 0 if the interface should be configured synchronously and -# 1 otherwise. -syncdhcpif() +# syncdhcpif4 if +# Returns 0 if the interface should be configured synchronously for IPv4 +# or 1 otherwise. +# +syncdhcpif4() { - _tmpargs=`_ifconfig_getargs $1` - for _arg in $_tmpargs; do + _syncdhcpif $1 ipv4 +} + +# syncdhcpif6 if +# Returns 0 if the interface should be configured synchronously for IPv6 +# or 1 otherwise. +# +syncdhcpif6() +{ + _syncdhcpif $1 ipv6 +} + +# _syncdhcpif args ip +# Evaluates args for keywords related to synchronous DHCP starting. It +# returns 0 if synchronous dhcp is enabled or 1 otherwise. +# +_syncdhcpif() +{ + local _sync args ip + + case $2 in + [Ii][Pp][Vv]4) + ip=ipv4;; + [Ii][Pp][Vv]6) + ip=ipv6;; + *) + return 2;; + esac + + args="`_ifconfig_getargs $1 ${ip}`" + for _arg in ${args}; do case $_arg in [Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]) return 1 @@ -215,7 +352,8 @@ ;; esac done - if checkyesno synchronous_dhclient; then + eval _sync="\${${ip}_synchronous_dhclient-${synchronous_dhclient}}" + if checkyesno _sync; then return 0 else return 1 @@ -237,30 +375,67 @@ return 1 } -# ipv6if if -# Returns 0 if the interface should be configured for IPv6 and +# _ipvXif() if ip +# Returns 0 if the interface should be configured for $ip and # 1 otherwise. -ipv6if() +# +_ipvXif() { - if ! checkyesno ipv6_enable; then - return 1 - fi - case "${ipv6_network_interfaces}" in - [Aa][Uu][Tt][Oo]) - return 0 + local _tmpargs ip netifs + + case $2 in + [Ii][Pp][Vv]4) + ip=ipv4 ;; - ''|[Nn][Oo][Nn][Ee]) + [Ii][Pp][Vv]6) + ip=ipv6 + ;; + *) return 1 ;; esac - for v6if in ${ipv6_network_interfaces}; do - if [ "${v6if}" = "${1}" ]; then - return 0 - fi + + # Does the interface exit? + ifexists $1 || return 1 + + # Exit immediately if the IP version is not enabled or + # the interface's ifconfig_ variable contains NOIPV4/6 + # + if ! checkyesno ${ip}_enable; then + return 1 + fi + _tmpargs=`_ifconfig_getargs $1` + for _arg in $_tmpargs; do + case $_arg in + [Nn][Oo][Ii][Pp][Vv]4) + [ "$ip" = "ipv4" ] && return 1 + ;; + [Nn][Oo][Ii][Pp][Vv]6) + [ "$ip" = "ipv6" ] && return 1 + ;; + esac done - return 1 + + return 0 } +# ipv4if if +# Returns 0 if the interface should be configured for IPv4 and +# 1 otherwise. +# +ipv4if() +{ + _ipvXif $1 IPv4 && return 0 || return 1 +} + +# ipv6if if +# Returns 0 if the interface should be configured for IPv6 and +# 1 otherwise. +ipv6if() +{ + _ipvXif $1 IPv6 && return 0 || return 1 +} + # ifexists if # Returns 0 if the interface exists and 1 otherwise. ifexists() @@ -268,19 +443,22 @@ ifconfig -n $1 > /dev/null 2>&1 } -# ipv4_up if -# add IPv4 addresses to the interface $if -ipv4_up() +# post_ifconfig_up4 if +# Add IPv4 addresses to the interface $if +post_ifconfig_up4() { + local _if _if=$1 - ifalias_up ${_if} + ifalias_up4 ${_if} ipv4_addrs_common ${_if} alias } -# ipv4_down if -# remove IPv4 addresses from the interface $if -ipv4_down() +# post_ifconfig_down4 if +# Remove IPv4 addresses from the interface $if +post_ifconfig_down4() { + local _if _ifs _ret + _if=$1 _ifs="^" _ret=1 @@ -304,17 +482,19 @@ done IFS="$oldifs" - ifalias_down ${_if} && _ret=0 + ifalias_down4 ${_if} && _ret=0 ipv4_addrs_common ${_if} -alias && _ret=0 return $_ret } # ipv4_addrs_common if action -# Evaluate the ifconfig_if_ipv4 arguments for interface $if +# Evaluate the ipv4_ifconfig_IF arguments for interface $if # and use $action to add or remove IPv4 addresses from $if. ipv4_addrs_common() { + local _ret _if _action + _ret=1 _if=$1 _action=$2 @@ -350,17 +530,18 @@ return $_ret } -# ifalias_up if -# Configure aliases for network interface $if. +# ifalias_up4 if +# Configure IPv4 aliases for network interface $if. # It returns 0 if at least one alias was configured or # 1 if there were none. # -ifalias_up() +ifalias_up4() { + local _ret alias _ret=1 alias=0 while : ; do - ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}` + ifconfig_args=`get_if_var $1 ipv4_ifconfig_IF_alias${alias}` if [ -n "${ifconfig_args}" ]; then ifconfig $1 ${ifconfig_args} alias alias=$((${alias} + 1)) @@ -372,17 +553,18 @@ return $_ret } -#ifalias_down if -# Remove aliases for network interface $if. +#ifalias_down4 if +# Remove IPV4 aliases for network interface $if. # It returns 0 if at least one alias was removed or # 1 if there were none. # -ifalias_down() +ifalias_down4() { + local _ret alias _ret=1 alias=0 while : ; do - ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}` + ifconfig_args=`get_if_var $1 ipv4_ifconfig_IF_alias${alias}` if [ -n "${ifconfig_args}" ]; then ifconfig $1 ${ifconfig_args} -alias alias=$((${alias} + 1)) @@ -394,6 +576,80 @@ return $_ret } +# delete_addrs6 if +# Remove IPv6 addresses from interface $if. +# +delete_addrs6() +{ + local _if _inet _ret inetList + _if=$1 + _ret=1 + + ifexists ${_if} || return 1 + + inetList="`ifconfig ${_if} | grep 'inet6 ' | cut -f2 -d ' ' | tr "\n" ' '`" + + for _inet in $inetList ; do + ifconfig ${_if} inet6 ${_inet} delete + _ret=0 + done + + return $_ret +} + +# ifalias_up6 +# Configure IPv6 aliases for network interface $if. +# It returns 0 if at least one alias was configured or +# 1 if there were none. +# +ifalias_up6() +{ + local _ret alias + _ret=1 + alias=0 + while : ; do + ifconfig_args=`get_if_var $1 ipv6_ifconfig_IF_alias${alias}` + if [ -z "${ifconfig_args}" ]; then + break; + fi + ifconfig $1 inet6 ${ifconfig_args} alias + alias=$((${alias} + 1)) + _ret=0 + done +} + +# post_ifconfig_up6 if +# Add IPv6 addresses to the interface $if +post_ifconfig_up6() +{ + local _if + _if=$1 + ifalias_up6 ${_if} +} + +#ifalias_down6 if +# Remove IPv6 aliases for network interface $if. +# It returns 0 if at least one alias was removed or +# 1 if there were none. +# +ifalias_down6() +{ + local _ret alias + _ret=1 + alias=0 + while : ; do + ifconfig_args=`get_if_var $1 ipv6_ifconfig_IF_alias${alias}` + if [ -n "${ifconfig_args}" ]; then + ifconfig inet6 $1 ${ifconfig_args} -alias + alias=$((${alias} + 1)) + _ret=0 + else + break + fi + done + return $_ret +} + # ifscript_up if # Evaluate a startup script for the $if interface. # It returns 0 if a script was found and processed or @@ -610,69 +866,85 @@ # List all network interfaces. The type of interface returned # can be controlled by the type argument. The type # argument can be any of the following: +# ipv4 - all IPv4 interfaces +# ipv6 - all IPv6 interfaces # nodhcp - all interfaces, excluding DHCP configured interfaces # dhcp - list only DHCP configured interfaces -# If no argument is specified all network interfaces are output. +# dhcp4 - list only DHCP configured IPv4 interfaces +# dhcp6 - list only DHCP configured IPv6 interfaces +# If no argument is specified all IPv4 network interfaces are +# output (to mimic behaviour in earlier versions). # Note that the list will include cloned interfaces if applicable. # Cloned interfaces must already exist to have a chance to appear -# in the list if ${network_interfaces} is set to `auto'. +# in the list. # list_net_interfaces() { + local _autolist _list4 _list6 _lo4 _lo6 _lodhcp _lodchp4 _lodchp6 _anydhcplist _dhcp4list _dhcp6list _nodhcplist type + type=$1 + _lo4= + _lo6= + _lodhcp= + _lodhcp4= + _lodhcp6= + _andydhcplist= + _dhcp4list= + _dhcp6list= + _nodhcplist= - # Get a list of ALL the interfaces and make lo0 first if it's there. + # Get a list of interfaces and make lo0 first if it's there. # - case ${network_interfaces} in - [Aa][Uu][Tt][Oo]) - _prefix='' - _autolist="`ifconfig -l`" - _lo= - for _if in ${_autolist} ; do - if autoif $_if; then - if [ "$_if" = "lo0" ]; then - _lo="lo0 " - else - _tmplist="${_tmplist}${_prefix}${_if}" - [ -z "$_prefix" ] && _prefix=' ' - fi - fi - done - _tmplist="${_lo}${_tmplist}" - ;; - *) - _tmplist="${network_interfaces} ${cloned_interfaces}" - ;; - esac - - if [ -z "$type" ]; then - echo $_tmplist - return 0 - fi - - # Separate out dhcp and non-dhcp interfaces - # - _aprefix= - _bprefix= - for _if in ${_tmplist} ; do - if dhcpif $_if; then - _dhcplist="${_dhcplist}${_aprefix}${_if}" - [ -z "$_aprefix" ] && _aprefix=' ' - elif [ -n "`_ifconfig_getargs $_if`" ]; then - _nodhcplist="${_nodhcplist}${_bprefix}${_if}" - [ -z "$_bprefix" ] && _bprefix=' ' + _autolist="`ifconfig -l`" + for _if in ${_autolist} ; do + if ! autoif $_if; then + continue fi + if [ "$_if" = "lo0" ]; then + ipv4if $_if && _lo4="lo0 " + ipv6if $_if && _lo6="lo0 " + dhcpif $_if && _lodhcp="lo0 " + dhcpif4 $_if && _lodhcp4="lo0 " + dhcpif6 $_if && _lodhcp6="lo0 " + dhcpif $_if || _lonodhcp="lo0 " + else + ipv4if $_if && _list4="${_list4} ${_if}" + ipv6if $_if && _list6="${_list6} ${_if}" + dhcpif $_if && _anydhcplist="${_anydhcplist} ${_if}" + dhcpif4 $_if && _dhcp4list="${_dhcp4list} ${_if}" + dhcpif6 $_if && _dhcp6list="${_dhcp6list} ${_if}" + dhcpif $_if || _nodhcplist="${_nodhcplist} ${_if}" + fi done + _list4="${_lo4}${_list4}" + _list6="${_lo6}${_list6}" + _anydhcplist="${_lodhcp}${_anydhcplist}" + _dhcp4list="${_lodhcp4}${_dhcp4list}" + _dhcp6list="${_lodhcp6}${_dhcp6list}" + _nodhcplist="${_lonodhcp}${_nodhcplist}" case "$type" in - nodhcp) - echo $_nodhcplist + ipv4|'') + echo ${_list4} ;; + ipv6) + echo ${_list6} + ;; dhcp) - echo $_dhcplist + echo ${_anydhcplist} ;; + nodhcp) + echo ${_nodhcplist} + ;; + dhcp4) + echo ${_dhcp4list} + ;; + dhcp6) + echo ${_dhcp6list} + ;; esac - return 0 + + return } hexdigit() @@ -708,91 +980,99 @@ echo ${str} } -# Setup the interfaces for IPv6 -network6_interface_setup() +# ifconfig_up6 if +# Configure IPv6 interface of $if. Returns 0 if any kind of configuration +# was done or 1 if route solicitation should be done on the interface. +# May modify global variable $rtsol_interface. +# +ifconfig_up6() { - interfaces=$* - rtsol_interfaces='' - case ${ipv6_gateway_enable} in - [Yy][Ee][Ss]) - rtsol_available=no - ;; - *) - rtsol_available=yes - ;; - esac - for i in $interfaces; do - rtsol_interface=yes - prefix=`get_if_var $i ipv6_prefix_IF` - if [ -n "${prefix}" ]; then - rtsol_available=no - rtsol_interface=no - laddr=`network6_getladdr $i` - hostid=`expr "${laddr}" : 'fe80::\(.*\)%\(.*\)'` - for j in ${prefix}; do - address=$j\:${hostid} - ifconfig $i inet6 ${address} prefixlen 64 alias + local prefix nortsol retval + dortsol=true + retval=0 - case ${ipv6_gateway_enable} in - [Yy][Ee][Ss]) - # subnet-router anycast address - # (rfc2373) - ifconfig $i inet6 $j:: prefixlen 64 \ - alias anycast - ;; - esac - done - fi - ipv6_ifconfig=`get_if_var $i ipv6_ifconfig_IF` - if [ -n "${ipv6_ifconfig}" ]; then - rtsol_available=no - rtsol_interface=no - ifconfig $i inet6 ${ipv6_ifconfig} alias - fi + # Configure interfaces with manually specified prefixes. + # + prefix=`get_if_var $1 ipv6_prefix_IF` + if [ -n "${prefix}" ]; then + dortsol=false + laddr=`network6_getladdr $1` + hostid=`expr "${laddr}" : 'fe80::\(.*\)%\(.*\)'` + for j in ${prefix}; do + address=$j\:${hostid} + ifconfig $1 inet6 ${address} prefixlen 64 alias - if [ ${rtsol_available} = yes -a ${rtsol_interface} = yes ] - then - case ${i} in - lo0|gif[0-9]*|stf[0-9]*|faith[0-9]*|lp[0-9]*|sl[0-9]*|tun[0-9]*|pflog[0-9]*|pfsync[0-9]*) - ;; - *) - rtsol_interfaces="${rtsol_interfaces} ${i}" - ;; - esac - else - ifconfig $i inet6 - fi - done + if checkyesno ipv6_gateway_enable; then + # subnet-router anycast address + # (rfc2373) + ifconfig $1 inet6 $j:: prefixlen 64 \ + alias anycast + fi + done + fi - if [ ${rtsol_available} = yes -a -n "${rtsol_interfaces}" ]; then + # Configure ifconfig_IF knob. If it has an ifconfig_IF knob + # then, we should not do route solicitation on it. + # + if _ifconfig_up $1 ipv6; then + dortsol=false + fi + + if ${dortsol} && ! checkyesno ipv6_gateway_enable; then + rtsol_interface=$1 + retval=1 + fi + + return ${retval} +} + +# ifconfig_down6 if +# +ifconfig_down6() +{ + delete_addrs6 $1 && return 0 || return 1 +} + +# rtsol_up if +# If variable $rtsol_interface is defined and it matches $if +# this subroutine will configure route solicitation on it. +# Returns 0 if rtsol was done, or 1 otherwise. +# +# Reads, but does not modify global variable $rtsol_interface. +# May modify global variable $rtsol_done. +# +rtsol_up() +{ + [ -z "${rtsol_interface}" ] && return 1 + ${rtsol_done} && return 1 + [ "$1" != "${rtsol_interface}" ] && return 1 + + case ${rtsol_interface} in + lo0|gif[0-9]*|stf[0-9]*|faith[0-9]*|lp[0-9]*|sl[0-9]*|tun[0-9]*|pflog[0-9]*|pfsync[0-9]*) + ;; + *) # Act as endhost - automatically configured. # You can configure only single interface, as # specification assumes that autoconfigured host has # single interface only. sysctl net.inet6.ip6.accept_rtadv=1 - set ${rtsol_interfaces} - ifconfig $1 up - rtsol ${rtsol_flags} $1 - fi - - for i in $interfaces; do - alias=0 - while : ; do - ipv6_ifconfig=`get_if_var $i ipv6_ifconfig_IF_alias${alias}` - if [ -z "${ipv6_ifconfig}" ]; then - break; - fi - ifconfig $i inet6 ${ipv6_ifconfig} alias - alias=$((${alias} + 1)) - done - done + rtsol ${rtsol_flags} ${rtsol_interface} + rtsol_done=true + return 0 + ;; + esac } # Setup IPv6 to IPv4 mapping -network6_stf_setup() +stf_up() { + local ipv6_network_interfaces + + ipv6_network_interfaces="`working_ipv6_interfaces`" + case ${stf_interface_ipv4addr} in [Nn][Oo] | '') + return 1 ;; *) # assign IPv6 addr and interface route for 6to4 interface @@ -835,34 +1115,12 @@ route add -inet6 2002:ff00:: -prefixlen 24 ::1 -reject ;; esac -} -# Setup static routes -network6_static_routes_setup() -{ - # Set up any static routes. - case ${ipv6_defaultrouter} in - [Nn][Oo] | '') - ;; - *) - ipv6_static_routes="default ${ipv6_static_routes}" - ipv6_route_default="default ${ipv6_defaultrouter}" - ;; - esac - case ${ipv6_static_routes} in - [Nn][Oo] | '') - ;; - *) - for i in ${ipv6_static_routes}; do - ipv6_route_args=`get_if_var $i ipv6_route_IF` - route add -inet6 ${ipv6_route_args} - done - ;; - esac + return 0 } # Setup faith -network6_faith_setup() +faith_up() { case ${ipv6_faith_prefix} in [Nn][Oo] | '') @@ -892,8 +1150,12 @@ # Install the "default interface" to kernel, which will be used # as the default route when there's no router. -network6_default_interface_setup() +default_interface_up() { + local ipv6_network_interfaces + + ipv6_network_interfaces="`working_ipv6_interfaces`" + # Choose IPv6 default interface if it is not clearly specified. case ${ipv6_default_interface} in '') @@ -933,16 +1195,12 @@ # net.inet6.ip6.accept_rtadv=0, due to avoid conflict # between the default router list and the manual # configured default route. - case ${ipv6_gateway_enable} in - [Yy][Ee][Ss]) - ;; - *) - if [ `sysctl -n net.inet6.ip6.accept_rtadv` -eq 1 ] + if ! checkyesno ipv6_gateway_enable; then + if [ `sysctl -n net.inet6.ip6.accept_rtadv` -eq 1 ]; then ndp -I ${ipv6_default_interface} fi - ;; - esac + fi ;; esac } @@ -970,3 +1228,35 @@ esac done } + +# working_ipv6_interfaces +# Echoes to standard output a list of valid IPv6 interfaces. In the +# case that this host acts as a router the list will contain only +# those interfaces on which initialization did not fail. +# +working_ipv6_interfaces() +{ + local ipv6_working_interfaces ipv6ifs + + ipv6ifs="`list_net_interfaces ipv6`" + + if checkyesno ipv6_gateway_enable; then + # Filter out interfaces on which IPv6 initialization failed. + # + ipv6_working_interfaces="" + for i in ${ipv6ifs}; do + laddr=`network6_getladdr $i exclude_tentative` + case ${laddr} in + '') + ;; + *) + ipv6_working_interfaces="$i \ + ${ipv6_working_interfaces}" + ;; + esac + done + echo ${ipv6_working_interfaces} + else + echo ${ipv6ifs} + fi +} Index: etc/rc.d/NETWORKING =================================================================== --- etc/rc.d/NETWORKING (.../vendor/FreeBSD/src) (revision 106) +++ etc/rc.d/NETWORKING (.../branches/rcd_ipv6) (revision 106) @@ -5,7 +5,7 @@ # # PROVIDE: NETWORKING NETWORK -# REQUIRE: netif netoptions routing network_ipv6 isdnd ppp +# REQUIRE: netif netoptions routing isdnd ppp ip6addrctl # REQUIRE: routed mrouted route6d mroute6d resolv # This is a dummy dependency, for services which require networking Index: etc/rc.d/dhclient =================================================================== --- etc/rc.d/dhclient (.../vendor/FreeBSD/src) (revision 106) +++ etc/rc.d/dhclient (.../branches/rcd_ipv6) (revision 106) @@ -28,17 +28,17 @@ fi # Override for $ifn specific flags (see rc.subr for $flags setting) - specific=`get_if_var $ifn dhclient_flags_IF` + specific=`get_if_var $ifn ipv4_dhclient_flags_IF` if [ -z "$flags" -a -n "$specific" ]; then rc_flags=$specific fi - background_dhclient=`get_if_var $ifn background_dhclient_IF $background_dhclient` + background_dhclient=`get_if_var $ifn ipv4_background_dhclient_IF $background_dhclient` if checkyesno background_dhclient; then rc_flags="${rc_flags} -b" fi - ${dhclient_program} ${rc_flags} $ifn + ${ipv4_dhclient_program} ${rc_flags} $ifn } dhclient_stop() @@ -51,7 +51,7 @@ load_rc_config $name load_rc_config network -if ! dhcpif $ifn; then +if ! dhcpif4 $ifn; then return 1 fi Index: etc/rc.d/network_ipv6 =================================================================== --- etc/rc.d/network_ipv6 (.../vendor/FreeBSD/src) (revision 106) +++ etc/rc.d/network_ipv6 (.../branches/rcd_ipv6) (revision 106) @@ -30,7 +30,7 @@ # PROVIDE: network_ipv6 # REQUIRE: routing -# KEYWORD: nojail +# KEYWORD: nojail nostart . /etc/rc.subr . /etc/network.subr Index: etc/rc.d/netif =================================================================== --- etc/rc.d/netif (.../vendor/FreeBSD/src) (revision 106) +++ etc/rc.d/netif (.../branches/rcd_ipv6) (revision 106) @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2003 The FreeBSD Project. All rights reserved. +# Copyright (c) 2003,2007 The FreeBSD Project. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -37,11 +37,55 @@ stop_cmd="network_stop" cloneup_cmd="clone_up" clonedown_cmd="clone_down" -extra_commands="cloneup clonedown" +extra_commands="cloneup clonedown start4 start6 stop4 stop6 restart4 restart6" cmdifn= +doIP4=false +doIP6=false +doAll=false + +# The user may specify whether to modify only IPv4 or v6 configuration by +# appending the version number onto the command: start6 stop4 +# +_cmd= +_cmdline= +_userIPv=false +case $1 in +onestart4|onestop4|onerestart4| \ +forcestart4|forcestop4|forcerestart4| \ +faststart4|faststop4|fastrestart4| \ +start4|stop4|restart4) + doIP4=true + _userIPv=true + _cmd=`expr $1 : '\(.*\)[46]$'` + ;; +onestart6|onestop6|onerestart6| \ +forcestart6|forcestop6|forcerestart6| \ +faststart6|faststop6|fastrestart6| \ +start6|stop6|restart6) + doIP6=true + _userIPv=true + _cmd=`expr $1 : '\(.*\)[46]$'` + ;; +*) + _cmd="$1" + ;; +esac +shift +_cmdline="$*" +if ! ${_userIPv}; then + doIP4=true + doIP6=true + doAll=true # for non-IP related stuff +fi + network_start() { + local rtsol_interface rtsol_done + # These are used in IPv6 configuration + rtsol_interface= + rtsol_done=false + # Set the list of interfaces to work on. # cmdifn=$* @@ -65,11 +109,44 @@ # Rename interfaces. ifnet_rename + + if ${doIP6} && checkyesno ipv6_enable; then + if checkyesno ipv6_gateway_enable; then + # act as a router + ${SYSCTL_W} net.inet6.ip6.forwarding=1 + ${SYSCTL_W} net.inet6.ip6.accept_rtadv=0 + + # wait for DAD + for i in `list_net_interfaces ipv6`; do + ifconfig $i up + done + sleep `${SYSCTL_N} net.inet6.ip6.dad_count` + sleep 1 + else + # act as endhost + ${SYSCTL_W} net.inet6.ip6.forwarding=0 + fi + fi fi # Configure the interface(s). network_common ifn_start verbose + if [ -z "$cmdifn" ] && ${doIP6} && checkyesno ipv6_enable; then + # wait for DAD's completion (for global addrs) + sleep `${SYSCTL_N} net.inet6.ip6.dad_count` + sleep 1 + + # Implement IPv6 in IPv4 incapsulation + stf_up + + # Install default IPv6 interface + default_interface_up + + # IPv6 to IPv4 TCP relay capturing + faith_up + fi + if [ -f /etc/rc.d/ipfilter ] ; then # Resync ipfilter /etc/rc.d/ipfilter resync @@ -149,6 +226,9 @@ debug "The following interfaces were not configured: $_fail" } +# Global variables rtsol_interface and rtsol_done may be modified +# by subroutines called by this routine. +# ifn_start() { local ifn cfg @@ -157,11 +237,27 @@ [ -z "$ifn" ] && return 1 - ifscript_up ${ifn} && cfg=0 - ifconfig_up ${ifn} && cfg=0 - ipv4_up ${ifn} && cfg=0 - ipx_up ${ifn} && cfg=0 + ${doAll} && ifscript_up ${ifn} && cfg=0 + ${doAll} && ifconfig_up ${ifn} && cfg=0 + # IPv4 + # + if ${doIP4} && checkyesno ipv4_enable && ipv4if ${ifn}; then + ifconfig_up4 ${ifn} && cfg=0 + post_ifconfig_up4 ${ifn} && cfg=0 + fi + + ${doAll} && ipx_up ${ifn} && cfg=0 + + # IPv6 + # + if ${doIP6} && checkyesno ipv6_enable && ipv6if ${ifn}; then + rtsol_interface= + ifconfig_up6 ${ifn} && cfg=0 + rtsol_up ${ifn} && cfg=0 + post_ifconfig_up6 ${ifn} && cfg=0 + fi + return $cfg } @@ -173,13 +269,19 @@ [ -z "$ifn" ] && return 1 - ipx_down ${ifn} && cfg=0 - ipv4_down ${ifn} && cfg=0 - ifconfig_down ${ifn} && cfg=0 - ifscript_down ${ifn} && cfg=0 + if ${doIP6} && checkyesno ipv6_enable && ipv6if ${ifn}; then + ifconfig_down6 ${ifn} && cfg=0 + fi + ${doAll} && ipx_down ${ifn} && cfg=0 + if ${doIP4} && checkyesno ipv4_enable && ipv4if ${ifn}; then + post_ifconfig_down4 ${ifn} && cfg=0 + ifconfig_down4 ${ifn} && cfg=0 + fi + ${doAll} && ifconfig_down ${ifn} && cfg=0 + ${doAll} && ifscript_down ${ifn} && cfg=0 return $cfg } load_rc_config $name -run_rc_command $* +run_rc_command ${_cmd} ${_cmdline} Index: etc/rc.d/devd =================================================================== --- etc/rc.d/devd (.../vendor/FreeBSD/src) (revision 106) +++ etc/rc.d/devd (.../branches/rcd_ipv6) (revision 106) @@ -4,7 +4,7 @@ # # PROVIDE: devd -# REQUIRE: netif network_ipv6 +# REQUIRE: netif # BEFORE: NETWORKING mountcritremote # KEYWORD: nojail Index: etc/rc.d/mroute6d =================================================================== --- etc/rc.d/mroute6d (.../vendor/FreeBSD/src) (revision 106) +++ etc/rc.d/mroute6d (.../branches/rcd_ipv6) (revision 106) @@ -4,7 +4,7 @@ # # PROVIDE: mroute6d -# REQUIRE: network_ipv6 +# REQUIRE: netif # KEYWORD: nojail . /etc/rc.subr Index: etc/rc.d/ip6addrctl =================================================================== --- etc/rc.d/ip6addrctl (.../vendor/FreeBSD/src) (revision 106) +++ etc/rc.d/ip6addrctl (.../branches/rcd_ipv6) (revision 106) @@ -5,7 +5,6 @@ # PROVIDE: ip6addrctl # REQUIRE: FILESYSTEMS netif -# BEFORE: network_ipv6 # KEYWORD: nojail . /etc/rc.subr Index: etc/rc.d/natd =================================================================== --- etc/rc.d/natd (.../vendor/FreeBSD/src) (revision 106) +++ etc/rc.d/natd (.../branches/rcd_ipv6) (revision 106) @@ -19,7 +19,7 @@ natd_precmd() { if [ -n "${natd_interface}" ]; then - dhcp_list="`list_net_interfaces dhcp`" + dhcp_list="`list_net_interfaces dhcp4`" for ifn in ${dhcp_list}; do case "${natd_interface}" in ${ifn}) Index: etc/rc.d/route6d =================================================================== --- etc/rc.d/route6d (.../vendor/FreeBSD/src) (revision 106) +++ etc/rc.d/route6d (.../branches/rcd_ipv6) (revision 106) @@ -5,7 +5,7 @@ # # PROVIDE: route6d -# REQUIRE: network_ipv6 +# REQUIRE: netif # KEYWORD: nojail . /etc/rc.subr Index: etc/rc.d/ip6fw =================================================================== --- etc/rc.d/ip6fw (.../vendor/FreeBSD/src) (revision 106) +++ etc/rc.d/ip6fw (.../branches/rcd_ipv6) (revision 106) @@ -5,7 +5,7 @@ # PROVIDE: ip6fw # REQUIRE: routing -# BEFORE: network_ipv6 +# BEFORE: NETWORKING # KEYWORD: nojail . /etc/rc.subr Index: etc/rc.d/routed =================================================================== --- etc/rc.d/routed (.../vendor/FreeBSD/src) (revision 106) +++ etc/rc.d/routed (.../branches/rcd_ipv6) (revision 106) @@ -17,7 +17,7 @@ # subroutines in rc.subr won't catch it. # load_rc_config $name -rcvar="router_enable" -command="${router:-/sbin/${name}}" -eval ${name}_flags=\"${router_flags}\" +rcvar="ipv4_router_enable" +command="${ipv4_router:-/sbin/${name}}" +eval ${name}_flags=\"${ipv4_router_flags}\" run_rc_command "$1" Index: etc/rc.d/routing =================================================================== --- etc/rc.d/routing (.../vendor/FreeBSD/src) (revision 106) +++ etc/rc.d/routing (.../branches/rcd_ipv6) (revision 106) @@ -1,10 +1,35 @@ #!/bin/sh # -# Configure routing and miscellaneous network tunables +# Copyright (c) 2007 The FreeBSD Project. All rights reserved. +# Copyright (c) 2000 The KAME Project. All rights reserved. # +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# # $FreeBSD: src/etc/rc.d/routing,v 1.143 2007/05/02 15:49:30 mtm Exp $ # +# Configure IPv4/IPv6 static routing and miscellaneous network tunables +# + # PROVIDE: routing # REQUIRE: netif ppp # KEYWORD: nojail @@ -17,7 +42,41 @@ extra_commands="options static" static_cmd="static_start" options_cmd="options_start" +doIP4=false +doIP6=false +doAll=false + +# The user may specify whether to modify only IPv4 or v6 configuration by +# appending the version number onto the command: start6 stop4 +# +_cmd= +_cmdline= +_userIPv=false +case $1 in +start4|stop4|restart4|options4|static4) + doIP4=true + _userIPv=true + _cmd=`expr $1 : '\(.*\)[46]$'` + ;; +start6|stop6|restart6|options6|static6) + doIP6=true + _userIPv=true + _cmd=`expr $1 : '\(.*\)[46]$'` + ;; +*) + _cmd="$1" + ;; +esac +shift +_cmdline="$*" +if ! ${_userIPv}; then + doIP4=true + doIP6=true + doAll=true # for non-IP routing information +fi + + routing_start() { static_start @@ -26,25 +85,42 @@ routing_stop() { - route -n flush + if ${doAll}; then + route -n flush + else + ${doIP4} && route -n flush -inet + ${doIP6} && route -n flush -inet6 + fi } static_start() { - case ${defaultrouter} in + ${doIP4} && ipv4_static_start + ${doIP6} && ipv6_static_start +} + +options_start() +{ + ${doIP4} && ipv4_options_start + ${doIP6} && ipv6_options_start +} + +ipv4_static_start() +{ + case ${ipv4_defaultrouter} in [Nn][Oo] | '') ;; *) - static_routes="default ${static_routes}" - route_default="default ${defaultrouter}" + ipv4_static_routes="default ${ipv4_static_routes}" + ipv4_route_default="default ${ipv4_defaultrouter}" ;; esac # Setup static routes. This should be done before router discovery. # - if [ -n "${static_routes}" ]; then - for i in ${static_routes}; do - eval route_args=\$route_${i} + if [ -n "${ipv4_static_routes}" ]; then + for i in ${ipv4_static_routes}; do + eval route_args=\$ipv4_route_${i} route add ${route_args} done fi @@ -58,8 +134,46 @@ fi } -options_start() +ipv6_static_start() { + checkyesno ipv6_enable || return + + # disallow "internal" addresses to appear on the wire + route add -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject + route add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject + + # Setup default router + # + case ${ipv6_defaultrouter} in + [Nn][Oo] | '') + ;; + *) + ipv6_static_routes="default ${ipv6_static_routes}" + ipv6_route_default="default ${ipv6_defaultrouter}" + ;; + esac + for i in ${ipv6_static_routes}; do + route_args=\$ipv6_route_${i} + route add -inet6 ${route_args} + done +} + +ipv6_options_start() +{ + checkyesno ipv6_enable || return + + # Support for IPv4 address tacked onto an IPv6 address + if checkyesno ipv6_ipv4mapping; then + echo 'IPv4 mapped IPv6 address support=YES' + ${SYSCTL_W} net.inet6.ip6.v6only=0 >/dev/null + else + echo 'IPv4 mapped IPv6 address support=NO' + ${SYSCTL_W} net.inet6.ip6.v6only=1 >/dev/null + fi +} + +ipv4_options_start() +{ echo -n 'Additional routing options:' case ${icmp_bmcastecho} in [Yy][Ee][Ss]) @@ -82,9 +196,9 @@ ;; esac - case ${gateway_enable} in + case ${ipv4_gateway_enable} in [Yy][Ee][Ss]) - echo -n ' IP gateway=YES' + echo -n ' IPv4 gateway=YES' sysctl net.inet.ip.forwarding=1 >/dev/null ;; esac @@ -121,4 +235,4 @@ } load_rc_config $name -run_rc_command "$1" +run_rc_command ${_cmd} ${_cmdline} Index: etc/defaults/rc.conf =================================================================== --- etc/defaults/rc.conf (.../vendor/FreeBSD/src) (revision 106) +++ etc/defaults/rc.conf (.../branches/rcd_ipv6) (revision 106) @@ -103,6 +103,7 @@ #background_dhclient_fxp0="YES" # Start dhcp client on fxp0 in the background. synchronous_dhclient="YES" # Start dhclient directly on configured # interfaces during startup. +#ipv4_synchronous_dhclient="YES" # Start dhclient directly on IPv4 interfaces. firewall_enable="NO" # Set to YES to enable firewall functionality firewall_script="/etc/rc.firewall" # Which script to run to set up the firewall firewall_type="UNKNOWN" # Firewall type (see /etc/rc.firewall) @@ -167,11 +168,14 @@ # NOTE: this violates the TCP specification icmp_drop_redirect="NO" # Set to YES to ignore ICMP REDIRECT packets icmp_log_redirect="NO" # Set to YES to log ICMP REDIRECT packets -network_interfaces="auto" # List of network interfaces (or "auto"). cloned_interfaces="" # List of cloned network interfaces to create. #cloned_interfaces="gif0 gif1 gif2 gif3" # Pre-cloning GENERIC config. -ifconfig_lo0="inet 127.0.0.1" # default loopback device configuration. -#ifconfig_lo0_alias0="inet 127.0.0.254 netmask 0xffffffff" # Sample alias entry. +ifconfig_plip0="NOIPV4 NOIPV6" # Don't ifconfig(8) by default +ifconfig_fwe0="NOIPV4 NOIPV6" # Don't ifconfig(8) by default +ifconfig_fwip0="NOIPV4 NOIPV6" # Don't ifconfig(8) by default +ipv4_enable="YES" # Enable IPv4 configuration of interfaces. +ipv4_ifconfig_lo0="inet 127.0.0.1" # default loopback device configuration. +#ipv4_ifconfig_lo0_alias0="inet 127.0.0.254 netmask 0xffffffff" # Sample alias entry. #ifconfig_ed0_ipx="ipx 0x00010010" # Sample IPX address family entry. #ifconfig_fxp0_name="net0" # Change interface name from fxp0 to net0. #ipv4_addrs_fxp0="192.168.0.1/24 192.168.1.1-5/28" # example IPv4 address entry. @@ -314,13 +318,13 @@ bsnmpd_flags="" # Flags for bsnmpd. ### Network routing options: ### -defaultrouter="NO" # Set to default gateway (or NO). -static_routes="" # Set to static route list (or leave empty). +ipv4_defaultrouter="NO" # Set to default gateway (or NO). +ipv4_static_routes="" # Set to static route list (or leave empty). natm_static_routes="" # Set to static route list for NATM (or leave empty). -gateway_enable="NO" # Set to YES if this host will be a gateway. -router_enable="NO" # Set to YES to enable a routing daemon. -router="/sbin/routed" # Name of routing daemon to use if enabled. -router_flags="-q" # Flags for routing daemon. +ipv4_gateway_enable="NO" # Set to YES if this host will be a gateway. +ipv4_router_enable="NO" # Set to YES to enable a routing daemon. +ipv4_router="/sbin/routed" # Name of routing daemon to use if enabled. +ipv4_router_flags="-q" # Flags for routing daemon. mrouted_enable="NO" # Do IPv4 multicast routing. mrouted_program="/usr/local/sbin/mrouted" # Name of IPv4 multicast # routing daemon. You need to @@ -331,7 +335,7 @@ ipxrouted_enable="NO" # Set to YES to run the IPX routing daemon. ipxrouted_flags="" # Flags for IPX routing daemon. arpproxy_all="NO" # replaces obsolete kernel option ARP_PROXYALL. -forward_sourceroute="NO" # do source routing (only if gateway_enable is set to "YES") +forward_sourceroute="NO" # do source routing (only if ipv4_gateway_enable is set to "YES") accept_sourceroute="NO" # accept source routed packets to us ### ATM interface options: ### @@ -372,7 +376,6 @@ ### IPv6 options: ### ipv6_enable="NO" # Set to YES to set up for IPv6. -ipv6_network_interfaces="auto" # List of network interfaces (or "auto"). ipv6_defaultrouter="NO" # Set to IPv6 default gateway (or NO). #ipv6_defaultrouter="2002:c058:6301::" # Use this for 6to4 (RFC 3068) ipv6_static_routes="" # Set to static route list (or leave empty). @@ -387,9 +390,6 @@ # addrs. #ipv6_router_flags="-q" # If you want to run a routing daemon on an end # node, you should stop advertisement. -#ipv6_network_interfaces="ed0 ep0" # Examples for router - # or static configuration for end node. - # Choose correct prefix value. #ipv6_prefix_ed0="fec0:0000:0000:0001 fec0:0000:0000:0002" # Examples for rtr. #ipv6_prefix_ep0="fec0:0000:0000:0003 fec0:0000:0000:0004" # Examples for rtr. #ipv6_ifconfig_ed0="fec0:0:0:5::1 prefixlen 64" # Sample manual assign entry Index: etc/rc.subr =================================================================== --- etc/rc.subr (.../vendor/FreeBSD/src) (revision 106) +++ etc/rc.subr (.../branches/rcd_ipv6) (revision 106) @@ -896,6 +896,92 @@ } # +# old2new_knobs +# Provide support for recognizing old/deprecated knobs and setting +# the appropriate new knobs with their values. +# +old2new_knobs() +{ + local i j wrd ifargs + + # Part of consolidation of IPv4 and IPv6 configuration + # + if [ -n "${network_interfaces}" ]; then + warn "network_interfaces variable was replaced with the NOIPV4 keyword. See rc.conf(5)." + fi + if [ -n "${ipv6_network_interfaces}" ]; then + warn "ipv6_network_interfaces variable was replaced with the NOIPV6 keyword. See rc.conf(5)." + fi + for i in `ifconfig -l`; do + + # ifconfig_ + eval ifargs=\"\$ifconfig_${i}\" + if [ -n "${ifargs}" ]; then + for wrd in $ifargs; do + case $wrd in + inet|netmask|broadcast|alias|-alias|remove| \ + inet6|anycast|eui64|prefixlen|[Dd][Hh][Cc][Pp]) + warn "IP configuration related arguments may not be set in ifconfig_${i}. See rc.conf(5)." + break + ;; + esac + done + fi + + # ifconfig__alias + # + eval ifargs=\"\$ifconfig_${i}_alias0\" + if [ -n "${ifargs}" ]; then + warn "One or more ifconfig_${i}_alias variables set. Please use IP protocol specific variables. See rc.conf(5)" + fi + + # static_routes_XXX + # Used in etc/pccard_ether to setup static routes + # specified for interface XXX. + # + eval ifargs=\"\$static_routes_${i}\" + if [ -n "${ifargs}" ]; then + eval ipv4_static_routes_${i}=\"${ifargs}\" + for j in ${ifargs}; do + eval ipv4_route_${j}=\"\$route_${j}\" + done + fi + + # per-interface dhclient_flags + # + eval ifargs=\"\$dhclient_flags_${i}\" + if [ -n "${ifargs}" ]; then + eval ipv4_dhclient_flags_${i}=\"${ifargs}\" + fi + eval ifargs=\"\$background_dhclient_${i}\" + if [ -n "${ifargs}" ]; then + eval ipv4_background_dhclient_${i}=\"${ifargs}\" + fi + done + if [ -n "${ifconfig_DEFAULT}" ]; then + for wrd in ${ifconfig_DEFAULT}; do + case $wrd in + inet|netmask|broadcast|alias|-alias|remove| \ + inet6|anycast|eui64|prefixlen|[Dd][Hh][Cc][Pp]) + warn "IP configuration related arguments may not be set in ifconfig_DEFAULT. See rc.conf(5)." + ;; + esac + done + fi + [ -n "${dhclient_program}" ] && ipv4_dhclient_program="${dhclient_program}" + [ -n "${dhclient_flags}" ] && ipv4_dhclient_flags="${dhclient_flags}" + [ -n "${gateway_enable}" ] && ipv4_gateway_enable="${gateway_enable}" + [ -n "${router_enable}" ] && ipv4_router_enable="${router_enable}" + [ -n "${router}" ] && ipv4_router="${router}" + ipv4_router_flags="${router_flags-${ipv4_router_flags}}" + [ -n "${defaultrouter}" ] && ipv4_defaultrouter="${defaultrouter}" + [ -n "${static_routes}" ] && ipv4_static_routes="${static_routes}" + for i in ${static_routes}; do + eval ipv4_route_${i}="\$route_${i}" + done +} + +# # load_rc_config name # Source in the configuration file for a given name. # @@ -923,6 +1009,10 @@ debug "Sourcing /etc/rc.conf.d/${_name}" . /etc/rc.conf.d/"$_name" fi + + # XXX - Deprecated variable name support + # + old2new_knobs } # Index: etc/pccard_ether =================================================================== --- etc/pccard_ether (.../vendor/FreeBSD/src) (revision 106) +++ etc/pccard_ether (.../branches/rcd_ipv6) (revision 106) @@ -20,26 +20,26 @@ setup_routes() { - # Add default route into $static_routes - case ${defaultrouter} in + # Add default route into $ipv4_static_routes + case ${ipv4_defaultrouter} in [Nn][Oo] | '') ;; *) - static_routes="default ${static_routes}" - route_default="default ${defaultrouter}" + ipv4_static_routes="default ${ipv4_static_routes}" + ipv4_route_default="default ${ipv4_defaultrouter}" ;; esac - # Add private route for this interface into $static_routes - eval ifx_routes=\$static_routes_${ifn} + # Add private route for this interface into $ipv4_static_routes + eval ifx_routes=\$ipv4_static_routes_${ifn} if [ -n "${ifx_routes}" ]; then - static_routes="${ifx_routes} ${static_routes}" + ipv4_static_routes="${ifx_routes} ${ipv4_static_routes}" fi # Set up any static routes if specified - if [ -n "${static_routes}" ]; then - for i in ${static_routes}; do - eval route_args=\$route_${i} + if [ -n "${ipv4_static_routes}" ]; then + for i in ${ipv4_static_routes}; do + eval route_args=\$ipv4_route_${i} route add ${route_args} done fi @@ -48,10 +48,10 @@ remove_routes() { # Delete static route if specified - eval ifx_routes=\$static_routes_${ifn} + eval ifx_routes=\$ipv4_static_routes_${ifn} if [ -n "${ifx_routes}" ]; then for i in ${ifx_routes}; do - eval route_args=\$route_${i} + eval route_args=\$ipv4_route_${i} route delete ${route_args} done fi @@ -61,7 +61,7 @@ { if [ -z "$rc_force" ]; then # Ignore interfaces with the NOAUTO keyword - autoif $ifn || exit 0 + autoif $ifn ipv4 || exit 0 fi } @@ -82,8 +82,8 @@ # Do route configuration if needed. # XXX: should probably do this by calling rc.d/routing. - if [ -n "`ifconfig_getargs $ifn`" ]; then - if ! dhcpif $ifn; then + if [ -n "`ifconfig_getargs $ifn ipv4`" ]; then + if ! dhcpif4 $ifn; then setup_routes fi fi @@ -93,8 +93,8 @@ pccard_ether_stop() { - if [ -n "`ifconfig_getargs $ifn`" ]; then - if ! dhcpif $ifn; then + if [ -n "`ifconfig_getargs $ifn ipv4`" ]; then + if ! dhcpif4 $ifn; then remove_routes fi fi Index: etc/netstart =================================================================== --- etc/netstart (.../vendor/FreeBSD/src) (revision 106) +++ etc/netstart (.../branches/rcd_ipv6) (revision 106) @@ -54,7 +54,6 @@ /etc/rc.d/ppp start /etc/rc.d/ipfw start /etc/rc.d/ip6fw start -/etc/rc.d/network_ipv6 start /etc/rc.d/routing start /etc/rc.d/mroute6d start /etc/rc.d/route6d start