Skip to content

Commit

Permalink
Merge tag 'batadv-net-for-davem-20160914' of git://git.open-mesh.org/…
Browse files Browse the repository at this point in the history
…linux-merge

Simon Wunderlich says:

====================
Here are two batman-adv bugfix patches:

 - Fix reference counting for last_bonding_candidate, by Sven Eckelmann

 - Fix head room reservation for ELP packets, by Linus Luessing
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Sep 16, 2016
2 parents 2a29282 + 1e5d343 commit 6777ae8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion net/batman-adv/bat_v_elp.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface)
goto out;

skb_reserve(hard_iface->bat_v.elp_skb, ETH_HLEN + NET_IP_ALIGN);
elp_buff = skb_push(hard_iface->bat_v.elp_skb, BATADV_ELP_HLEN);
elp_buff = skb_put(hard_iface->bat_v.elp_skb, BATADV_ELP_HLEN);
elp_packet = (struct batadv_elp_packet *)elp_buff;
memset(elp_packet, 0, BATADV_ELP_HLEN);

Expand Down
28 changes: 27 additions & 1 deletion net/batman-adv/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,29 @@ static int batadv_check_unicast_packet(struct batadv_priv *bat_priv,
return 0;
}

/**
* batadv_last_bonding_get - Get last_bonding_candidate of orig_node
* @orig_node: originator node whose last bonding candidate should be retrieved
*
* Return: last bonding candidate of router or NULL if not found
*
* The object is returned with refcounter increased by 1.
*/
static struct batadv_orig_ifinfo *
batadv_last_bonding_get(struct batadv_orig_node *orig_node)
{
struct batadv_orig_ifinfo *last_bonding_candidate;

spin_lock_bh(&orig_node->neigh_list_lock);
last_bonding_candidate = orig_node->last_bonding_candidate;

if (last_bonding_candidate)
kref_get(&last_bonding_candidate->refcount);
spin_unlock_bh(&orig_node->neigh_list_lock);

return last_bonding_candidate;
}

/**
* batadv_last_bonding_replace - Replace last_bonding_candidate of orig_node
* @orig_node: originator node whose bonding candidates should be replaced
Expand Down Expand Up @@ -539,7 +562,7 @@ batadv_find_router(struct batadv_priv *bat_priv,
* router - obviously there are no other candidates.
*/
rcu_read_lock();
last_candidate = orig_node->last_bonding_candidate;
last_candidate = batadv_last_bonding_get(orig_node);
if (last_candidate)
last_cand_router = rcu_dereference(last_candidate->router);

Expand Down Expand Up @@ -631,6 +654,9 @@ batadv_find_router(struct batadv_priv *bat_priv,
batadv_orig_ifinfo_put(next_candidate);
}

if (last_candidate)
batadv_orig_ifinfo_put(last_candidate);

return router;
}

Expand Down

0 comments on commit 6777ae8

Please sign in to comment.