|
@@ -32,6 +32,7 @@
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/kernel.h>
|
|
|
#include <linux/kref.h>
|
|
#include <linux/kref.h>
|
|
|
#include <linux/list.h>
|
|
#include <linux/list.h>
|
|
|
|
|
+#include <linux/lockdep.h>
|
|
|
#include <linux/netdevice.h>
|
|
#include <linux/netdevice.h>
|
|
|
#include <linux/netlink.h>
|
|
#include <linux/netlink.h>
|
|
|
#include <linux/rculist.h>
|
|
#include <linux/rculist.h>
|
|
@@ -348,6 +349,9 @@ out:
|
|
|
* @bat_priv: the bat priv with all the soft interface information
|
|
* @bat_priv: the bat priv with all the soft interface information
|
|
|
* @orig_node: originator announcing gateway capabilities
|
|
* @orig_node: originator announcing gateway capabilities
|
|
|
* @gateway: announced bandwidth information
|
|
* @gateway: announced bandwidth information
|
|
|
|
|
+ *
|
|
|
|
|
+ * Has to be called with the appropriate locks being acquired
|
|
|
|
|
+ * (gw.list_lock).
|
|
|
*/
|
|
*/
|
|
|
static void batadv_gw_node_add(struct batadv_priv *bat_priv,
|
|
static void batadv_gw_node_add(struct batadv_priv *bat_priv,
|
|
|
struct batadv_orig_node *orig_node,
|
|
struct batadv_orig_node *orig_node,
|
|
@@ -355,6 +359,8 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv,
|
|
|
{
|
|
{
|
|
|
struct batadv_gw_node *gw_node;
|
|
struct batadv_gw_node *gw_node;
|
|
|
|
|
|
|
|
|
|
+ lockdep_assert_held(&bat_priv->gw.list_lock);
|
|
|
|
|
+
|
|
|
if (gateway->bandwidth_down == 0)
|
|
if (gateway->bandwidth_down == 0)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
@@ -369,10 +375,8 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv,
|
|
|
gw_node->bandwidth_down = ntohl(gateway->bandwidth_down);
|
|
gw_node->bandwidth_down = ntohl(gateway->bandwidth_down);
|
|
|
gw_node->bandwidth_up = ntohl(gateway->bandwidth_up);
|
|
gw_node->bandwidth_up = ntohl(gateway->bandwidth_up);
|
|
|
|
|
|
|
|
- spin_lock_bh(&bat_priv->gw.list_lock);
|
|
|
|
|
kref_get(&gw_node->refcount);
|
|
kref_get(&gw_node->refcount);
|
|
|
hlist_add_head_rcu(&gw_node->list, &bat_priv->gw.gateway_list);
|
|
hlist_add_head_rcu(&gw_node->list, &bat_priv->gw.gateway_list);
|
|
|
- spin_unlock_bh(&bat_priv->gw.list_lock);
|
|
|
|
|
|
|
|
|
|
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
|
|
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
|
|
|
"Found new gateway %pM -> gw bandwidth: %u.%u/%u.%u MBit\n",
|
|
"Found new gateway %pM -> gw bandwidth: %u.%u/%u.%u MBit\n",
|
|
@@ -428,11 +432,14 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv,
|
|
|
{
|
|
{
|
|
|
struct batadv_gw_node *gw_node, *curr_gw = NULL;
|
|
struct batadv_gw_node *gw_node, *curr_gw = NULL;
|
|
|
|
|
|
|
|
|
|
+ spin_lock_bh(&bat_priv->gw.list_lock);
|
|
|
gw_node = batadv_gw_node_get(bat_priv, orig_node);
|
|
gw_node = batadv_gw_node_get(bat_priv, orig_node);
|
|
|
if (!gw_node) {
|
|
if (!gw_node) {
|
|
|
batadv_gw_node_add(bat_priv, orig_node, gateway);
|
|
batadv_gw_node_add(bat_priv, orig_node, gateway);
|
|
|
|
|
+ spin_unlock_bh(&bat_priv->gw.list_lock);
|
|
|
goto out;
|
|
goto out;
|
|
|
}
|
|
}
|
|
|
|
|
+ spin_unlock_bh(&bat_priv->gw.list_lock);
|
|
|
|
|
|
|
|
if (gw_node->bandwidth_down == ntohl(gateway->bandwidth_down) &&
|
|
if (gw_node->bandwidth_down == ntohl(gateway->bandwidth_down) &&
|
|
|
gw_node->bandwidth_up == ntohl(gateway->bandwidth_up))
|
|
gw_node->bandwidth_up == ntohl(gateway->bandwidth_up))
|