Network stack locking question
Bruce M. Simpson
bms at FreeBSD.org
Wed Sep 5 08:16:58 PDT 2007
Ivo Vachkov wrote:
> My lookup code looks like the following:
>
> struct sockaddr_in6 *dst = NULL;
> struct route_in6 out_rt;
>
> /* ... */
>
> dst = (struct sockaddr_in6 *)&out_rt.ro_dst;
> bzero(dst, sizeof(*dst));
> dst->sin6_len = sizeof(struct sockaddr_in6);
> dst->sin6_family = AF_INET6;
> dst->sin6_addr = ip6->ip6_dst;
>
> rtalloc((struct route *)&out_rt);
>
You need to remember to drop the lock which rtalloc() acquires on your
behalf using RTFREE() before leaving the function or possibly calling a
function which needs exclusive/write access to the rtentry.
If your code needs this rtentry to remain in the system, a call to
RT_ADDREF() with the lock held may be necessary, although you should
remember to RT_REMREF() with the lock held when done with the rtentry.
See «net/route.h» for more info.
regards,
BMS
More information about the freebsd-net
mailing list