The following commit has been merged in the merge/master branch: commit 088a8c56b9d38fd988c4823e5e5e8d1f2bfbec31 Merge: 97af1909b58c1e32e1504b7f5ef9bbdcf62eb72a 6863d3b59fd1f1bef3c4b86707a0b1c5d21e0a07 Author: Antonio Quartulli a@unstable.cc Date: Fri May 13 19:00:37 2016 +0800
Merge remote-tracking branch 'pkg/maint' into merge/master
Signed-off-by: Antonio Quartulli a@unstable.cc
diff --combined net/batman-adv/bat_v.c index 554ccd5,1f960c9..0a12e5c --- a/net/batman-adv/bat_v.c +++ b/net/batman-adv/bat_v.c @@@ -27,6 -27,7 +27,7 @@@ #include <linux/rculist.h> #include <linux/rcupdate.h> #include <linux/seq_file.h> + #include <linux/stddef.h> #include <linux/types.h> #include <linux/workqueue.h>
@@@ -39,6 -40,16 +40,16 @@@
static void batadv_v_iface_activate(struct batadv_hard_iface *hard_iface) { + struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); + struct batadv_hard_iface *primary_if; + + primary_if = batadv_primary_if_get_selected(bat_priv); + + if (primary_if) { + batadv_v_elp_iface_activate(primary_if, hard_iface); + batadv_hardif_put(primary_if); + } + /* B.A.T.M.A.N. V does not use any queuing mechanism, therefore it can * set the interface as ACTIVE right away, without any risk of race * condition @@@ -78,6 -89,13 +89,13 @@@ static void batadv_v_primary_iface_set( batadv_v_ogm_primary_iface_set(hard_iface); }
+ /** + * batadv_v_iface_update_mac - react to hard-interface MAC address change + * @hard_iface: the modified interface + * + * If the modified interface is the primary one, update the originator + * address in the ELP and OGM messages to reflect the new MAC address. + */ static void batadv_v_iface_update_mac(struct batadv_hard_iface *hard_iface) { struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); @@@ -173,8 -191,8 +191,8 @@@ static void batadv_v_neigh_print(struc struct batadv_hard_iface *hard_iface; int batman_count = 0;
- seq_printf(seq, " %-15s %s (%11s) [%10s]\n", "Neighbor", - "last-seen", "throughput", "IF"); + seq_puts(seq, + " Neighbor last-seen ( throughput) [ IF]\n");
rcu_read_lock(); list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { @@@ -213,8 -231,9 +231,8 @@@ static void batadv_v_orig_print(struct int batman_count = 0; u32 i;
- seq_printf(seq, " %-15s %s (%11s) %17s [%10s]: %20s ...\n", - "Originator", "last-seen", "throughput", "Nexthop", - "outgoingIF", "Potential nexthops"); + seq_puts(seq, + " Originator last-seen ( throughput) Nexthop [outgoingIF]: Potential nexthops ...\n");
for (i = 0; i < hash->size; i++) { head = &hash->table[i]; @@@ -266,14 -285,23 +284,23 @@@ static int batadv_v_neigh_cmp(struct ba struct batadv_hard_iface *if_outgoing2) { struct batadv_neigh_ifinfo *ifinfo1, *ifinfo2; + int ret = 0;
ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1); + if (WARN_ON(!ifinfo1)) + goto err_ifinfo1; + ifinfo2 = batadv_neigh_ifinfo_get(neigh2, if_outgoing2); + if (WARN_ON(!ifinfo2)) + goto err_ifinfo2;
- if (WARN_ON(!ifinfo1 || !ifinfo2)) - return 0; + ret = ifinfo1->bat_v.throughput - ifinfo2->bat_v.throughput;
- return ifinfo1->bat_v.throughput - ifinfo2->bat_v.throughput; + batadv_neigh_ifinfo_put(ifinfo2); + err_ifinfo2: + batadv_neigh_ifinfo_put(ifinfo1); + err_ifinfo1: + return ret; }
static bool batadv_v_neigh_is_sob(struct batadv_neigh_node *neigh1, @@@ -283,14 -311,26 +310,26 @@@ { struct batadv_neigh_ifinfo *ifinfo1, *ifinfo2; u32 threshold; + bool ret = false;
ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1); + if (WARN_ON(!ifinfo1)) + goto err_ifinfo1; + ifinfo2 = batadv_neigh_ifinfo_get(neigh2, if_outgoing2); + if (WARN_ON(!ifinfo2)) + goto err_ifinfo2;
threshold = ifinfo1->bat_v.throughput / 4; threshold = ifinfo1->bat_v.throughput - threshold;
- return ifinfo2->bat_v.throughput > threshold; + ret = ifinfo2->bat_v.throughput > threshold; + + batadv_neigh_ifinfo_put(ifinfo2); + err_ifinfo2: + batadv_neigh_ifinfo_put(ifinfo1); + err_ifinfo1: + return ret; }
static struct batadv_algo_ops batadv_batman_v __read_mostly = { diff --combined net/batman-adv/originator.c index 1ff4ee4,28241a4d..7f51bc2 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@@ -54,9 -54,9 +54,9 @@@ static void batadv_purge_orig(struct wo * @node: node in the local table * @data2: second object to compare the node to * - * Return: 1 if they are the same originator + * Return: true if they are the same originator */ -int batadv_compare_orig(const struct hlist_node *node, const void *data2) +bool batadv_compare_orig(const struct hlist_node *node, const void *data2) { const void *data1 = container_of(node, struct batadv_orig_node, hash_entry); @@@ -282,7 -282,7 +282,7 @@@ void batadv_neigh_node_put(struct batad }
/** - * batadv_orig_node_get_router - router to the originator depending on iface + * batadv_orig_router_get - router to the originator depending on iface * @orig_node: the orig node for the router * @if_outgoing: the interface where the payload packet has been received or * the OGM should be sent to @@@ -374,8 -374,12 +374,8 @@@ batadv_orig_ifinfo_new(struct batadv_or if (!orig_ifinfo) goto out;
- if (if_outgoing != BATADV_IF_DEFAULT && - !kref_get_unless_zero(&if_outgoing->refcount)) { - kfree(orig_ifinfo); - orig_ifinfo = NULL; - goto out; - } + if (if_outgoing != BATADV_IF_DEFAULT) + kref_get(&if_outgoing->refcount);
reset_time = jiffies - 1; reset_time -= msecs_to_jiffies(BATADV_RESET_PROTECTION_MS); @@@ -451,8 -455,11 +451,8 @@@ batadv_neigh_ifinfo_new(struct batadv_n if (!neigh_ifinfo) goto out;
- if (if_outgoing && !kref_get_unless_zero(&if_outgoing->refcount)) { - kfree(neigh_ifinfo); - neigh_ifinfo = NULL; - goto out; - } + if (if_outgoing) + kref_get(&if_outgoing->refcount);
INIT_HLIST_NODE(&neigh_ifinfo->list); kref_init(&neigh_ifinfo->refcount); @@@ -525,11 -532,15 +525,11 @@@ batadv_hardif_neigh_create(struct batad if (hardif_neigh) goto out;
- if (!kref_get_unless_zero(&hard_iface->refcount)) - goto out; - hardif_neigh = kzalloc(sizeof(*hardif_neigh), GFP_ATOMIC); - if (!hardif_neigh) { - batadv_hardif_put(hard_iface); + if (!hardif_neigh) goto out; - }
+ kref_get(&hard_iface->refcount); INIT_HLIST_NODE(&hardif_neigh->list); ether_addr_copy(hardif_neigh->addr, neigh_addr); hardif_neigh->if_incoming = hard_iface; @@@ -619,6 -630,8 +619,8 @@@ batadv_neigh_node_new(struct batadv_ori struct batadv_neigh_node *neigh_node; struct batadv_hardif_neigh_node *hardif_neigh = NULL;
+ spin_lock_bh(&orig_node->neigh_list_lock); + neigh_node = batadv_neigh_node_get(orig_node, hard_iface, neigh_addr); if (neigh_node) goto out; @@@ -632,11 -645,16 +634,11 @@@ if (!neigh_node) goto out;
- if (!kref_get_unless_zero(&hard_iface->refcount)) { - kfree(neigh_node); - neigh_node = NULL; - goto out; - } - INIT_HLIST_NODE(&neigh_node->list); INIT_HLIST_HEAD(&neigh_node->ifinfo_list); spin_lock_init(&neigh_node->ifinfo_lock);
+ kref_get(&hard_iface->refcount); ether_addr_copy(neigh_node->addr, neigh_addr); neigh_node->if_incoming = hard_iface; neigh_node->orig_node = orig_node; @@@ -650,15 -668,15 +652,15 @@@ kref_init(&neigh_node->refcount); kref_get(&neigh_node->refcount);
- spin_lock_bh(&orig_node->neigh_list_lock); hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list); - spin_unlock_bh(&orig_node->neigh_list_lock);
batadv_dbg(BATADV_DBG_BATMAN, orig_node->bat_priv, "Creating new neighbor %pM for orig_node %pM on interface %s\n", neigh_addr, orig_node->orig, hard_iface->net_dev->name);
out: + spin_unlock_bh(&orig_node->neigh_list_lock); + if (hardif_neigh) batadv_hardif_neigh_put(hardif_neigh); return neigh_node; @@@ -1144,9 -1162,6 +1146,9 @@@ static bool batadv_purge_orig_node(stru if (hard_iface->soft_iface != bat_priv->soft_iface) continue;
+ if (!kref_get_unless_zero(&hard_iface->refcount)) + continue; + best_neigh_node = batadv_find_best_neighbor(bat_priv, orig_node, hard_iface); @@@ -1154,8 -1169,6 +1156,8 @@@ best_neigh_node); if (best_neigh_node) batadv_neigh_node_put(best_neigh_node); + + batadv_hardif_put(hard_iface); } rcu_read_unlock();
@@@ -1206,7 -1219,7 +1208,7 @@@ static void batadv_purge_orig(struct wo struct delayed_work *delayed_work; struct batadv_priv *bat_priv;
- delayed_work = container_of(work, struct delayed_work, work); + delayed_work = to_delayed_work(work); bat_priv = container_of(delayed_work, struct batadv_priv, orig_work); _batadv_purge_orig(bat_priv); queue_delayed_work(batadv_event_workqueue, diff --combined net/batman-adv/routing.c index ae850f2,0c0c30e..e3857ed --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@@ -100,6 -100,10 +100,6 @@@ static void _batadv_update_route(struc if (curr_router) batadv_neigh_node_put(curr_router);
- /* increase refcount of new best neighbor */ - if (neigh_node && !kref_get_unless_zero(&neigh_node->refcount)) - neigh_node = NULL; - spin_lock_bh(&orig_node->neigh_list_lock); /* curr_router used earlier may not be the current orig_ifinfo->router * anymore because it was dereferenced outside of the neigh_list_lock @@@ -110,10 -114,6 +110,10 @@@ */ curr_router = rcu_dereference_protected(orig_ifinfo->router, true);
+ /* increase refcount of new best neighbor */ + if (neigh_node) + kref_get(&neigh_node->refcount); + rcu_assign_pointer(orig_ifinfo->router, neigh_node); spin_unlock_bh(&orig_node->neigh_list_lock); batadv_orig_ifinfo_put(orig_ifinfo); @@@ -163,18 -163,18 +163,18 @@@ out * doesn't change otherwise. * * Return: - * 0 if the packet is to be accepted. - * 1 if the packet is to be ignored. + * false if the packet is to be accepted. + * true if the packet is to be ignored. */ -int batadv_window_protected(struct batadv_priv *bat_priv, s32 seq_num_diff, - s32 seq_old_max_diff, unsigned long *last_reset, - bool *protection_started) +bool batadv_window_protected(struct batadv_priv *bat_priv, s32 seq_num_diff, + s32 seq_old_max_diff, unsigned long *last_reset, + bool *protection_started) { if (seq_num_diff <= -seq_old_max_diff || seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE) { if (!batadv_has_timed_out(*last_reset, BATADV_RESET_PROTECTION_MS)) - return 1; + return true;
*last_reset = jiffies; if (protection_started) @@@ -183,7 -183,7 +183,7 @@@ "old packet received, start protection\n"); }
- return 0; + return false; }
bool batadv_check_management_packet(struct sk_buff *skb, @@@ -601,6 -601,7 +601,7 @@@ static int batadv_route_unicast_packet( struct batadv_unicast_packet *unicast_packet; struct ethhdr *ethhdr = eth_hdr(skb); int res, hdr_len, ret = NET_RX_DROP; + unsigned int len;
unicast_packet = (struct batadv_unicast_packet *)skb->data;
@@@ -641,6 -642,7 +642,7 @@@ if (hdr_len > 0) batadv_skb_set_priority(skb, hdr_len);
+ len = skb->len; res = batadv_send_skb_to_orig(skb, orig_node, recv_if);
/* translate transmit result into receive result */ @@@ -648,7 -650,7 +650,7 @@@ /* skb was transmitted and consumed */ batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD); batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES, - skb->len + ETH_HLEN); + len + ETH_HLEN);
ret = NET_RX_SUCCESS; } else if (res == NET_XMIT_POLICED) { @@@ -718,9 -720,8 +720,9 @@@ out return ret; }
-static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, - struct sk_buff *skb, int hdr_len) { +static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, + struct sk_buff *skb, int hdr_len) +{ struct batadv_unicast_packet *unicast_packet; struct batadv_hard_iface *primary_if; struct batadv_orig_node *orig_node; @@@ -731,11 -732,11 +733,11 @@@
/* check if there is enough data before accessing it */ if (!pskb_may_pull(skb, hdr_len + ETH_HLEN)) - return 0; + return false;
/* create a copy of the skb (in case of for re-routing) to modify it. */ if (skb_cow(skb, sizeof(*unicast_packet)) < 0) - return 0; + return false;
unicast_packet = (struct batadv_unicast_packet *)skb->data; vid = batadv_get_vid(skb, hdr_len); @@@ -759,7 -760,7 +761,7 @@@ * table. If not, let the packet go untouched anyway because * there is nothing the node can do */ - return 1; + return true; }
/* retrieve the TTVN known by this node for the packet destination. This @@@ -775,7 -776,7 +777,7 @@@ * not be possible to deliver it */ if (!orig_node) - return 0; + return false;
curr_ttvn = (u8)atomic_read(&orig_node->last_ttvn); batadv_orig_node_put(orig_node); @@@ -786,7 -787,7 +788,7 @@@ */ is_old_ttvn = batadv_seq_before(unicast_packet->ttvn, curr_ttvn); if (!is_old_ttvn) - return 1; + return true;
old_ttvn = unicast_packet->ttvn; /* the packet was forged based on outdated network information. Its @@@ -799,7 -800,7 +801,7 @@@ "Rerouting unicast packet to %pM (dst=%pM): TTVN mismatch old_ttvn=%u new_ttvn=%u\n", unicast_packet->dest, ethhdr->h_dest, old_ttvn, curr_ttvn); - return 1; + return true; }
/* the packet has not been re-routed: either the destination is @@@ -807,14 -808,14 +809,14 @@@ * it is possible to drop the packet */ if (!batadv_is_my_client(bat_priv, ethhdr->h_dest, vid)) - return 0; + return false;
/* update the header in order to let the packet be delivered to this * node's soft interface */ primary_if = batadv_primary_if_get_selected(bat_priv); if (!primary_if) - return 0; + return false;
ether_addr_copy(unicast_packet->dest, primary_if->net_dev->dev_addr);
@@@ -822,7 -823,7 +824,7 @@@
unicast_packet->ttvn = curr_ttvn;
- return 1; + return true; }
/** @@@ -913,7 -914,7 +915,7 @@@ int batadv_recv_unicast_packet(struct s hdr_size)) goto rx_success;
- batadv_interface_rx(recv_if->soft_iface, skb, recv_if, hdr_size, + batadv_interface_rx(recv_if->soft_iface, skb, hdr_size, orig_node);
rx_success: @@@ -1123,7 -1124,8 +1125,7 @@@ int batadv_recv_bcast_packet(struct sk_ goto rx_success;
/* broadcast for me */ - batadv_interface_rx(recv_if->soft_iface, skb, recv_if, hdr_size, - orig_node); + batadv_interface_rx(recv_if->soft_iface, skb, hdr_size, orig_node);
rx_success: ret = NET_RX_SUCCESS;