-
- Downloads
Merge branch 'rtnetlink-rework-handler-registration'
Florian Westphal says: ==================== rtnetlink: rework handler (un)registering Peter Zijlstra reported (referring to commit 019a3169, "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. ==================== Signed-off-by:David S. Miller <davem@davemloft.net>
Showing
- include/net/rtnetlink.h 2 additions, 2 deletionsinclude/net/rtnetlink.h
- net/bridge/br_mdb.c 3 additions, 3 deletionsnet/bridge/br_mdb.c
- net/can/gw.c 10 additions, 4 deletionsnet/can/gw.c
- net/core/rtnetlink.c 172 additions, 98 deletionsnet/core/rtnetlink.c
- net/decnet/dn_dev.c 6 additions, 3 deletionsnet/decnet/dn_dev.c
- net/decnet/dn_fib.c 4 additions, 2 deletionsnet/decnet/dn_fib.c
- net/decnet/dn_route.c 4 additions, 4 deletionsnet/decnet/dn_route.c
- net/ipv6/addrconf.c 30 additions, 14 deletionsnet/ipv6/addrconf.c
- net/ipv6/addrlabel.c 6 additions, 7 deletionsnet/ipv6/addrlabel.c
- net/ipv6/ip6_fib.c 2 additions, 2 deletionsnet/ipv6/ip6_fib.c
- net/ipv6/route.c 15 additions, 5 deletionsnet/ipv6/route.c
- net/mpls/af_mpls.c 9 additions, 6 deletionsnet/mpls/af_mpls.c
- net/phonet/pn_netlink.c 13 additions, 8 deletionsnet/phonet/pn_netlink.c
- net/qrtr/qrtr.c 6 additions, 2 deletionsnet/qrtr/qrtr.c
Loading
Please register or sign in to comment