OpenVZ Forum


Home » Mailing lists » Devel » [PATCH 1/5] net: Modify all rtnetlink methods to only work in the initial namespace
Re: [PATCH 2/5] net: Make rtnetlink infrastructure network namespace aware [message #20990 is a reply to message #20980] Sat, 29 September 2007 15:44 Go to previous messageGo to previous message
Patrick McHardy is currently offline  Patrick McHardy
Messages: 107
Registered: March 2006
Senior Member
Eric W. Biederman wrote:
>  void rtnl_unlock(void)
>  {
> -	mutex_unlock(&rtnl_mutex);
> -	if (rtnl && rtnl->sk_receive_queue.qlen)
> +	struct net *net;
> +
> +	/*
> +	 * Loop through all of the rtnl sockets until none of them (in
> +	 * a live network namespace) have queue packets.
> +	 *
> +	 * We have to be careful with the locking here as
> +	 * sk_data_ready aka rtnetlink_rcv takes the rtnl_mutex.
> +	 *
> +	 * To ensure the network namespace does not exit while
> +	 * we are processing packets on it's rtnl socket we
> +	 * grab a reference to the network namespace, ignoring
> +	 * it if the network namespace has already exited.
> +	 */
> +retry:
> +	for_each_net(net) {
> +		struct sock *rtnl = net->rtnl;
> +
> +		if (!rtnl || !rtnl->sk_receive_queue.qlen)
> +			continue;
> +
> +		if (!maybe_get_net(net))
> +			continue;
> +
> +		mutex_unlock(&rtnl_mutex);
>  		rtnl->sk_data_ready(rtnl, 0);
> +		mutex_lock(&rtnl_mutex);
> +		put_net(net);
> +		goto retry;
> +	}
> +	mutex_unlock(&rtnl_mutex);
> +
>  	netdev_run_todo();
>  }


I'm wondering why this receive queue processing on unlock is still
necessary today, we don't do trylock in rtnetlink_rcv anymore, so
all senders will simply wait until the lock is released and then
process the queue.
_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [PATCH][NETNS] Make ifindex generation per-namespace
Next Topic: [PATCH RFC] cgroups: implement device whitelist cgroup+lsm
Goto Forum:
  


Current Time: Fri Jul 18 00:51:54 GMT 2025

Total time taken to generate the page: 0.04168 seconds