Skip to content

Commit

Permalink
Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge
Browse files Browse the repository at this point in the history
Included changes:
- use per_cpu_add when possible
- prevent the TT component to add multicast address as "mesh clients"
- some debug output improvements
- proper lockdeps class initializations
- new style fixes (space before/after brackets)
- other minor fixes and refactoring

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jan 14, 2013
2 parents dd3332b + 0c430d0 commit a4412a6
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 70 deletions.
8 changes: 1 addition & 7 deletions net/batman-adv/bat_iv_ogm.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet,
/* adjust all flags and log packets */
while (batadv_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len,
batadv_ogm_packet->tt_num_changes)) {

/* we might have aggregated direct link packets with an
* ordinary base packet
*/
Expand Down Expand Up @@ -261,7 +260,6 @@ static void batadv_iv_ogm_emit(struct batadv_forw_packet *forw_packet)
*/
if ((directlink && (batadv_ogm_packet->header.ttl == 1)) ||
(forw_packet->own && (forw_packet->if_incoming != primary_if))) {

/* FIXME: what about aggregated packets ? */
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"%s packet (originator %pM, seqno %u, TTL %d) on interface %s [%pM]\n",
Expand Down Expand Up @@ -325,7 +323,6 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet,
if (time_before(send_time, forw_packet->send_time) &&
time_after_eq(aggregation_end_time, forw_packet->send_time) &&
(aggregated_bytes <= BATADV_MAX_AGGREGATION_BYTES)) {

/* check aggregation compatibility
* -> direct link packets are broadcasted on
* their interface only
Expand Down Expand Up @@ -815,7 +812,6 @@ static int batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
rcu_read_lock();
hlist_for_each_entry_rcu(tmp_neigh_node, node,
&orig_neigh_node->neigh_list, list) {

if (!batadv_compare_eth(tmp_neigh_node->addr,
orig_neigh_node->orig))
continue;
Expand Down Expand Up @@ -949,7 +945,6 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
rcu_read_lock();
hlist_for_each_entry_rcu(tmp_neigh_node, node,
&orig_node->neigh_list, list) {

is_duplicate |= batadv_test_bit(tmp_neigh_node->real_bits,
orig_node->last_real_seqno,
seqno);
Expand Down Expand Up @@ -1033,7 +1028,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
is_single_hop_neigh = true;

batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n",
"Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %#.4x, changes %u, tq %d, TTL %d, V %d, IDF %d)\n",
ethhdr->h_source, if_incoming->net_dev->name,
if_incoming->net_dev->dev_addr, batadv_ogm_packet->orig,
batadv_ogm_packet->prev_sender,
Expand Down Expand Up @@ -1223,7 +1218,6 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,

/* is single hop (direct) neighbor */
if (is_single_hop_neigh) {

/* mark direct link on incoming interface */
batadv_iv_ogm_forward(orig_node, ethhdr, batadv_ogm_packet,
is_single_hop_neigh,
Expand Down
24 changes: 10 additions & 14 deletions net/batman-adv/bridge_loop_avoidance.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static inline uint32_t batadv_choose_claim(const void *data, uint32_t size)
static inline uint32_t batadv_choose_backbone_gw(const void *data,
uint32_t size)
{
struct batadv_claim *claim = (struct batadv_claim *)data;
const struct batadv_claim *claim = (struct batadv_claim *)data;
uint32_t hash = 0;

hash = batadv_hash_bytes(hash, &claim->addr, sizeof(claim->addr));
Expand Down Expand Up @@ -235,7 +235,6 @@ batadv_bla_del_backbone_claims(struct batadv_backbone_gw *backbone_gw)
spin_lock_bh(list_lock);
hlist_for_each_entry_safe(claim, node, node_tmp,
head, hash_entry) {

if (claim->backbone_gw != backbone_gw)
continue;

Expand Down Expand Up @@ -338,7 +337,6 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac,
"bla_send_claim(): REQUEST of %pM to %pMon vid %d\n",
ethhdr->h_source, ethhdr->h_dest, vid);
break;

}

if (vid != -1)
Expand Down Expand Up @@ -539,7 +537,6 @@ static void batadv_bla_send_announce(struct batadv_priv *bat_priv,

batadv_bla_send_claim(bat_priv, mac, backbone_gw->vid,
BATADV_CLAIM_TYPE_ANNOUNCE);

}

/**
Expand Down Expand Up @@ -598,7 +595,6 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,

claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
batadv_backbone_gw_free_ref(claim->backbone_gw);

}
/* set (new) backbone gw */
atomic_inc(&backbone_gw->refcount);
Expand Down Expand Up @@ -661,12 +657,12 @@ static int batadv_handle_announce(struct batadv_priv *bat_priv,
crc = ntohs(*((__be16 *)(&an_addr[4])));

batadv_dbg(BATADV_DBG_BLA, bat_priv,
"handle_announce(): ANNOUNCE vid %d (sent by %pM)... CRC = %04x\n",
"handle_announce(): ANNOUNCE vid %d (sent by %pM)... CRC = %#.4x\n",
vid, backbone_gw->orig, crc);

if (backbone_gw->crc != crc) {
batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv,
"handle_announce(): CRC FAILED for %pM/%d (my = %04x, sent = %04x)\n",
"handle_announce(): CRC FAILED for %pM/%d (my = %#.4x, sent = %#.4x)\n",
backbone_gw->orig, backbone_gw->vid,
backbone_gw->crc, crc);

Expand Down Expand Up @@ -835,7 +831,7 @@ static int batadv_check_claim_group(struct batadv_priv *bat_priv,
/* if our mesh friends mac is bigger, use it for ourselves. */
if (ntohs(bla_dst->group) > ntohs(bla_dst_own->group)) {
batadv_dbg(BATADV_DBG_BLA, bat_priv,
"taking other backbones claim group: %04x\n",
"taking other backbones claim group: %#.4x\n",
ntohs(bla_dst->group));
bla_dst_own->group = bla_dst->group;
}
Expand Down Expand Up @@ -1626,10 +1622,10 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)

primary_addr = primary_if->net_dev->dev_addr;
seq_printf(seq,
"Claims announced for the mesh %s (orig %pM, group id %04x)\n",
"Claims announced for the mesh %s (orig %pM, group id %#.4x)\n",
net_dev->name, primary_addr,
ntohs(bat_priv->bla.claim_dest.group));
seq_printf(seq, " %-17s %-5s %-17s [o] (%-4s)\n",
seq_printf(seq, " %-17s %-5s %-17s [o] (%-6s)\n",
"Client", "VID", "Originator", "CRC");
for (i = 0; i < hash->size; i++) {
head = &hash->table[i];
Expand All @@ -1638,7 +1634,7 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
hlist_for_each_entry_rcu(claim, node, head, hash_entry) {
is_own = batadv_compare_eth(claim->backbone_gw->orig,
primary_addr);
seq_printf(seq, " * %pM on % 5d by %pM [%c] (%04x)\n",
seq_printf(seq, " * %pM on % 5d by %pM [%c] (%#.4x)\n",
claim->addr, claim->vid,
claim->backbone_gw->orig,
(is_own ? 'x' : ' '),
Expand Down Expand Up @@ -1672,10 +1668,10 @@ int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset)

primary_addr = primary_if->net_dev->dev_addr;
seq_printf(seq,
"Backbones announced for the mesh %s (orig %pM, group id %04x)\n",
"Backbones announced for the mesh %s (orig %pM, group id %#.4x)\n",
net_dev->name, primary_addr,
ntohs(bat_priv->bla.claim_dest.group));
seq_printf(seq, " %-17s %-5s %-9s (%-4s)\n",
seq_printf(seq, " %-17s %-5s %-9s (%-6s)\n",
"Originator", "VID", "last seen", "CRC");
for (i = 0; i < hash->size; i++) {
head = &hash->table[i];
Expand All @@ -1693,7 +1689,7 @@ int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset)
continue;

seq_printf(seq,
" * %pM on % 5d % 4i.%03is (%04x)\n",
" * %pM on % 5d % 4i.%03is (%#.4x)\n",
backbone_gw->orig, backbone_gw->vid,
secs, msecs, backbone_gw->crc);
}
Expand Down
8 changes: 2 additions & 6 deletions net/batman-adv/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf,

buf++;
i++;

}

spin_unlock_bh(&debug_log->lock);
Expand Down Expand Up @@ -230,7 +229,6 @@ static void batadv_debug_log_cleanup(struct batadv_priv *bat_priv)
#else /* CONFIG_BATMAN_ADV_DEBUG */
static int batadv_debug_log_setup(struct batadv_priv *bat_priv)
{
bat_priv->debug_log = NULL;
return 0;
}

Expand Down Expand Up @@ -397,10 +395,8 @@ void batadv_debugfs_init(void)

void batadv_debugfs_destroy(void)
{
if (batadv_debugfs) {
debugfs_remove_recursive(batadv_debugfs);
batadv_debugfs = NULL;
}
debugfs_remove_recursive(batadv_debugfs);
batadv_debugfs = NULL;
}

int batadv_debugfs_add_meshif(struct net_device *dev)
Expand Down
2 changes: 1 addition & 1 deletion net/batman-adv/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static inline void batadv_hash_delete(struct batadv_hashtable *hash,
*
* Returns the new hash value.
*/
static inline uint32_t batadv_hash_bytes(uint32_t hash, void *data,
static inline uint32_t batadv_hash_bytes(uint32_t hash, const void *data,
uint32_t size)
{
const unsigned char *key = data;
Expand Down
6 changes: 2 additions & 4 deletions net/batman-adv/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* -> TODO: check influence on BATADV_TQ_LOCAL_WINDOW_SIZE
*/
#define BATADV_PURGE_TIMEOUT 200000 /* 200 seconds */
#define BATADV_TT_LOCAL_TIMEOUT 3600000 /* in milliseconds */
#define BATADV_TT_LOCAL_TIMEOUT 600000 /* in milliseconds */
#define BATADV_TT_CLIENT_ROAM_TIMEOUT 600000 /* in milliseconds */
#define BATADV_TT_CLIENT_TEMP_TIMEOUT 600000 /* in milliseconds */
#define BATADV_DAT_ENTRY_TIMEOUT (5*60000) /* 5 mins in milliseconds */
Expand Down Expand Up @@ -276,9 +276,7 @@ static inline bool batadv_has_timed_out(unsigned long timestamp,
static inline void batadv_add_counter(struct batadv_priv *bat_priv, size_t idx,
size_t count)
{
int cpu = get_cpu();
per_cpu_ptr(bat_priv->bat_counters, cpu)[idx] += count;
put_cpu();
this_cpu_add(bat_priv->bat_counters[idx], count);
}

#define batadv_inc_counter(b, i) batadv_add_counter(b, i, 1)
Expand Down
9 changes: 6 additions & 3 deletions net/batman-adv/originator.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#include "soft-interface.h"
#include "bridge_loop_avoidance.h"

/* hash class keys */
static struct lock_class_key batadv_orig_hash_lock_class_key;

static void batadv_purge_orig(struct work_struct *work);

static void batadv_start_purge_timer(struct batadv_priv *bat_priv)
Expand Down Expand Up @@ -57,6 +60,9 @@ int batadv_originator_init(struct batadv_priv *bat_priv)
if (!bat_priv->orig_hash)
goto err;

batadv_hash_set_lock_class(bat_priv->orig_hash,
&batadv_orig_hash_lock_class_key);

batadv_start_purge_timer(bat_priv);
return 0;

Expand Down Expand Up @@ -178,7 +184,6 @@ void batadv_originator_free(struct batadv_priv *bat_priv)
spin_lock_bh(list_lock);
hlist_for_each_entry_safe(orig_node, node, node_tmp,
head, hash_entry) {

hlist_del_rcu(node);
batadv_orig_node_free_ref(orig_node);
}
Expand Down Expand Up @@ -285,15 +290,13 @@ batadv_purge_orig_neighbors(struct batadv_priv *bat_priv,
/* for all neighbors towards this originator ... */
hlist_for_each_entry_safe(neigh_node, node, node_tmp,
&orig_node->neigh_list, list) {

last_seen = neigh_node->last_seen;
if_incoming = neigh_node->if_incoming;

if ((batadv_has_timed_out(last_seen, BATADV_PURGE_TIMEOUT)) ||
(if_incoming->if_status == BATADV_IF_INACTIVE) ||
(if_incoming->if_status == BATADV_IF_NOT_IN_USE) ||
(if_incoming->if_status == BATADV_IF_TO_BE_REMOVED)) {

if ((if_incoming->if_status == BATADV_IF_INACTIVE) ||
(if_incoming->if_status == BATADV_IF_NOT_IN_USE) ||
(if_incoming->if_status == BATADV_IF_TO_BE_REMOVED))
Expand Down
4 changes: 0 additions & 4 deletions net/batman-adv/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ static void _batadv_update_route(struct batadv_priv *bat_priv,

/* route added */
} else if ((!curr_router) && (neigh_node)) {

batadv_dbg(BATADV_DBG_ROUTES, bat_priv,
"Adding route towards: %pM (via %pM)\n",
orig_node->orig, neigh_node->addr);
Expand Down Expand Up @@ -172,7 +171,6 @@ void batadv_bonding_candidate_add(struct batadv_orig_node *orig_node,
*/
hlist_for_each_entry_rcu(tmp_neigh_node, node,
&orig_node->neigh_list, list) {

if (tmp_neigh_node == neigh_node)
continue;

Expand Down Expand Up @@ -836,7 +834,6 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
if (unicast_packet->header.packet_type == BATADV_UNICAST_FRAG &&
batadv_frag_can_reassemble(skb,
neigh_node->if_incoming->net_dev->mtu)) {

ret = batadv_frag_reassemble_skb(skb, bat_priv, &new_skb);

if (ret == NET_RX_DROP)
Expand Down Expand Up @@ -1103,7 +1100,6 @@ int batadv_recv_ucast_frag_packet(struct sk_buff *skb,

/* packet for me */
if (batadv_is_my_mac(unicast_packet->dest)) {

ret = batadv_frag_reassemble_skb(skb, bat_priv, &new_skb);

if (ret == NET_RX_DROP)
Expand Down
2 changes: 0 additions & 2 deletions net/batman-adv/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ batadv_purge_outstanding_packets(struct batadv_priv *bat_priv,
spin_lock_bh(&bat_priv->forw_bcast_list_lock);
hlist_for_each_entry_safe(forw_packet, tmp_node, safe_tmp_node,
&bat_priv->forw_bcast_list, list) {

/* if purge_outstanding_packets() was called with an argument
* we delete only packets belonging to the given interface
*/
Expand All @@ -357,7 +356,6 @@ batadv_purge_outstanding_packets(struct batadv_priv *bat_priv,
spin_lock_bh(&bat_priv->forw_bat_list_lock);
hlist_for_each_entry_safe(forw_packet, tmp_node, safe_tmp_node,
&bat_priv->forw_bat_list, list) {

/* if purge_outstanding_packets() was called with an argument
* we delete only packets belonging to the given interface
*/
Expand Down
7 changes: 6 additions & 1 deletion net/batman-adv/soft-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ static int batadv_interface_tx(struct sk_buff *skb,
goto dropped;

/* Register the client MAC in the transtable */
batadv_tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif);
if (!is_multicast_ether_addr(ethhdr->h_source))
batadv_tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif);

/* don't accept stp packets. STP does not help in meshes.
* better use the bridge loop avoidance ...
Expand Down Expand Up @@ -479,7 +480,9 @@ struct net_device *batadv_softif_create(const char *name)

atomic_set(&bat_priv->aggregated_ogms, 1);
atomic_set(&bat_priv->bonding, 0);
#ifdef CONFIG_BATMAN_ADV_BLA
atomic_set(&bat_priv->bridge_loop_avoidance, 0);
#endif
#ifdef CONFIG_BATMAN_ADV_DAT
atomic_set(&bat_priv->distributed_arp_table, 1);
#endif
Expand All @@ -490,7 +493,9 @@ struct net_device *batadv_softif_create(const char *name)
atomic_set(&bat_priv->gw_bandwidth, 41);
atomic_set(&bat_priv->orig_interval, 1000);
atomic_set(&bat_priv->hop_penalty, 30);
#ifdef CONFIG_BATMAN_ADV_DEBUG
atomic_set(&bat_priv->log_level, 0);
#endif
atomic_set(&bat_priv->fragmentation, 1);
atomic_set(&bat_priv->bcast_queue_left, BATADV_BCAST_QUEUE_LEN);
atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
Expand Down
Loading

0 comments on commit a4412a6

Please sign in to comment.