From: Nicolas Schichan <nschichan@freebox•fr>
To: Eric Dumazet <eric.dumazet@gmail•com>
Cc: netdev@vger•kernel.org, "David S. Miller" <davem@davemloft•net>,
Cong Wang <amwang@redhat•com>
Subject: Re: freeze with interface rename & SIOCGIFNAME
Date: Tue, 25 Jun 2013 18:27:43 +0200 [thread overview]
Message-ID: <51C9C4FF.1020706@freebox.fr> (raw)
In-Reply-To: <1372176951.3301.103.camel@edumazet-glaptop>
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
next prev parent reply other threads:[~2013-06-25 16:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <51C9BB9C.4050405@freebox.fr>
2013-06-25 16:15 ` freeze with interface rename & SIOCGIFNAME Eric Dumazet
2013-06-25 16:27 ` Nicolas Schichan [this message]
2013-06-25 16:57 ` Eric Dumazet
2013-06-25 17:05 ` Eric Dumazet
2013-06-25 17:12 ` Nicolas Schichan
2013-06-25 17:19 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51C9C4FF.1020706@freebox.fr \
--to=nschichan@freebox$(echo .)fr \
--cc=amwang@redhat$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=eric.dumazet@gmail$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox