Date: Tue, 29 Dec 2009 21:03:36 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r201215 - in head: etc etc/defaults share/man/man5 Message-ID: <200912292103.nBTL3aw2035945@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Tue Dec 29 21:03:36 2009 New Revision: 201215 URL: http://svn.freebsd.org/changeset/base/201215 Log: 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 Modified: head/etc/defaults/rc.conf head/etc/network.subr head/share/man/man5/rc.conf.5 Modified: head/etc/defaults/rc.conf ============================================================================== --- head/etc/defaults/rc.conf Tue Dec 29 20:30:50 2009 (r201214) +++ head/etc/defaults/rc.conf Tue Dec 29 21:03:36 2009 (r201215) @@ -213,6 +213,8 @@ ifconfig_lo0="inet 127.0.0.1" # default #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. Modified: head/etc/network.subr ============================================================================== --- head/etc/network.subr Tue Dec 29 20:30:50 2009 (r201214) +++ head/etc/network.subr Tue Dec 29 21:03:36 2009 (r201215) @@ -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 Modified: head/share/man/man5/rc.conf.5 ============================================================================== --- head/share/man/man5/rc.conf.5 Tue Dec 29 20:30:50 2009 (r201214) +++ head/share/man/man5/rc.conf.5 Tue Dec 29 21:03:36 2009 (r201215) @@ -1156,6 +1156,45 @@ and variables. .Pp If a +.Va vlans_ Ns Aq Ar interface +variable is set, +a +.Xr vlan 4 +interface will be created for each item in the list with the +.Ar vlandev +argument set to +.Ar interface . +If a vlan interface's name is a number, +then that number is used as the vlan tag and the new vlan interface is +named +.Ar interface . Ns Ar tag . +Otherwise, +the vlan tag must be specified via a +.Va vlan +parameter in the +.Va create_args_ Ns Aq Ar interface +variable. +.Pp +To create a vlan device named +.Li em0.101 +on +.Li em0 +with the vlan tag 101: +.Bd -literal +vlans_em0="101" +.Ed +.Pp +To create a vlan device named +.Li myvlan +on +.Li em0 +with the vlan tag 102: +.Bd -literal +vlans_em0="myvlan" +create_args_myvlan="vlan 102" +.Ed +.Pp +If a .Va wlans_ Ns Aq Ar interface variable is set, an @@ -1222,7 +1261,7 @@ Finally, you can add options in this variable, in addition to the .Pa /etc/start_if. Ns Aq Ar interface file. -For instance, configure an +For instance, to configure an .Xr ath 4 wireless device in station mode with an address obtained via DHCP, using WPA authentication and 802.11b mode, it is @@ -1244,7 +1283,7 @@ This is intended to replace the no longe .Va pccard_ifconfig variable. .Pp -It is also possible to rename interface by doing: +It is also possible to rename an interface by doing: .Bd -literal ifconfig_ed0_name="net0" ifconfig_net0="inet 192.0.2.1 netmask 0xffffff00" @@ -1355,6 +1394,12 @@ the IPv6-preferred one is used. Default .It Va cloned_interfaces .Pq Vt str Set to the list of clonable network interfaces to create on this host. +Further cloning arguments may be passed to the +.Xr ifconfig 8 +.Cm create +command for each interface by setting the +.Va create_args_ Ns Aq Ar interface +variable. Entries in .Va cloned_interfaces are automatically appended to
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200912292103.nBTL3aw2035945>