netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: David Miller <davem@davemloft.net>
Cc: fw@strlen.de, netdev@vger.kernel.org
Subject: Re: [PATCH next-next 0/4] rtnetlink: rework handler (un)registering
Date: Mon, 4 Dec 2017 17:53:04 +0100	[thread overview]
Message-ID: <20171204165304.GC28667@breakpoint.cc> (raw)
In-Reply-To: <20171204.113401.1266159215993063523.davem@davemloft.net>

David Miller <davem@davemloft.net> wrote:
> From: Florian Westphal <fw@strlen.de>
> Date: Sat,  2 Dec 2017 21:44:04 +0100
> 
> > Peter Zijlstra reported (referring to commit 019a316992ee0d983,
> > "rtnetlink: add reference counting to prevent module unload while dump is in progress"):
> > 
> >  1) it not in fact a refcount, so using refcount_t is silly
> >  2) there is a distinct lack of memory barriers, so we can easily
> >     observe the decrement while the msg_handler is still in progress.
> >  3) waiting with a schedule()/yield() loop is complete crap and subject
> >     life-locks, imagine doing that rtnl_unregister_all() from a RT task.
> > 
> > In ancient times rtnetlink exposed a statically-sized table with
> > preset doit/dumpit handlers to be called for a protocol/type pair.
> > 
> > Later the rtnl_register interface was added and the table was allocated
> > on demand.  Eventually these were also used by modules.
> > 
> > Problem is that nothing prevents module unload while a netlink dump
> > is in progress.  netlink dumps can be span multiple recv calls and
> > netlink core saves the to-be-repeated dumper address for later invocation.
> > 
> > To prevent rmmod the netlink core expects callers to pass in the owning
> > module so a reference can be taken.
> > 
> > So far rtnetlink wasn't doing this, add new interface to pass THIS_MODULE.
> > Moreover, when converting parts of the rtnetlink handling to rcu this code
> > gained way too many READ_ONCE spots, remove them and the extra refcounting.
> > 
> > Take a module reference when running dumpit and doit callbacks
> > and never alter content of rtnl_link structures after they have been
> > published via rcu_assign_pointer.
> > 
> > Based partially on earlier patch from Peter.
> 
> Series applied, thanks Florian.
> 
> BTW, why did you use rtnl_register_module() for most of ipv6 but
> specifically not for the net/ipv6/addrconf.c stuff?

Right, originally I did not convert ipv6 at all, as even if its
a module it cannot be unloaded.

Then I thought it might be good to also get rid of of panic() in
rtnl_register (which made __rtnl_register redundant).

I switched to _module() where error handling wasn't too hard
(i.e., where we can make module insertion fail without adding too many
 error unwinding stunts).

The only difference is that theoretically some addrlabel rtnetlink
ops are not available if registration fails, but thats not really worse
than before as this used to panic() instead :-)

I can send a followup patch, to convert all of ipv6, should be easy
to propagate errors from addrlabel initialisation to its callsite.

  reply	other threads:[~2017-12-04 16:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-02 20:44 [PATCH next-next 0/4] rtnetlink: rework handler (un)registering Florian Westphal
2017-12-02 20:44 ` [PATCH net-next 1/4] net: rtnetlink: use rcu to free rtnl message handlers Florian Westphal
2017-12-02 20:44 ` [PATCH net-next 2/4] rtnetlink: get reference on module before invoking handlers Florian Westphal
2017-12-02 20:44 ` [PATCH net-next 3/4] net: use rtnl_register_module where needed Florian Westphal
2017-12-04  2:56   ` David Ahern
2017-12-04  2:57     ` David Ahern
2017-12-02 20:44 ` [PATCH net-next 4/4] rtnetlink: remove __rtnl_register Florian Westphal
2017-12-04 16:34 ` [PATCH next-next 0/4] rtnetlink: rework handler (un)registering David Miller
2017-12-04 16:53   ` Florian Westphal [this message]
2017-12-04 16:57     ` David Miller

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=20171204165304.GC28667@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).