From owner-freebsd-bugs@FreeBSD.ORG Fri Jan 27 18:00:28 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C6F8C16A422 for ; Fri, 27 Jan 2006 18:00:28 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5813143D90 for ; Fri, 27 Jan 2006 18:00:16 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k0RI0FaQ031491 for ; Fri, 27 Jan 2006 18:00:15 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k0RI0F6l031490; Fri, 27 Jan 2006 18:00:15 GMT (envelope-from gnats) Resent-Date: Fri, 27 Jan 2006 18:00:15 GMT Resent-Message-Id: <200601271800.k0RI0F6l031490@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Alex Semenyaka Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 670A416A420 for ; Fri, 27 Jan 2006 17:53:44 +0000 (GMT) (envelope-from alexs@snark.rinet.ru) Received: from snark.rinet.ru (snark.rinet.ru [195.54.192.73]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2A59643D6B for ; Fri, 27 Jan 2006 17:53:42 +0000 (GMT) (envelope-from alexs@snark.rinet.ru) Received: from snark.rinet.ru (alexs@localhost.rinet.ru [127.0.0.1]) by snark.rinet.ru (8.13.4/8.13.4) with ESMTP id k0RHsY9S063996; Fri, 27 Jan 2006 20:54:34 +0300 (MSK) (envelope-from alexs@snark.rinet.ru) Received: (from alexs@localhost) by snark.rinet.ru (8.13.4/8.13.4/Submit) id k0RHsYbI063995; Fri, 27 Jan 2006 20:54:34 +0300 (MSK) (envelope-from alexs) Message-Id: <200601271754.k0RHsYbI063995@snark.rinet.ru> Date: Fri, 27 Jan 2006 20:54:34 +0300 (MSK) From: Alex Semenyaka To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: glebius@cell.sick.ru Subject: conf/92433: /etc/nework.subr cannot handle interfaces like bge0.13 properly X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Alex Semenyaka List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jan 2006 18:00:29 -0000 >Number: 92433 >Category: conf >Synopsis: /etc/nework.subr cannot handle interfaces like bge0.13 properly >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Jan 27 18:00:15 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Alex Semenyaka >Release: FreeBSD 6.0-STABLE amd64 >Organization: ZAO "SonicDuo" >Environment: FreeBSD packets-sr2.sonicduo.com 6.0-RELEASE FreeBSD 6.0-RELEASE #0: Thu Nov 3 09:36:13 UTC 2005 root@x64.samsco.home:/usr/obj/usr/src/sys/GENERIC i386 >Description: The interface name like "bge0.13" listed as the cloned interfaces in the /etc/rc.conf cannot be handled by /etc/network.subr properly. Thus interfaces with those names cannot be configured. >How-To-Repeat: 1. Add the interface with the dot in the name to the list of cloned interfaces. 2. Add configuration for it. 3. Run /etc/rc.d/netif start >Fix: 1) Add procedure to trasform interface names with dots with the names without dot. In this way they will be used in the configuration strings of /etc/rc.conf. Example: from "bge0.13" will obtain "bge0_13". The corresponding config-string in /etc/rc.conf will be ifconfig_bge0_13="inet 10.0.13.1 netmask 255.255.255.0" 2) classify procedures from network.subr into the three groups. First group needs real name of the interface only, so we can feed it as is without changes. Second one needs only modifyed name to work with the configuration. Third group needs both. 3) In the procedures belonging to the third group we will transform the real interface name to the name without dot to use inside and pass as the argument to the procedures from the second group. Here is the patch for FreeBSD 6.0-RELEASE. If this change is acceptable I'll prepare the patch for CURRENT. --- network.subr.old Fri Jan 27 20:08:21 2006 +++ network.subr Fri Jan 27 20:28:55 2006 @@ -30,6 +30,21 @@ # Requires that rc.conf be loaded first. # +# cfg_ifname if +# Evaluate the name for the dotted VLAN interface which should +# be used inrc.conf (for example, makes "bge0_1" from "bge0.1") +# and print it out to the stdout. +cfg_ifname() +{ + _devpart=${1%.*} + _vlanpart=${1#*.} + if [ -n "${_vlanpart}" ]; then + echo "${_devpart}_${_vlanpart}" + else + echo $1 + fi +} + # ifconfig_up if # Evaluate ifconfig(8) arguments for interface $if and # run ifconfig(8) with those arguments. It returns 0 if @@ -41,14 +56,16 @@ { _cfg=1 - ifconfig_args=`ifconfig_getargs $1` + _cfgif="`cfg_ifname "$1"`" + + ifconfig_args=`ifconfig_getargs "${_cfgif}"` if [ -n "${ifconfig_args}" ]; then ifconfig $1 up eval "ifconfig $1 ${ifconfig_args}" _cfg=0 fi - if wpaif $1; then + if wpaif "${_cfgif}"; then if [ $_cfg -ne 0 ] ; then ifconfig $1 up fi @@ -56,7 +73,7 @@ _cfg=0 # XXX: not sure this should count fi - if dhcpif $1; then + if dhcpif "${_cfgif}"; then if [ $_cfg -ne 0 ] ; then ifconfig $1 up fi @@ -78,6 +95,8 @@ _ifs="^" _cfg=1 + _cfgif="`cfg_ifname "$1"`" + inetList="`ifconfig $1 | grep 'inet ' | tr "\n" "$_ifs"`" oldifs="$IFS" @@ -95,12 +114,12 @@ done IFS="$oldifs" - if wpaif $1; then + if wpaif "${_cfgif}"; then /etc/rc.d/wpa_supplicant stop $1 _cfg=0 fi - if dhcpif $1; then + if dhcpif "${_cfgif}"; then /etc/rc.d/dhclient stop $1 _cfg=0 fi @@ -108,7 +127,7 @@ return $_cfg } -# _ifconfig_getargs if +# _ifconfig_getargs cfgif # Echos the arguments for the supplied interface to stdout. # returns 1 if empty. In general, ifconfig_getargs should be used # outside this file. @@ -124,7 +143,7 @@ echo "$_args" } -# ifconfig_getargs if +# ifconfig_getargs cfgif # Takes the result from _ifconfig_getargs and removes pseudo # args such as DHCP and WPA. ifconfig_getargs() @@ -152,7 +171,7 @@ echo $_args } -# autoif +# autoif cfgif # Returns 0 if the interface should be automaticly configured at # boot time and 1 otherwise. autoif() @@ -168,7 +187,7 @@ return 0 } -# dhcpif if +# dhcpif cfgif # Returns 0 if the interface is a DHCP interface and 1 otherwise. dhcpif() { @@ -183,7 +202,7 @@ return 1 } -# wpaif if +# wpaif cfgif # Returns 0 if the interface is a WPA interface and 1 otherwise. wpaif() { @@ -207,8 +226,11 @@ { _ret=1 alias=0 + + _cfgif="`cfg_ifname "$1"`" + while : ; do - eval ifconfig_args=\$ifconfig_$1_alias${alias} + eval ifconfig_args=\$ifconfig_${_cfgif}_alias${alias} if [ -n "${ifconfig_args}" ]; then ifconfig $1 ${ifconfig_args} alias alias=$((${alias} + 1)) @@ -229,8 +251,11 @@ { _ret=1 alias=0 + + _cfgif="`cfg_ifname "$1"`" + while : ; do - eval ifconfig_args=\$ifconfig_$1_alias${alias} + eval ifconfig_args=\$ifconfig_${_cfgif}_alias${alias} if [ -n "${ifconfig_args}" ]; then ifconfig $1 ${ifconfig_args} -alias alias=$((${alias} + 1)) @@ -380,7 +405,8 @@ _ifn_list="`ifconfig -l`" [ -z "$_ifn_list" ] && return 0 for _if in ${_ifn_list} ; do - eval _ifname=\$ifconfig_${_if}_name + _cfgif="`cfg_ifname "$1"`" + eval _ifname=\$ifconfig_${_cfgif}_name if [ ! -z "$_ifname" ]; then ifconfig $_if name $_ifname fi @@ -438,11 +464,12 @@ _aprefix= _bprefix= for _if in ${_tmplist} ; do - if dhcpif $_if; then - _dhcplist="${_dhcplist}${_aprefix}${_if}" + _cfgif="`cfg_ifname "$1"`" + if dhcpif $_cfgif; then + _dhcplist="${_dhcplist}${_aprefix}${_cfgif}" [ -z "$_aprefix" ] && _aprefix=' ' - elif [ -n "`_ifconfig_getargs $if`" ]; then - _nodhcplist="${_nodhcplist}${_bprefix}${_if}" + elif [ -n "`_ifconfig_getargs $cfgif`" ]; then + _nodhcplist="${_nodhcplist}${_bprefix}${_cfgif}" [ -z "$_bprefix" ] && _bprefix=' ' fi done @@ -560,8 +587,9 @@ for i in $interfaces; do alias=0 + _cfgif="`cfg_ifname "$i"`" while : ; do - eval ipv6_ifconfig=\$ipv6_ifconfig_${i}_alias${alias} + eval ipv6_ifconfig=\$ipv6_ifconfig_${_cfgif}_alias${alias} if [ -z "${ipv6_ifconfig}" ]; then break; fi >Release-Note: >Audit-Trail: >Unformatted: