From nobody@FreeBSD.org  Thu Dec 29 21:13:57 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E2789106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 29 Dec 2011 21:13:57 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id B71DE8FC18
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 29 Dec 2011 21:13:57 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id pBTLDvf1037156
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 29 Dec 2011 21:13:57 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id pBTLDvkY037142;
	Thu, 29 Dec 2011 21:13:57 GMT
	(envelope-from nobody)
Message-Id: <201112292113.pBTLDvkY037142@red.freebsd.org>
Date: Thu, 29 Dec 2011 21:13:57 GMT
From: Dmitry Kazarov <d.y.kazarov@mail.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ifconfig: group parameter makes impossible to restart interface 
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         163701
>Category:       kern
>Synopsis:       ifconfig: group parameter makes impossible to restart interface
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    asomers
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 29 21:20:08 UTC 2011
>Closed-Date:    Tue Mar 25 16:50:41 UTC 2014
>Last-Modified:  Tue Mar 25 16:50:41 UTC 2014
>Originator:     Dmitry Kazarov
>Release:        8.2-STABLE
>Organization:
>Environment:
FreeBSD Trudiaga.localdomain 8.2-STABLE FreeBSD 8.2-STABLE #0: Mon Dec 12 01:42:49 MSK 2011     root@Trudiaga.localdomain:/var/obj/usr/src/sys/GENERIC  i386

>Description:
If group parameter is specified in /etc/rc.conf it makes /etc/rc.d/netif restart to fail:

# fgrep re0 /etc/rc.conf
ifconfig_re0='192.168.1.20/24 group ifgrp'

# ifconfig -v re0
re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=3898<VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_UCAST,WOL_MCAST,WOL_MAGIC>
        ether 00:1f:d0:5e:8f:57
        inet 192.168.1.20 netmask 0xffffff00 broadcast 192.168.1.255
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
        groups: ifgrp 

# /etc/rc.d/netif restart re0
Stopping Network: re0.
re0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=3898<VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_UCAST,WOL_MCAST,WOL_MAGIC>
        ether 00:1f:d0:5e:8f:57
        media: Ethernet autoselect (none)
        status: no carrier
ifconfig:  SIOCAIFGROUP: File exists
Starting Network: re0.
re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=3898<VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_UCAST,WOL_MCAST,WOL_MAGIC>
        ether 00:1f:d0:5e:8f:57
        media: Ethernet autoselect (none)
        status: no carrier


The source of problem is that groups parameter persist when interface goes down:

# /etc/rc.d/netif stop re0
Stopping Network: re0.
re0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=3898<VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_UCAST,WOL_MCAST,WOL_MAGIC>
        ether 00:1f:d0:5e:8f:57
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
# ifconfig -v re0
re0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=3898<VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_UCAST,WOL_MCAST,WOL_MAGIC>
        ether 00:1f:d0:5e:8f:57
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
        groups: ifgrp 


IMHO it's better to just ignore error when group param specifies groupname to which interface is already  assigned.
>How-To-Repeat:

>Fix:
--- src/sbin/ifconfig/ifgroup.c.orig    2011-12-30 01:07:54.000000000 +0400
+++ src/sbin/ifconfig/ifgroup.c 2011-12-30 01:09:09.000000000 +0400
@@ -58,7 +58,10 @@
        if (strlcpy(ifgr.ifgr_group, group_name, IFNAMSIZ) >= IFNAMSIZ)
                errx(1, "setifgroup: group name too long");
        if (ioctl(s, SIOCAIFGROUP, (caddr_t)&ifgr) == -1)
-               err(1," SIOCAIFGROUP");
+               if (errno == EEXIST)
+                       return;
+               else
+                       err(1," SIOCAIFGROUP");
 }
 
 /* ARGSUSED */


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->asomers 
Responsible-Changed-By: asomers 
Responsible-Changed-When: Sat Mar 8 00:31:28 UTC 2014 
Responsible-Changed-Why:  
I'll take it 

http://www.freebsd.org/cgi/query-pr.cgi?pr=163701 
State-Changed-From-To: open->patched 
State-Changed-By: asomers 
State-Changed-When: Tue Mar 25 15:09:44 UTC 2014 
State-Changed-Why:  
Independently fixed by des in change 256768.  The fix is in stable/10 
but not yet in stable/9 

http://www.freebsd.org/cgi/query-pr.cgi?pr=163701 
State-Changed-From-To: patched->closed 
State-Changed-By: asomers 
State-Changed-When: Tue Mar 25 16:50:41 UTC 2014 
State-Changed-Why:  
MFCed to stable/9 by r263739 

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