From owner-freebsd-net@FreeBSD.ORG Wed Sep 5 15:16:58 2007 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2AC516A419 for ; Wed, 5 Sep 2007 15:16:58 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from out2.smtp.messagingengine.com (out2.smtp.messagingengine.com [66.111.4.26]) by mx1.freebsd.org (Postfix) with ESMTP id A5C7113C45D for ; Wed, 5 Sep 2007 15:16:58 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 0679227AE3; Wed, 5 Sep 2007 11:16:23 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 05 Sep 2007 11:16:24 -0400 X-Sasl-enc: 8wcTIXyjf3mra5ozYPBdz8ZVdirisu0cZ6kBq/YKKFWP 1189004905 Received: from empiric.lon.incunabulum.net (82-35-112-254.cable.ubr07.dals.blueyonder.co.uk [82.35.112.254]) by mail.messagingengine.com (Postfix) with ESMTP id 9DAAB4478; Wed, 5 Sep 2007 11:08:25 -0400 (EDT) Message-ID: <46DEC668.50509@FreeBSD.org> Date: Wed, 05 Sep 2007 16:08:24 +0100 From: "Bruce M. Simpson" User-Agent: Thunderbird 2.0.0.4 (X11/20070630) MIME-Version: 1.0 To: Ivo Vachkov References: <46DD2A1E.3060109@FreeBSD.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Cc: freebsd-net Subject: Re: Network stack locking question X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2007 15:16:58 -0000 Ivo Vachkov wrote: > My lookup code looks like the following: > > struct sockaddr_in6 *dst =3D NULL; > struct route_in6 out_rt; > > /* ... */ > > dst =3D (struct sockaddr_in6 *)&out_rt.ro_dst; > bzero(dst, sizeof(*dst)); > dst->sin6_len =3D sizeof(struct sockaddr_in6); > dst->sin6_family =3D AF_INET6; > dst->sin6_addr =3D ip6->ip6_dst; > > rtalloc((struct route *)&out_rt); > =20 You need to remember to drop the lock which rtalloc() acquires on your=20 behalf using RTFREE() before leaving the function or possibly calling a=20 function which needs exclusive/write access to the rtentry. If your code needs this rtentry to remain in the system, a call to=20 RT_ADDREF() with the lock held may be necessary, although you should=20 remember to RT_REMREF() with the lock held when done with the rtentry. See =ABnet/route.h=BB for more info. regards, BMS