Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 219759
b: refs/heads/master
c: 8c70f13
h: refs/heads/master
i:
  219757: 4731177
  219755: 08384f2
  219751: 7051f0c
  219743: 791f06e
v: v3
  • Loading branch information
Marek Lindner authored and Greg Kroah-Hartman committed Sep 5, 2010
1 parent 45618e7 commit 614fbd6
Show file tree
Hide file tree
Showing 21 changed files with 680 additions and 600 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6a0e9fa88df9e3a517a2fd317706aefa10a43191
refs/heads/master: 8c70f13832ecaa0e4fc312d38990a25bc99e633b
18 changes: 9 additions & 9 deletions trunk/drivers/staging/batman-adv/aggregation.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ static void new_aggregated_packet(unsigned char *packet_buff, int packet_len,
struct batman_if *if_incoming,
int own_packet)
{
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
struct forw_packet *forw_packet_aggr;
unsigned long flags;
unsigned char *skb_buff;
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);

/* own packet should always be scheduled */
if (!own_packet) {
Expand Down Expand Up @@ -150,9 +150,9 @@ static void new_aggregated_packet(unsigned char *packet_buff, int packet_len,
forw_packet_aggr->direct_link_flags |= 1;

/* add new packet to packet list */
spin_lock_irqsave(&forw_bat_list_lock, flags);
hlist_add_head(&forw_packet_aggr->list, &forw_bat_list);
spin_unlock_irqrestore(&forw_bat_list_lock, flags);
spin_lock_irqsave(&bat_priv->forw_bat_list_lock, flags);
hlist_add_head(&forw_packet_aggr->list, &bat_priv->forw_bat_list);
spin_unlock_irqrestore(&bat_priv->forw_bat_list_lock, flags);

/* start timer for this packet */
INIT_DELAYED_WORK(&forw_packet_aggr->delayed_work,
Expand Down Expand Up @@ -198,11 +198,11 @@ void add_bat_packet_to_list(struct bat_priv *bat_priv,
unsigned long flags;

/* find position for the packet in the forward queue */
spin_lock_irqsave(&forw_bat_list_lock, flags);
spin_lock_irqsave(&bat_priv->forw_bat_list_lock, flags);
/* own packets are not to be aggregated */
if ((atomic_read(&bat_priv->aggregation_enabled)) && (!own_packet)) {
hlist_for_each_entry(forw_packet_pos, tmp_node, &forw_bat_list,
list) {
hlist_for_each_entry(forw_packet_pos, tmp_node,
&bat_priv->forw_bat_list, list) {
if (can_aggregate_with(batman_packet,
packet_len,
send_time,
Expand All @@ -219,7 +219,7 @@ void add_bat_packet_to_list(struct bat_priv *bat_priv,
* suitable aggregation packet found */
if (forw_packet_aggr == NULL) {
/* the following section can run without the lock */
spin_unlock_irqrestore(&forw_bat_list_lock, flags);
spin_unlock_irqrestore(&bat_priv->forw_bat_list_lock, flags);

/**
* if we could not aggregate this packet with one of the others
Expand All @@ -237,7 +237,7 @@ void add_bat_packet_to_list(struct bat_priv *bat_priv,
aggregate(forw_packet_aggr,
packet_buff, packet_len,
direct_link);
spin_unlock_irqrestore(&forw_bat_list_lock, flags);
spin_unlock_irqrestore(&bat_priv->forw_bat_list_lock, flags);
}
}

Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/staging/batman-adv/bat_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ static ssize_t show_mesh_iface(struct kobject *kobj, struct attribute *attr,

return sprintf(buff, "%s\n",
batman_if->if_status == IF_NOT_IN_USE ?
"none" : "bat0");
"none" : batman_if->soft_iface->name);
}

static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
Expand Down
48 changes: 27 additions & 21 deletions trunk/drivers/staging/batman-adv/hard-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ static int is_valid_iface(struct net_device *net_dev)
return 1;
}

static struct batman_if *get_active_batman_if(void)
static struct batman_if *get_active_batman_if(struct net_device *soft_iface)
{
struct batman_if *batman_if;

/* TODO: should check interfaces belonging to bat_priv */
rcu_read_lock();
list_for_each_entry_rcu(batman_if, &if_list, list) {
if (batman_if->soft_iface != soft_iface)
continue;

if (batman_if->if_status == IF_ACTIVE)
goto out;
}
Expand All @@ -99,23 +101,29 @@ static void set_primary_if(struct bat_priv *bat_priv,
struct batman_if *batman_if)
{
struct batman_packet *batman_packet;
struct vis_packet *vis_packet;

bat_priv->primary_if = batman_if;

if (!bat_priv->primary_if)
return;

set_main_if_addr(batman_if->net_dev->dev_addr);

batman_packet = (struct batman_packet *)(batman_if->packet_buff);
batman_packet->flags = PRIMARIES_FIRST_HOP;
batman_packet->ttl = TTL;

vis_packet = (struct vis_packet *)
bat_priv->my_vis_info->skb_packet->data;
memcpy(vis_packet->vis_orig,
bat_priv->primary_if->net_dev->dev_addr, ETH_ALEN);
memcpy(vis_packet->sender_orig,
bat_priv->primary_if->net_dev->dev_addr, ETH_ALEN);

/***
* hacky trick to make sure that we send the HNA information via
* our new primary interface
*/
atomic_set(&hna_local_changed, 1);
atomic_set(&bat_priv->hna_local_changed, 1);
}

static bool hardif_is_iface_up(struct batman_if *batman_if)
Expand Down Expand Up @@ -217,9 +225,6 @@ static void hardif_activate_interface(struct batman_if *batman_if)
bat_info(batman_if->soft_iface, "Interface activated: %s\n",
batman_if->dev);

if (atomic_read(&module_state) == MODULE_INACTIVE)
activate_module();

update_min_mtu(batman_if->soft_iface);
return;
}
Expand Down Expand Up @@ -347,22 +352,23 @@ void hardif_disable_interface(struct batman_if *batman_if)
orig_hash_del_if(batman_if, bat_priv->num_ifaces);

if (batman_if == bat_priv->primary_if)
set_primary_if(bat_priv, get_active_batman_if());
set_primary_if(bat_priv,
get_active_batman_if(batman_if->soft_iface));

kfree(batman_if->packet_buff);
batman_if->packet_buff = NULL;
batman_if->if_status = IF_NOT_IN_USE;

/* delete all references to this batman_if */
purge_orig_ref(bat_priv);
purge_outstanding_packets(bat_priv, batman_if);
dev_put(batman_if->soft_iface);

/* nobody uses this interface anymore */
if (!bat_priv->num_ifaces)
softif_destroy(batman_if->soft_iface);

batman_if->soft_iface = NULL;

/*if ((atomic_read(&module_state) == MODULE_ACTIVE) &&
(bat_priv->num_ifaces == 0))
deactivate_module();*/
}

static struct batman_if *hardif_add_interface(struct net_device *net_dev)
Expand Down Expand Up @@ -415,10 +421,6 @@ static void hardif_free_interface(struct rcu_head *rcu)
{
struct batman_if *batman_if = container_of(rcu, struct batman_if, rcu);

/* delete all references to this batman_if */
purge_orig(NULL);
purge_outstanding_packets(batman_if);

kfree(batman_if->dev);
kfree(batman_if);
}
Expand Down Expand Up @@ -512,9 +514,6 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
if (!skb)
goto err_out;

if (atomic_read(&module_state) != MODULE_ACTIVE)
goto err_free;

/* packet should hold at least type and version */
if (unlikely(!pskb_may_pull(skb, 2)))
goto err_free;
Expand All @@ -524,12 +523,19 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
|| !skb_mac_header(skb)))
goto err_free;

if (!batman_if->soft_iface)
goto err_free;

bat_priv = netdev_priv(batman_if->soft_iface);

if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE)
goto err_free;

/* discard frames on not active interfaces */
if (batman_if->if_status != IF_ACTIVE)
goto err_free;

batman_packet = (struct batman_packet *)skb->data;
bat_priv = netdev_priv(batman_if->soft_iface);

if (batman_packet->version != COMPAT_VERSION) {
bat_dbg(DBG_BATMAN, bat_priv,
Expand Down
11 changes: 6 additions & 5 deletions trunk/drivers/staging/batman-adv/icmp_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,12 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
goto free_skb;
}

if (atomic_read(&module_state) != MODULE_ACTIVE)
if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE)
goto dst_unreach;

spin_lock_irqsave(&orig_hash_lock, flags);
orig_node = (struct orig_node *)hash_find(orig_hash, icmp_packet->dst);
spin_lock_irqsave(&bat_priv->orig_hash_lock, flags);
orig_node = ((struct orig_node *)hash_find(bat_priv->orig_hash,
icmp_packet->dst));

if (!orig_node)
goto unlock;
Expand All @@ -233,7 +234,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
batman_if = orig_node->router->if_incoming;
memcpy(dstaddr, orig_node->router->addr, ETH_ALEN);

spin_unlock_irqrestore(&orig_hash_lock, flags);
spin_unlock_irqrestore(&bat_priv->orig_hash_lock, flags);

if (!batman_if)
goto dst_unreach;
Expand All @@ -253,7 +254,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
goto out;

unlock:
spin_unlock_irqrestore(&orig_hash_lock, flags);
spin_unlock_irqrestore(&bat_priv->orig_hash_lock, flags);
dst_unreach:
icmp_packet->msg_type = DESTINATION_UNREACHABLE;
bat_socket_add_packet(socket_client, icmp_packet, packet_len);
Expand Down
74 changes: 37 additions & 37 deletions trunk/drivers/staging/batman-adv/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,14 @@
#include "hash.h"

struct list_head if_list;
struct hlist_head forw_bat_list;
struct hlist_head forw_bcast_list;
struct hashtable_t *orig_hash;

DEFINE_SPINLOCK(orig_hash_lock);
DEFINE_SPINLOCK(forw_bat_list_lock);
DEFINE_SPINLOCK(forw_bcast_list_lock);

int16_t num_hna;

unsigned char broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
atomic_t module_state;

struct workqueue_struct *bat_event_workqueue;

static int __init batman_init(void)
{
INIT_LIST_HEAD(&if_list);
INIT_HLIST_HEAD(&forw_bat_list);
INIT_HLIST_HEAD(&forw_bcast_list);

atomic_set(&module_state, MODULE_INACTIVE);

/* the name should not be longer than 10 chars - see
* http://lwn.net/Articles/23634/ */
Expand All @@ -78,64 +64,78 @@ static int __init batman_init(void)

static void __exit batman_exit(void)
{
deactivate_module();

debugfs_destroy();
unregister_netdevice_notifier(&hard_if_notifier);
hardif_remove_interfaces();

flush_workqueue(bat_event_workqueue);
destroy_workqueue(bat_event_workqueue);
bat_event_workqueue = NULL;
}

/* activates the module, starts timer ... */
void activate_module(void)
int mesh_init(struct net_device *soft_iface)
{
if (originator_init() < 1)
struct bat_priv *bat_priv = netdev_priv(soft_iface);

spin_lock_init(&bat_priv->orig_hash_lock);
spin_lock_init(&bat_priv->forw_bat_list_lock);
spin_lock_init(&bat_priv->forw_bcast_list_lock);
spin_lock_init(&bat_priv->hna_lhash_lock);
spin_lock_init(&bat_priv->hna_ghash_lock);
spin_lock_init(&bat_priv->gw_list_lock);
spin_lock_init(&bat_priv->vis_hash_lock);
spin_lock_init(&bat_priv->vis_list_lock);

INIT_HLIST_HEAD(&bat_priv->forw_bat_list);
INIT_HLIST_HEAD(&bat_priv->forw_bcast_list);
INIT_HLIST_HEAD(&bat_priv->gw_list);

if (originator_init(bat_priv) < 1)
goto err;

if (hna_local_init() < 1)
if (hna_local_init(bat_priv) < 1)
goto err;

if (hna_global_init() < 1)
if (hna_global_init(bat_priv) < 1)
goto err;

/*hna_local_add(soft_device->dev_addr);*/
hna_local_add(soft_iface, soft_iface->dev_addr);

if (vis_init() < 1)
if (vis_init(bat_priv) < 1)
goto err;

/*update_min_mtu();*/
atomic_set(&module_state, MODULE_ACTIVE);
atomic_set(&bat_priv->mesh_state, MESH_ACTIVE);
goto end;

err:
pr_err("Unable to allocate memory for mesh information structures: "
"out of mem ?\n");
deactivate_module();
mesh_free(soft_iface);
return -1;

end:
return;
return 0;
}

/* shuts down the whole module.*/
void deactivate_module(void)
void mesh_free(struct net_device *soft_iface)
{
atomic_set(&module_state, MODULE_DEACTIVATING);
struct bat_priv *bat_priv = netdev_priv(soft_iface);

purge_outstanding_packets(NULL);
flush_workqueue(bat_event_workqueue);
atomic_set(&bat_priv->mesh_state, MESH_DEACTIVATING);

purge_outstanding_packets(bat_priv, NULL);

vis_quit();
vis_quit(bat_priv);

originator_free();
originator_free(bat_priv);

hna_local_free();
hna_global_free();
hna_local_free(bat_priv);
hna_global_free(bat_priv);

synchronize_net();

synchronize_rcu();
atomic_set(&module_state, MODULE_INACTIVE);
atomic_set(&bat_priv->mesh_state, MESH_INACTIVE);
}

void inc_module_count(void)
Expand Down
Loading

0 comments on commit 614fbd6

Please sign in to comment.