Re: [PATCH net-next 2/8] rtnetlink: add rtnl_register_module

2017-11-13 Thread Florian Westphal
Peter Zijlstra wrote: > On Mon, Nov 13, 2017 at 08:21:59AM +0100, Florian Westphal wrote: > > Reason is that some places do this: > > > > rtnl_register(pf, RTM_FOO, doit, NULL, 0); > > rtnl_register(pf, RTM_FOO, NULL, dumpit, 0); > > Sure, however, > > > (from different call sites in the stack)

Re: [PATCH net-next 2/8] rtnetlink: add rtnl_register_module

2017-11-12 Thread Peter Zijlstra
On Mon, Nov 13, 2017 at 08:21:59AM +0100, Florian Westphal wrote: > Reason is that some places do this: > > rtnl_register(pf, RTM_FOO, doit, NULL, 0); > rtnl_register(pf, RTM_FOO, NULL, dumpit, 0); Sure, however, > (from different call sites in the stack). > > - if (doit) > > - tab[m

Re: [PATCH net-next 2/8] rtnetlink: add rtnl_register_module

2017-11-12 Thread Florian Westphal
Peter Zijlstra wrote: > On Tue, Nov 07, 2017 at 10:47:51AM +0100, Florian Westphal wrote: > > I would expect this to trigger all the time, due to > > > > rtnl_register(AF_INET, RTM_GETROUTE, ... > > rtnl_register(AF_INET, RTM_GETADDR, ... > > Ah, sure, then something like so then... > > There's

Re: [PATCH net-next 2/8] rtnetlink: add rtnl_register_module

2017-11-08 Thread Stephen Hemminger
On Tue, 7 Nov 2017 15:57:36 +0100 Peter Zijlstra wrote: > + link = tab[msgindex]; > + rcu_assign_pointer(tab[msgindex], NULL); It is not necessary (or useful) to use rcu_assign_pointer with NULL. The rcu_assign_pointer used to special case NULL but doesn't in recent years.

Re: [PATCH net-next 2/8] rtnetlink: add rtnl_register_module

2017-11-07 Thread Peter Zijlstra
On Tue, Nov 07, 2017 at 10:47:51AM +0100, Florian Westphal wrote: > I would expect this to trigger all the time, due to > > rtnl_register(AF_INET, RTM_GETROUTE, ... > rtnl_register(AF_INET, RTM_GETADDR, ... Ah, sure, then something like so then... There's bound to be bugs there too, as I pretty

Re: [PATCH net-next 2/8] rtnetlink: add rtnl_register_module

2017-11-07 Thread Florian Westphal
Peter Zijlstra wrote: > Something like the below would go some way toward sanitizing this stuff; > rcu_assign_pointer() is a store-release, meaning it happens after > everything coming before. > > Therefore, when you observe that tab (through rcu_dereference) you're > guaranteed to see the thing

Re: [PATCH net-next 2/8] rtnetlink: add rtnl_register_module

2017-11-07 Thread Florian Westphal
Peter Zijlstra wrote: > > rtnetlink_rcv_msg: > > > > 4406 dumpit = READ_ONCE(handlers[type].dumpit); > > 4407 if (!dumpit) > > 4408 goto err_unlock; > > 4409 owner = READ_ONCE(handlers[type].ow

Re: [PATCH net-next 2/8] rtnetlink: add rtnl_register_module

2017-11-07 Thread Peter Zijlstra
On Tue, Nov 07, 2017 at 10:10:04AM +0100, Peter Zijlstra wrote: > On Tue, Nov 07, 2017 at 07:11:56AM +0100, Florian Westphal wrote: > > Peter Zijlstra wrote: > > > On Mon, Nov 06, 2017 at 11:51:07AM +0100, Florian Westphal wrote: > > > > @@ -180,6 +164,12 @@ int __rtnl_register(int protocol, int m

Re: [PATCH net-next 2/8] rtnetlink: add rtnl_register_module

2017-11-07 Thread Peter Zijlstra
On Tue, Nov 07, 2017 at 07:11:56AM +0100, Florian Westphal wrote: > Peter Zijlstra wrote: > > On Mon, Nov 06, 2017 at 11:51:07AM +0100, Florian Westphal wrote: > > > @@ -180,6 +164,12 @@ int __rtnl_register(int protocol, int msgtype, > > > rcu_assign_pointer(rtnl_msg_handlers[protocol],

Re: [PATCH net-next 2/8] rtnetlink: add rtnl_register_module

2017-11-06 Thread Florian Westphal
Peter Zijlstra wrote: > On Mon, Nov 06, 2017 at 11:51:07AM +0100, Florian Westphal wrote: > > @@ -180,6 +164,12 @@ int __rtnl_register(int protocol, int msgtype, > > rcu_assign_pointer(rtnl_msg_handlers[protocol], tab); > > } > > > > + WARN_ON(tab[msgindex].owner && tab[msginde

Re: [PATCH net-next 2/8] rtnetlink: add rtnl_register_module

2017-11-06 Thread Peter Zijlstra
On Mon, Nov 06, 2017 at 11:51:07AM +0100, Florian Westphal wrote: > @@ -180,6 +164,12 @@ int __rtnl_register(int protocol, int msgtype, > rcu_assign_pointer(rtnl_msg_handlers[protocol], tab); > } > > + WARN_ON(tab[msgindex].owner && tab[msgindex].owner != owner); > + > +

[PATCH net-next 2/8] rtnetlink: add rtnl_register_module

2017-11-06 Thread Florian Westphal
Add yet another rtnl_register function. It will be used by modules that can be removed. The passed module struct is used to take a reference while a netlink dump is in progress to prevent module unload while netlink core can invoke registered dumper function again. Signed-off-by: Florian Westpha