Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 05 Sep 2007 16:08:24 +0100
From:      "Bruce M. Simpson" <bms@FreeBSD.org>
To:        Ivo Vachkov <ivo.vachkov@gmail.com>
Cc:        freebsd-net <freebsd-net@freebsd.org>
Subject:   Re: Network stack locking question
Message-ID:  <46DEC668.50509@FreeBSD.org>
In-Reply-To: <f85d6aa70709050216j72d8d2f4qce46e65e675a8ee3@mail.gmail.com>
References:  <f85d6aa70709040234w3abc3e05n9cf9c9d86cb994cd@mail.gmail.com>	<46DD2A1E.3060109@FreeBSD.org> <f85d6aa70709050216j72d8d2f4qce46e65e675a8ee3@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?46DEC668.50509>