Re: Panic in netnatm

From: Craig Rodrigues <rodrigc_at_crodrigues.org>
Date: Fri, 29 Jul 2005 00:42:17 -0400
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
_at__at_ -224,9 +224,13 _at__at_
 		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 */
_at__at_ -255,6 +259,7 _at__at_
 			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
_at__at_ -269,10 +274,12 _at__at_
 		 * 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
 		/*
Received on Fri Jul 29 2005 - 02:42:18 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:40 UTC