[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <51C9C4FF.1020706@freebox.fr>
Date: Tue, 25 Jun 2013 18:27:43 +0200
From: Nicolas Schichan <nschichan@...ebox.fr>
To: Eric Dumazet <eric.dumazet@...il.com>
CC: netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>,
Cong Wang <amwang@...hat.com>
Subject: Re: freeze with interface rename & SIOCGIFNAME
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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists