Subject: Re: freeze with interface rename & SIOCGIFNAME

From: Nicolas Schichan <[email-masked]>
Date: Tue, 25 Jun 2013 18:27:43 +0200

On 06/25/2013 06:15 PM, Eric Dumazet wrote:
> Nice catch !
>
> Please add a helper so that we can use it as well from
> sock_getbindtodevice(), and submit an official patch ?

Sure, I'll do that.

> int netdev_get_name(char *name, int ifindex)
> {
> 	struct net_device *dev;
> 	unsigned int seq;
>
> retry:
>          seq = read_seqcount_begin(&devnet_rename_seq);

raw_seqcount_begin is required here here. read_seqcount_begin will spin 
forever as the s->sequence & 1 check will always be true in 
__read_seqcount_begin(). This will incur some unneed work if a rename is in 
progress, but that's better than locking the system up.

>          rcu_read_lock();
>          dev = dev_get_by_index_rcu(net, ifindex);
>          if (!dev) {
>                  rcu_read_unlock();
>                  return -ENODEV;
>          }
>
>          strcpy(name, dev->name);
>          rcu_read_unlock();
>          if (read_seqcount_retry(&devnet_rename_seq, seq)) {
> 		cond_resched();
>                  goto retry;
> 	}
> }
>
>
> Thanks !
>
>
>
>

-- 
Nicolas Schichan
Freebox SAS