From nobody@FreeBSD.org  Tue Apr 15 14:49:34 2008
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 E6880106567B
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 15 Apr 2008 14:49:34 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id D2CE88FC2D
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 15 Apr 2008 14:49:34 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m3FEnQ89038911
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 15 Apr 2008 14:49:26 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m3FEnQgj038910;
	Tue, 15 Apr 2008 14:49:26 GMT
	(envelope-from nobody)
Message-Id: <200804151449.m3FEnQgj038910@www.freebsd.org>
Date: Tue, 15 Apr 2008 14:49:26 GMT
From: Robert Hass <robhass@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Kernel panic after brings lagg(8) up if NICs are not bringed up before
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         122794
>Category:       kern
>Synopsis:       [lagg] Kernel panic after brings lagg(8) up if NICs are not bringed up before
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-net
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Apr 15 14:50:03 UTC 2008
>Closed-Date:    Mon Aug 17 20:17:23 UTC 2009
>Last-Modified:  Mon Aug 17 20:17:23 UTC 2009
>Originator:     Robert Hass
>Release:        7.0-STABLE
>Organization:
>Environment:
FreeBSD lab02 7.0-STABLE FreeBSD 7.0-STABLE #0: Tue Apr 15 09:04:04 CEST 2008     root@lab02:/usr/src/sys/i386/compile/LAB  i386

>Description:
I noticed lagg(8) bug. If I will issue below commands:

ifconfig lagg0 create
ifconfig lagg0 laggproto lacp laggport fxp0 laggport fxp1
ifconfig lagg0 1.1.1.2/24
ifconfig lagg0 up

Effect is kernel panic.

If I will bring fxp0 and fxp1 (ifconfig fxpX up) before adding
them do lagg0 then everthing is working correctly.

[root@lab02 ~]# dmesg | grep fxp
fxp0: <Intel 82558 Pro/100 Ethernet> port 0xdcc0-0xdcdf mem 0xfa001000-0xfa001fff,0xff100000-0xff1fffff irq 10 at device 13.0 on pci0
miibus0: <MII bus> on fxp0
fxp0: Ethernet address: 00:08:c7:59:ab:3f
fxp0: [ITHREAD]
fxp1: <Intel 82558 Pro/100 Ethernet> port 0xdca0-0xdcbf mem 0xfa000000-0xfa000fff,0xff000000-0xff0fffff irq 7 at device 14.0 on pci0
miibus1: <MII bus> on fxp1
fxp1: Ethernet address: 00:08:c7:52:b7:85
fxp1: [ITHREAD]

>How-To-Repeat:
Just start the system and use below commands:

ifconfig lagg0 create
ifconfig lagg0 laggproto lacp laggport fxp0 laggport fxp1
ifconfig lagg0 1.1.1.2/24
ifconfig lagg0 up

Effect -> PANIC

fxp0 and fxp1 are not configured in rc.conf or command line

>Fix:
None

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: vwe 
State-Changed-When: Tue Apr 15 20:22:21 UTC 2008 
State-Changed-Why:  

Robert, 
please provide us with the panic message and a backtrace, please for 
further inspection. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=122794 
Responsible-Changed-From-To: freebsd-i386->freebsd-net 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Sat Apr 19 14:19:13 UTC 2008 
Responsible-Changed-Why:  
Looks like -net are probably responsible for this one 

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

From: =?koi8-r?Q?=EC=CF=D4=C3_=E1=CE=D4=CF=CE_?= =?koi8-r?Q?=F7=CC=C1=C4=C9=CD=C9=D2=CF=D7=C9=DE?= <A.V.Lotts@chelindbank.ru>
To: bug-followup@FreeBSD.org, robhass@gmail.com
Cc:  
Subject: Re: kern/122794: [lagg] Kernel panic after brings lagg(8) up if
	NICs are not bringed up before
Date: Thu, 18 Sep 2008 09:08:56 +0600

 --=-pYK/Vjp63XwXQm/bEEhQ
 Content-Type: text/plain
 Content-Transfer-Encoding: 7bit
 
 Hello
 
 I have found similar problem: kernel panic occurs if you try to use lagg
 interface without any laggport configured.
 
 Is this the same problem?
 
 There are at least two way to reproduce problem:
 1. Boot to single-user mode and issue commands
 	ifconfig lagg0 create
 	ifconfig lagg0 laggproto loadbalance  # does it really need to crash?
 	ifconfig lagg0 inet 10.10.10.10 netmask 255.255.255.0
 
    Kernel panic follows (possible need to send a packet)
 
 Fatal trap 18: integer divide fault while in kernel mode
 cpuid = 0; apic id = 00
 instruction pointer     = 0x20:0x80441f38
 stack pointer           = 0x28:0xec046988
 frame pointer           = 0x28:0xec04699c
 code segment            = base 0x0, limit 0xfffff, type 0x1b
                         = DPL 0, pres 1, def32 1, gran 1
 processor eflags        = interrupt enabled, resume, IOPL = 0
 current process         = 57 (ifconfig)
 trap number             = 18
 panic: integer divide fault
 cpuid = 0
 Uptime: 3m5s
 Cannot dump. No dump device defined.
 Automatic reboot in 15 seconds - press a key on the console to abort
 
 
 2. Boot to any network-enabled mode and remove all laggport from the
 lagg interface. Kernel panic follows (possible need to send a packet).
 
 	ifconfig lagg0 -laggport bce0
 	ping 10.10.10.11
 Fatal trap 18: integer divide fault while in kernel mode
 cpuid = 0; apic id = 00
 instruction pointer     = 0x20:0x80441f38
 stack pointer           = 0x28:0xec0a19ec
 frame pointer           = 0x28:0xec0a1a00
 code segment            = base 0x0, limit 0xfffff, type 0x1b
                         = DPL 0, pres 1, def32 1, gran 1
 processor eflags        = interrupt enabled, resume, IOPL = 0
 current process         = 52383 (ping)
 trap number             = 18
 panic: integer divide fault
 cpuid = 0
 Uptime: 13m53s
 Physical memory: 4086 MB
 Dumping 128 MB: 113 97 81 65 49 33 17 1
 Dump complete
 Automatic reboot in 15 seconds - press a key on the console to abort
 
 
 Possible solution could be following:
 
 *** if_lagg.c-orig	Thu Sep 18 08:29:25 2008
 --- if_lagg.c	Thu Sep 18 08:32:39 2008
 ***************
 *** 1403,1408 ****
 --- 1403,1412 ----
   	uint32_t p;
   
   	p = atomic_fetchadd_32(&sc->sc_seq, 1);
 + 	if (sc->sc_count == 0) {
 + 		m_freem(m);
 + 		return (ENOENT);
 + 	}
   	p %= sc->sc_count;
   	lp = SLIST_FIRST(&sc->sc_ports);
   	while (p--)
 ***************
 *** 1580,1585 ****
 --- 1584,1593 ----
   	int idx;
   
   	p = lagg_hashmbuf(m, lb->lb_key);
 + 	if (sc->sc_count == 0) {
 + 		m_freem(m);
 + 		return (ENOENT);
 + 	}
   	if ((idx = p % sc->sc_count) >= LAGG_MAX_PORTS) {
   		m_freem(m);
   		return (EINVAL);
 
 
 I'm not a qualified kernel-hacker so please provide a better solution.
 
 Regards
 --
 Anton Lotts
 
 --=-pYK/Vjp63XwXQm/bEEhQ
 Content-Disposition: attachment; filename=lagg.patch
 Content-Type: text/x-patch; name=lagg.patch; charset=utf-8
 Content-Transfer-Encoding: 7bit
 
 *** if_lagg.c-orig	Thu Sep 18 08:29:25 2008
 --- if_lagg.c	Thu Sep 18 08:32:39 2008
 ***************
 *** 1403,1408 ****
 --- 1403,1412 ----
   	uint32_t p;
   
   	p = atomic_fetchadd_32(&sc->sc_seq, 1);
 + 	if (sc->sc_count == 0) {
 + 		m_freem(m);
 + 		return (ENOENT);
 + 	}
   	p %= sc->sc_count;
   	lp = SLIST_FIRST(&sc->sc_ports);
   	while (p--)
 ***************
 *** 1580,1585 ****
 --- 1584,1593 ----
   	int idx;
   
   	p = lagg_hashmbuf(m, lb->lb_key);
 + 	if (sc->sc_count == 0) {
 + 		m_freem(m);
 + 		return (ENOENT);
 + 	}
   	if ((idx = p % sc->sc_count) >= LAGG_MAX_PORTS) {
   		m_freem(m);
   		return (EINVAL);
 
 --=-pYK/Vjp63XwXQm/bEEhQ--
 
State-Changed-From-To: feedback->patched 
State-Changed-By: thompsa 
State-Changed-When: Thu Sep 18 04:14:56 UTC 2008 
State-Changed-Why:  
This has been fixed in r183135, please update. I missed this 
PR, sorry for the delay. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/122794: commit references a PR
Date: Thu, 18 Sep 2008 04:14:43 +0000 (UTC)

 thompsa     2008-09-18 04:14:28 UTC
 
   FreeBSD src repository
 
   Modified files:
     sys/net              if_lagg.c 
   Log:
   SVN rev 183135 on 2008-09-18 04:14:28Z by thompsa
   
   Make sure there is at least one port to avoid divide by zero when choosing the
   tx port.
   
   PR:             kern/122794
   MFC after:      3 days
   
   Revision  Changes    Path
   1.29      +2 -1      src/sys/net/if_lagg.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: emaste 
State-Changed-When: Mon Aug 17 20:16:50 UTC 2009 
State-Changed-Why:  
I see that thompsa has MFC'd this to 7 & 6. 

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