Locking fixes to IPv6 scope6.c

Robert Watson rwatson at freebsd.org
Thu Oct 21 14:43:18 PDT 2004


On Sat, 16 Oct 2004 gnn at freebsd.org wrote:

> @@ -71,12 +71,14 @@
>  scope6_ifattach(ifp)
>  	struct ifnet *ifp;
>  {
> -	int s = splnet();
> +
>  	struct scope6_id *sid;
>  
>  	sid = (struct scope6_id *)malloc(sizeof(*sid), M_IFADDR, M_WAITOK);
>  	bzero(sid, sizeof(*sid));
>  
> +	IFNET_WLOCK();
> +
>  	/*
>  	 * XXX: IPV6_ADDR_SCOPE_xxx macros are not standard.
>  	 * Should we rather hardcode here?

I notice that the comments indicate that you acquire the ifnet list lock
to prevent the ifnet from going away; however, the caller passes in an
ifnet pointer.  Shouldn't it be the responsibility of the caller to make
sure the ifnet doesn't go away, or it could go away before you could
aquire the lock?  I.e., either by virtue of the ifnet life cycle, or by
virtue of the caller locking the list and these functions asserting it?

Robert N M Watson             FreeBSD Core Team, TrustedBSD Projects
robert at fledge.watson.org      Principal Research Scientist, McAfee Research



More information about the freebsd-net mailing list