From eugen@www.svzserv.kemerovo.su  Fri Sep  8 09:06:37 2006
Return-Path: <eugen@www.svzserv.kemerovo.su>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id CF7B116A4DE;
	Fri,  8 Sep 2006 09:06:37 +0000 (UTC)
	(envelope-from eugen@www.svzserv.kemerovo.su)
Received: from www.svzserv.kemerovo.su (www.svzserv.kemerovo.su [213.184.65.80])
	by mx1.FreeBSD.org (Postfix) with ESMTP id EDA1D43D45;
	Fri,  8 Sep 2006 09:06:36 +0000 (GMT)
	(envelope-from eugen@www.svzserv.kemerovo.su)
Received: from www.svzserv.kemerovo.su (eugen@localhost [127.0.0.1])
	by www.svzserv.kemerovo.su (8.13.8/8.13.8) with ESMTP id k8896XQO016992;
	Fri, 8 Sep 2006 17:06:33 +0800 (KRAST)
	(envelope-from eugen@www.svzserv.kemerovo.su)
Received: (from eugen@localhost)
	by www.svzserv.kemerovo.su (8.13.8/8.13.8/Submit) id k8896XrE016991;
	Fri, 8 Sep 2006 17:06:33 +0800 (KRAST)
	(envelope-from eugen)
Message-Id: <200609080906.k8896XrE016991@www.svzserv.kemerovo.su>
Date: Fri, 8 Sep 2006 17:06:33 +0800 (KRAST)
From: Eugene Grosbein <eugen@grosbein.pp.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc: jhb@freebsd.org
Subject: [patch] MFC link flapping workaround for em(4) to RELENG_4
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         103019
>Category:       kern
>Synopsis:       [patch] MFC link flapping workaround for em(4) to RELENG_4
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jhb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 08 09:10:22 GMT 2006
>Closed-Date:    Tue Apr 24 03:29:35 GMT 2007
>Last-Modified:  Tue Apr 24 03:29:35 GMT 2007
>Originator:     Eugene Grosbein
>Release:        FreeBSD 4.11-STABLE i386
>Organization:
Svyaz Service JSC
>Environment:
System: FreeBSD www.svzserv.kemerovo.su 4.11-STABLE FreeBSD 4.11-STABLE #17: Fri Sep 8 12:21:26 KRAST 2006 eu@www.svzserv.kemerovo.su:/home4/obj/home/src/sys/WWW i386

>Description:

	Please MFC part of if_em.c,v1.119 to RELENG_4 to work aroung
	link flapping problem. Path follows (tested).

>How-To-Repeat:
	ifconfig em0 inet ... alias produces timeout, link regenitiation
	and there is no outgoing ARP cache update packet.
>Fix:

--- sys/dev/em/if_em.c.orig	Fri Sep  8 10:36:26 2006
+++ sys/dev/em/if_em.c	Fri Sep  8 12:19:50 2006
@@ -61,6 +61,7 @@
 
 #include <netinet/in_systm.h>
 #include <netinet/in.h>
+#include <netinet/if_ether.h>
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
 #include <netinet/udp.h>
@@ -729,6 +730,7 @@
 {
 	struct adapter	*adapter = ifp->if_softc;
 	struct ifreq *ifr = (struct ifreq *)data;
+	struct ifaddr *ifa = (struct ifaddr *)data;
 	int error = 0;
 	int s;
 
@@ -741,7 +743,21 @@
 	case SIOCSIFADDR:
 	case SIOCGIFADDR:
 		IOCTL_DEBUGOUT("ioctl rcv'd: SIOCxIFADDR (Get/Set Interface Addr)");
-		ether_ioctl(ifp, command, data);
+		if (ifa->ifa_addr->sa_family == AF_INET) {
+			/*
+			 * XXX
+			 * Since resetting hardware takes a very long time
+			 * and results in link renegotiation we only
+			 * initialize the hardware only when it is absolutely
+			 * required.
+			 */
+			ifp->if_flags |= IFF_UP;
+			if (!(ifp->if_flags & IFF_RUNNING)) {
+				em_init(adapter);
+			}
+			arp_ifinit(ifp, ifa);
+		} else
+			error = ether_ioctl(ifp, command, data);
 		break;
 	case SIOCSIFMTU:
 	    {
@@ -790,12 +806,13 @@
 	case SIOCSIFFLAGS:
 		IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFFLAGS (Set Interface Flags)");
 		if (ifp->if_flags & IFF_UP) {
-			if (!(ifp->if_flags & IFF_RUNNING)) {
+			if ((ifp->if_flags & IFF_RUNNING)) {
+				if (ifp->if_flags & IFF_PROMISC) {
+					em_disable_promisc(adapter);
+					em_set_promisc(adapter);
+				}
+			} else
 				em_init(adapter);
-			}
-
-			em_disable_promisc(adapter);
-			em_set_promisc(adapter);
 		} else {
 			if (ifp->if_flags & IFF_RUNNING) {
 				em_stop(adapter);



Eugene Grosbein
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->jhb 
Responsible-Changed-By: ru 
Responsible-Changed-When: Fri Sep 8 09:26:34 UTC 2006 
Responsible-Changed-Why:  
Up to John. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=103019 
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Tue Apr 24 03:28:38 UTC 2007 
State-Changed-Why:  
Since RELENG_4 is EOL, this PR is probably not going to be dealt with. 
With bugmeister hat on, go ahead and close it. 

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