The branch, batadv/net-next2 has been created at 5dc14eca2d6135e584d7f82051600ee3dad645b6 (commit)
- Shortlog ------------------------------------------------------------ commit 5dc14eca2d6135e584d7f82051600ee3dad645b6 Author: Linus Lüssing linus.luessing@c0d3.blue Date: Tue Nov 1 09:44:44 2016 +0100
batman-adv: fix rare race conditions on interface removal
In rare cases during shutdown the following general protection fault can happen:
general protection fault: 0000 [#1] SMP Modules linked in: batman_adv(O-) [...] CPU: 3 PID: 1714 Comm: rmmod Tainted: G O 4.6.0-rc6+ #1 [...] Call Trace: [<ffffffffa0363294>] batadv_hardif_disable_interface+0x29a/0x3a6 [batman_adv] [<ffffffffa0373db4>] batadv_softif_destroy_netlink+0x4b/0xa4 [batman_adv] [<ffffffff813b52f3>] __rtnl_link_unregister+0x48/0x92 [<ffffffff813b9240>] rtnl_link_unregister+0xc1/0xdb [<ffffffff8108547c>] ? bit_waitqueue+0x87/0x87 [<ffffffffa03850d2>] batadv_exit+0x1a/0xf48 [batman_adv] [<ffffffff810c26f9>] SyS_delete_module+0x136/0x1b0 [<ffffffff8144dc65>] entry_SYSCALL_64_fastpath+0x18/0xa8 [<ffffffff8108aaca>] ? trace_hardirqs_off_caller+0x37/0xa6 Code: 89 f7 e8 21 bd 0d e1 4d 85 e4 75 0e 31 f6 48 c7 c7 50 d7 3b a0 e8 50 16 f2 e0 49 8b 9c 24 28 01 00 00 48 85 db 0f 84 b2 00 00 00 <48> 8b 03 4d 85 ed 48 89 45 c8 74 09 4c 39 ab f8 00 00 00 75 1c RIP [<ffffffffa0371852>] batadv_purge_outstanding_packets+0x1c8/0x291 [batman_adv] RSP <ffff88001da5fd78> ---[ end trace 803b9bdc6a4a952b ]--- Kernel panic - not syncing: Fatal exception in interrupt Kernel Offset: disabled ---[ end Kernel panic - not syncing: Fatal exception in interrupt
It does not happen often, but may potentially happen when frequently shutting down and reinitializing an interface. With some carefully placed msleep()s/mdelay()s it can be reproduced easily.
The issue is, that on interface removal, any still running worker thread of a forwarding packet will race with the interface purging routine to free a forwarding packet. Temporarily giving up a spin-lock to be able to sleep in the purging routine is not safe.
Furthermore, there is a potential general protection fault not just for the purging side shown above, but also on the worker side: Temporarily removing a forw_packet from the according forw_{bcast,bat}_list will make it impossible for the purging routine to catch and cancel it.
# How this patch tries to fix it:
With this patch we split the queue purging into three steps: Step 1), removing forward packets from the queue of an interface and by that claim it as our responsibility to free.
Step 2), we are either lucky to cancel a pending worker before it starts to run. Or if it is already running, we wait and let it do its thing, except two things:
Through the claiming in step 1) we prevent workers from a) re-arming themselves. And b) prevent workers from freeing packets which we still hold in the interface purging routine.
Finally, step 3, we are sure that no forwarding packets are pending or even running anymore on the interface to remove. We can then safely free the claimed forwarding packets.
Signed-off-by: Linus Lüssing linus.luessing@c0d3.blue Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
commit d3f02fbf62d76b8d5e86262a327a9940b53f518b Author: Sven Eckelmann sven@narfation.org Date: Sat Oct 29 13:56:23 2016 +0200
batman-adv: Add module alias for batadv netlink family
The batman-adv module has to be loaded to fulfill genl request by the userspace. When it is not loaded then requests will fail. It is therefore useful to get the module automatically loaded when such a request is made.
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
commit ebbf81dfba957760366567c28b6a4a79e8c1efdc Author: Sven Eckelmann sven.eckelmann@open-mesh.com Date: Fri Sep 30 15:21:06 2016 +0200
batman-adv: Update wifi flags on upper link change
Things like VLANs don't have their link set when they are created. Thus the wifi flags have to be evaluated later to fix their contents for the link interface.
Signed-off-by: Sven Eckelmann sven.eckelmann@open-mesh.com Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
commit 5000765467207c8beecb587ebb9c2bd0c991fac9 Author: Marek Lindner mareklindner@neomailbox.ch Date: Fri Sep 30 15:21:05 2016 +0200
batman-adv: retrieve B.A.T.M.A.N. V WiFi neighbor stats from real interface
Signed-off-by: Marek Lindner mareklindner@neomailbox.ch [sven.eckelmann@open-mesh.com: re-add batadv_get_real_netdev to take rtnl semaphore for batadv_get_real_netdevice] Signed-off-by: Sven Eckelmann sven.eckelmann@open-mesh.com Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
commit d9bdcb4b1962244a2a1a12803ed150809983074b Author: Marek Lindner mareklindner@neomailbox.ch Date: Fri Sep 30 15:21:04 2016 +0200
batman-adv: additional checks for virtual interfaces on top of WiFi
In a few situations batman-adv tries to determine whether a given interface is a WiFi interface to enable specific WiFi optimizations. If the interface batman-adv has been configured with is a virtual interface (e.g. VLAN) it would not be properly detected as WiFi interface and thus not benefit from the special WiFi treatment. This patch changes that by peeking under the hood whenever a virtual interface is in play.
Signed-off-by: Marek Lindner mareklindner@neomailbox.ch [sven.eckelmann@open-mesh.com: integrate in wifi_flags caching, retrieve namespace of link interface] Signed-off-by: Sven Eckelmann sven.eckelmann@open-mesh.com Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
commit dc25ca1b24b9e7b24be5d6897677681098e83f44 Author: Sven Eckelmann sven.eckelmann@open-mesh.com Date: Fri Sep 30 15:21:03 2016 +0200
batman-adv: Cache the type of wifi device for each hardif
batman-adv is requiring the type of wifi device in different contexts. Some of them can take the rtnl semaphore and some of them already have the semaphore taken. But even others don't allow that the semaphore will be taken.
The data has to be retrieved when the hardif is added to batman-adv because some of the wifi information for an hardif will only be available with rtnl lock. It can then be cached in the batadv_hard_iface and the functions is_wifi_netdev and is_cfg80211_netdev can just compare the correct bits without imposing extra locking requirements.
Signed-off-by: Sven Eckelmann sven.eckelmann@open-mesh.com Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
commit 17681fb14d85c5b54fe869944f7ed29b244ded40 Author: Marek Lindner mareklindner@neomailbox.ch Date: Fri Sep 30 15:21:02 2016 +0200
batman-adv: refactor wifi interface detection
The ELP protocol requires cfg80211 to auto-detect the WiFi througput to a given neighbor. Use batadv_is_cfg80211_netdev() to determine whether or not an interface is eligible.
Signed-off-by: Marek Lindner mareklindner@neomailbox.ch Signed-off-by: Sven Eckelmann sven.eckelmann@open-mesh.com Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
commit a1a400c20220736cff514c1de065e66c574b5ec4 Author: Sven Eckelmann sven.eckelmann@open-mesh.com Date: Fri Sep 30 15:21:00 2016 +0200
batman-adv: Return non-const ptr in batadv_getlink_net
The returned net_namespace of batadv_getlink_net may be used with functions that potentially modify the struct. Thus it must return the pointer as non-const like rtnl_link_ops::get_link_net does.
Signed-off-by: Sven Eckelmann sven.eckelmann@open-mesh.com Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
commit cbec72d8b8ced43135b2e9375f658172ff326caa Author: Sven Eckelmann sven@narfation.org Date: Sat Aug 6 17:04:23 2016 +0200
batman-adv: Reject unicast packet with zero/mcast dst address
An unicast batman-adv packet cannot be transmitted to a multicast or zero mac address. So reject incoming packets which still have these classes of addresses as destination mac address in the outer ethernet header.
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
commit 4597f37c8bdf269c77d66f4571f8a4a6ec7e66be Author: Sven Eckelmann sven@narfation.org Date: Sat Aug 6 17:04:22 2016 +0200
batman-adv: Disallow zero and mcast src address for mgmt frames
The routing check for management frames is validating the source mac address in the outer ethernet header. It rejects every source mac address which is a broadcast address. But it also has to reject the zero-mac address and multicast mac addresses.
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
commit 26290f96a668de47f3234f33f9ba8169f19265ab Author: Sven Eckelmann sven@narfation.org Date: Sat Aug 6 17:04:21 2016 +0200
batman-adv: Disallow mcast src address for data frames
The routing checks are validating the source mac address of the outer ethernet header. They reject every source mac address which is a broadcast address. But they also have to reject any multicast mac addresses.
Signed-off-by: Sven Eckelmann sven@narfation.org [sw@simonwunderlich.de: fix commit message typo] Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
commit 4a0260755e12bbc490e2d2ad0b5c5abc1e54471a Author: Sven Eckelmann sven@narfation.org Date: Sun Jul 17 21:04:05 2016 +0200
batman-adv: Remove dev_queue_xmit return code exception
No caller of batadv_send_skb_to_orig is expecting the results to be -1 (-EPERM) anymore when the skbuff was not consumed. They will instead expect that the skbuff is always consumed. Having such return code filter is therefore not needed anymore.
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
-----------------------------------------------------------------------