summaryrefslogtreecommitdiffstats
path: root/drivers/staging/batman-adv/soft-interface.c
diff options
context:
space:
mode:
authorMarek Lindner <lindner_marek@yahoo.de>2010-09-05 01:58:35 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2010-09-05 00:29:49 -0700
commit8c70f13832ecaa0e4fc312d38990a25bc99e633b (patch)
tree7f6df2f4a78cea92ed25329c3243bb8d71cbe3ad /drivers/staging/batman-adv/soft-interface.c
parent6a0e9fa88df9e3a517a2fd317706aefa10a43191 (diff)
downloadop-kernel-dev-8c70f13832ecaa0e4fc312d38990a25bc99e633b.zip
op-kernel-dev-8c70f13832ecaa0e4fc312d38990a25bc99e633b.tar.gz
Staging: batman-adv: multiple mesh clouds
This patch removes all remaining global variables and includes the necessary bits into the bat_priv structure. It is the last remaining piece to allow multiple concurrent mesh clouds on the same device. A few global variables have been rendered obsolete during the process and have been removed entirely. Signed-off-by: Marek Lindner <lindner_marek@yahoo.de> [sven.eckelmann@gmx.de: Rework on top of current version] Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/batman-adv/soft-interface.c')
-rw-r--r--drivers/staging/batman-adv/soft-interface.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/drivers/staging/batman-adv/soft-interface.c b/drivers/staging/batman-adv/soft-interface.c
index 864f85d..8d14343 100644
--- a/drivers/staging/batman-adv/soft-interface.c
+++ b/drivers/staging/batman-adv/soft-interface.c
@@ -35,10 +35,7 @@
#include <linux/etherdevice.h>
#include "unicast.h"
-static uint32_t bcast_seqno = 1; /* give own bcast messages seq numbers to avoid
- * broadcast storms */
-unsigned char main_if_addr[ETH_ALEN];
static int bat_get_settings(struct net_device *dev, struct ethtool_cmd *cmd);
static void bat_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info);
@@ -58,11 +55,6 @@ static const struct ethtool_ops bat_ethtool_ops = {
.set_rx_csum = bat_set_rx_csum
};
-void set_main_if_addr(uint8_t *addr)
-{
- memcpy(main_if_addr, addr, ETH_ALEN);
-}
-
int my_skb_head_push(struct sk_buff *skb, unsigned int len)
{
int result;
@@ -76,7 +68,6 @@ int my_skb_head_push(struct sk_buff *skb, unsigned int len)
* to write freely in that area.
*/
result = skb_cow_head(skb, len);
-
if (result < 0)
return result;
@@ -111,7 +102,7 @@ static int interface_set_mac_addr(struct net_device *dev, void *p)
return -EADDRNOTAVAIL;
/* only modify hna-table if it has been initialised before */
- if (atomic_read(&module_state) == MODULE_ACTIVE) {
+ if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) {
hna_local_remove(bat_priv, dev->dev_addr,
"mac address changed");
hna_local_add(dev, addr->sa_data);
@@ -140,7 +131,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
struct bcast_packet *bcast_packet;
int data_len = skb->len, ret;
- if (atomic_read(&module_state) != MODULE_ACTIVE)
+ if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE)
goto dropped;
soft_iface->trans_start = jiffies;
@@ -150,6 +141,8 @@ int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
/* ethernet packet should be broadcasted */
if (is_bcast(ethhdr->h_dest) || is_mcast(ethhdr->h_dest)) {
+ if (!bat_priv->primary_if)
+ goto dropped;
if (my_skb_head_push(skb, sizeof(struct bcast_packet)) < 0)
goto dropped;
@@ -163,14 +156,14 @@ int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
/* hw address of first interface is the orig mac because only
* this mac is known throughout the mesh */
- memcpy(bcast_packet->orig, main_if_addr, ETH_ALEN);
+ memcpy(bcast_packet->orig,
+ bat_priv->primary_if->net_dev->dev_addr, ETH_ALEN);
/* set broadcast sequence number */
- bcast_packet->seqno = htonl(bcast_seqno);
+ bcast_packet->seqno =
+ htonl(atomic_inc_return(&bat_priv->bcast_seqno));
- /* broadcast packet. on success, increase seqno. */
- if (add_bcast_packet_to_list(bat_priv, skb) == NETDEV_TX_OK)
- bcast_seqno++;
+ add_bcast_packet_to_list(bat_priv, skb);
/* a copy is stored in the bcast list, therefore removing
* the original skb. */
@@ -179,10 +172,8 @@ int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
/* unicast packet */
} else {
ret = unicast_send_skb(skb, bat_priv);
- if (ret != 0) {
- bat_priv->stats.tx_dropped++;
- goto end;
- }
+ if (ret != 0)
+ goto dropped_freed;
}
bat_priv->stats.tx_packets++;
@@ -190,8 +181,9 @@ int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
goto end;
dropped:
- bat_priv->stats.tx_dropped++;
kfree_skb(skb);
+dropped_freed:
+ bat_priv->stats.tx_dropped++;
end:
return NETDEV_TX_OK;
}
@@ -292,7 +284,6 @@ struct net_device *softif_create(char *name)
}
ret = register_netdev(soft_iface);
-
if (ret < 0) {
pr_err("Unable to register the batman interface '%s': %i\n",
name, ret);
@@ -310,21 +301,29 @@ struct net_device *softif_create(char *name)
atomic_set(&bat_priv->bcast_queue_left, BCAST_QUEUE_LEN);
atomic_set(&bat_priv->batman_queue_left, BATMAN_QUEUE_LEN);
+ atomic_set(&bat_priv->mesh_state, MESH_INACTIVE);
+ atomic_set(&bat_priv->bcast_seqno, 1);
+ atomic_set(&bat_priv->hna_local_changed, 0);
+
bat_priv->primary_if = NULL;
bat_priv->num_ifaces = 0;
ret = sysfs_add_meshif(soft_iface);
-
if (ret < 0)
goto unreg_soft_iface;
ret = debugfs_add_meshif(soft_iface);
-
if (ret < 0)
goto unreg_sysfs;
+ ret = mesh_init(soft_iface);
+ if (ret < 0)
+ goto unreg_debugfs;
+
return soft_iface;
+unreg_debugfs:
+ debugfs_del_meshif(soft_iface);
unreg_sysfs:
sysfs_del_meshif(soft_iface);
unreg_soft_iface:
@@ -341,6 +340,7 @@ void softif_destroy(struct net_device *soft_iface)
{
debugfs_del_meshif(soft_iface);
sysfs_del_meshif(soft_iface);
+ mesh_free(soft_iface);
unregister_netdevice(soft_iface);
}
OpenPOWER on IntegriCloud