The following commit has been merged in the merge/master branch: commit 4030943108e5f6af6f97ac64ab4e1b38d14b04de Merge: 7028cda17de6fd524c7cf99c50eab15fa07e8ed8 789b846af6a9471982b181687a1cba8dc996b269 Author: Marek Lindner mareklindner@neomailbox.ch Date: Sun Feb 28 12:45:31 2016 +0800
Merge branch 'maint' into next
diff --combined net/batman-adv/bat_iv_ogm.c index af8bd86,da0ad2b..dadd52a --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@@ -1,4 -1,4 +1,4 @@@ -/* Copyright (C) 2007-2015 B.A.T.M.A.N. contributors: +/* Copyright (C) 2007-2016 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * @@@ -31,7 -31,6 +31,7 @@@ #include <linux/init.h> #include <linux/jiffies.h> #include <linux/list.h> +#include <linux/kref.h> #include <linux/netdevice.h> #include <linux/pkt_sched.h> #include <linux/printk.h> @@@ -285,8 -284,8 +285,8 @@@ batadv_iv_ogm_orig_get(struct batadv_pr
free_orig_node: /* free twice, as batadv_orig_node_new sets refcount to 2 */ - batadv_orig_node_free_ref(orig_node); - batadv_orig_node_free_ref(orig_node); + batadv_orig_node_put(orig_node); + batadv_orig_node_put(orig_node);
return NULL; } @@@ -395,14 -394,7 +395,14 @@@ static u8 batadv_hop_penalty(u8 tq, con return new_tq; }
-/* is there another aggregated packet here? */ +/** + * batadv_iv_ogm_aggr_packet - checks if there is another OGM attached + * @buff_pos: current position in the skb + * @packet_len: total length of the skb + * @tvlv_len: tvlv length of the previously considered OGM + * + * Return: true if there is enough space for another OGM, false otherwise. + */ static bool batadv_iv_ogm_aggr_packet(int buff_pos, int packet_len, __be16 tvlv_len) { @@@ -476,7 -468,7 +476,7 @@@ static void batadv_iv_ogm_send_to_if(st batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_TX); batadv_add_counter(bat_priv, BATADV_CNT_MGMT_TX_BYTES, skb->len + ETH_HLEN); - batadv_send_skb_packet(skb, hard_iface, batadv_broadcast_addr); + batadv_send_broadcast_skb(skb, hard_iface); } }
@@@ -513,7 -505,7 +513,7 @@@ static void batadv_iv_ogm_emit(struct b
out: if (primary_if) - batadv_hardif_free_ref(primary_if); + batadv_hardif_put(primary_if); }
/** @@@ -615,7 -607,7 +615,7 @@@ batadv_iv_ogm_can_aggregate(const struc
out: if (primary_if) - batadv_hardif_free_ref(primary_if); + batadv_hardif_put(primary_if); return res; }
@@@ -642,10 -634,10 +642,10 @@@ static void batadv_iv_ogm_aggregate_new unsigned char *skb_buff; unsigned int skb_size;
- if (!atomic_inc_not_zero(&if_incoming->refcount)) + if (!kref_get_unless_zero(&if_incoming->refcount)) return;
- if (!atomic_inc_not_zero(&if_outgoing->refcount)) + if (!kref_get_unless_zero(&if_outgoing->refcount)) goto out_free_incoming;
/* own packet should always be scheduled */ @@@ -709,9 -701,9 +709,9 @@@ out_nomem if (!own_packet) atomic_inc(&bat_priv->batman_queue_left); out_free_outgoing: - batadv_hardif_free_ref(if_outgoing); + batadv_hardif_put(if_outgoing); out_free_incoming: - batadv_hardif_free_ref(if_incoming); + batadv_hardif_put(if_incoming); }
/* aggregate a new packet into the existing ogm packet */ @@@ -956,7 -948,7 +956,7 @@@ static void batadv_iv_ogm_schedule(stru
out: if (primary_if) - batadv_hardif_free_ref(primary_if); + batadv_hardif_put(primary_if); }
/** @@@ -1001,9 -993,9 +1001,9 @@@ batadv_iv_ogm_orig_update(struct batadv neigh_addr = tmp_neigh_node->addr; if (batadv_compare_eth(neigh_addr, ethhdr->h_source) && tmp_neigh_node->if_incoming == if_incoming && - atomic_inc_not_zero(&tmp_neigh_node->refcount)) { + kref_get_unless_zero(&tmp_neigh_node->refcount)) { 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; continue; } @@@ -1024,7 -1016,7 +1024,7 @@@ neigh_ifinfo->bat_iv.tq_avg = tq_avg; spin_unlock_bh(&tmp_neigh_node->ifinfo_lock);
- batadv_neigh_ifinfo_free_ref(neigh_ifinfo); + batadv_neigh_ifinfo_put(neigh_ifinfo); neigh_ifinfo = NULL; }
@@@ -1039,7 -1031,7 +1039,7 @@@ ethhdr->h_source, orig_node, orig_tmp);
- batadv_orig_node_free_ref(orig_tmp); + batadv_orig_node_put(orig_tmp); if (!neigh_node) goto unlock; } else { @@@ -1114,13 -1106,13 +1114,13 @@@ unlock rcu_read_unlock(); out: if (neigh_node) - batadv_neigh_node_free_ref(neigh_node); + batadv_neigh_node_put(neigh_node); if (router) - batadv_neigh_node_free_ref(router); + batadv_neigh_node_put(router); if (neigh_ifinfo) - batadv_neigh_ifinfo_free_ref(neigh_ifinfo); + batadv_neigh_ifinfo_put(neigh_ifinfo); if (router_ifinfo) - batadv_neigh_ifinfo_free_ref(router_ifinfo); + batadv_neigh_ifinfo_put(router_ifinfo); }
/** @@@ -1145,9 -1137,10 +1145,10 @@@ static int batadv_iv_ogm_calc_tq(struc u8 total_count; u8 orig_eq_count, neigh_rq_count, neigh_rq_inv, tq_own; unsigned int neigh_rq_inv_cube, neigh_rq_max_cube; - int tq_asym_penalty, inv_asym_penalty, if_num, ret = 0; + int if_num, ret = 0; + unsigned int tq_asym_penalty, inv_asym_penalty; unsigned int combined_tq; - int tq_iface_penalty; + unsigned int tq_iface_penalty;
/* find corresponding one hop neighbor */ rcu_read_lock(); @@@ -1160,7 -1153,7 +1161,7 @@@ if (tmp_neigh_node->if_incoming != if_incoming) continue;
- if (!atomic_inc_not_zero(&tmp_neigh_node->refcount)) + if (!kref_get_unless_zero(&tmp_neigh_node->refcount)) continue;
neigh_node = tmp_neigh_node; @@@ -1190,7 -1183,7 +1191,7 @@@ neigh_ifinfo = batadv_neigh_ifinfo_new(neigh_node, if_outgoing); if (neigh_ifinfo) { neigh_rq_count = neigh_ifinfo->bat_iv.real_packet_count; - batadv_neigh_ifinfo_free_ref(neigh_ifinfo); + batadv_neigh_ifinfo_put(neigh_ifinfo); } else { neigh_rq_count = 0; } @@@ -1263,7 -1256,7 +1264,7 @@@
out: if (neigh_node) - batadv_neigh_node_free_ref(neigh_node); + batadv_neigh_node_put(neigh_node); return ret; }
@@@ -1304,7 -1297,7 +1305,7 @@@ batadv_iv_ogm_update_seqnos(const struc
orig_ifinfo = batadv_orig_ifinfo_new(orig_node, if_outgoing); if (WARN_ON(!orig_ifinfo)) { - batadv_orig_node_free_ref(orig_node); + batadv_orig_node_put(orig_node); return 0; }
@@@ -1314,8 -1307,7 +1315,8 @@@ /* signalize caller that the packet is to be dropped. */ if (!hlist_empty(&orig_node->neigh_list) && batadv_window_protected(bat_priv, seq_diff, - &orig_ifinfo->batman_seqno_reset)) { + BATADV_TQ_LOCAL_WINDOW_SIZE, + &orig_ifinfo->batman_seqno_reset, NULL)) { ret = BATADV_PROTECTED; goto out; } @@@ -1351,7 -1343,7 +1352,7 @@@ packet_count = bitmap_weight(bitmap, BATADV_TQ_LOCAL_WINDOW_SIZE); 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();
@@@ -1365,8 -1357,8 +1366,8 @@@
out: spin_unlock_bh(&orig_node->bat_iv.ogm_cnt_lock); - batadv_orig_node_free_ref(orig_node); - batadv_orig_ifinfo_free_ref(orig_ifinfo); + batadv_orig_node_put(orig_node); + batadv_orig_ifinfo_put(orig_ifinfo); return ret; }
@@@ -1512,7 -1504,7 +1513,7 @@@ batadv_iv_ogm_process_per_outif(const s ogm_packet, if_incoming, 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. */ if (if_outgoing == BATADV_IF_DEFAULT) @@@ -1561,18 -1553,18 +1562,18 @@@
out_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: if (router_ifinfo) - batadv_neigh_ifinfo_free_ref(router_ifinfo); + batadv_neigh_ifinfo_put(router_ifinfo); if (router) - batadv_neigh_node_free_ref(router); + batadv_neigh_node_put(router); if (router_router) - batadv_neigh_node_free_ref(router_router); + batadv_neigh_node_put(router_router); if (orig_neigh_router) - batadv_neigh_node_free_ref(orig_neigh_router); + batadv_neigh_node_put(orig_neigh_router); if (hardif_neigh) - batadv_hardif_neigh_free_ref(hardif_neigh); + batadv_hardif_neigh_put(hardif_neigh);
kfree_skb(skb_priv); } @@@ -1695,7 -1687,7 +1696,7 @@@ static void batadv_iv_ogm_process(cons
batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "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; }
@@@ -1733,7 -1725,7 +1734,7 @@@ } 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, @@@ -1803,7 -1795,7 +1804,7 @@@ batadv_iv_ogm_orig_print_neigh(struct b neigh_node->addr, n_ifinfo->bat_iv.tq_avg);
- batadv_neigh_ifinfo_free_ref(n_ifinfo); + batadv_neigh_ifinfo_put(n_ifinfo); } }
@@@ -1866,9 -1858,9 +1867,9 @@@ static void batadv_iv_ogm_orig_print(st batman_count++;
next: - batadv_neigh_node_free_ref(neigh_node); + batadv_neigh_node_put(neigh_node); if (n_ifinfo) - batadv_neigh_ifinfo_free_ref(n_ifinfo); + batadv_neigh_ifinfo_put(n_ifinfo); } rcu_read_unlock(); } @@@ -1962,9 -1954,9 +1963,9 @@@ static int batadv_iv_ogm_neigh_cmp(stru
out: if (neigh1_ifinfo) - batadv_neigh_ifinfo_free_ref(neigh1_ifinfo); + batadv_neigh_ifinfo_put(neigh1_ifinfo); if (neigh2_ifinfo) - batadv_neigh_ifinfo_free_ref(neigh2_ifinfo); + batadv_neigh_ifinfo_put(neigh2_ifinfo);
return diff; } @@@ -2005,9 -1997,9 +2006,9 @@@ batadv_iv_ogm_neigh_is_sob(struct batad
out: if (neigh1_ifinfo) - batadv_neigh_ifinfo_free_ref(neigh1_ifinfo); + batadv_neigh_ifinfo_put(neigh1_ifinfo); if (neigh2_ifinfo) - batadv_neigh_ifinfo_free_ref(neigh2_ifinfo); + batadv_neigh_ifinfo_put(neigh2_ifinfo);
return ret; }