From owner-freebsd-current@FreeBSD.ORG Fri Jul 29 04:42:18 2005 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DC64B16A41F; Fri, 29 Jul 2005 04:42:18 +0000 (GMT) (envelope-from rodrigc@crodrigues.org) Received: from sccrmhc14.comcast.net (sccrmhc14.comcast.net [204.127.202.59]) by mx1.FreeBSD.org (Postfix) with ESMTP id 46C9243D45; Fri, 29 Jul 2005 04:42:18 +0000 (GMT) (envelope-from rodrigc@crodrigues.org) Received: from c-66-30-114-143.hsd1.ma.comcast.net ([66.30.114.143]) by comcast.net (sccrmhc14) with ESMTP id <2005072904421701400jda3oe>; Fri, 29 Jul 2005 04:42:17 +0000 Received: from c-66-30-114-143.hsd1.ma.comcast.net (localhost.127.in-addr.arpa [127.0.0.1]) by c-66-30-114-143.hsd1.ma.comcast.net (8.13.4/8.13.1) with ESMTP id j6T4gH7R016995; Fri, 29 Jul 2005 00:42:17 -0400 (EDT) (envelope-from rodrigc@c-66-30-114-143.hsd1.ma.comcast.net) Received: (from rodrigc@localhost) by c-66-30-114-143.hsd1.ma.comcast.net (8.13.4/8.13.1/Submit) id j6T4gHRS016994; Fri, 29 Jul 2005 00:42:17 -0400 (EDT) (envelope-from rodrigc) Date: Fri, 29 Jul 2005 00:42:17 -0400 From: Craig Rodrigues To: Robert Watson Message-ID: <20050729044217.GA16981@crodrigues.org> References: <20050726124222.GA1109@crodrigues.org> <20050726131712.GC46538@darkness.comp.waw.pl> <20050726145334.GA1826@crodrigues.org> <20050727223351.A54330@fledge.watson.org> <20050727214820.GA1123@crodrigues.org> <20050727235142.F54330@fledge.watson.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050727235142.F54330@fledge.watson.org> User-Agent: Mutt/1.5.9i Cc: freebsd-current@freebsd.org, Harti Brandt Subject: Re: Panic in netnatm X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jul 2005 04:42:19 -0000 On Wed, Jul 27, 2005 at 11:53:07PM +0100, Robert Watson wrote: > I think you still need an NATM_UNLOCK() in the 'goto failed' case, > probably placed outside of the "if (npcb) {' block since it will need to > be unlocked in both cases. OK, how about this patch. In this case, for RTM_ADD, I only unlock things in the failed: block if npcb != NULL. If npcb == NULL, by the time we reach the failed: block, we should not be holding NATM_LOCK, so we do not unlock it there. Index: if_atm.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/if_atm.c,v retrieving revision 1.19 diff -u -u -r1.19 if_atm.c --- if_atm.c 7 Jan 2005 01:45:44 -0000 1.19 +++ if_atm.c 29 Jul 2005 04:37:50 -0000 @@ -224,9 +224,13 @@ sin = (struct sockaddr_in *) rt_key(rt); if (sin->sin_family != AF_INET) goto failed; + + NATM_LOCK(); npcb = npcb_add(NULL, rt->rt_ifp, op.param.vci, op.param.vpi); - if (npcb == NULL) + if (npcb == NULL) { + NATM_UNLOCK(); goto failed; + } npcb->npcb_flags |= NPCB_IP; npcb->ipaddr.s_addr = sin->sin_addr.s_addr; /* XXX: move npcb to llinfo when ATM ARP is ready */ @@ -255,6 +259,7 @@ npcb_free(npcb, NPCB_DESTROY); rt->rt_llinfo = NULL; rt->rt_flags &= ~RTF_LLINFO; + NATM_UNLOCK(); } #endif /* mark as invalid. We cannot RTM_DELETE the route from @@ -269,10 +274,12 @@ * tell native ATM we are done with this VC */ if (rt->rt_flags & RTF_LLINFO) { + NATM_LOCK(); npcb_free((struct natmpcb *)rt->rt_llinfo, NPCB_DESTROY); rt->rt_llinfo = NULL; rt->rt_flags &= ~RTF_LLINFO; + NATM_UNLOCK(); } #endif /*