Skip to content

Commit

Permalink
Merge branch 'batman-adv/next' of git://git.open-mesh.org/ecsv/linux-…
Browse files Browse the repository at this point in the history
…merge
  • Loading branch information
David S. Miller committed Apr 18, 2011
2 parents 03746b0 + af20b71 commit 9c6bc16
Show file tree
Hide file tree
Showing 11 changed files with 537 additions and 393 deletions.
259 changes: 151 additions & 108 deletions net/batman-adv/gateway_client.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion net/batman-adv/gateway_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

void gw_deselect(struct bat_priv *bat_priv);
void gw_election(struct bat_priv *bat_priv);
void *gw_get_selected(struct bat_priv *bat_priv);
struct orig_node *gw_get_selected_orig(struct bat_priv *bat_priv);
void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node);
void gw_node_update(struct bat_priv *bat_priv,
struct orig_node *orig_node, uint8_t new_gwflags);
Expand Down
18 changes: 3 additions & 15 deletions net/batman-adv/icmp_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,23 +218,13 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE)
goto dst_unreach;

rcu_read_lock();
orig_node = orig_hash_find(bat_priv, icmp_packet->dst);

if (!orig_node)
goto unlock;

neigh_node = orig_node->router;
goto dst_unreach;

neigh_node = orig_node_get_router(orig_node);
if (!neigh_node)
goto unlock;

if (!atomic_inc_not_zero(&neigh_node->refcount)) {
neigh_node = NULL;
goto unlock;
}

rcu_read_unlock();
goto dst_unreach;

if (!neigh_node->if_incoming)
goto dst_unreach;
Expand All @@ -252,8 +242,6 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
goto out;

unlock:
rcu_read_unlock();
dst_unreach:
icmp_packet->msg_type = DESTINATION_UNREACHABLE;
bat_socket_add_packet(socket_client, icmp_packet, packet_len);
Expand Down
38 changes: 29 additions & 9 deletions net/batman-adv/originator.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ void neigh_node_free_ref(struct neigh_node *neigh_node)
call_rcu(&neigh_node->rcu, neigh_node_free_rcu);
}

/* increases the refcounter of a found router */
struct neigh_node *orig_node_get_router(struct orig_node *orig_node)
{
struct neigh_node *router;

rcu_read_lock();
router = rcu_dereference(orig_node->router);

if (router && !atomic_inc_not_zero(&router->refcount))
router = NULL;

rcu_read_unlock();
return router;
}

struct neigh_node *create_neighbor(struct orig_node *orig_node,
struct orig_node *orig_neigh_node,
uint8_t *neigh,
Expand All @@ -87,6 +102,7 @@ struct neigh_node *create_neighbor(struct orig_node *orig_node,

INIT_HLIST_NODE(&neigh_node->list);
INIT_LIST_HEAD(&neigh_node->bonding_list);
spin_lock_init(&neigh_node->tq_lock);

memcpy(neigh_node->addr, neigh, ETH_ALEN);
neigh_node->orig_node = orig_neigh_node;
Expand Down Expand Up @@ -390,7 +406,7 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
struct hlist_node *node, *node_tmp;
struct hlist_head *head;
struct orig_node *orig_node;
struct neigh_node *neigh_node;
struct neigh_node *neigh_node, *neigh_node_tmp;
int batman_count = 0;
int last_seen_secs;
int last_seen_msecs;
Expand Down Expand Up @@ -421,37 +437,41 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)

rcu_read_lock();
hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) {
if (!orig_node->router)
neigh_node = orig_node_get_router(orig_node);
if (!neigh_node)
continue;

if (orig_node->router->tq_avg == 0)
continue;
if (neigh_node->tq_avg == 0)
goto next;

last_seen_secs = jiffies_to_msecs(jiffies -
orig_node->last_valid) / 1000;
last_seen_msecs = jiffies_to_msecs(jiffies -
orig_node->last_valid) % 1000;

neigh_node = orig_node->router;
seq_printf(seq, "%pM %4i.%03is (%3i) %pM [%10s]:",
orig_node->orig, last_seen_secs,
last_seen_msecs, neigh_node->tq_avg,
neigh_node->addr,
neigh_node->if_incoming->net_dev->name);

hlist_for_each_entry_rcu(neigh_node, node_tmp,
hlist_for_each_entry_rcu(neigh_node_tmp, node_tmp,
&orig_node->neigh_list, list) {
seq_printf(seq, " %pM (%3i)", neigh_node->addr,
neigh_node->tq_avg);
seq_printf(seq, " %pM (%3i)",
neigh_node_tmp->addr,
neigh_node_tmp->tq_avg);
}

seq_printf(seq, "\n");
batman_count++;

next:
neigh_node_free_ref(neigh_node);
}
rcu_read_unlock();
}

if ((batman_count == 0))
if (batman_count == 0)
seq_printf(seq, "No batman nodes in range ...\n");

return 0;
Expand Down
1 change: 1 addition & 0 deletions net/batman-adv/originator.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct neigh_node *create_neighbor(struct orig_node *orig_node,
uint8_t *neigh,
struct hard_iface *if_incoming);
void neigh_node_free_ref(struct neigh_node *neigh_node);
struct neigh_node *orig_node_get_router(struct orig_node *orig_node);
int orig_seq_print_text(struct seq_file *seq, void *offset);
int orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num);
int orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num);
Expand Down
Loading

0 comments on commit 9c6bc16

Please sign in to comment.