Commit 25bb2509 authored by Sven Eckelmann's avatar Sven Eckelmann Committed by Antonio Quartulli

batman-adv: Rename batadv_neigh_node *_free_ref function to *_put

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.
Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
Signed-off-by: default avatarMarek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: default avatarAntonio Quartulli <a@unstable.cc>
parent 82047ad7
...@@ -1005,7 +1005,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv, ...@@ -1005,7 +1005,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
tmp_neigh_node->if_incoming == if_incoming && tmp_neigh_node->if_incoming == if_incoming &&
kref_get_unless_zero(&tmp_neigh_node->refcount)) { kref_get_unless_zero(&tmp_neigh_node->refcount)) {
if (WARN(neigh_node, "too many matching neigh_nodes")) if (WARN(neigh_node, "too many matching neigh_nodes"))
batadv_neigh_node_free_ref(neigh_node); batadv_neigh_node_put(neigh_node);
neigh_node = tmp_neigh_node; neigh_node = tmp_neigh_node;
continue; continue;
} }
...@@ -1116,9 +1116,9 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv, ...@@ -1116,9 +1116,9 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
rcu_read_unlock(); rcu_read_unlock();
out: out:
if (neigh_node) if (neigh_node)
batadv_neigh_node_free_ref(neigh_node); batadv_neigh_node_put(neigh_node);
if (router) if (router)
batadv_neigh_node_free_ref(router); batadv_neigh_node_put(router);
if (neigh_ifinfo) if (neigh_ifinfo)
batadv_neigh_ifinfo_free_ref(neigh_ifinfo); batadv_neigh_ifinfo_free_ref(neigh_ifinfo);
if (router_ifinfo) if (router_ifinfo)
...@@ -1265,7 +1265,7 @@ static int batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node, ...@@ -1265,7 +1265,7 @@ static int batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
out: out:
if (neigh_node) if (neigh_node)
batadv_neigh_node_free_ref(neigh_node); batadv_neigh_node_put(neigh_node);
return ret; return ret;
} }
...@@ -1568,11 +1568,11 @@ batadv_iv_ogm_process_per_outif(const struct sk_buff *skb, int ogm_offset, ...@@ -1568,11 +1568,11 @@ batadv_iv_ogm_process_per_outif(const struct sk_buff *skb, int ogm_offset,
if (router_ifinfo) if (router_ifinfo)
batadv_neigh_ifinfo_free_ref(router_ifinfo); batadv_neigh_ifinfo_free_ref(router_ifinfo);
if (router) if (router)
batadv_neigh_node_free_ref(router); batadv_neigh_node_put(router);
if (router_router) if (router_router)
batadv_neigh_node_free_ref(router_router); batadv_neigh_node_put(router_router);
if (orig_neigh_router) if (orig_neigh_router)
batadv_neigh_node_free_ref(orig_neigh_router); batadv_neigh_node_put(orig_neigh_router);
if (hardif_neigh) if (hardif_neigh)
batadv_hardif_neigh_free_ref(hardif_neigh); batadv_hardif_neigh_free_ref(hardif_neigh);
...@@ -1868,7 +1868,7 @@ static void batadv_iv_ogm_orig_print(struct batadv_priv *bat_priv, ...@@ -1868,7 +1868,7 @@ static void batadv_iv_ogm_orig_print(struct batadv_priv *bat_priv,
batman_count++; batman_count++;
next: next:
batadv_neigh_node_free_ref(neigh_node); batadv_neigh_node_put(neigh_node);
if (n_ifinfo) if (n_ifinfo)
batadv_neigh_ifinfo_free_ref(n_ifinfo); batadv_neigh_ifinfo_free_ref(n_ifinfo);
} }
......
...@@ -674,7 +674,7 @@ static bool batadv_dat_send_data(struct batadv_priv *bat_priv, ...@@ -674,7 +674,7 @@ static bool batadv_dat_send_data(struct batadv_priv *bat_priv,
ret = true; ret = true;
} }
free_neigh: free_neigh:
batadv_neigh_node_free_ref(neigh_node); batadv_neigh_node_put(neigh_node);
free_orig: free_orig:
batadv_orig_node_put(cand[i].orig_node); batadv_orig_node_put(cand[i].orig_node);
} }
......
...@@ -387,7 +387,7 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb, ...@@ -387,7 +387,7 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb,
if (orig_node_dst) if (orig_node_dst)
batadv_orig_node_put(orig_node_dst); batadv_orig_node_put(orig_node_dst);
if (neigh_node) if (neigh_node)
batadv_neigh_node_free_ref(neigh_node); batadv_neigh_node_put(neigh_node);
return ret; return ret;
} }
......
...@@ -235,7 +235,7 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv) ...@@ -235,7 +235,7 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
batadv_gw_node_free_ref(gw_node); batadv_gw_node_free_ref(gw_node);
next: next:
batadv_neigh_node_free_ref(router); batadv_neigh_node_put(router);
if (router_ifinfo) if (router_ifinfo)
batadv_neigh_ifinfo_free_ref(router_ifinfo); batadv_neigh_ifinfo_free_ref(router_ifinfo);
} }
...@@ -352,7 +352,7 @@ void batadv_gw_election(struct batadv_priv *bat_priv) ...@@ -352,7 +352,7 @@ void batadv_gw_election(struct batadv_priv *bat_priv)
if (next_gw) if (next_gw)
batadv_gw_node_free_ref(next_gw); batadv_gw_node_free_ref(next_gw);
if (router) if (router)
batadv_neigh_node_free_ref(router); batadv_neigh_node_put(router);
if (router_ifinfo) if (router_ifinfo)
batadv_neigh_ifinfo_free_ref(router_ifinfo); batadv_neigh_ifinfo_free_ref(router_ifinfo);
} }
...@@ -417,9 +417,9 @@ void batadv_gw_check_election(struct batadv_priv *bat_priv, ...@@ -417,9 +417,9 @@ void batadv_gw_check_election(struct batadv_priv *bat_priv,
if (curr_gw_orig) if (curr_gw_orig)
batadv_orig_node_put(curr_gw_orig); batadv_orig_node_put(curr_gw_orig);
if (router_gw) if (router_gw)
batadv_neigh_node_free_ref(router_gw); batadv_neigh_node_put(router_gw);
if (router_orig) if (router_orig)
batadv_neigh_node_free_ref(router_orig); batadv_neigh_node_put(router_orig);
if (router_gw_tq) if (router_gw_tq)
batadv_neigh_ifinfo_free_ref(router_gw_tq); batadv_neigh_ifinfo_free_ref(router_gw_tq);
if (router_orig_tq) if (router_orig_tq)
...@@ -626,7 +626,7 @@ static int batadv_write_buffer_text(struct batadv_priv *bat_priv, ...@@ -626,7 +626,7 @@ static int batadv_write_buffer_text(struct batadv_priv *bat_priv,
if (router_ifinfo) if (router_ifinfo)
batadv_neigh_ifinfo_free_ref(router_ifinfo); batadv_neigh_ifinfo_free_ref(router_ifinfo);
if (router) if (router)
batadv_neigh_node_free_ref(router); batadv_neigh_node_put(router);
return ret; return ret;
} }
...@@ -885,8 +885,8 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, ...@@ -885,8 +885,8 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
if (gw_node) if (gw_node)
batadv_gw_node_free_ref(gw_node); batadv_gw_node_free_ref(gw_node);
if (neigh_old) if (neigh_old)
batadv_neigh_node_free_ref(neigh_old); batadv_neigh_node_put(neigh_old);
if (neigh_curr) if (neigh_curr)
batadv_neigh_node_free_ref(neigh_curr); batadv_neigh_node_put(neigh_curr);
return out_of_range; return out_of_range;
} }
...@@ -290,7 +290,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, ...@@ -290,7 +290,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
if (primary_if) if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
if (neigh_node) if (neigh_node)
batadv_neigh_node_free_ref(neigh_node); batadv_neigh_node_put(neigh_node);
if (orig_node) if (orig_node)
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
return len; return len;
......
...@@ -1228,9 +1228,9 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv, ...@@ -1228,9 +1228,9 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv,
res = true; res = true;
out: out:
if (router_neigh) if (router_neigh)
batadv_neigh_node_free_ref(router_neigh); batadv_neigh_node_put(router_neigh);
if (router_coding) if (router_coding)
batadv_neigh_node_free_ref(router_coding); batadv_neigh_node_put(router_coding);
if (router_neigh_ifinfo) if (router_neigh_ifinfo)
batadv_neigh_ifinfo_free_ref(router_neigh_ifinfo); batadv_neigh_ifinfo_free_ref(router_neigh_ifinfo);
if (router_coding_ifinfo) if (router_coding_ifinfo)
......
...@@ -279,11 +279,11 @@ static void batadv_neigh_node_release(struct kref *ref) ...@@ -279,11 +279,11 @@ static void batadv_neigh_node_release(struct kref *ref)
} }
/** /**
* batadv_neigh_node_free_ref - decrement the neighbors refcounter and possibly * batadv_neigh_node_put - decrement the neighbors refcounter and possibly
* release it * release it
* @neigh_node: neigh neighbor to free * @neigh_node: neigh neighbor to free
*/ */
void batadv_neigh_node_free_ref(struct batadv_neigh_node *neigh_node) void batadv_neigh_node_put(struct batadv_neigh_node *neigh_node)
{ {
kref_put(&neigh_node->refcount, batadv_neigh_node_release); kref_put(&neigh_node->refcount, batadv_neigh_node_release);
} }
...@@ -737,7 +737,7 @@ static void batadv_orig_ifinfo_release(struct kref *ref) ...@@ -737,7 +737,7 @@ static void batadv_orig_ifinfo_release(struct kref *ref)
/* this is the last reference to this object */ /* this is the last reference to this object */
router = rcu_dereference_protected(orig_ifinfo->router, true); router = rcu_dereference_protected(orig_ifinfo->router, true);
if (router) if (router)
batadv_neigh_node_free_ref(router); batadv_neigh_node_put(router);
kfree_rcu(orig_ifinfo, rcu); kfree_rcu(orig_ifinfo, rcu);
} }
...@@ -793,7 +793,7 @@ static void batadv_orig_node_release(struct kref *ref) ...@@ -793,7 +793,7 @@ static void batadv_orig_node_release(struct kref *ref)
hlist_for_each_entry_safe(neigh_node, node_tmp, hlist_for_each_entry_safe(neigh_node, node_tmp,
&orig_node->neigh_list, list) { &orig_node->neigh_list, list) {
hlist_del_rcu(&neigh_node->list); hlist_del_rcu(&neigh_node->list);
batadv_neigh_node_free_ref(neigh_node); batadv_neigh_node_put(neigh_node);
} }
hlist_for_each_entry_safe(orig_ifinfo, node_tmp, hlist_for_each_entry_safe(orig_ifinfo, node_tmp,
...@@ -1069,7 +1069,7 @@ batadv_purge_orig_neighbors(struct batadv_priv *bat_priv, ...@@ -1069,7 +1069,7 @@ batadv_purge_orig_neighbors(struct batadv_priv *bat_priv,
neigh_purged = true; neigh_purged = true;
hlist_del_rcu(&neigh_node->list); hlist_del_rcu(&neigh_node->list);
batadv_neigh_node_free_ref(neigh_node); batadv_neigh_node_put(neigh_node);
} else { } else {
/* only necessary if not the whole neighbor is to be /* only necessary if not the whole neighbor is to be
* deleted, but some interface has been removed. * deleted, but some interface has been removed.
...@@ -1108,7 +1108,7 @@ batadv_find_best_neighbor(struct batadv_priv *bat_priv, ...@@ -1108,7 +1108,7 @@ batadv_find_best_neighbor(struct batadv_priv *bat_priv,
continue; continue;
if (best) if (best)
batadv_neigh_node_free_ref(best); batadv_neigh_node_put(best);
best = neigh; best = neigh;
} }
...@@ -1154,7 +1154,7 @@ static bool batadv_purge_orig_node(struct batadv_priv *bat_priv, ...@@ -1154,7 +1154,7 @@ static bool batadv_purge_orig_node(struct batadv_priv *bat_priv,
batadv_update_route(bat_priv, orig_node, BATADV_IF_DEFAULT, batadv_update_route(bat_priv, orig_node, BATADV_IF_DEFAULT,
best_neigh_node); best_neigh_node);
if (best_neigh_node) if (best_neigh_node)
batadv_neigh_node_free_ref(best_neigh_node); batadv_neigh_node_put(best_neigh_node);
/* ... then for all other interfaces. */ /* ... then for all other interfaces. */
rcu_read_lock(); rcu_read_lock();
...@@ -1171,7 +1171,7 @@ static bool batadv_purge_orig_node(struct batadv_priv *bat_priv, ...@@ -1171,7 +1171,7 @@ static bool batadv_purge_orig_node(struct batadv_priv *bat_priv,
batadv_update_route(bat_priv, orig_node, hard_iface, batadv_update_route(bat_priv, orig_node, hard_iface,
best_neigh_node); best_neigh_node);
if (best_neigh_node) if (best_neigh_node)
batadv_neigh_node_free_ref(best_neigh_node); batadv_neigh_node_put(best_neigh_node);
} }
rcu_read_unlock(); rcu_read_unlock();
......
...@@ -49,7 +49,7 @@ struct batadv_neigh_node * ...@@ -49,7 +49,7 @@ struct batadv_neigh_node *
batadv_neigh_node_new(struct batadv_orig_node *orig_node, batadv_neigh_node_new(struct batadv_orig_node *orig_node,
struct batadv_hard_iface *hard_iface, struct batadv_hard_iface *hard_iface,
const u8 *neigh_addr); const u8 *neigh_addr);
void batadv_neigh_node_free_ref(struct batadv_neigh_node *neigh_node); void batadv_neigh_node_put(struct batadv_neigh_node *neigh_node);
struct batadv_neigh_node * struct batadv_neigh_node *
batadv_orig_router_get(struct batadv_orig_node *orig_node, batadv_orig_router_get(struct batadv_orig_node *orig_node,
const struct batadv_hard_iface *if_outgoing); const struct batadv_hard_iface *if_outgoing);
......
...@@ -98,7 +98,7 @@ static void _batadv_update_route(struct batadv_priv *bat_priv, ...@@ -98,7 +98,7 @@ static void _batadv_update_route(struct batadv_priv *bat_priv,
} }
if (curr_router) if (curr_router)
batadv_neigh_node_free_ref(curr_router); batadv_neigh_node_put(curr_router);
/* increase refcount of new best neighbor */ /* increase refcount of new best neighbor */
if (neigh_node && !kref_get_unless_zero(&neigh_node->refcount)) if (neigh_node && !kref_get_unless_zero(&neigh_node->refcount))
...@@ -111,7 +111,7 @@ static void _batadv_update_route(struct batadv_priv *bat_priv, ...@@ -111,7 +111,7 @@ static void _batadv_update_route(struct batadv_priv *bat_priv,
/* decrease refcount of previous best neighbor */ /* decrease refcount of previous best neighbor */
if (curr_router) if (curr_router)
batadv_neigh_node_free_ref(curr_router); batadv_neigh_node_put(curr_router);
} }
/** /**
...@@ -138,7 +138,7 @@ void batadv_update_route(struct batadv_priv *bat_priv, ...@@ -138,7 +138,7 @@ void batadv_update_route(struct batadv_priv *bat_priv,
out: out:
if (router) if (router)
batadv_neigh_node_free_ref(router); batadv_neigh_node_put(router);
} }
/** /**
...@@ -545,7 +545,7 @@ batadv_find_router(struct batadv_priv *bat_priv, ...@@ -545,7 +545,7 @@ batadv_find_router(struct batadv_priv *bat_priv,
next: next:
/* free references */ /* free references */
if (cand_router) { if (cand_router) {
batadv_neigh_node_free_ref(cand_router); batadv_neigh_node_put(cand_router);
cand_router = NULL; cand_router = NULL;
} }
batadv_orig_ifinfo_free_ref(cand); batadv_orig_ifinfo_free_ref(cand);
...@@ -562,17 +562,17 @@ batadv_find_router(struct batadv_priv *bat_priv, ...@@ -562,17 +562,17 @@ batadv_find_router(struct batadv_priv *bat_priv,
* 3) there is no candidate at all, return the default router * 3) there is no candidate at all, return the default router
*/ */
if (next_candidate) { if (next_candidate) {
batadv_neigh_node_free_ref(router); batadv_neigh_node_put(router);
/* remove references to first candidate, we don't need it. */ /* remove references to first candidate, we don't need it. */
if (first_candidate) { if (first_candidate) {
batadv_neigh_node_free_ref(first_candidate_router); batadv_neigh_node_put(first_candidate_router);
batadv_orig_ifinfo_free_ref(first_candidate); batadv_orig_ifinfo_free_ref(first_candidate);
} }
router = next_candidate_router; router = next_candidate_router;
orig_node->last_bonding_candidate = next_candidate; orig_node->last_bonding_candidate = next_candidate;
} else if (first_candidate) { } else if (first_candidate) {
batadv_neigh_node_free_ref(router); batadv_neigh_node_put(router);
/* refcounting has already been done in the loop above. */ /* refcounting has already been done in the loop above. */
router = first_candidate_router; router = first_candidate_router;
......
...@@ -153,7 +153,7 @@ int batadv_send_skb_to_orig(struct sk_buff *skb, ...@@ -153,7 +153,7 @@ int batadv_send_skb_to_orig(struct sk_buff *skb,
out: out:
if (neigh_node) if (neigh_node)
batadv_neigh_node_free_ref(neigh_node); batadv_neigh_node_put(neigh_node);
return ret; return ret;
} }
......
...@@ -1586,20 +1586,20 @@ batadv_transtable_best_orig(struct batadv_priv *bat_priv, ...@@ -1586,20 +1586,20 @@ batadv_transtable_best_orig(struct batadv_priv *bat_priv,
if (best_router && if (best_router &&
bao->bat_neigh_cmp(router, BATADV_IF_DEFAULT, bao->bat_neigh_cmp(router, BATADV_IF_DEFAULT,
best_router, BATADV_IF_DEFAULT) <= 0) { best_router, BATADV_IF_DEFAULT) <= 0) {
batadv_neigh_node_free_ref(router); batadv_neigh_node_put(router);
continue; continue;
} }
/* release the refcount for the "old" best */ /* release the refcount for the "old" best */
if (best_router) if (best_router)
batadv_neigh_node_free_ref(best_router); batadv_neigh_node_put(best_router);
best_entry = orig_entry; best_entry = orig_entry;
best_router = router; best_router = router;
} }
if (best_router) if (best_router)
batadv_neigh_node_free_ref(best_router); batadv_neigh_node_put(best_router);
return best_entry; return best_entry;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment