The following commit has been merged in the merge/master branch: commit 02e9463137bf7ed3175e864bcbfe3f3638e70bb7 Merge: a998bf5dfbd7b9eef46a14e63676ca2a99899a0c 69cfb8bc1af37de5be9a1a73141f33fc45f6df24 Author: Marek Lindner mareklindner@neomailbox.ch Date: Thu Apr 21 18:13:24 2016 +0800
Merge branch 'next'
diff --combined net/batman-adv/bat_v.c index 246f9e9,4026f19..3ff8bd1 --- a/net/batman-adv/bat_v.c +++ b/net/batman-adv/bat_v.c @@@ -32,10 -32,21 +32,21 @@@
#include "bat_v_elp.h" #include "bat_v_ogm.h" + #include "hard-interface.h" #include "hash.h" #include "originator.h" #include "packet.h"
+ static void batadv_v_iface_activate(struct batadv_hard_iface *hard_iface) + { + /* 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 + */ + if (hard_iface->if_status == BATADV_IF_TO_BE_ACTIVATED) + hard_iface->if_status = BATADV_IF_ACTIVE; + } + static int batadv_v_iface_enable(struct batadv_hard_iface *hard_iface) { int ret; @@@ -151,8 -162,8 +162,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) { @@@ -191,8 -202,9 +202,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]; @@@ -273,6 -285,7 +284,7 @@@ static bool batadv_v_neigh_is_sob(struc
static struct batadv_algo_ops batadv_batman_v __read_mostly = { .name = "BATMAN_V", + .bat_iface_activate = batadv_v_iface_activate, .bat_iface_enable = batadv_v_iface_enable, .bat_iface_disable = batadv_v_iface_disable, .bat_iface_update_mac = batadv_v_iface_update_mac, diff --combined net/batman-adv/hard-interface.c index 1ef180a,0a7deaf..c5cfda1 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@@ -146,22 -146,22 +146,22 @@@ static bool batadv_is_on_batman_iface(c return ret; }
-static int batadv_is_valid_iface(const struct net_device *net_dev) +static bool batadv_is_valid_iface(const struct net_device *net_dev) { if (net_dev->flags & IFF_LOOPBACK) - return 0; + return false;
if (net_dev->type != ARPHRD_ETHER) - return 0; + return false;
if (net_dev->addr_len != ETH_ALEN) - return 0; + return false;
/* no batman over batman */ if (batadv_is_on_batman_iface(net_dev)) - return 0; + return false;
- return 1; + return true; }
/** @@@ -236,8 -236,8 +236,8 @@@ static void batadv_primary_if_select(st
ASSERT_RTNL();
- if (new_hard_iface && !kref_get_unless_zero(&new_hard_iface->refcount)) - new_hard_iface = NULL; + if (new_hard_iface) + kref_get(&new_hard_iface->refcount);
curr_hard_iface = rcu_dereference_protected(bat_priv->primary_if, 1); rcu_assign_pointer(bat_priv->primary_if, new_hard_iface); @@@ -407,6 -407,9 +407,9 @@@ batadv_hardif_activate_interface(struc
batadv_update_min_mtu(hard_iface->soft_iface);
+ if (bat_priv->bat_algo_ops->bat_iface_activate) + bat_priv->bat_algo_ops->bat_iface_activate(hard_iface); + out: if (primary_if) batadv_hardif_put(primary_if); @@@ -464,7 -467,8 +467,7 @@@ int batadv_hardif_enable_interface(stru if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) goto out;
- if (!kref_get_unless_zero(&hard_iface->refcount)) - goto out; + kref_get(&hard_iface->refcount);
soft_iface = dev_get_by_name(&init_net, iface_name);
@@@ -518,7 -522,6 +521,7 @@@ goto err_upper; }
+ kref_get(&hard_iface->refcount); hard_iface->batman_adv_ptype.type = ethertype; hard_iface->batman_adv_ptype.func = batadv_batman_skb_recv; hard_iface->batman_adv_ptype.dev = hard_iface->net_dev; @@@ -580,7 -583,6 +583,7 @@@ void batadv_hardif_disable_interface(st batadv_info(hard_iface->soft_iface, "Removing interface: %s\n", hard_iface->net_dev->name); dev_remove_pack(&hard_iface->batman_adv_ptype); + batadv_hardif_put(hard_iface);
bat_priv->num_ifaces--; batadv_orig_hash_del_if(hard_iface, bat_priv->num_ifaces); @@@ -650,7 -652,8 +653,7 @@@ batadv_hardif_add_interface(struct net_
ASSERT_RTNL();
- ret = batadv_is_valid_iface(net_dev); - if (ret != 1) + if (!batadv_is_valid_iface(net_dev)) goto out;
dev_hold(net_dev); diff --combined net/batman-adv/types.h index cd5a070,443e9b8..5aee801 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@@ -655,9 -655,6 +655,9 @@@ struct batadv_priv_tt * @num_requests: number of bla requests in flight * @claim_hash: hash table containing mesh nodes this host has claimed * @backbone_hash: hash table containing all detected backbone gateways + * @loopdetect_addr: MAC address used for own loopdetection frames + * @loopdetect_lasttime: time when the loopdetection frames were sent + * @loopdetect_next: how many periods to wait for the next loopdetect process * @bcast_duplist: recently received broadcast packets array (for broadcast * duplicate suppression) * @bcast_duplist_curr: index of last broadcast packet added to bcast_duplist @@@ -669,9 -666,6 +669,9 @@@ struct batadv_priv_bla atomic_t num_requests; struct batadv_hashtable *claim_hash; struct batadv_hashtable *backbone_hash; + u8 loopdetect_addr[ETH_ALEN]; + unsigned long loopdetect_lasttime; + atomic_t loopdetect_next; struct batadv_bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE]; int bcast_duplist_curr; /* protects bcast_duplist & bcast_duplist_curr */ @@@ -1016,7 -1010,6 +1016,7 @@@ struct batadv_socket_packet * resolved * @crc: crc16 checksum over all claims * @crc_lock: lock protecting crc + * @report_work: work struct for reporting detected loops * @refcount: number of contexts the object is used * @rcu: struct used for freeing in an RCU-safe manner */ @@@ -1030,7 -1023,6 +1030,7 @@@ struct batadv_bla_backbone_gw atomic_t request_sent; u16 crc; spinlock_t crc_lock; /* protects crc */ + struct work_struct report_work; struct kref refcount; struct rcu_head rcu; }; @@@ -1258,6 -1250,8 +1258,8 @@@ struct batadv_forw_packet * struct batadv_algo_ops - mesh algorithm callbacks * @list: list node for the batadv_algo_list * @name: name of the algorithm + * @bat_iface_activate: start routing mechanisms when hard-interface is brought + * up * @bat_iface_enable: init routing info when hard-interface is enabled * @bat_iface_disable: de-init routing info when hard-interface is disabled * @bat_iface_update_mac: (re-)init mac addresses of the protocol information @@@ -1285,6 -1279,7 +1287,7 @@@ struct batadv_algo_ops { struct hlist_node list; char *name; + void (*bat_iface_activate)(struct batadv_hard_iface *hard_iface); int (*bat_iface_enable)(struct batadv_hard_iface *hard_iface); void (*bat_iface_disable)(struct batadv_hard_iface *hard_iface); void (*bat_iface_update_mac)(struct batadv_hard_iface *hard_iface);