From ade@FreeBSD.org  Thu Mar  2 16:55:27 2006
Return-Path: <ade@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 04AB816A423;
	Thu,  2 Mar 2006 16:55:27 +0000 (GMT)
	(envelope-from ade@FreeBSD.org)
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 0EC6743D6D;
	Thu,  2 Mar 2006 16:55:25 +0000 (GMT)
	(envelope-from ade@FreeBSD.org)
Received: from freefall.freebsd.org (ade@localhost [127.0.0.1])
	by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k22GtPX6063041;
	Thu, 2 Mar 2006 16:55:25 GMT
	(envelope-from ade@freefall.freebsd.org)
Received: (from ade@localhost)
	by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k22GtPcT063040;
	Thu, 2 Mar 2006 16:55:25 GMT
	(envelope-from ade)
Message-Id: <200603021655.k22GtPcT063040@freefall.freebsd.org>
Date: Thu, 2 Mar 2006 16:55:25 GMT
From: Ade Lovett <ade@FreeBSD.org>
Reply-To: Ade Lovett <ade@FreeBSD.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: re@FreeBSD.org, ade@FreeBSD.org
Subject: Show-stopping regression in sbin/ifconfig
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         94028
>Category:       bin
>Synopsis:       Show-stopping regression in sbin/ifconfig
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    yar
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 02 17:00:19 GMT 2006
>Closed-Date:    Wed Mar 22 18:02:53 GMT 2006
>Last-Modified:  Wed Mar 22 18:02:53 GMT 2006
>Originator:     Ade Lovett
>Release:        FreeBSD 6.0-STABLE i386
>Organization:
>Environment:

RELENG_6, all architectures

>Description:
Revision 1.7.2.4 of sbin/ifconfig/ifvlan.c has introduced a critical
regression into the handling of ifconfig on vlan interfaces.

This is a show-stopping problem for the impending 6.1-RELEASE, hence
the cc to re@

>How-To-Repeat:

With the following parent interface:

foo# ifconfig em0
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 8448
        options=1b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING>
[...]

The following can be observed:

foo# ifconfig vlan9 destroy
foo# ifconfig vlan9 create
foo# ifconfig vlan9 vlan 666 vlandev em0 mtu 1500
ifconfig: ioctl (set mtu): Invalid argument
foo#

However, this works:

foo# ifconfig vlan9 destroy
foo# ifconfig vlan9 create
foo# ifconfig vlan9 vlan 666 vlandev em0
foo# ifconfig vlan9 mtu 1500
foo# ifconfig vlan9
vlan9: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        [...]
        vlan: 666 parent interface: em0
foo#

Reverting to revision 1.7.2.3 of sbin/ifconfig/ifvlan.c shows the
expected behavior:

foo# ifconfig vlan9 destroy
foo# ifconfig vlan9 create
foo# ifconfig vlan9 vlan 666 vlandev em0 mtu 1500
foo# ifconfig vlan9
vlan9: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        [...]
        vlan: 666 parent interface: em0
foo#

>Fix:
Revert back to 1.7.2.3 of sbin/ifconfig/ifvlan.c


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->re 
Responsible-Changed-By: ade 
Responsible-Changed-When: Thu Mar 2 17:05:51 UTC 2006 
Responsible-Changed-Why:  
Punting this to re@ since it's a show-stopper 6.1-RELEASE issue. 
Once that's addressed, this should go to yar@ for a real fix. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=94028 
State-Changed-From-To: open->analyzed 
State-Changed-By: yar 
State-Changed-When: Tue Mar 7 09:55:39 UTC 2006 
State-Changed-Why:  
The probelm has been fully understood; a fix is in the works. 

As a side note, I don't think that the severity of this problem 
is really so high.  The originator of this PR just seems to have  
yielded to mental panic, as opposed to kernel panic ;-) 


Responsible-Changed-From-To: re->yar 
Responsible-Changed-By: yar 
Responsible-Changed-When: Tue Mar 7 09:55:39 UTC 2006 
Responsible-Changed-Why:  
This problem results from my changes to ifconfig, so Ade, you 
should have notified me of it, not put the burden on the RE 
team, who are having a rush period already, facing 2 releases 
at once. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=94028 

From: Yar Tikhiy <yar@comp.chem.msu.su>
To: bug-followup@FreeBSD.org, ade@FreeBSD.org
Cc:  
Subject: Re: bin/94028: Show-stopping regression in sbin/ifconfig
Date: Tue, 7 Mar 2006 21:50:23 +0300

 Please test this patch.  Thanks!
 
 === For reviewers ===
 
 The idea behind the patch is as follows:
 
 We revert back to setting vlan and vlandev parametes synchronously,
 as soon as both have been read from the command line.  We still use
 the callback, but this time only to verify that both vlan and vlandev
 have been found on the command line.
 
 This should allow for control over the relative order of processing
 parameters.  Here are some examples assuming that vlan0 is initially
 unconfigured before each command:
 
 ifconfig vlan0 vlan 33 vlandev fxp0		# valid
 
 ifconfig vlan0 vlandev fxp0 vlan 33 		# valid
 
 ifconfig vlan0 vlandev fxp0			# invalid
 
 ifconfig vlan0 mtu 1200 vlandev em1 vlan 55	# mtu will be refused by kernel:
 						# can't set mtu on unconf'd vlan
 
 ifconfig vlan0 vlandev em1 vlan 55 mtu 1200	# valid
 
 ifconfig vlan0 vlan 55 vlandev em1 vlan 66	# 2nd vlan will be
 						# rejected by kernel:
 						# must -vlandev first
 
 ifconfig vlan0 vlan 55 vlandev em1 -vlandev em1 vlandev em0 vlan 66 # valid
 						# but will emit a warning
 						# about argument to -vlandev
 
 -- 
 Yar
 
 Index: ifvlan.c
 ===================================================================
 RCS file: /home/ncvs/src/sbin/ifconfig/ifvlan.c,v
 retrieving revision 1.7.2.4
 diff -u -p -r1.7.2.4 ifvlan.c
 --- ifvlan.c	9 Feb 2006 10:48:43 -0000	1.7.2.4
 +++ ifvlan.c	7 Mar 2006 18:16:27 -0000
 @@ -62,6 +62,8 @@ static struct vlanreq		__vreq;
  static int			__have_dev = 0;
  static int			__have_tag = 0;
  
 +static void			vlan_set(int);
 +
  static void
  vlan_status(int s)
  {
 @@ -93,6 +95,7 @@ setvlantag(const char *val, int d, int s
  		errx(1, "value for vlan out of range");
  	/* the kernel will do more specific checks on vlr_tag */
  	__have_tag = 1;
 +	vlan_set(s);	/* try setting vlan params in kernel */
  }
  
  static void
 @@ -101,6 +104,7 @@ setvlandev(const char *val, int d, int s
  
  	strncpy(__vreq.vlr_parent, val, sizeof(__vreq.vlr_parent));
  	__have_dev = 1;
 +	vlan_set(s);	/* try setting vlan params in kernel */
  }
  
  static void
 @@ -130,6 +134,11 @@ vlan_cb(int s, void *arg)
  
  	if (__have_tag ^ __have_dev)
  		errx(1, "both vlan and vlandev must be specified");
 +}
 +
 +static void
 +vlan_set(int s)
 +{
  
  	if (__have_tag && __have_dev) {
  		ifr.ifr_data = (caddr_t)&__vreq;
State-Changed-From-To: analyzed->patched 
State-Changed-By: yar 
State-Changed-When: Thu Mar 9 14:58:21 UTC 2006 
State-Changed-Why:  
The patch has been reviewed OK and committed to HEAD. 
MFC is due in 3 days. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=94028 
State-Changed-From-To: patched->closed 
State-Changed-By: yar 
State-Changed-When: Wed Mar 22 18:02:21 UTC 2006 
State-Changed-Why:  
Fixed in RELENG_6, too.  Thanks! 

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