summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2009-12-29 21:03:36 +0000
committerjhb <jhb@FreeBSD.org>2009-12-29 21:03:36 +0000
commit1265488e3a4d7abd1779d779e75ab20a8c5072d9 (patch)
tree4b0b88bf8b6b03cef8ebeafc2d69db1267fc554f /etc
parentbf4cb685bfd5559b494005cf1e548e11491a58b0 (diff)
downloadFreeBSD-src-1265488e3a4d7abd1779d779e75ab20a8c5072d9.zip
FreeBSD-src-1265488e3a4d7abd1779d779e75ab20a8c5072d9.tar.gz
Add support for configuring vlan(4) interfaces as child devices similar to
wlan(4) interfaces. vlan(4) interfaces are listed via a new 'vlans_<IF>' variable. If a vlan interface is a number, then that number is treated as the vlan tag for the interface and the interface will be named '<IF>.<tag>'. Otherwise, the vlan tag must be provided via a vlan parameter in a 'create_args_<vlan>' variable. While I'm here, fix a few nits in rc.conf(5) and mention create_args_<IF> in the description of cloned_interfaces. Reviewed by: brooks MFC after: 2 weeks
Diffstat (limited to 'etc')
-rw-r--r--etc/defaults/rc.conf2
-rw-r--r--etc/network.subr50
2 files changed, 50 insertions, 2 deletions
diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf
index 19a9a39..fa7f46a 100644
--- a/etc/defaults/rc.conf
+++ b/etc/defaults/rc.conf
@@ -213,6 +213,8 @@ ifconfig_lo0="inet 127.0.0.1" # default loopback device configuration.
#ifconfig_ed0_ipv6="inet6 2001:db8:1::1 prefixlen 64" # Sample IPv6 addr entry
#ifconfig_ed0_alias0="inet6 2001:db8:2::1 prefixlen 64" # Sample IPv6 alias
#ifconfig_fxp0_name="net0" # Change interface name from fxp0 to net0.
+#vlans_fxp0="101 vlan0" # vlan(4) interfaces for fxp0 device
+#create_arg_vlan0="vlan 102" # vlan tag for vlan0 device
#wlans_ath0="wlan0" # wlan(4) interfaces for ath0 device
#wlandebug_wlan0="scan+auth+assoc" # Set debug flags with wlanddebug(8)
#ipv4_addrs_fxp0="192.168.0.1/24 192.168.1.1-5/28" # example IPv4 address entry.
diff --git a/etc/network.subr b/etc/network.subr
index d2c2111..0fcb3df 100644
--- a/etc/network.subr
+++ b/etc/network.subr
@@ -971,7 +971,7 @@ clone_down()
#
childif_create()
{
- local cfg child child_wlans create_args debug_flags ifn i
+ local cfg child child_vlans child_wlans create_args debug_flags ifn i
cfg=1
ifn=$1
@@ -999,6 +999,32 @@ childif_create()
fi
done
+ # Create vlan interfaces
+ child_vlans=`get_if_var $ifn vlans_IF`
+
+ if [ -n "${child_vlans}" ]; then
+ load_kld if_vlan
+ fi
+
+ for child in ${child_vlans}; do
+ if expr $child : '[1-9][0-9]*$' >/dev/null 2>&1; then
+ child="${ifn}.${child}"
+ create_args=`get_if_var $child create_args_IF`
+ ifconfig $child create ${create_args} && cfg=0
+ else
+ create_args="vlandev $ifn `get_if_var $child create_args_IF`"
+ if expr $child : 'vlan[0-9][0-9]*$' >/dev/null 2>&1; then
+ ifconfig $child create ${create_args} && cfg=0
+ else
+ i=`ifconfig vlan create ${create_args}`
+ ifconfig $i name $child && cfg=0
+ fi
+ fi
+ if autoif $child; then
+ ifn_start $child
+ fi
+ done
+
return ${cfg}
}
@@ -1007,11 +1033,31 @@ childif_create()
#
childif_destroy()
{
- local cfg child child_wlans ifn
+ local cfg child child_vlans child_wlans ifn
cfg=1
child_wlans="`get_if_var $ifn wlans_IF` `get_if_var $ifn vaps_IF`"
for child in ${child_wlans}; do
+ if ! ifexists $child; then
+ continue
+ fi
+ if autoif $child; then
+ ifn_stop $child
+ fi
+ ifconfig $child destroy && cfg=0
+ done
+
+ child_vlans=`get_if_var $ifn vlans_IF`
+ for child in ${child_vlans}; do
+ if expr $child : '[1-9][0-9]*$' >/dev/null 2>&1; then
+ child="${ifn}.${child}"
+ fi
+ if ! ifexists $child; then
+ continue
+ fi
+ if autoif $child; then
+ ifn_stop $child
+ fi
ifconfig $child destroy && cfg=0
done
OpenPOWER on IntegriCloud