Commit 9b69d206 authored by David S. Miller's avatar David S. Miller

Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge

Antonio Quartulli says:

====================
pull request [net-next]: batman-adv 20160223

This is a cleanup patchset: first the BATADV_BONDING_TQ_THRESHOLD
constant gets removed as it was defined but not used anywhere,
then all our *_free_ref functions are renamed to *_put in order
to follow the kernel naming convention by Sven Eckelmann.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents a30a9ea6 7e2366c6
...@@ -287,8 +287,8 @@ batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const u8 *addr) ...@@ -287,8 +287,8 @@ batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const u8 *addr)
free_orig_node: free_orig_node:
/* free twice, as batadv_orig_node_new sets refcount to 2 */ /* free twice, as batadv_orig_node_new sets refcount to 2 */
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
return NULL; return NULL;
} }
...@@ -515,7 +515,7 @@ static void batadv_iv_ogm_emit(struct batadv_forw_packet *forw_packet) ...@@ -515,7 +515,7 @@ static void batadv_iv_ogm_emit(struct batadv_forw_packet *forw_packet)
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
} }
/** /**
...@@ -617,7 +617,7 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet, ...@@ -617,7 +617,7 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet,
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
return res; return res;
} }
...@@ -711,9 +711,9 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, ...@@ -711,9 +711,9 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
if (!own_packet) if (!own_packet)
atomic_inc(&bat_priv->batman_queue_left); atomic_inc(&bat_priv->batman_queue_left);
out_free_outgoing: out_free_outgoing:
batadv_hardif_free_ref(if_outgoing); batadv_hardif_put(if_outgoing);
out_free_incoming: out_free_incoming:
batadv_hardif_free_ref(if_incoming); batadv_hardif_put(if_incoming);
} }
/* aggregate a new packet into the existing ogm packet */ /* aggregate a new packet into the existing ogm packet */
...@@ -958,7 +958,7 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface) ...@@ -958,7 +958,7 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
} }
/** /**
...@@ -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;
} }
...@@ -1026,7 +1026,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv, ...@@ -1026,7 +1026,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
neigh_ifinfo->bat_iv.tq_avg = tq_avg; neigh_ifinfo->bat_iv.tq_avg = tq_avg;
spin_unlock_bh(&tmp_neigh_node->ifinfo_lock); spin_unlock_bh(&tmp_neigh_node->ifinfo_lock);
batadv_neigh_ifinfo_free_ref(neigh_ifinfo); batadv_neigh_ifinfo_put(neigh_ifinfo);
neigh_ifinfo = NULL; neigh_ifinfo = NULL;
} }
...@@ -1041,7 +1041,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv, ...@@ -1041,7 +1041,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
ethhdr->h_source, ethhdr->h_source,
orig_node, orig_tmp); orig_node, orig_tmp);
batadv_orig_node_free_ref(orig_tmp); batadv_orig_node_put(orig_tmp);
if (!neigh_node) if (!neigh_node)
goto unlock; goto unlock;
} else { } else {
...@@ -1116,13 +1116,13 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv, ...@@ -1116,13 +1116,13 @@ 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_put(neigh_ifinfo);
if (router_ifinfo) if (router_ifinfo)
batadv_neigh_ifinfo_free_ref(router_ifinfo); batadv_neigh_ifinfo_put(router_ifinfo);
} }
/** /**
...@@ -1192,7 +1192,7 @@ static int batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node, ...@@ -1192,7 +1192,7 @@ static int batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
neigh_ifinfo = batadv_neigh_ifinfo_new(neigh_node, if_outgoing); neigh_ifinfo = batadv_neigh_ifinfo_new(neigh_node, if_outgoing);
if (neigh_ifinfo) { if (neigh_ifinfo) {
neigh_rq_count = neigh_ifinfo->bat_iv.real_packet_count; neigh_rq_count = neigh_ifinfo->bat_iv.real_packet_count;
batadv_neigh_ifinfo_free_ref(neigh_ifinfo); batadv_neigh_ifinfo_put(neigh_ifinfo);
} else { } else {
neigh_rq_count = 0; neigh_rq_count = 0;
} }
...@@ -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;
} }
...@@ -1306,7 +1306,7 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, ...@@ -1306,7 +1306,7 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
orig_ifinfo = batadv_orig_ifinfo_new(orig_node, if_outgoing); orig_ifinfo = batadv_orig_ifinfo_new(orig_node, if_outgoing);
if (WARN_ON(!orig_ifinfo)) { if (WARN_ON(!orig_ifinfo)) {
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
return 0; return 0;
} }
...@@ -1353,7 +1353,7 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, ...@@ -1353,7 +1353,7 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
packet_count = bitmap_weight(bitmap, packet_count = bitmap_weight(bitmap,
BATADV_TQ_LOCAL_WINDOW_SIZE); BATADV_TQ_LOCAL_WINDOW_SIZE);
neigh_ifinfo->bat_iv.real_packet_count = packet_count; neigh_ifinfo->bat_iv.real_packet_count = packet_count;
batadv_neigh_ifinfo_free_ref(neigh_ifinfo); batadv_neigh_ifinfo_put(neigh_ifinfo);
} }
rcu_read_unlock(); rcu_read_unlock();
...@@ -1367,8 +1367,8 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, ...@@ -1367,8 +1367,8 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
out: out:
spin_unlock_bh(&orig_node->bat_iv.ogm_cnt_lock); spin_unlock_bh(&orig_node->bat_iv.ogm_cnt_lock);
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
batadv_orig_ifinfo_free_ref(orig_ifinfo); batadv_orig_ifinfo_put(orig_ifinfo);
return ret; return ret;
} }
...@@ -1514,7 +1514,7 @@ batadv_iv_ogm_process_per_outif(const struct sk_buff *skb, int ogm_offset, ...@@ -1514,7 +1514,7 @@ batadv_iv_ogm_process_per_outif(const struct sk_buff *skb, int ogm_offset,
ogm_packet, if_incoming, ogm_packet, if_incoming,
if_outgoing, dup_status); if_outgoing, dup_status);
} }
batadv_orig_ifinfo_free_ref(orig_ifinfo); batadv_orig_ifinfo_put(orig_ifinfo);
/* only forward for specific interface, not for the default one. */ /* only forward for specific interface, not for the default one. */
if (if_outgoing == BATADV_IF_DEFAULT) if (if_outgoing == BATADV_IF_DEFAULT)
...@@ -1563,18 +1563,18 @@ batadv_iv_ogm_process_per_outif(const struct sk_buff *skb, int ogm_offset, ...@@ -1563,18 +1563,18 @@ batadv_iv_ogm_process_per_outif(const struct sk_buff *skb, int ogm_offset,
out_neigh: out_neigh:
if ((orig_neigh_node) && (!is_single_hop_neigh)) if ((orig_neigh_node) && (!is_single_hop_neigh))
batadv_orig_node_free_ref(orig_neigh_node); batadv_orig_node_put(orig_neigh_node);
out: out:
if (router_ifinfo) if (router_ifinfo)
batadv_neigh_ifinfo_free_ref(router_ifinfo); batadv_neigh_ifinfo_put(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_put(hardif_neigh);
kfree_skb(skb_priv); kfree_skb(skb_priv);
} }
...@@ -1697,7 +1697,7 @@ static void batadv_iv_ogm_process(const struct sk_buff *skb, int ogm_offset, ...@@ -1697,7 +1697,7 @@ static void batadv_iv_ogm_process(const struct sk_buff *skb, int ogm_offset,
batadv_dbg(BATADV_DBG_BATMAN, bat_priv, batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Drop packet: originator packet from myself (via neighbor)\n"); "Drop packet: originator packet from myself (via neighbor)\n");
batadv_orig_node_free_ref(orig_neigh_node); batadv_orig_node_put(orig_neigh_node);
return; return;
} }
...@@ -1735,7 +1735,7 @@ static void batadv_iv_ogm_process(const struct sk_buff *skb, int ogm_offset, ...@@ -1735,7 +1735,7 @@ static void batadv_iv_ogm_process(const struct sk_buff *skb, int ogm_offset,
} }
rcu_read_unlock(); rcu_read_unlock();
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
} }
static int batadv_iv_ogm_receive(struct sk_buff *skb, static int batadv_iv_ogm_receive(struct sk_buff *skb,
...@@ -1805,7 +1805,7 @@ batadv_iv_ogm_orig_print_neigh(struct batadv_orig_node *orig_node, ...@@ -1805,7 +1805,7 @@ batadv_iv_ogm_orig_print_neigh(struct batadv_orig_node *orig_node,
neigh_node->addr, neigh_node->addr,
n_ifinfo->bat_iv.tq_avg); n_ifinfo->bat_iv.tq_avg);
batadv_neigh_ifinfo_free_ref(n_ifinfo); batadv_neigh_ifinfo_put(n_ifinfo);
} }
} }
...@@ -1868,9 +1868,9 @@ static void batadv_iv_ogm_orig_print(struct batadv_priv *bat_priv, ...@@ -1868,9 +1868,9 @@ 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_put(n_ifinfo);
} }
rcu_read_unlock(); rcu_read_unlock();
} }
...@@ -1964,9 +1964,9 @@ static int batadv_iv_ogm_neigh_cmp(struct batadv_neigh_node *neigh1, ...@@ -1964,9 +1964,9 @@ static int batadv_iv_ogm_neigh_cmp(struct batadv_neigh_node *neigh1,
out: out:
if (neigh1_ifinfo) if (neigh1_ifinfo)
batadv_neigh_ifinfo_free_ref(neigh1_ifinfo); batadv_neigh_ifinfo_put(neigh1_ifinfo);
if (neigh2_ifinfo) if (neigh2_ifinfo)
batadv_neigh_ifinfo_free_ref(neigh2_ifinfo); batadv_neigh_ifinfo_put(neigh2_ifinfo);
return diff; return diff;
} }
...@@ -2007,9 +2007,9 @@ batadv_iv_ogm_neigh_is_sob(struct batadv_neigh_node *neigh1, ...@@ -2007,9 +2007,9 @@ batadv_iv_ogm_neigh_is_sob(struct batadv_neigh_node *neigh1,
out: out:
if (neigh1_ifinfo) if (neigh1_ifinfo)
batadv_neigh_ifinfo_free_ref(neigh1_ifinfo); batadv_neigh_ifinfo_put(neigh1_ifinfo);
if (neigh2_ifinfo) if (neigh2_ifinfo)
batadv_neigh_ifinfo_free_ref(neigh2_ifinfo); batadv_neigh_ifinfo_put(neigh2_ifinfo);
return ret; return ret;
} }
......
...@@ -159,12 +159,11 @@ static void batadv_backbone_gw_release(struct kref *ref) ...@@ -159,12 +159,11 @@ static void batadv_backbone_gw_release(struct kref *ref)
} }
/** /**
* batadv_backbone_gw_free_ref - decrement the backbone gw refcounter and * batadv_backbone_gw_put - decrement the backbone gw refcounter and possibly
* possibly release it * release it
* @backbone_gw: backbone gateway to be free'd * @backbone_gw: backbone gateway to be free'd
*/ */
static void static void batadv_backbone_gw_put(struct batadv_bla_backbone_gw *backbone_gw)
batadv_backbone_gw_free_ref(struct batadv_bla_backbone_gw *backbone_gw)
{ {
kref_put(&backbone_gw->refcount, batadv_backbone_gw_release); kref_put(&backbone_gw->refcount, batadv_backbone_gw_release);
} }
...@@ -180,16 +179,16 @@ static void batadv_claim_release(struct kref *ref) ...@@ -180,16 +179,16 @@ static void batadv_claim_release(struct kref *ref)
claim = container_of(ref, struct batadv_bla_claim, refcount); claim = container_of(ref, struct batadv_bla_claim, refcount);
batadv_backbone_gw_free_ref(claim->backbone_gw); batadv_backbone_gw_put(claim->backbone_gw);
kfree_rcu(claim, rcu); kfree_rcu(claim, rcu);
} }
/** /**
* batadv_claim_free_ref - decrement the claim refcounter and possibly * batadv_claim_put - decrement the claim refcounter and possibly
* release it * release it
* @claim: claim to be free'd * @claim: claim to be free'd
*/ */
static void batadv_claim_free_ref(struct batadv_bla_claim *claim) static void batadv_claim_put(struct batadv_bla_claim *claim)
{ {
kref_put(&claim->refcount, batadv_claim_release); kref_put(&claim->refcount, batadv_claim_release);
} }
...@@ -305,7 +304,7 @@ batadv_bla_del_backbone_claims(struct batadv_bla_backbone_gw *backbone_gw) ...@@ -305,7 +304,7 @@ batadv_bla_del_backbone_claims(struct batadv_bla_backbone_gw *backbone_gw)
if (claim->backbone_gw != backbone_gw) if (claim->backbone_gw != backbone_gw)
continue; continue;
batadv_claim_free_ref(claim); batadv_claim_put(claim);
hlist_del_rcu(&claim->hash_entry); hlist_del_rcu(&claim->hash_entry);
} }
spin_unlock_bh(list_lock); spin_unlock_bh(list_lock);
...@@ -424,7 +423,7 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac, ...@@ -424,7 +423,7 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac,
netif_rx(skb); netif_rx(skb);
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
} }
/** /**
...@@ -486,7 +485,7 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, u8 *orig, ...@@ -486,7 +485,7 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, u8 *orig,
if (orig_node) { if (orig_node) {
batadv_tt_global_del_orig(bat_priv, orig_node, vid, batadv_tt_global_del_orig(bat_priv, orig_node, vid,
"became a backbone gateway"); "became a backbone gateway");
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
} }
if (own_backbone) { if (own_backbone) {
...@@ -524,7 +523,7 @@ batadv_bla_update_own_backbone_gw(struct batadv_priv *bat_priv, ...@@ -524,7 +523,7 @@ batadv_bla_update_own_backbone_gw(struct batadv_priv *bat_priv,
return; return;
backbone_gw->lasttime = jiffies; backbone_gw->lasttime = jiffies;
batadv_backbone_gw_free_ref(backbone_gw); batadv_backbone_gw_put(backbone_gw);
} }
/** /**
...@@ -573,7 +572,7 @@ static void batadv_bla_answer_request(struct batadv_priv *bat_priv, ...@@ -573,7 +572,7 @@ static void batadv_bla_answer_request(struct batadv_priv *bat_priv,
/* finally, send an announcement frame */ /* finally, send an announcement frame */
batadv_bla_send_announce(bat_priv, backbone_gw); batadv_bla_send_announce(bat_priv, backbone_gw);
batadv_backbone_gw_free_ref(backbone_gw); batadv_backbone_gw_put(backbone_gw);
} }
/** /**
...@@ -682,7 +681,7 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv, ...@@ -682,7 +681,7 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
spin_lock_bh(&claim->backbone_gw->crc_lock); spin_lock_bh(&claim->backbone_gw->crc_lock);
claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN); claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
spin_unlock_bh(&claim->backbone_gw->crc_lock); spin_unlock_bh(&claim->backbone_gw->crc_lock);
batadv_backbone_gw_free_ref(claim->backbone_gw); batadv_backbone_gw_put(claim->backbone_gw);
} }
/* set (new) backbone gw */ /* set (new) backbone gw */
kref_get(&backbone_gw->refcount); kref_get(&backbone_gw->refcount);
...@@ -694,7 +693,7 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv, ...@@ -694,7 +693,7 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
backbone_gw->lasttime = jiffies; backbone_gw->lasttime = jiffies;
claim_free_ref: claim_free_ref:
batadv_claim_free_ref(claim); batadv_claim_put(claim);
} }
/** /**
...@@ -719,14 +718,14 @@ static void batadv_bla_del_claim(struct batadv_priv *bat_priv, ...@@ -719,14 +718,14 @@ static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
batadv_hash_remove(bat_priv->bla.claim_hash, batadv_compare_claim, batadv_hash_remove(bat_priv->bla.claim_hash, batadv_compare_claim,
batadv_choose_claim, claim); batadv_choose_claim, claim);
batadv_claim_free_ref(claim); /* reference from the hash is gone */ batadv_claim_put(claim); /* reference from the hash is gone */
spin_lock_bh(&claim->backbone_gw->crc_lock); spin_lock_bh(&claim->backbone_gw->crc_lock);
claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN); claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
spin_unlock_bh(&claim->backbone_gw->crc_lock); spin_unlock_bh(&claim->backbone_gw->crc_lock);
/* don't need the reference from hash_find() anymore */ /* don't need the reference from hash_find() anymore */
batadv_claim_free_ref(claim); batadv_claim_put(claim);
} }
/** /**
...@@ -783,7 +782,7 @@ static int batadv_handle_announce(struct batadv_priv *bat_priv, u8 *an_addr, ...@@ -783,7 +782,7 @@ static int batadv_handle_announce(struct batadv_priv *bat_priv, u8 *an_addr,
} }
} }
batadv_backbone_gw_free_ref(backbone_gw); batadv_backbone_gw_put(backbone_gw);
return 1; return 1;
} }
...@@ -854,7 +853,7 @@ static int batadv_handle_unclaim(struct batadv_priv *bat_priv, ...@@ -854,7 +853,7 @@ static int batadv_handle_unclaim(struct batadv_priv *bat_priv,
claim_addr, BATADV_PRINT_VID(vid), backbone_gw->orig); claim_addr, BATADV_PRINT_VID(vid), backbone_gw->orig);
batadv_bla_del_claim(bat_priv, claim_addr, vid); batadv_bla_del_claim(bat_priv, claim_addr, vid);
batadv_backbone_gw_free_ref(backbone_gw); batadv_backbone_gw_put(backbone_gw);
return 1; return 1;
} }
...@@ -891,7 +890,7 @@ static int batadv_handle_claim(struct batadv_priv *bat_priv, ...@@ -891,7 +890,7 @@ static int batadv_handle_claim(struct batadv_priv *bat_priv,
/* TODO: we could call something like tt_local_del() here. */ /* TODO: we could call something like tt_local_del() here. */
batadv_backbone_gw_free_ref(backbone_gw); batadv_backbone_gw_put(backbone_gw);
return 1; return 1;
} }
...@@ -965,7 +964,7 @@ static int batadv_check_claim_group(struct batadv_priv *bat_priv, ...@@ -965,7 +964,7 @@ static int batadv_check_claim_group(struct batadv_priv *bat_priv,
bla_dst_own->group = bla_dst->group; bla_dst_own->group = bla_dst->group;
} }
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
return 2; return 2;
} }
...@@ -1154,7 +1153,7 @@ static void batadv_bla_purge_backbone_gw(struct batadv_priv *bat_priv, int now) ...@@ -1154,7 +1153,7 @@ static void batadv_bla_purge_backbone_gw(struct batadv_priv *bat_priv, int now)
batadv_bla_del_backbone_claims(backbone_gw); batadv_bla_del_backbone_claims(backbone_gw);
hlist_del_rcu(&backbone_gw->hash_entry); hlist_del_rcu(&backbone_gw->hash_entry);
batadv_backbone_gw_free_ref(backbone_gw); batadv_backbone_gw_put(backbone_gw);
} }
spin_unlock_bh(list_lock); spin_unlock_bh(list_lock);
} }
...@@ -1282,7 +1281,7 @@ void batadv_bla_status_update(struct net_device *net_dev) ...@@ -1282,7 +1281,7 @@ void batadv_bla_status_update(struct net_device *net_dev)
* so just call that one. * so just call that one.
*/ */
batadv_bla_update_orig_address(bat_priv, primary_if, primary_if); batadv_bla_update_orig_address(bat_priv, primary_if, primary_if);
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
} }
/** /**
...@@ -1356,7 +1355,7 @@ static void batadv_bla_periodic_work(struct work_struct *work) ...@@ -1356,7 +1355,7 @@ static void batadv_bla_periodic_work(struct work_struct *work)
} }
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work, queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH)); msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
...@@ -1395,7 +1394,7 @@ int batadv_bla_init(struct batadv_priv *bat_priv) ...@@ -1395,7 +1394,7 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
if (primary_if) { if (primary_if) {
crc = crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN); crc = crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN);
bat_priv->bla.claim_dest.group = htons(crc); bat_priv->bla.claim_dest.group = htons(crc);
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
} else { } else {
bat_priv->bla.claim_dest.group = 0; /* will be set later */ bat_priv->bla.claim_dest.group = 0; /* will be set later */
} }
...@@ -1571,7 +1570,7 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb, ...@@ -1571,7 +1570,7 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb,
if (!backbone_gw) if (!backbone_gw)
return 0; return 0;
batadv_backbone_gw_free_ref(backbone_gw); batadv_backbone_gw_put(backbone_gw);
return 1; return 1;
} }
...@@ -1599,7 +1598,7 @@ void batadv_bla_free(struct batadv_priv *bat_priv) ...@@ -1599,7 +1598,7 @@ void batadv_bla_free(struct batadv_priv *bat_priv)
bat_priv->bla.backbone_hash = NULL; bat_priv->bla.backbone_hash = NULL;
} }
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
} }
/** /**
...@@ -1692,9 +1691,9 @@ int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, ...@@ -1692,9 +1691,9 @@ int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
if (claim) if (claim)
batadv_claim_free_ref(claim); batadv_claim_put(claim);
return ret; return ret;
} }
...@@ -1781,9 +1780,9 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, ...@@ -1781,9 +1780,9 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
ret = 1; ret = 1;
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
if (claim) if (claim)
batadv_claim_free_ref(claim); batadv_claim_put(claim);
return ret; return ret;
} }
...@@ -1839,7 +1838,7 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset) ...@@ -1839,7 +1838,7 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
} }
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
return 0; return 0;
} }
...@@ -1904,6 +1903,6 @@ int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset) ...@@ -1904,6 +1903,6 @@ int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset)
} }
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
return 0; return 0;
} }
...@@ -77,11 +77,11 @@ static void batadv_dat_entry_release(struct kref *ref) ...@@ -77,11 +77,11 @@ static void batadv_dat_entry_release(struct kref *ref)
} }
/** /**
* batadv_dat_entry_free_ref - decrement the dat_entry refcounter and possibly * batadv_dat_entry_put - decrement the dat_entry refcounter and possibly
* release it * release it
* @dat_entry: dat_entry to be free'd * @dat_entry: dat_entry to be free'd
*/ */
static void batadv_dat_entry_free_ref(struct batadv_dat_entry *dat_entry) static void batadv_dat_entry_put(struct batadv_dat_entry *dat_entry)
{ {
kref_put(&dat_entry->refcount, batadv_dat_entry_release); kref_put(&dat_entry->refcount, batadv_dat_entry_release);
} }
...@@ -135,7 +135,7 @@ static void __batadv_dat_purge(struct batadv_priv *bat_priv, ...@@ -135,7 +135,7 @@ static void __batadv_dat_purge(struct batadv_priv *bat_priv,
continue; continue;
hlist_del_rcu(&dat_entry->hash_entry); hlist_del_rcu(&dat_entry->hash_entry);
batadv_dat_entry_free_ref(dat_entry); batadv_dat_entry_put(dat_entry);
} }
spin_unlock_bh(list_lock); spin_unlock_bh(list_lock);
} }
...@@ -349,7 +349,7 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip, ...@@ -349,7 +349,7 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
if (unlikely(hash_added != 0)) { if (unlikely(hash_added != 0)) {
/* remove the reference for the hash */ /* remove the reference for the hash */
batadv_dat_entry_free_ref(dat_entry); batadv_dat_entry_put(dat_entry);
goto out; goto out;
} }
...@@ -358,7 +358,7 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip, ...@@ -358,7 +358,7 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
out: out:
if (dat_entry) if (dat_entry)
batadv_dat_entry_free_ref(dat_entry); batadv_dat_entry_put(dat_entry);
} }
#ifdef CONFIG_BATMAN_ADV_DEBUG #ifdef CONFIG_BATMAN_ADV_DEBUG
...@@ -547,7 +547,7 @@ static void batadv_choose_next_candidate(struct batadv_priv *bat_priv, ...@@ -547,7 +547,7 @@ static void batadv_choose_next_candidate(struct batadv_priv *bat_priv,
max = tmp_max; max = tmp_max;
if (max_orig_node) if (max_orig_node)
batadv_orig_node_free_ref(max_orig_node); batadv_orig_node_put(max_orig_node);
max_orig_node = orig_node; max_orig_node = orig_node;
} }
rcu_read_unlock(); rcu_read_unlock();
...@@ -674,9 +674,9 @@ static bool batadv_dat_send_data(struct batadv_priv *bat_priv, ...@@ -674,9 +674,9 @@ 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_free_ref(cand[i].orig_node); batadv_orig_node_put(cand[i].orig_node);
} }
out: out:
...@@ -840,7 +840,7 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset) ...@@ -840,7 +840,7 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset)
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
return 0; return 0;
} }
...@@ -1029,7 +1029,7 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, ...@@ -1029,7 +1029,7 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
} }
out: out:
if (dat_entry) if (dat_entry)
batadv_dat_entry_free_ref(dat_entry); batadv_dat_entry_put(dat_entry);
return ret; return ret;
} }
...@@ -1109,7 +1109,7 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv, ...@@ -1109,7 +1109,7 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
} }
out: out:
if (dat_entry) if (dat_entry)
batadv_dat_entry_free_ref(dat_entry); batadv_dat_entry_put(dat_entry);
if (ret) if (ret)
kfree_skb(skb); kfree_skb(skb);
return ret; return ret;
...@@ -1262,6 +1262,6 @@ bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv, ...@@ -1262,6 +1262,6 @@ bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
out: out:
if (dat_entry) if (dat_entry)
batadv_dat_entry_free_ref(dat_entry); batadv_dat_entry_put(dat_entry);
return ret; return ret;
} }
...@@ -385,9 +385,9 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb, ...@@ -385,9 +385,9 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb,
out: out:
if (orig_node_dst) if (orig_node_dst)
batadv_orig_node_free_ref(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;
} }
...@@ -512,7 +512,7 @@ bool batadv_frag_send_packet(struct sk_buff *skb, ...@@ -512,7 +512,7 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
out_err: out_err:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
return ret; return ret;
} }
...@@ -71,16 +71,15 @@ static void batadv_gw_node_release(struct kref *ref) ...@@ -71,16 +71,15 @@ static void batadv_gw_node_release(struct kref *ref)
gw_node = container_of(ref, struct batadv_gw_node, refcount); gw_node = container_of(ref, struct batadv_gw_node, refcount);
batadv_orig_node_free_ref(gw_node->orig_node); batadv_orig_node_put(gw_node->orig_node);
kfree_rcu(gw_node, rcu); kfree_rcu(gw_node, rcu);
} }
/** /**
* batadv_gw_node_free_ref - decrement the gw_node refcounter and possibly * batadv_gw_node_put - decrement the gw_node refcounter and possibly release it
* release it
* @gw_node: gateway node to free * @gw_node: gateway node to free
*/ */
static void batadv_gw_node_free_ref(struct batadv_gw_node *gw_node) static void batadv_gw_node_put(struct batadv_gw_node *gw_node)
{ {
kref_put(&gw_node->refcount, batadv_gw_node_release); kref_put(&gw_node->refcount, batadv_gw_node_release);
} }
...@@ -125,7 +124,7 @@ batadv_gw_get_selected_orig(struct batadv_priv *bat_priv) ...@@ -125,7 +124,7 @@ batadv_gw_get_selected_orig(struct batadv_priv *bat_priv)
rcu_read_unlock(); rcu_read_unlock();
out: out:
if (gw_node) if (gw_node)
batadv_gw_node_free_ref(gw_node); batadv_gw_node_put(gw_node);
return orig_node; return orig_node;
} }
...@@ -143,7 +142,7 @@ static void batadv_gw_select(struct batadv_priv *bat_priv, ...@@ -143,7 +142,7 @@ static void batadv_gw_select(struct batadv_priv *bat_priv,
rcu_assign_pointer(bat_priv->gw.curr_gw, new_gw_node); rcu_assign_pointer(bat_priv->gw.curr_gw, new_gw_node);
if (curr_gw_node) if (curr_gw_node)
batadv_gw_node_free_ref(curr_gw_node); batadv_gw_node_put(curr_gw_node);
spin_unlock_bh(&bat_priv->gw.list_lock); spin_unlock_bh(&bat_priv->gw.list_lock);
} }
...@@ -204,7 +203,7 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv) ...@@ -204,7 +203,7 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
((tmp_gw_factor == max_gw_factor) && ((tmp_gw_factor == max_gw_factor) &&
(tq_avg > max_tq))) { (tq_avg > max_tq))) {
if (curr_gw) if (curr_gw)
batadv_gw_node_free_ref(curr_gw); batadv_gw_node_put(curr_gw);
curr_gw = gw_node; curr_gw = gw_node;
kref_get(&curr_gw->refcount); kref_get(&curr_gw->refcount);
} }
...@@ -219,7 +218,7 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv) ...@@ -219,7 +218,7 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
*/ */
if (tq_avg > max_tq) { if (tq_avg > max_tq) {
if (curr_gw) if (curr_gw)
batadv_gw_node_free_ref(curr_gw); batadv_gw_node_put(curr_gw);
curr_gw = gw_node; curr_gw = gw_node;
kref_get(&curr_gw->refcount); kref_get(&curr_gw->refcount);
} }
...@@ -232,12 +231,12 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv) ...@@ -232,12 +231,12 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
if (tmp_gw_factor > max_gw_factor) if (tmp_gw_factor > max_gw_factor)
max_gw_factor = tmp_gw_factor; max_gw_factor = tmp_gw_factor;
batadv_gw_node_free_ref(gw_node); batadv_gw_node_put(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_put(router_ifinfo);
} }
rcu_read_unlock(); rcu_read_unlock();
...@@ -273,7 +272,7 @@ void batadv_gw_check_client_stop(struct batadv_priv *bat_priv) ...@@ -273,7 +272,7 @@ void batadv_gw_check_client_stop(struct batadv_priv *bat_priv)
*/ */
batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_DEL, NULL); batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_DEL, NULL);
batadv_gw_node_free_ref(curr_gw); batadv_gw_node_put(curr_gw);
} }
void batadv_gw_election(struct batadv_priv *bat_priv) void batadv_gw_election(struct batadv_priv *bat_priv)
...@@ -348,13 +347,13 @@ void batadv_gw_election(struct batadv_priv *bat_priv) ...@@ -348,13 +347,13 @@ void batadv_gw_election(struct batadv_priv *bat_priv)
out: out:
if (curr_gw) if (curr_gw)
batadv_gw_node_free_ref(curr_gw); batadv_gw_node_put(curr_gw);
if (next_gw) if (next_gw)
batadv_gw_node_free_ref(next_gw); batadv_gw_node_put(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_put(router_ifinfo);
} }
void batadv_gw_check_election(struct batadv_priv *bat_priv, void batadv_gw_check_election(struct batadv_priv *bat_priv,
...@@ -415,15 +414,15 @@ void batadv_gw_check_election(struct batadv_priv *bat_priv, ...@@ -415,15 +414,15 @@ void batadv_gw_check_election(struct batadv_priv *bat_priv,
batadv_gw_reselect(bat_priv); batadv_gw_reselect(bat_priv);
out: out:
if (curr_gw_orig) if (curr_gw_orig)
batadv_orig_node_free_ref(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_put(router_gw_tq);
if (router_orig_tq) if (router_orig_tq)
batadv_neigh_ifinfo_free_ref(router_orig_tq); batadv_neigh_ifinfo_put(router_orig_tq);
} }
/** /**
...@@ -446,7 +445,7 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv, ...@@ -446,7 +445,7 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv,
gw_node = kzalloc(sizeof(*gw_node), GFP_ATOMIC); gw_node = kzalloc(sizeof(*gw_node), GFP_ATOMIC);
if (!gw_node) { if (!gw_node) {
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
return; return;
} }
...@@ -547,7 +546,7 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv, ...@@ -547,7 +546,7 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv,
spin_lock_bh(&bat_priv->gw.list_lock); spin_lock_bh(&bat_priv->gw.list_lock);
if (!hlist_unhashed(&gw_node->list)) { if (!hlist_unhashed(&gw_node->list)) {
hlist_del_init_rcu(&gw_node->list); hlist_del_init_rcu(&gw_node->list);
batadv_gw_node_free_ref(gw_node); batadv_gw_node_put(gw_node);
} }
spin_unlock_bh(&bat_priv->gw.list_lock); spin_unlock_bh(&bat_priv->gw.list_lock);
...@@ -556,12 +555,12 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv, ...@@ -556,12 +555,12 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv,
batadv_gw_reselect(bat_priv); batadv_gw_reselect(bat_priv);
if (curr_gw) if (curr_gw)
batadv_gw_node_free_ref(curr_gw); batadv_gw_node_put(curr_gw);
} }
out: out:
if (gw_node) if (gw_node)
batadv_gw_node_free_ref(gw_node); batadv_gw_node_put(gw_node);
} }
void batadv_gw_node_delete(struct batadv_priv *bat_priv, void batadv_gw_node_delete(struct batadv_priv *bat_priv,
...@@ -584,7 +583,7 @@ void batadv_gw_node_free(struct batadv_priv *bat_priv) ...@@ -584,7 +583,7 @@ void batadv_gw_node_free(struct batadv_priv *bat_priv)
hlist_for_each_entry_safe(gw_node, node_tmp, hlist_for_each_entry_safe(gw_node, node_tmp,
&bat_priv->gw.list, list) { &bat_priv->gw.list, list) {
hlist_del_init_rcu(&gw_node->list); hlist_del_init_rcu(&gw_node->list);
batadv_gw_node_free_ref(gw_node); batadv_gw_node_put(gw_node);
} }
spin_unlock_bh(&bat_priv->gw.list_lock); spin_unlock_bh(&bat_priv->gw.list_lock);
} }
...@@ -621,12 +620,12 @@ static int batadv_write_buffer_text(struct batadv_priv *bat_priv, ...@@ -621,12 +620,12 @@ static int batadv_write_buffer_text(struct batadv_priv *bat_priv,
ret = seq_has_overflowed(seq) ? -1 : 0; ret = seq_has_overflowed(seq) ? -1 : 0;
if (curr_gw) if (curr_gw)
batadv_gw_node_free_ref(curr_gw); batadv_gw_node_put(curr_gw);
out: out:
if (router_ifinfo) if (router_ifinfo)
batadv_neigh_ifinfo_free_ref(router_ifinfo); batadv_neigh_ifinfo_put(router_ifinfo);
if (router) if (router)
batadv_neigh_node_free_ref(router); batadv_neigh_node_put(router);
return ret; return ret;
} }
...@@ -663,7 +662,7 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset) ...@@ -663,7 +662,7 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
return 0; return 0;
} }
...@@ -857,7 +856,7 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, ...@@ -857,7 +856,7 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
goto out; goto out;
curr_tq_avg = curr_ifinfo->bat_iv.tq_avg; curr_tq_avg = curr_ifinfo->bat_iv.tq_avg;
batadv_neigh_ifinfo_free_ref(curr_ifinfo); batadv_neigh_ifinfo_put(curr_ifinfo);
break; break;
case BATADV_GW_MODE_OFF: case BATADV_GW_MODE_OFF:
...@@ -875,18 +874,18 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, ...@@ -875,18 +874,18 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
if ((curr_tq_avg - old_ifinfo->bat_iv.tq_avg) > BATADV_GW_THRESHOLD) if ((curr_tq_avg - old_ifinfo->bat_iv.tq_avg) > BATADV_GW_THRESHOLD)
out_of_range = true; out_of_range = true;
batadv_neigh_ifinfo_free_ref(old_ifinfo); batadv_neigh_ifinfo_put(old_ifinfo);
out: out:
if (orig_dst_node) if (orig_dst_node)
batadv_orig_node_free_ref(orig_dst_node); batadv_orig_node_put(orig_dst_node);
if (curr_gw) if (curr_gw)
batadv_gw_node_free_ref(curr_gw); batadv_gw_node_put(curr_gw);
if (gw_node) if (gw_node)
batadv_gw_node_free_ref(gw_node); batadv_gw_node_put(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;
} }
...@@ -226,7 +226,7 @@ static void batadv_primary_if_update_addr(struct batadv_priv *bat_priv, ...@@ -226,7 +226,7 @@ static void batadv_primary_if_update_addr(struct batadv_priv *bat_priv,
batadv_bla_update_orig_address(bat_priv, primary_if, oldif); batadv_bla_update_orig_address(bat_priv, primary_if, oldif);
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
} }
static void batadv_primary_if_select(struct batadv_priv *bat_priv, static void batadv_primary_if_select(struct batadv_priv *bat_priv,
...@@ -250,7 +250,7 @@ static void batadv_primary_if_select(struct batadv_priv *bat_priv, ...@@ -250,7 +250,7 @@ static void batadv_primary_if_select(struct batadv_priv *bat_priv,
out: out:
if (curr_hard_iface) if (curr_hard_iface)
batadv_hardif_free_ref(curr_hard_iface); batadv_hardif_put(curr_hard_iface);
} }
static bool static bool
...@@ -409,7 +409,7 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface) ...@@ -409,7 +409,7 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface)
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
} }
static void static void
...@@ -562,7 +562,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, ...@@ -562,7 +562,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
hard_iface->soft_iface = NULL; hard_iface->soft_iface = NULL;
dev_put(soft_iface); dev_put(soft_iface);
err: err:
batadv_hardif_free_ref(hard_iface); batadv_hardif_put(hard_iface);
return ret; return ret;
} }
...@@ -593,7 +593,7 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface, ...@@ -593,7 +593,7 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface,
batadv_primary_if_select(bat_priv, new_if); batadv_primary_if_select(bat_priv, new_if);
if (new_if) if (new_if)
batadv_hardif_free_ref(new_if); batadv_hardif_put(new_if);
} }
bat_priv->bat_algo_ops->bat_iface_disable(hard_iface); bat_priv->bat_algo_ops->bat_iface_disable(hard_iface);
...@@ -616,11 +616,11 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface, ...@@ -616,11 +616,11 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface,
} }
hard_iface->soft_iface = NULL; hard_iface->soft_iface = NULL;
batadv_hardif_free_ref(hard_iface); batadv_hardif_put(hard_iface);
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
} }
/** /**
...@@ -639,7 +639,7 @@ static void batadv_hardif_remove_interface_finish(struct work_struct *work) ...@@ -639,7 +639,7 @@ static void batadv_hardif_remove_interface_finish(struct work_struct *work)
batadv_debugfs_del_hardif(hard_iface); batadv_debugfs_del_hardif(hard_iface);
batadv_sysfs_del_hardif(&hard_iface->hardif_obj); batadv_sysfs_del_hardif(&hard_iface->hardif_obj);
batadv_hardif_free_ref(hard_iface); batadv_hardif_put(hard_iface);
} }
static struct batadv_hard_iface * static struct batadv_hard_iface *
...@@ -794,10 +794,10 @@ static int batadv_hard_if_event(struct notifier_block *this, ...@@ -794,10 +794,10 @@ static int batadv_hard_if_event(struct notifier_block *this,
} }
hardif_put: hardif_put:
batadv_hardif_free_ref(hard_iface); batadv_hardif_put(hard_iface);
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
return NOTIFY_DONE; return NOTIFY_DONE;
} }
......
...@@ -64,11 +64,11 @@ void batadv_update_min_mtu(struct net_device *soft_iface); ...@@ -64,11 +64,11 @@ void batadv_update_min_mtu(struct net_device *soft_iface);
void batadv_hardif_release(struct kref *ref); void batadv_hardif_release(struct kref *ref);
/** /**
* batadv_hardif_free_ref - decrement the hard interface refcounter and possibly * batadv_hardif_put - decrement the hard interface refcounter and possibly
* release it * release it
* @hard_iface: the hard interface to free * @hard_iface: the hard interface to free
*/ */
static inline void batadv_hardif_free_ref(struct batadv_hard_iface *hard_iface) static inline void batadv_hardif_put(struct batadv_hard_iface *hard_iface)
{ {
kref_put(&hard_iface->refcount, batadv_hardif_release); kref_put(&hard_iface->refcount, batadv_hardif_release);
} }
......
...@@ -288,11 +288,11 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, ...@@ -288,11 +288,11 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
kfree_skb(skb); kfree_skb(skb);
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(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_free_ref(orig_node); batadv_orig_node_put(orig_node);
return len; return len;
} }
......
...@@ -287,7 +287,7 @@ batadv_seq_print_text_primary_if_get(struct seq_file *seq) ...@@ -287,7 +287,7 @@ batadv_seq_print_text_primary_if_get(struct seq_file *seq)
seq_printf(seq, seq_printf(seq,
"BATMAN mesh %s disabled - primary interface not active\n", "BATMAN mesh %s disabled - primary interface not active\n",
net_dev->name); net_dev->name);
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
primary_if = NULL; primary_if = NULL;
out: out:
...@@ -638,12 +638,11 @@ static void batadv_tvlv_handler_release(struct kref *ref) ...@@ -638,12 +638,11 @@ static void batadv_tvlv_handler_release(struct kref *ref)
} }
/** /**
* batadv_tvlv_handler_free_ref - decrement the tvlv container refcounter and * batadv_tvlv_handler_put - decrement the tvlv container refcounter and
* possibly release it * possibly release it
* @tvlv_handler: the tvlv handler to free * @tvlv_handler: the tvlv handler to free
*/ */
static void static void batadv_tvlv_handler_put(struct batadv_tvlv_handler *tvlv_handler)
batadv_tvlv_handler_free_ref(struct batadv_tvlv_handler *tvlv_handler)
{ {
kref_put(&tvlv_handler->refcount, batadv_tvlv_handler_release); kref_put(&tvlv_handler->refcount, batadv_tvlv_handler_release);
} }
...@@ -695,11 +694,11 @@ static void batadv_tvlv_container_release(struct kref *ref) ...@@ -695,11 +694,11 @@ static void batadv_tvlv_container_release(struct kref *ref)
} }
/** /**
* batadv_tvlv_container_free_ref - decrement the tvlv container refcounter and * batadv_tvlv_container_put - decrement the tvlv container refcounter and
* possibly release it * possibly release it
* @tvlv: the tvlv container to free * @tvlv: the tvlv container to free
*/ */
static void batadv_tvlv_container_free_ref(struct batadv_tvlv_container *tvlv) static void batadv_tvlv_container_put(struct batadv_tvlv_container *tvlv)
{ {
kref_put(&tvlv->refcount, batadv_tvlv_container_release); kref_put(&tvlv->refcount, batadv_tvlv_container_release);
} }
...@@ -785,8 +784,8 @@ static void batadv_tvlv_container_remove(struct batadv_priv *bat_priv, ...@@ -785,8 +784,8 @@ static void batadv_tvlv_container_remove(struct batadv_priv *bat_priv,
hlist_del(&tvlv->list); hlist_del(&tvlv->list);
/* first call to decrement the counter, second call to free */ /* first call to decrement the counter, second call to free */
batadv_tvlv_container_free_ref(tvlv); batadv_tvlv_container_put(tvlv);
batadv_tvlv_container_free_ref(tvlv); batadv_tvlv_container_put(tvlv);
} }
/** /**
...@@ -1031,7 +1030,7 @@ int batadv_tvlv_containers_process(struct batadv_priv *bat_priv, ...@@ -1031,7 +1030,7 @@ int batadv_tvlv_containers_process(struct batadv_priv *bat_priv,
src, dst, tvlv_value, src, dst, tvlv_value,
tvlv_value_cont_len); tvlv_value_cont_len);
if (tvlv_handler) if (tvlv_handler)
batadv_tvlv_handler_free_ref(tvlv_handler); batadv_tvlv_handler_put(tvlv_handler);
tvlv_value = (u8 *)tvlv_value + tvlv_value_cont_len; tvlv_value = (u8 *)tvlv_value + tvlv_value_cont_len;
tvlv_value_len -= tvlv_value_cont_len; tvlv_value_len -= tvlv_value_cont_len;
} }
...@@ -1111,7 +1110,7 @@ void batadv_tvlv_handler_register(struct batadv_priv *bat_priv, ...@@ -1111,7 +1110,7 @@ void batadv_tvlv_handler_register(struct batadv_priv *bat_priv,
tvlv_handler = batadv_tvlv_handler_get(bat_priv, type, version); tvlv_handler = batadv_tvlv_handler_get(bat_priv, type, version);
if (tvlv_handler) { if (tvlv_handler) {
batadv_tvlv_handler_free_ref(tvlv_handler); batadv_tvlv_handler_put(tvlv_handler);
return; return;
} }
...@@ -1148,11 +1147,11 @@ void batadv_tvlv_handler_unregister(struct batadv_priv *bat_priv, ...@@ -1148,11 +1147,11 @@ void batadv_tvlv_handler_unregister(struct batadv_priv *bat_priv,
if (!tvlv_handler) if (!tvlv_handler)
return; return;
batadv_tvlv_handler_free_ref(tvlv_handler); batadv_tvlv_handler_put(tvlv_handler);
spin_lock_bh(&bat_priv->tvlv.handler_list_lock); spin_lock_bh(&bat_priv->tvlv.handler_list_lock);
hlist_del_rcu(&tvlv_handler->list); hlist_del_rcu(&tvlv_handler->list);
spin_unlock_bh(&bat_priv->tvlv.handler_list_lock); spin_unlock_bh(&bat_priv->tvlv.handler_list_lock);
batadv_tvlv_handler_free_ref(tvlv_handler); batadv_tvlv_handler_put(tvlv_handler);
} }
/** /**
...@@ -1212,7 +1211,7 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src, ...@@ -1212,7 +1211,7 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src,
if (batadv_send_skb_to_orig(skb, orig_node, NULL) == NET_XMIT_DROP) if (batadv_send_skb_to_orig(skb, orig_node, NULL) == NET_XMIT_DROP)
kfree_skb(skb); kfree_skb(skb);
out: out:
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
} }
/** /**
...@@ -1262,7 +1261,7 @@ bool batadv_vlan_ap_isola_get(struct batadv_priv *bat_priv, unsigned short vid) ...@@ -1262,7 +1261,7 @@ bool batadv_vlan_ap_isola_get(struct batadv_priv *bat_priv, unsigned short vid)
vlan = batadv_softif_vlan_get(bat_priv, vid); vlan = batadv_softif_vlan_get(bat_priv, vid);
if (vlan) { if (vlan) {
ap_isolation_enabled = atomic_read(&vlan->ap_isolation); ap_isolation_enabled = atomic_read(&vlan->ap_isolation);
batadv_softif_vlan_free_ref(vlan); batadv_softif_vlan_put(vlan);
} }
return ap_isolation_enabled; return ap_isolation_enabled;
......
...@@ -100,11 +100,6 @@ ...@@ -100,11 +100,6 @@
*/ */
#define BATADV_TQ_SIMILARITY_THRESHOLD 50 #define BATADV_TQ_SIMILARITY_THRESHOLD 50
/* how much worse secondary interfaces may be to be considered as bonding
* candidates
*/
#define BATADV_BONDING_TQ_THRESHOLD 50
/* should not be bigger than 512 bytes or change the size of /* should not be bigger than 512 bytes or change the size of
* forw_packet->direct_link_flags * forw_packet->direct_link_flags
*/ */
......
...@@ -218,16 +218,16 @@ static void batadv_nc_node_release(struct kref *ref) ...@@ -218,16 +218,16 @@ static void batadv_nc_node_release(struct kref *ref)
nc_node = container_of(ref, struct batadv_nc_node, refcount); nc_node = container_of(ref, struct batadv_nc_node, refcount);
batadv_orig_node_free_ref(nc_node->orig_node); batadv_orig_node_put(nc_node->orig_node);
kfree_rcu(nc_node, rcu); kfree_rcu(nc_node, rcu);
} }
/** /**
* batadv_nc_node_free_ref - decrement the nc_node refcounter and possibly * batadv_nc_node_put - decrement the nc_node refcounter and possibly
* release it * release it
* @nc_node: nc_node to be free'd * @nc_node: nc_node to be free'd
*/ */
static void batadv_nc_node_free_ref(struct batadv_nc_node *nc_node) static void batadv_nc_node_put(struct batadv_nc_node *nc_node)
{ {
kref_put(&nc_node->refcount, batadv_nc_node_release); kref_put(&nc_node->refcount, batadv_nc_node_release);
} }
...@@ -247,11 +247,11 @@ static void batadv_nc_path_release(struct kref *ref) ...@@ -247,11 +247,11 @@ static void batadv_nc_path_release(struct kref *ref)
} }
/** /**
* batadv_nc_path_free_ref - decrement the nc_path refcounter and possibly * batadv_nc_path_put - decrement the nc_path refcounter and possibly
* release it * release it
* @nc_path: nc_path to be free'd * @nc_path: nc_path to be free'd
*/ */
static void batadv_nc_path_free_ref(struct batadv_nc_path *nc_path) static void batadv_nc_path_put(struct batadv_nc_path *nc_path)
{ {
kref_put(&nc_path->refcount, batadv_nc_path_release); kref_put(&nc_path->refcount, batadv_nc_path_release);
} }
...@@ -263,7 +263,7 @@ static void batadv_nc_path_free_ref(struct batadv_nc_path *nc_path) ...@@ -263,7 +263,7 @@ static void batadv_nc_path_free_ref(struct batadv_nc_path *nc_path)
static void batadv_nc_packet_free(struct batadv_nc_packet *nc_packet) static void batadv_nc_packet_free(struct batadv_nc_packet *nc_packet)
{ {
kfree_skb(nc_packet->skb); kfree_skb(nc_packet->skb);
batadv_nc_path_free_ref(nc_packet->nc_path); batadv_nc_path_put(nc_packet->nc_path);
kfree(nc_packet); kfree(nc_packet);
} }
...@@ -356,7 +356,7 @@ batadv_nc_purge_orig_nc_nodes(struct batadv_priv *bat_priv, ...@@ -356,7 +356,7 @@ batadv_nc_purge_orig_nc_nodes(struct batadv_priv *bat_priv,
"Removing nc_node %pM -> %pM\n", "Removing nc_node %pM -> %pM\n",
nc_node->addr, nc_node->orig_node->orig); nc_node->addr, nc_node->orig_node->orig);
list_del_rcu(&nc_node->list); list_del_rcu(&nc_node->list);
batadv_nc_node_free_ref(nc_node); batadv_nc_node_put(nc_node);
} }
spin_unlock_bh(lock); spin_unlock_bh(lock);
} }
...@@ -467,7 +467,7 @@ static void batadv_nc_purge_paths(struct batadv_priv *bat_priv, ...@@ -467,7 +467,7 @@ static void batadv_nc_purge_paths(struct batadv_priv *bat_priv,
"Remove nc_path %pM -> %pM\n", "Remove nc_path %pM -> %pM\n",
nc_path->prev_hop, nc_path->next_hop); nc_path->prev_hop, nc_path->next_hop);
hlist_del_rcu(&nc_path->hash_entry); hlist_del_rcu(&nc_path->hash_entry);
batadv_nc_path_free_ref(nc_path); batadv_nc_path_put(nc_path);
} }
spin_unlock_bh(lock); spin_unlock_bh(lock);
} }
...@@ -772,7 +772,7 @@ static bool batadv_can_nc_with_orig(struct batadv_priv *bat_priv, ...@@ -772,7 +772,7 @@ static bool batadv_can_nc_with_orig(struct batadv_priv *bat_priv,
last_ttl = orig_ifinfo->last_ttl; last_ttl = orig_ifinfo->last_ttl;
last_real_seqno = orig_ifinfo->last_real_seqno; last_real_seqno = orig_ifinfo->last_real_seqno;
batadv_orig_ifinfo_free_ref(orig_ifinfo); batadv_orig_ifinfo_put(orig_ifinfo);
if (last_real_seqno != ntohl(ogm_packet->seqno)) if (last_real_seqno != ntohl(ogm_packet->seqno))
return false; return false;
...@@ -942,9 +942,9 @@ void batadv_nc_update_nc_node(struct batadv_priv *bat_priv, ...@@ -942,9 +942,9 @@ void batadv_nc_update_nc_node(struct batadv_priv *bat_priv,
out: out:
if (in_nc_node) if (in_nc_node)
batadv_nc_node_free_ref(in_nc_node); batadv_nc_node_put(in_nc_node);
if (out_nc_node) if (out_nc_node)
batadv_nc_node_free_ref(out_nc_node); batadv_nc_node_put(out_nc_node);
} }
/** /**
...@@ -1228,13 +1228,13 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv, ...@@ -1228,13 +1228,13 @@ 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_put(router_neigh_ifinfo);
if (router_coding_ifinfo) if (router_coding_ifinfo)
batadv_neigh_ifinfo_free_ref(router_coding_ifinfo); batadv_neigh_ifinfo_put(router_coding_ifinfo);
return res; return res;
} }
...@@ -1372,7 +1372,7 @@ batadv_nc_skb_src_search(struct batadv_priv *bat_priv, ...@@ -1372,7 +1372,7 @@ batadv_nc_skb_src_search(struct batadv_priv *bat_priv,
} }
rcu_read_unlock(); rcu_read_unlock();
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
return nc_packet; return nc_packet;
} }
...@@ -1555,7 +1555,7 @@ bool batadv_nc_skb_forward(struct sk_buff *skb, ...@@ -1555,7 +1555,7 @@ bool batadv_nc_skb_forward(struct sk_buff *skb,
return true; return true;
free_nc_path: free_nc_path:
batadv_nc_path_free_ref(nc_path); batadv_nc_path_put(nc_path);
out: out:
/* Packet is not consumed */ /* Packet is not consumed */
return false; return false;
...@@ -1617,7 +1617,7 @@ void batadv_nc_skb_store_for_decoding(struct batadv_priv *bat_priv, ...@@ -1617,7 +1617,7 @@ void batadv_nc_skb_store_for_decoding(struct batadv_priv *bat_priv,
free_skb: free_skb:
kfree_skb(skb); kfree_skb(skb);
free_nc_path: free_nc_path:
batadv_nc_path_free_ref(nc_path); batadv_nc_path_put(nc_path);
out: out:
return; return;
} }
...@@ -1950,7 +1950,7 @@ int batadv_nc_nodes_seq_print_text(struct seq_file *seq, void *offset) ...@@ -1950,7 +1950,7 @@ int batadv_nc_nodes_seq_print_text(struct seq_file *seq, void *offset)
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
return 0; return 0;
} }
......
...@@ -151,11 +151,11 @@ static void batadv_orig_node_vlan_release(struct kref *ref) ...@@ -151,11 +151,11 @@ static void batadv_orig_node_vlan_release(struct kref *ref)
} }
/** /**
* batadv_orig_node_vlan_free_ref - decrement the refcounter and possibly * batadv_orig_node_vlan_put - decrement the refcounter and possibly release
* release the originator-vlan object * the originator-vlan object
* @orig_vlan: the originator-vlan object to release * @orig_vlan: the originator-vlan object to release
*/ */
void batadv_orig_node_vlan_free_ref(struct batadv_orig_node_vlan *orig_vlan) void batadv_orig_node_vlan_put(struct batadv_orig_node_vlan *orig_vlan)
{ {
kref_put(&orig_vlan->refcount, batadv_orig_node_vlan_release); kref_put(&orig_vlan->refcount, batadv_orig_node_vlan_release);
} }
...@@ -196,17 +196,17 @@ static void batadv_neigh_ifinfo_release(struct kref *ref) ...@@ -196,17 +196,17 @@ static void batadv_neigh_ifinfo_release(struct kref *ref)
neigh_ifinfo = container_of(ref, struct batadv_neigh_ifinfo, refcount); neigh_ifinfo = container_of(ref, struct batadv_neigh_ifinfo, refcount);
if (neigh_ifinfo->if_outgoing != BATADV_IF_DEFAULT) if (neigh_ifinfo->if_outgoing != BATADV_IF_DEFAULT)
batadv_hardif_free_ref(neigh_ifinfo->if_outgoing); batadv_hardif_put(neigh_ifinfo->if_outgoing);
kfree_rcu(neigh_ifinfo, rcu); kfree_rcu(neigh_ifinfo, rcu);
} }
/** /**
* batadv_neigh_ifinfo_free_ref - decrement the refcounter and possibly release * batadv_neigh_ifinfo_put - decrement the refcounter and possibly release
* the neigh_ifinfo * the neigh_ifinfo
* @neigh_ifinfo: the neigh_ifinfo object to release * @neigh_ifinfo: the neigh_ifinfo object to release
*/ */
void batadv_neigh_ifinfo_free_ref(struct batadv_neigh_ifinfo *neigh_ifinfo) void batadv_neigh_ifinfo_put(struct batadv_neigh_ifinfo *neigh_ifinfo)
{ {
kref_put(&neigh_ifinfo->refcount, batadv_neigh_ifinfo_release); kref_put(&neigh_ifinfo->refcount, batadv_neigh_ifinfo_release);
} }
...@@ -227,16 +227,16 @@ static void batadv_hardif_neigh_release(struct kref *ref) ...@@ -227,16 +227,16 @@ static void batadv_hardif_neigh_release(struct kref *ref)
hlist_del_init_rcu(&hardif_neigh->list); hlist_del_init_rcu(&hardif_neigh->list);
spin_unlock_bh(&hardif_neigh->if_incoming->neigh_list_lock); spin_unlock_bh(&hardif_neigh->if_incoming->neigh_list_lock);
batadv_hardif_free_ref(hardif_neigh->if_incoming); batadv_hardif_put(hardif_neigh->if_incoming);
kfree_rcu(hardif_neigh, rcu); kfree_rcu(hardif_neigh, rcu);
} }
/** /**
* batadv_hardif_neigh_free_ref - decrement the hardif neighbors refcounter * batadv_hardif_neigh_put - decrement the hardif neighbors refcounter
* and possibly release it * and possibly release it
* @hardif_neigh: hardif neigh neighbor to free * @hardif_neigh: hardif neigh neighbor to free
*/ */
void batadv_hardif_neigh_free_ref(struct batadv_hardif_neigh_node *hardif_neigh) void batadv_hardif_neigh_put(struct batadv_hardif_neigh_node *hardif_neigh)
{ {
kref_put(&hardif_neigh->refcount, batadv_hardif_neigh_release); kref_put(&hardif_neigh->refcount, batadv_hardif_neigh_release);
} }
...@@ -259,31 +259,31 @@ static void batadv_neigh_node_release(struct kref *ref) ...@@ -259,31 +259,31 @@ static void batadv_neigh_node_release(struct kref *ref)
hlist_for_each_entry_safe(neigh_ifinfo, node_tmp, hlist_for_each_entry_safe(neigh_ifinfo, node_tmp,
&neigh_node->ifinfo_list, list) { &neigh_node->ifinfo_list, list) {
batadv_neigh_ifinfo_free_ref(neigh_ifinfo); batadv_neigh_ifinfo_put(neigh_ifinfo);
} }
hardif_neigh = batadv_hardif_neigh_get(neigh_node->if_incoming, hardif_neigh = batadv_hardif_neigh_get(neigh_node->if_incoming,
neigh_node->addr); neigh_node->addr);
if (hardif_neigh) { if (hardif_neigh) {
/* batadv_hardif_neigh_get() increases refcount too */ /* batadv_hardif_neigh_get() increases refcount too */
batadv_hardif_neigh_free_ref(hardif_neigh); batadv_hardif_neigh_put(hardif_neigh);
batadv_hardif_neigh_free_ref(hardif_neigh); batadv_hardif_neigh_put(hardif_neigh);
} }
if (bao->bat_neigh_free) if (bao->bat_neigh_free)
bao->bat_neigh_free(neigh_node); bao->bat_neigh_free(neigh_node);
batadv_hardif_free_ref(neigh_node->if_incoming); batadv_hardif_put(neigh_node->if_incoming);
kfree_rcu(neigh_node, rcu); kfree_rcu(neigh_node, rcu);
} }
/** /**
* 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);
} }
...@@ -544,7 +544,7 @@ batadv_hardif_neigh_create(struct batadv_hard_iface *hard_iface, ...@@ -544,7 +544,7 @@ batadv_hardif_neigh_create(struct batadv_hard_iface *hard_iface,
hardif_neigh = kzalloc(sizeof(*hardif_neigh), GFP_ATOMIC); hardif_neigh = kzalloc(sizeof(*hardif_neigh), GFP_ATOMIC);
if (!hardif_neigh) { if (!hardif_neigh) {
batadv_hardif_free_ref(hard_iface); batadv_hardif_put(hard_iface);
goto out; goto out;
} }
...@@ -681,7 +681,7 @@ batadv_neigh_node_new(struct batadv_orig_node *orig_node, ...@@ -681,7 +681,7 @@ batadv_neigh_node_new(struct batadv_orig_node *orig_node,
out: out:
if (hardif_neigh) if (hardif_neigh)
batadv_hardif_neigh_free_ref(hardif_neigh); batadv_hardif_neigh_put(hardif_neigh);
return neigh_node; return neigh_node;
} }
...@@ -707,7 +707,7 @@ int batadv_hardif_neigh_seq_print_text(struct seq_file *seq, void *offset) ...@@ -707,7 +707,7 @@ int batadv_hardif_neigh_seq_print_text(struct seq_file *seq, void *offset)
primary_if->net_dev->dev_addr, net_dev->name, primary_if->net_dev->dev_addr, net_dev->name,
bat_priv->bat_algo_ops->name); bat_priv->bat_algo_ops->name);
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
if (!bat_priv->bat_algo_ops->bat_neigh_print) { if (!bat_priv->bat_algo_ops->bat_neigh_print) {
seq_puts(seq, seq_puts(seq,
...@@ -732,22 +732,22 @@ static void batadv_orig_ifinfo_release(struct kref *ref) ...@@ -732,22 +732,22 @@ static void batadv_orig_ifinfo_release(struct kref *ref)
orig_ifinfo = container_of(ref, struct batadv_orig_ifinfo, refcount); orig_ifinfo = container_of(ref, struct batadv_orig_ifinfo, refcount);
if (orig_ifinfo->if_outgoing != BATADV_IF_DEFAULT) if (orig_ifinfo->if_outgoing != BATADV_IF_DEFAULT)
batadv_hardif_free_ref(orig_ifinfo->if_outgoing); batadv_hardif_put(orig_ifinfo->if_outgoing);
/* 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);
} }
/** /**
* batadv_orig_ifinfo_free_ref - decrement the refcounter and possibly release * batadv_orig_ifinfo_put - decrement the refcounter and possibly release
* the orig_ifinfo * the orig_ifinfo
* @orig_ifinfo: the orig_ifinfo object to release * @orig_ifinfo: the orig_ifinfo object to release
*/ */
void batadv_orig_ifinfo_free_ref(struct batadv_orig_ifinfo *orig_ifinfo) void batadv_orig_ifinfo_put(struct batadv_orig_ifinfo *orig_ifinfo)
{ {
kref_put(&orig_ifinfo->refcount, batadv_orig_ifinfo_release); kref_put(&orig_ifinfo->refcount, batadv_orig_ifinfo_release);
} }
...@@ -793,13 +793,13 @@ static void batadv_orig_node_release(struct kref *ref) ...@@ -793,13 +793,13 @@ 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,
&orig_node->ifinfo_list, list) { &orig_node->ifinfo_list, list) {
hlist_del_rcu(&orig_ifinfo->list); hlist_del_rcu(&orig_ifinfo->list);
batadv_orig_ifinfo_free_ref(orig_ifinfo); batadv_orig_ifinfo_put(orig_ifinfo);
} }
spin_unlock_bh(&orig_node->neigh_list_lock); spin_unlock_bh(&orig_node->neigh_list_lock);
...@@ -810,11 +810,11 @@ static void batadv_orig_node_release(struct kref *ref) ...@@ -810,11 +810,11 @@ static void batadv_orig_node_release(struct kref *ref)
} }
/** /**
* batadv_orig_node_free_ref - decrement the orig node refcounter and possibly * batadv_orig_node_put - decrement the orig node refcounter and possibly
* release it * release it
* @orig_node: the orig node to free * @orig_node: the orig node to free
*/ */
void batadv_orig_node_free_ref(struct batadv_orig_node *orig_node) void batadv_orig_node_put(struct batadv_orig_node *orig_node)
{ {
kref_put(&orig_node->refcount, batadv_orig_node_release); kref_put(&orig_node->refcount, batadv_orig_node_release);
} }
...@@ -843,7 +843,7 @@ void batadv_originator_free(struct batadv_priv *bat_priv) ...@@ -843,7 +843,7 @@ void batadv_originator_free(struct batadv_priv *bat_priv)
hlist_for_each_entry_safe(orig_node, node_tmp, hlist_for_each_entry_safe(orig_node, node_tmp,
head, hash_entry) { head, hash_entry) {
hlist_del_rcu(&orig_node->hash_entry); hlist_del_rcu(&orig_node->hash_entry);
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
} }
spin_unlock_bh(list_lock); spin_unlock_bh(list_lock);
} }
...@@ -917,7 +917,7 @@ struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv, ...@@ -917,7 +917,7 @@ struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,
* Immediately release vlan since it is not needed anymore in this * Immediately release vlan since it is not needed anymore in this
* context * context
*/ */
batadv_orig_node_vlan_free_ref(vlan); batadv_orig_node_vlan_put(vlan);
for (i = 0; i < BATADV_FRAG_BUFFER_COUNT; i++) { for (i = 0; i < BATADV_FRAG_BUFFER_COUNT; i++) {
INIT_HLIST_HEAD(&orig_node->fragments[i].head); INIT_HLIST_HEAD(&orig_node->fragments[i].head);
...@@ -966,7 +966,7 @@ batadv_purge_neigh_ifinfo(struct batadv_priv *bat_priv, ...@@ -966,7 +966,7 @@ batadv_purge_neigh_ifinfo(struct batadv_priv *bat_priv,
neigh->addr, if_outgoing->net_dev->name); neigh->addr, if_outgoing->net_dev->name);
hlist_del_rcu(&neigh_ifinfo->list); hlist_del_rcu(&neigh_ifinfo->list);
batadv_neigh_ifinfo_free_ref(neigh_ifinfo); batadv_neigh_ifinfo_put(neigh_ifinfo);
} }
spin_unlock_bh(&neigh->ifinfo_lock); spin_unlock_bh(&neigh->ifinfo_lock);
...@@ -1012,10 +1012,10 @@ batadv_purge_orig_ifinfo(struct batadv_priv *bat_priv, ...@@ -1012,10 +1012,10 @@ batadv_purge_orig_ifinfo(struct batadv_priv *bat_priv,
ifinfo_purged = true; ifinfo_purged = true;
hlist_del_rcu(&orig_ifinfo->list); hlist_del_rcu(&orig_ifinfo->list);
batadv_orig_ifinfo_free_ref(orig_ifinfo); batadv_orig_ifinfo_put(orig_ifinfo);
if (orig_node->last_bonding_candidate == orig_ifinfo) { if (orig_node->last_bonding_candidate == orig_ifinfo) {
orig_node->last_bonding_candidate = NULL; orig_node->last_bonding_candidate = NULL;
batadv_orig_ifinfo_free_ref(orig_ifinfo); batadv_orig_ifinfo_put(orig_ifinfo);
} }
} }
...@@ -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();
...@@ -1204,7 +1204,7 @@ static void _batadv_purge_orig(struct batadv_priv *bat_priv) ...@@ -1204,7 +1204,7 @@ static void _batadv_purge_orig(struct batadv_priv *bat_priv)
batadv_tt_global_del_orig(orig_node->bat_priv, batadv_tt_global_del_orig(orig_node->bat_priv,
orig_node, -1, orig_node, -1,
"originator timed out"); "originator timed out");
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
continue; continue;
} }
...@@ -1250,7 +1250,7 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset) ...@@ -1250,7 +1250,7 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
primary_if->net_dev->dev_addr, net_dev->name, primary_if->net_dev->dev_addr, net_dev->name,
bat_priv->bat_algo_ops->name); bat_priv->bat_algo_ops->name);
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
if (!bat_priv->bat_algo_ops->bat_orig_print) { if (!bat_priv->bat_algo_ops->bat_orig_print) {
seq_puts(seq, seq_puts(seq,
...@@ -1306,7 +1306,7 @@ int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset) ...@@ -1306,7 +1306,7 @@ int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset)
out: out:
if (hard_iface) if (hard_iface)
batadv_hardif_free_ref(hard_iface); batadv_hardif_put(hard_iface);
return 0; return 0;
} }
......
...@@ -37,19 +37,19 @@ int batadv_compare_orig(const struct hlist_node *node, const void *data2); ...@@ -37,19 +37,19 @@ int batadv_compare_orig(const struct hlist_node *node, const void *data2);
int batadv_originator_init(struct batadv_priv *bat_priv); int batadv_originator_init(struct batadv_priv *bat_priv);
void batadv_originator_free(struct batadv_priv *bat_priv); void batadv_originator_free(struct batadv_priv *bat_priv);
void batadv_purge_orig_ref(struct batadv_priv *bat_priv); void batadv_purge_orig_ref(struct batadv_priv *bat_priv);
void batadv_orig_node_free_ref(struct batadv_orig_node *orig_node); void batadv_orig_node_put(struct batadv_orig_node *orig_node);
struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv, struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,
const u8 *addr); const u8 *addr);
struct batadv_hardif_neigh_node * struct batadv_hardif_neigh_node *
batadv_hardif_neigh_get(const struct batadv_hard_iface *hard_iface, batadv_hardif_neigh_get(const struct batadv_hard_iface *hard_iface,
const u8 *neigh_addr); const u8 *neigh_addr);
void void
batadv_hardif_neigh_free_ref(struct batadv_hardif_neigh_node *hardif_neigh); batadv_hardif_neigh_put(struct batadv_hardif_neigh_node *hardif_neigh);
struct batadv_neigh_node * 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);
...@@ -59,7 +59,7 @@ batadv_neigh_ifinfo_new(struct batadv_neigh_node *neigh, ...@@ -59,7 +59,7 @@ batadv_neigh_ifinfo_new(struct batadv_neigh_node *neigh,
struct batadv_neigh_ifinfo * struct batadv_neigh_ifinfo *
batadv_neigh_ifinfo_get(struct batadv_neigh_node *neigh, batadv_neigh_ifinfo_get(struct batadv_neigh_node *neigh,
struct batadv_hard_iface *if_outgoing); struct batadv_hard_iface *if_outgoing);
void batadv_neigh_ifinfo_free_ref(struct batadv_neigh_ifinfo *neigh_ifinfo); void batadv_neigh_ifinfo_put(struct batadv_neigh_ifinfo *neigh_ifinfo);
int batadv_hardif_neigh_seq_print_text(struct seq_file *seq, void *offset); int batadv_hardif_neigh_seq_print_text(struct seq_file *seq, void *offset);
...@@ -69,7 +69,7 @@ batadv_orig_ifinfo_get(struct batadv_orig_node *orig_node, ...@@ -69,7 +69,7 @@ batadv_orig_ifinfo_get(struct batadv_orig_node *orig_node,
struct batadv_orig_ifinfo * struct batadv_orig_ifinfo *
batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node, batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node,
struct batadv_hard_iface *if_outgoing); struct batadv_hard_iface *if_outgoing);
void batadv_orig_ifinfo_free_ref(struct batadv_orig_ifinfo *orig_ifinfo); void batadv_orig_ifinfo_put(struct batadv_orig_ifinfo *orig_ifinfo);
int batadv_orig_seq_print_text(struct seq_file *seq, void *offset); int batadv_orig_seq_print_text(struct seq_file *seq, void *offset);
int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset); int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset);
...@@ -83,7 +83,7 @@ batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node, ...@@ -83,7 +83,7 @@ batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node,
struct batadv_orig_node_vlan * struct batadv_orig_node_vlan *
batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node, batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node,
unsigned short vid); unsigned short vid);
void batadv_orig_node_vlan_free_ref(struct batadv_orig_node_vlan *orig_vlan); void batadv_orig_node_vlan_put(struct batadv_orig_node_vlan *orig_vlan);
/* hashfunction to choose an entry in a hash table of given size /* hashfunction to choose an entry in a hash table of given size
* hash algorithm from http://en.wikipedia.org/wiki/Hash_table * hash algorithm from http://en.wikipedia.org/wiki/Hash_table
......
...@@ -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))
...@@ -107,11 +107,11 @@ static void _batadv_update_route(struct batadv_priv *bat_priv, ...@@ -107,11 +107,11 @@ static void _batadv_update_route(struct batadv_priv *bat_priv,
spin_lock_bh(&orig_node->neigh_list_lock); spin_lock_bh(&orig_node->neigh_list_lock);
rcu_assign_pointer(orig_ifinfo->router, neigh_node); rcu_assign_pointer(orig_ifinfo->router, neigh_node);
spin_unlock_bh(&orig_node->neigh_list_lock); spin_unlock_bh(&orig_node->neigh_list_lock);
batadv_orig_ifinfo_free_ref(orig_ifinfo); batadv_orig_ifinfo_put(orig_ifinfo);
/* 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);
} }
/** /**
...@@ -269,9 +269,9 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv, ...@@ -269,9 +269,9 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv,
} }
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
if (orig_node) if (orig_node)
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
return ret; return ret;
} }
...@@ -317,9 +317,9 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv, ...@@ -317,9 +317,9 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
if (orig_node) if (orig_node)
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
return ret; return ret;
} }
...@@ -403,7 +403,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, ...@@ -403,7 +403,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
out: out:
if (orig_node) if (orig_node)
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
return ret; return ret;
} }
...@@ -545,16 +545,16 @@ batadv_find_router(struct batadv_priv *bat_priv, ...@@ -545,16 +545,16 @@ 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_put(cand);
} }
rcu_read_unlock(); rcu_read_unlock();
/* last_bonding_candidate is reset below, remove the old reference. */ /* last_bonding_candidate is reset below, remove the old reference. */
if (orig_node->last_bonding_candidate) if (orig_node->last_bonding_candidate)
batadv_orig_ifinfo_free_ref(orig_node->last_bonding_candidate); batadv_orig_ifinfo_put(orig_node->last_bonding_candidate);
/* After finding candidates, handle the three cases: /* After finding candidates, handle the three cases:
* 1) there is a next candidate, use that * 1) there is a next candidate, use that
...@@ -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_put(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;
...@@ -649,7 +649,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb, ...@@ -649,7 +649,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
out: out:
if (orig_node) if (orig_node)
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
return ret; return ret;
} }
...@@ -702,9 +702,9 @@ batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, ...@@ -702,9 +702,9 @@ batadv_reroute_unicast_packet(struct batadv_priv *bat_priv,
ret = true; ret = true;
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
if (orig_node) if (orig_node)
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
return ret; return ret;
} }
...@@ -768,7 +768,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, ...@@ -768,7 +768,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
return 0; return 0;
curr_ttvn = (u8)atomic_read(&orig_node->last_ttvn); curr_ttvn = (u8)atomic_read(&orig_node->last_ttvn);
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
} }
/* check if the TTVN contained in the packet is fresher than what the /* check if the TTVN contained in the packet is fresher than what the
...@@ -808,7 +808,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, ...@@ -808,7 +808,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
ether_addr_copy(unicast_packet->dest, primary_if->net_dev->dev_addr); ether_addr_copy(unicast_packet->dest, primary_if->net_dev->dev_addr);
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
unicast_packet->ttvn = curr_ttvn; unicast_packet->ttvn = curr_ttvn;
...@@ -908,7 +908,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, ...@@ -908,7 +908,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
rx_success: rx_success:
if (orig_node) if (orig_node)
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
return NET_RX_SUCCESS; return NET_RX_SUCCESS;
} }
...@@ -1019,7 +1019,7 @@ int batadv_recv_frag_packet(struct sk_buff *skb, ...@@ -1019,7 +1019,7 @@ int batadv_recv_frag_packet(struct sk_buff *skb,
out: out:
if (orig_node_src) if (orig_node_src)
batadv_orig_node_free_ref(orig_node_src); batadv_orig_node_put(orig_node_src);
return ret; return ret;
} }
...@@ -1124,6 +1124,6 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, ...@@ -1124,6 +1124,6 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,
spin_unlock_bh(&orig_node->bcast_seqno_lock); spin_unlock_bh(&orig_node->bcast_seqno_lock);
out: out:
if (orig_node) if (orig_node)
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
return ret; return ret;
} }
...@@ -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;
} }
...@@ -246,7 +246,7 @@ bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv, ...@@ -246,7 +246,7 @@ bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv,
ret = true; ret = true;
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
return ret; return ret;
} }
...@@ -317,7 +317,7 @@ int batadv_send_skb_unicast(struct batadv_priv *bat_priv, ...@@ -317,7 +317,7 @@ int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
out: out:
if (orig_node) if (orig_node)
batadv_orig_node_free_ref(orig_node); batadv_orig_node_put(orig_node);
if (ret == NET_XMIT_DROP) if (ret == NET_XMIT_DROP)
kfree_skb(skb); kfree_skb(skb);
return ret; return ret;
...@@ -409,9 +409,9 @@ static void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet) ...@@ -409,9 +409,9 @@ static void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet)
{ {
kfree_skb(forw_packet->skb); kfree_skb(forw_packet->skb);
if (forw_packet->if_incoming) if (forw_packet->if_incoming)
batadv_hardif_free_ref(forw_packet->if_incoming); batadv_hardif_put(forw_packet->if_incoming);
if (forw_packet->if_outgoing) if (forw_packet->if_outgoing)
batadv_hardif_free_ref(forw_packet->if_outgoing); batadv_hardif_put(forw_packet->if_outgoing);
kfree(forw_packet); kfree(forw_packet);
} }
...@@ -497,7 +497,7 @@ int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv, ...@@ -497,7 +497,7 @@ int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
atomic_inc(&bat_priv->bcast_queue_left); atomic_inc(&bat_priv->bcast_queue_left);
out: out:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
return NETDEV_TX_BUSY; return NETDEV_TX_BUSY;
} }
......
...@@ -377,7 +377,7 @@ static int batadv_interface_tx(struct sk_buff *skb, ...@@ -377,7 +377,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
batadv_inc_counter(bat_priv, BATADV_CNT_TX_DROPPED); batadv_inc_counter(bat_priv, BATADV_CNT_TX_DROPPED);
end: end:
if (primary_if) if (primary_if)
batadv_hardif_free_ref(primary_if); batadv_hardif_put(primary_if);
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
...@@ -497,11 +497,11 @@ static void batadv_softif_vlan_release(struct kref *ref) ...@@ -497,11 +497,11 @@ static void batadv_softif_vlan_release(struct kref *ref)
} }
/** /**
* batadv_softif_vlan_free_ref - decrease the vlan object refcounter and * batadv_softif_vlan_put - decrease the vlan object refcounter and
* possibly release it * possibly release it
* @vlan: the vlan object to release * @vlan: the vlan object to release
*/ */
void batadv_softif_vlan_free_ref(struct batadv_softif_vlan *vlan) void batadv_softif_vlan_put(struct batadv_softif_vlan *vlan)
{ {
if (!vlan) if (!vlan)
return; return;
...@@ -552,7 +552,7 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid) ...@@ -552,7 +552,7 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid)
vlan = batadv_softif_vlan_get(bat_priv, vid); vlan = batadv_softif_vlan_get(bat_priv, vid);
if (vlan) { if (vlan) {
batadv_softif_vlan_free_ref(vlan); batadv_softif_vlan_put(vlan);
return -EEXIST; return -EEXIST;
} }
...@@ -601,7 +601,7 @@ static void batadv_softif_destroy_vlan(struct batadv_priv *bat_priv, ...@@ -601,7 +601,7 @@ static void batadv_softif_destroy_vlan(struct batadv_priv *bat_priv,
vlan->vid, "vlan interface destroyed", false); vlan->vid, "vlan interface destroyed", false);
batadv_sysfs_del_vlan(bat_priv, vlan); batadv_sysfs_del_vlan(bat_priv, vlan);
batadv_softif_vlan_free_ref(vlan); batadv_softif_vlan_put(vlan);
} }
/** /**
...@@ -646,7 +646,7 @@ static int batadv_interface_add_vid(struct net_device *dev, __be16 proto, ...@@ -646,7 +646,7 @@ static int batadv_interface_add_vid(struct net_device *dev, __be16 proto,
if (!vlan->kobj) { if (!vlan->kobj) {
ret = batadv_sysfs_add_vlan(bat_priv->soft_iface, vlan); ret = batadv_sysfs_add_vlan(bat_priv->soft_iface, vlan);
if (ret) { if (ret) {
batadv_softif_vlan_free_ref(vlan); batadv_softif_vlan_put(vlan);
return ret; return ret;
} }
} }
...@@ -693,7 +693,7 @@ static int batadv_interface_kill_vid(struct net_device *dev, __be16 proto, ...@@ -693,7 +693,7 @@ static int batadv_interface_kill_vid(struct net_device *dev, __be16 proto,
batadv_softif_destroy_vlan(bat_priv, vlan); batadv_softif_destroy_vlan(bat_priv, vlan);
/* finally free the vlan object */ /* finally free the vlan object */
batadv_softif_vlan_free_ref(vlan); batadv_softif_vlan_put(vlan);
return 0; return 0;
} }
...@@ -749,7 +749,7 @@ static void batadv_softif_destroy_finish(struct work_struct *work) ...@@ -749,7 +749,7 @@ static void batadv_softif_destroy_finish(struct work_struct *work)
vlan = batadv_softif_vlan_get(bat_priv, BATADV_NO_FLAGS); vlan = batadv_softif_vlan_get(bat_priv, BATADV_NO_FLAGS);
if (vlan) { if (vlan) {
batadv_softif_destroy_vlan(bat_priv, vlan); batadv_softif_destroy_vlan(bat_priv, vlan);
batadv_softif_vlan_free_ref(vlan); batadv_softif_vlan_put(vlan);
} }
batadv_sysfs_del_meshif(soft_iface); batadv_sysfs_del_meshif(soft_iface);
...@@ -878,7 +878,7 @@ static int batadv_softif_slave_add(struct net_device *dev, ...@@ -878,7 +878,7 @@ static int batadv_softif_slave_add(struct net_device *dev,
out: out:
if (hard_iface) if (hard_iface)
batadv_hardif_free_ref(hard_iface); batadv_hardif_put(hard_iface);
return ret; return ret;
} }
...@@ -905,7 +905,7 @@ static int batadv_softif_slave_del(struct net_device *dev, ...@@ -905,7 +905,7 @@ static int batadv_softif_slave_del(struct net_device *dev,
out: out:
if (hard_iface) if (hard_iface)
batadv_hardif_free_ref(hard_iface); batadv_hardif_put(hard_iface);
return ret; return ret;
} }
......
...@@ -34,7 +34,7 @@ void batadv_softif_destroy_sysfs(struct net_device *soft_iface); ...@@ -34,7 +34,7 @@ void batadv_softif_destroy_sysfs(struct net_device *soft_iface);
int batadv_softif_is_valid(const struct net_device *net_dev); int batadv_softif_is_valid(const struct net_device *net_dev);
extern struct rtnl_link_ops batadv_link_ops; extern struct rtnl_link_ops batadv_link_ops;
int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid); int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid);
void batadv_softif_vlan_free_ref(struct batadv_softif_vlan *softif_vlan); void batadv_softif_vlan_put(struct batadv_softif_vlan *softif_vlan);
struct batadv_softif_vlan *batadv_softif_vlan_get(struct batadv_priv *bat_priv, struct batadv_softif_vlan *batadv_softif_vlan_get(struct batadv_priv *bat_priv,
unsigned short vid); unsigned short vid);
......
...@@ -216,7 +216,7 @@ ssize_t batadv_store_vlan_##_name(struct kobject *kobj, \ ...@@ -216,7 +216,7 @@ ssize_t batadv_store_vlan_##_name(struct kobject *kobj, \
attr, &vlan->_name, \ attr, &vlan->_name, \
bat_priv->soft_iface); \ bat_priv->soft_iface); \
\ \
batadv_softif_vlan_free_ref(vlan); \ batadv_softif_vlan_put(vlan); \
return res; \ return res; \
} }
...@@ -231,7 +231,7 @@ ssize_t batadv_show_vlan_##_name(struct kobject *kobj, \ ...@@ -231,7 +231,7 @@ ssize_t batadv_show_vlan_##_name(struct kobject *kobj, \
atomic_read(&vlan->_name) == 0 ? \ atomic_read(&vlan->_name) == 0 ? \
"disabled" : "enabled"); \ "disabled" : "enabled"); \
\ \
batadv_softif_vlan_free_ref(vlan); \ batadv_softif_vlan_put(vlan); \
return res; \ return res; \
} }
...@@ -771,7 +771,7 @@ static ssize_t batadv_show_mesh_iface(struct kobject *kobj, ...@@ -771,7 +771,7 @@ static ssize_t batadv_show_mesh_iface(struct kobject *kobj,
length = sprintf(buff, "%s\n", ifname); length = sprintf(buff, "%s\n", ifname);
batadv_hardif_free_ref(hard_iface); batadv_hardif_put(hard_iface);
return length; return length;
} }
...@@ -795,7 +795,7 @@ static ssize_t batadv_store_mesh_iface(struct kobject *kobj, ...@@ -795,7 +795,7 @@ static ssize_t batadv_store_mesh_iface(struct kobject *kobj,
if (strlen(buff) >= IFNAMSIZ) { if (strlen(buff) >= IFNAMSIZ) {
pr_err("Invalid parameter for 'mesh_iface' setting received: interface name too long '%s'\n", pr_err("Invalid parameter for 'mesh_iface' setting received: interface name too long '%s'\n",
buff); buff);
batadv_hardif_free_ref(hard_iface); batadv_hardif_put(hard_iface);
return -EINVAL; return -EINVAL;
} }
...@@ -829,7 +829,7 @@ static ssize_t batadv_store_mesh_iface(struct kobject *kobj, ...@@ -829,7 +829,7 @@ static ssize_t batadv_store_mesh_iface(struct kobject *kobj,
unlock: unlock:
rtnl_unlock(); rtnl_unlock();
out: out:
batadv_hardif_free_ref(hard_iface); batadv_hardif_put(hard_iface);
return ret; return ret;
} }
...@@ -863,7 +863,7 @@ static ssize_t batadv_show_iface_status(struct kobject *kobj, ...@@ -863,7 +863,7 @@ static ssize_t batadv_show_iface_status(struct kobject *kobj,
break; break;
} }
batadv_hardif_free_ref(hard_iface); batadv_hardif_put(hard_iface);
return length; return length;
} }
......
This diff is collapsed.
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