From: Stephen Hemminger <shemminger@vyatta.com>
To: Madhvapathi Sriram <sriram.madhvapathi@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: query : unregister/register netdev
Date: Fri, 18 Nov 2011 08:22:00 -0800 [thread overview]
Message-ID: <20111118082200.2c973d0c@nehalam.linuxnetplumber.net> (raw)
In-Reply-To: <CAAvRe=jhfXEnLFkwbPmWEroDE-qHUpZ54TSSdw=WpmfPGZpsPQ@mail.gmail.com>
On Fri, 18 Nov 2011 17:53:37 +0530
Madhvapathi Sriram <sriram.madhvapathi@gmail.com> wrote:
> In register_netdevice(), BUG_ON(dev->reg_state != NETREG_UNINITIALIZED) is
> used to check if the device that is being registered is indeed a new one.
>
> However, I see that this state is never moved to. It only happens when a
> netdevice is allocated (by default to 0 using kzalloc).
>
> So, the cycle register-->unregister-->register would fail since in the
> unregister_netdevice the state is only moved to NETREG_UNREGISTERED (at max
> to NETREG_RELEASED using free_netdev)
>
> So, I presume that to reinitialize a netdevice one has to free the
> netdevice, re allocate netdevice and only then re register.
>
> Wondering why unregister and reregister is not allowed, rather than having
> go through the free/alloc cycle - I am not an expert though.
There are two reasons. First because of RCU the device object still might
be in use after unregister (until after RCU quiescent period). But the real
reason is that no device driver existing needed it. The normal use case
of unregister is when device is being removed or session for a virtual device
is going away.
next prev parent reply other threads:[~2011-11-18 16:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-18 12:23 query : unregister/register netdev Madhvapathi Sriram
2011-11-18 15:52 ` Ben Hutchings
2011-11-18 16:22 ` Stephen Hemminger [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-11-23 11:14 manoj bm
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=20111118082200.2c973d0c@nehalam.linuxnetplumber.net \
--to=shemminger@vyatta.com \
--cc=netdev@vger.kernel.org \
--cc=sriram.madhvapathi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.