diff options
author | jhb <jhb@FreeBSD.org> | 2009-12-29 21:03:36 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2009-12-29 21:03:36 +0000 |
commit | 1265488e3a4d7abd1779d779e75ab20a8c5072d9 (patch) | |
tree | 4b0b88bf8b6b03cef8ebeafc2d69db1267fc554f /etc/network.subr | |
parent | bf4cb685bfd5559b494005cf1e548e11491a58b0 (diff) | |
download | FreeBSD-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/network.subr')
-rw-r--r-- | etc/network.subr | 50 |
1 files changed, 48 insertions, 2 deletions
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 |