From novel@FreeBSD.org  Sun Jan 16 18:51:05 2011
Return-Path: <novel@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 84B00106567A
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 16 Jan 2011 18:51:05 +0000 (UTC)
	(envelope-from novel@FreeBSD.org)
Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28])
	by mx1.freebsd.org (Postfix) with ESMTP id 592518FC0C;
	Sun, 16 Jan 2011 18:51:05 +0000 (UTC)
Received: from freefall.freebsd.org (localhost [127.0.0.1])
	by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p0GIp5Yi073365;
	Sun, 16 Jan 2011 18:51:05 GMT
	(envelope-from novel@freefall.freebsd.org)
Received: (from novel@localhost)
	by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p0GIp5Dv073358;
	Sun, 16 Jan 2011 18:51:05 GMT
	(envelope-from novel)
Message-Id: <201101161851.p0GIp5Dv073358@freefall.freebsd.org>
Date: Sun, 16 Jan 2011 18:51:05 GMT
From: Roman Bogorodskiy <novel@freebsd.org>
Reply-To: Roman Bogorodskiy <novel@freebsd.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: vysster@gmail.com
Subject: [ patch ] change to way of auto-generatation of vlan devices based on the chosen parent device
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         154062
>Category:       conf
>Synopsis:       [vlan] [patch] change to way of auto-generatation of vlan devices based on the chosen parent device
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-net
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 16 19:00:18 UTC 2011
>Closed-Date:    
>Last-Modified:  Sat Jan 29 00:01:15 UTC 2011
>Originator:     Roman Bogorodskiy
>Release:        FreeBSD 8.1-STABLE i386
>Organization:
>Environment:

>Description:
	The attached patch modifies the way vlan devices are generated based
	on the chosen parent device (rc.conf:vlans_IFNAME). In case when a name
        of the generated device is implicitly connected to an interface number it's
	split with a dot from a virtual network number. This symbol is not allowed
	in an interface name when referring it from netgraph subsystem and therefore
	it's visible as 'unnamed'.

	The attached patch allows to change a different separator when generating vlan
	device names. It also loads netgraph(4) so interface creation didn't depend on
	current system configuration.

	Consistency of interface names in negraph and ifconfig is required by mpd
        (/usr/ports/net/mpd5). The patch also adds default value to /etc/defauls/rc.conf
        to allow things to be backward-compatible.

	Patch is created and tested on 8.1-RELEASE-p2. The patch is authored by
	Vladimir Stepanov <vysster@gmail.com>, my role is only to help with
	translation and sending of this PR. Please keep both him and me in CC.

>How-To-Repeat:
>Fix:


--- ng_char4vlan.diff begins here ---
*** etc/network.subr.orig	Tue Dec 28 07:48:40 2010
--- etc/network.subr	Wed Dec 29 21:42:21 2010
***************
*** 564,576 ****
  
  	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
--- 564,587 ----
  
  	if [ -n "${child_vlans}" ]; then
  		load_kld if_vlan
+ 		if [ "${ng_char4vlan}" != "." && "${ng_char4vlan}" != ":" ]; then
+ 			load_kld netgraph
+ 		fi
  	fi
  
  	for child in ${child_vlans}; do
  		if expr $child : '[1-9][0-9]*$' >/dev/null 2>&1; then
! 			if [ "${ng_char4vlan}" = "." ]; 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 vlan $child `get_if_var ${ifn}_${child} create_args_IF`"
! 				child="${ifn}${ng_char4vlan}${child}"
! 				i=`ifconfig vlan create ${create_args}`
! 				ngctl name "${i}:" $child
! 				ifconfig $i name $child && cfg=0
! 			fi
  		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
*** etc/defaults/rc.conf.orig	Wed Dec 29 19:47:01 2010
--- etc/defaults/rc.conf	Wed Dec 29 19:48:41 2010
***************
*** 211,216 ****
--- 211,217 ----
  #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.
+ ng_char4vlan="."		# Must be changed for work with netgraph system.
  #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
--- ng_char4vlan.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Jan 29 00:00:29 UTC 2011 
Responsible-Changed-Why:  
Although part of the patch affects rc.d, the overall patch should 
probably be reviewed by -net. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=154062 
>Unformatted:
