6338edc5aa39d7576e223e922f15ffb8305cc859
[feed/routing.git] / batman-adv / patches / 0012-batman-adv-initialize-up-down-values-when-adding-a-g.patch
1 From 3c92b633715b7eca80dc7a2347e0e4dbcce1f018 Mon Sep 17 00:00:00 2001
2 From: Simon Wunderlich <simon@open-mesh.com>
3 Date: Wed, 24 Jun 2015 14:50:19 +0200
4 Subject: [PATCH 12/13] batman-adv: initialize up/down values when adding a
5 gateway
6
7 Without this initialization, gateways which actually announce up/down
8 bandwidth of 0/0 could be added. If these nodes get purged via
9 _batadv_purge_orig() later, the gw_node structure does not get removed
10 since batadv_gw_node_delete() updates the gw_node with up/down
11 bandwidth of 0/0, and the updating function then discards the change
12 and does not free gw_node.
13
14 This results in leaking the gw_node structures, which references other
15 structures: gw_node -> orig_node -> orig_node_ifinfo -> hardif. When
16 removing the interface later, the open reference on the hardif may cause
17 hangs with the infamous "unregister_netdevice: waiting for mesh1 to
18 become free. Usage count = 1" message.
19
20 Signed-off-by: Simon Wunderlich <simon@open-mesh.com>
21 Acked-by: Antonio Quartulli <antonio@meshcoding.com>
22 Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
23 ---
24 gateway_client.c | 2 ++
25 1 file changed, 2 insertions(+)
26
27 diff --git a/gateway_client.c b/gateway_client.c
28 index 3f32357..d8e3ead 100644
29 --- a/gateway_client.c
30 +++ b/gateway_client.c
31 @@ -419,6 +419,8 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv,
32
33 INIT_HLIST_NODE(&gw_node->list);
34 gw_node->orig_node = orig_node;
35 + gw_node->bandwidth_down = ntohl(gateway->bandwidth_down);
36 + gw_node->bandwidth_up = ntohl(gateway->bandwidth_up);
37 atomic_set(&gw_node->refcount, 1);
38
39 spin_lock_bh(&bat_priv->gw.list_lock);
40 --
41 2.1.4
42