Bug 191961 - [regression] network.subr fails to assign vlan aliases
Summary: [regression] network.subr fails to assign vlan aliases
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: 9.3-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Devin Teske
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-18 22:52 UTC by ben
Modified: 2014-10-21 18:36 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ben 2014-07-18 22:52:55 UTC
Assigning aliases to vlan interfaces in /etc/rc.conf no longer works in 9.3-RELEASE.  The following script demonstrates the problem:

#!/bin/sh
. /etc/rc.subr
. /etc/network.subr
IFCONFIG_CMD="/bin/echo ${IFCONFIG_CMD}"
ifconfig_em0_1_alias0="inet 10.0.16.16/32"
ifconfig_em0_1_alias1="inet 10.0.16.18/32"
ifconfig_em0_1_alias2="inet 10.0.16.20/32"
ifalias_af_common em0.1 inet alias

On 9.3-RELEASE this incorrectly attempts to call ifconfig with "em0_1":

/sbin/ifconfig em0_1 inet 10.0.16.16/32 alias
/sbin/ifconfig em0_1 inet 10.0.16.18/32 alias
/sbin/ifconfig em0_1 inet 10.0.16.20/32 alias

The correct output when run on 9.2-RELEASE:

/sbin/ifconfig em0.1 inet 10.0.16.16/32 alias
/sbin/ifconfig em0.1 inet 10.0.16.18/32 alias
/sbin/ifconfig em0.1 inet 10.0.16.20/32 alias

The relevant commit in stable/9 is r264439 (MFC of r264243).

The original code only normalized (ltr $_if) in subshells so the normalized value was not exposed to ifalias_af_common_handler().  The following hack fixes the regression although it should probably be re-factored:

--- /etc/network.subr   2014-07-18 05:33:57.000000000 +0000
+++ network.subr        2014-07-18 22:44:35.000000000 +0000
@@ -1019,11 +1019,9 @@
        _af=$2
        _action=$3
 
-       # Normalize $_if before using it in a pattern to list_vars()
-       ltr "$_if" "$_punct" "_" _if
-
        # ifconfig_IF_aliasN which starts with $_af
-       for alias in `list_vars ifconfig_${_if}_alias[0-9]\* |
+       for alias in `ltr "$_if" "$_punct" "_" _if;
+               list_vars ifconfig_${_if}_alias[0-9]\* |
                sort_lite -nk1.$((9+${#_if}+7))`
        do
                eval ifconfig_args=\"\$$alias\"
@@ -1053,7 +1051,8 @@
        # backward compatibility: ipv6_ifconfig_IF_aliasN.
        case $_af in
        inet6)
-               for alias in `list_vars ipv6_ifconfig_${_if}_alias[0-9]\* |
+               for alias in `ltr "$_if" "$_punct" "_" _if;
+                       list_vars ipv6_ifconfig_${_if}_alias[0-9]\* |
                        sort_lite -nk1.$((14+${#_if}+7))`
                do
                        eval ifconfig_args=\"\$$alias\"
Comment 1 Devin Teske freebsd_committer freebsd_triage 2014-07-18 23:30:29 UTC
Missing MFC of http://svnweb.freebsd.org/base?view=revision&revision=267812
Comment 2 commit-hook freebsd_committer freebsd_triage 2014-07-23 22:11:34 UTC
A commit references this bug:

Author: dteske
Date: Wed Jul 23 22:10:34 UTC 2014
New revision: 269028
URL: http://svnweb.freebsd.org/changeset/base/269028

Log:
  MFC r267812 (hrs): Fix ifname normalization. ifconfig_IF_alias{es,N} did not
  work if ifname has any of [.-/+].

  PR:		conf/191961
  Spotted by:	jhay
  MFC after:	3 days

Changes:
_U  stable/9/etc/
  stable/9/etc/network.subr
Comment 3 commit-hook freebsd_committer freebsd_triage 2014-07-23 22:47:37 UTC
A commit references this bug:

Author: dteske
Date: Wed Jul 23 22:47:00 UTC 2014
New revision: 269035
URL: http://svnweb.freebsd.org/changeset/base/269035

Log:
  MFC r267812 (hrs): Fix ifname normalization. ifconfig_IF_alias{es,N} did not
  work if ifname has any of [.-/+].

  While here, also perform the following to reduce diff size between major
  branches for etc/network.subr:

  MFC r266475 (rea): Fix warning messages after r252015

  $alias used to hold alias number, but now it carries full variable name,
  so messages were tuned to account for that.

  Other fixes:
   - eliminate unneeded double spaces;
   - tell user where inet/inet6 keywords are expected to be.

  Reviewed by:	hrs
  Spotted by:	jhay
  PR:		conf/191961

Changes:
_U  stable/10/
  stable/10/etc/network.subr
Comment 4 Devin Teske freebsd_committer freebsd_triage 2014-07-23 22:59:27 UTC
MFC to stable/9 completed as SVN r269028.
MFS to releng/9.3 pending 3 days + approval time.
Comment 5 Devin Teske freebsd_committer freebsd_triage 2014-10-21 18:36:36 UTC
We missed the releng/9.3 cut, but I did get this merged to stable/9 (in the event that we ever have a 9.4-RELEASE in the future).