b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] Staging: batman-adv for 2.6.36 (6: fixes)
@ 2010-08-09 21:56 Sven Eckelmann
  2010-08-09 21:56 ` [B.A.T.M.A.N.] [PATCH 1/5] Staging: batman-adv: Fix merge of linus tree Sven Eckelmann
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Sven Eckelmann @ 2010-08-09 21:56 UTC (permalink / raw)
  To: greg; +Cc: b.a.t.m.a.n

Hi,

here are patches targeted for 2.6.36. All patches needed for that patchset are
already part of Linus' tree. They are smaller bugfixes and add no new features.

The only special fix is "unify orig_hash_lock spinlock handling to avoid
deadlocks" which fixes the usage of the same spinlock with spin_lock and
spin_lock_irqsave. This one should also be applied in 2.6.35.x

"Fix merge of linus tree" should readd an older bugfix again which was removed
by your merge with Linus' tree.

The patches for 2.6.37 will follow later.

thanks,
	Sven

Marek Lindner (4):
      Staging: batman-adv: unify orig_hash_lock spinlock handling to avoid deadlocks
      Staging: batman-adv: fix batman icmp originating from secondary interface
      Staging: batman-adv: always reply batman icmp packets with primary mac
      Staging: batman-adv: fix own mac address detection

Sven Eckelmann (1):
      Staging: batman-adv: Fix merge of linus tree

 drivers/staging/batman-adv/bat_sysfs.c      |    4 ++++
 drivers/staging/batman-adv/hard-interface.c |    8 --------
 drivers/staging/batman-adv/icmp_socket.c    |   12 ++++++++----
 drivers/staging/batman-adv/main.c           |    7 +++++--
 drivers/staging/batman-adv/originator.c     |   14 ++++++++------
 drivers/staging/batman-adv/routing.c        |   16 ++++++++++++++--
 drivers/staging/batman-adv/types.h          |    1 +
 7 files changed, 40 insertions(+), 22 deletions(-)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [B.A.T.M.A.N.] [PATCH 1/5] Staging: batman-adv: Fix merge of linus tree
  2010-08-09 21:56 [B.A.T.M.A.N.] Staging: batman-adv for 2.6.36 (6: fixes) Sven Eckelmann
@ 2010-08-09 21:56 ` Sven Eckelmann
  2010-08-09 21:56 ` [B.A.T.M.A.N.] [PATCH 2/5] Staging: batman-adv: unify orig_hash_lock spinlock handling to avoid deadlocks Sven Eckelmann
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Sven Eckelmann @ 2010-08-09 21:56 UTC (permalink / raw)
  To: greg; +Cc: b.a.t.m.a.n

Greg Kroah-Hartman merged Linus 2.6.36 tree in
e9563355ac1175dd3440dc2ea5c28b27ed51a283 with his staging tree.
Different parts of the merge conflicts were resolved incorrectly and may
result in an abnormal behavior.

Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 drivers/staging/batman-adv/bat_sysfs.c      |    4 ++++
 drivers/staging/batman-adv/hard-interface.c |    8 --------
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/batman-adv/bat_sysfs.c b/drivers/staging/batman-adv/bat_sysfs.c
index b4a8d5e..05ca15a 100644
--- a/drivers/staging/batman-adv/bat_sysfs.c
+++ b/drivers/staging/batman-adv/bat_sysfs.c
@@ -267,6 +267,10 @@ static ssize_t store_log_level(struct kobject *kobj, struct attribute *attr,
 	if (atomic_read(&bat_priv->log_level) == log_level_tmp)
 		return count;
 
+	bat_info(net_dev, "Changing log level from: %i to: %li\n",
+		 atomic_read(&bat_priv->log_level),
+		 log_level_tmp);
+
 	atomic_set(&bat_priv->log_level, (unsigned)log_level_tmp);
 	return count;
 }
diff --git a/drivers/staging/batman-adv/hard-interface.c b/drivers/staging/batman-adv/hard-interface.c
index 92c216a..f6345c4 100644
--- a/drivers/staging/batman-adv/hard-interface.c
+++ b/drivers/staging/batman-adv/hard-interface.c
@@ -442,8 +442,6 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
 	struct bat_priv *bat_priv = netdev_priv(soft_device);
 	struct batman_packet *batman_packet;
 	struct batman_if *batman_if;
-	struct net_device_stats *stats;
-	struct rtnl_link_stats64 temp;
 	int ret;
 
 	skb = skb_share_check(skb, GFP_ATOMIC);
@@ -479,12 +477,6 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
 	if (batman_if->if_status != IF_ACTIVE)
 		goto err_free;
 
-	stats = (struct net_device_stats *)dev_get_stats(skb->dev, &temp);
-	if (stats) {
-		stats->rx_packets++;
-		stats->rx_bytes += skb->len;
-	}
-
 	batman_packet = (struct batman_packet *)skb->data;
 
 	if (batman_packet->version != COMPAT_VERSION) {
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [B.A.T.M.A.N.] [PATCH 2/5] Staging: batman-adv: unify orig_hash_lock spinlock handling to avoid deadlocks
  2010-08-09 21:56 [B.A.T.M.A.N.] Staging: batman-adv for 2.6.36 (6: fixes) Sven Eckelmann
  2010-08-09 21:56 ` [B.A.T.M.A.N.] [PATCH 1/5] Staging: batman-adv: Fix merge of linus tree Sven Eckelmann
@ 2010-08-09 21:56 ` Sven Eckelmann
  2010-08-09 21:56 ` [B.A.T.M.A.N.] [PATCH 3/5] Staging: batman-adv: fix batman icmp originating from secondary interface Sven Eckelmann
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Sven Eckelmann @ 2010-08-09 21:56 UTC (permalink / raw)
  To: greg; +Cc: Marek Lindner, b.a.t.m.a.n, stable

From: Marek Lindner <lindner_marek@yahoo.de>

The orig_hash_lock spinlock always has to be locked with IRQs being
disabled to avoid deadlocks between code that is being executed in
IRQ context and code that is being executed in non-IRQ context.

Reported-by: Sven Eckelmann <sven.eckelmann@gmx.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
Cc: stable <stable@kernel.org>
---
 drivers/staging/batman-adv/originator.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/batman-adv/originator.c b/drivers/staging/batman-adv/originator.c
index 28bb627..de5a8c1 100644
--- a/drivers/staging/batman-adv/originator.c
+++ b/drivers/staging/batman-adv/originator.c
@@ -391,11 +391,12 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)
 int orig_hash_add_if(struct batman_if *batman_if, int max_if_num)
 {
 	struct orig_node *orig_node;
+	unsigned long flags;
 	HASHIT(hashit);
 
 	/* resize all orig nodes because orig_node->bcast_own(_sum) depend on
 	 * if_num */
-	spin_lock(&orig_hash_lock);
+	spin_lock_irqsave(&orig_hash_lock, flags);
 
 	while (hash_iterate(orig_hash, &hashit)) {
 		orig_node = hashit.bucket->data;
@@ -404,11 +405,11 @@ int orig_hash_add_if(struct batman_if *batman_if, int max_if_num)
 			goto err;
 	}
 
-	spin_unlock(&orig_hash_lock);
+	spin_unlock_irqrestore(&orig_hash_lock, flags);
 	return 0;
 
 err:
-	spin_unlock(&orig_hash_lock);
+	spin_unlock_irqrestore(&orig_hash_lock, flags);
 	return -ENOMEM;
 }
 
@@ -468,12 +469,13 @@ int orig_hash_del_if(struct batman_if *batman_if, int max_if_num)
 {
 	struct batman_if *batman_if_tmp;
 	struct orig_node *orig_node;
+	unsigned long flags;
 	HASHIT(hashit);
 	int ret;
 
 	/* resize all orig nodes because orig_node->bcast_own(_sum) depend on
 	 * if_num */
-	spin_lock(&orig_hash_lock);
+	spin_lock_irqsave(&orig_hash_lock, flags);
 
 	while (hash_iterate(orig_hash, &hashit)) {
 		orig_node = hashit.bucket->data;
@@ -500,10 +502,10 @@ int orig_hash_del_if(struct batman_if *batman_if, int max_if_num)
 	rcu_read_unlock();
 
 	batman_if->if_num = -1;
-	spin_unlock(&orig_hash_lock);
+	spin_unlock_irqrestore(&orig_hash_lock, flags);
 	return 0;
 
 err:
-	spin_unlock(&orig_hash_lock);
+	spin_unlock_irqrestore(&orig_hash_lock, flags);
 	return -ENOMEM;
 }
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [B.A.T.M.A.N.] [PATCH 3/5] Staging: batman-adv: fix batman icmp originating from secondary interface
  2010-08-09 21:56 [B.A.T.M.A.N.] Staging: batman-adv for 2.6.36 (6: fixes) Sven Eckelmann
  2010-08-09 21:56 ` [B.A.T.M.A.N.] [PATCH 1/5] Staging: batman-adv: Fix merge of linus tree Sven Eckelmann
  2010-08-09 21:56 ` [B.A.T.M.A.N.] [PATCH 2/5] Staging: batman-adv: unify orig_hash_lock spinlock handling to avoid deadlocks Sven Eckelmann
@ 2010-08-09 21:56 ` Sven Eckelmann
  2010-08-09 21:56 ` [B.A.T.M.A.N.] [PATCH 4/5] Staging: batman-adv: always reply batman icmp packets with primary mac Sven Eckelmann
  2010-08-09 21:56 ` [B.A.T.M.A.N.] [PATCH 5/5] Staging: batman-adv: fix own mac address detection Sven Eckelmann
  4 siblings, 0 replies; 6+ messages in thread
From: Sven Eckelmann @ 2010-08-09 21:56 UTC (permalink / raw)
  To: greg; +Cc: Marek Lindner, b.a.t.m.a.n

From: Marek Lindner <lindner_marek@yahoo.de>

If a batman icmp packet had to be routed over a secondary interface
at the first hop, the mac address of that secondary interface would
be written in the 'orig' field of the icmp packet. A node which is
more than one hop away is not aware of the mac address because
secondary interfaces are not flooded through the whole mesh and
therefore can't send a reply.
This patch always sends the mac address of the primary interface
in the 'orig' field of the icmp packet.

Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 drivers/staging/batman-adv/icmp_socket.c |   12 ++++++++----
 drivers/staging/batman-adv/types.h       |    1 +
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/batman-adv/icmp_socket.c b/drivers/staging/batman-adv/icmp_socket.c
index fc3d32c..3ae7dd2 100644
--- a/drivers/staging/batman-adv/icmp_socket.c
+++ b/drivers/staging/batman-adv/icmp_socket.c
@@ -67,6 +67,7 @@ static int bat_socket_open(struct inode *inode, struct file *file)
 	INIT_LIST_HEAD(&socket_client->queue_list);
 	socket_client->queue_len = 0;
 	socket_client->index = i;
+	socket_client->bat_priv = inode->i_private;
 	spin_lock_init(&socket_client->lock);
 	init_waitqueue_head(&socket_client->queue_wait);
 
@@ -151,9 +152,8 @@ static ssize_t bat_socket_read(struct file *file, char __user *buf,
 static ssize_t bat_socket_write(struct file *file, const char __user *buff,
 				size_t len, loff_t *off)
 {
-	/* FIXME: each orig_node->batman_if will be attached to a softif */
-	struct bat_priv *bat_priv = netdev_priv(soft_device);
 	struct socket_client *socket_client = file->private_data;
+	struct bat_priv *bat_priv = socket_client->bat_priv;
 	struct icmp_packet_rr icmp_packet;
 	struct orig_node *orig_node;
 	struct batman_if *batman_if;
@@ -168,6 +168,9 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
 		return -EINVAL;
 	}
 
+	if (!bat_priv->primary_if)
+		return -EFAULT;
+
 	if (len >= sizeof(struct icmp_packet_rr))
 		packet_len = sizeof(struct icmp_packet_rr);
 
@@ -223,7 +226,8 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
 	if (batman_if->if_status != IF_ACTIVE)
 		goto dst_unreach;
 
-	memcpy(icmp_packet.orig, batman_if->net_dev->dev_addr, ETH_ALEN);
+	memcpy(icmp_packet.orig,
+	       bat_priv->primary_if->net_dev->dev_addr, ETH_ALEN);
 
 	if (packet_len == sizeof(struct icmp_packet_rr))
 		memcpy(icmp_packet.rr, batman_if->net_dev->dev_addr, ETH_ALEN);
@@ -271,7 +275,7 @@ int bat_socket_setup(struct bat_priv *bat_priv)
 		goto err;
 
 	d = debugfs_create_file(ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR,
-				bat_priv->debug_dir, NULL, &fops);
+				bat_priv->debug_dir, bat_priv, &fops);
 	if (d)
 		goto err;
 
diff --git a/drivers/staging/batman-adv/types.h b/drivers/staging/batman-adv/types.h
index 21d0717..9aa9d36 100644
--- a/drivers/staging/batman-adv/types.h
+++ b/drivers/staging/batman-adv/types.h
@@ -126,6 +126,7 @@ struct socket_client {
 	unsigned char index;
 	spinlock_t lock;
 	wait_queue_head_t queue_wait;
+	struct bat_priv *bat_priv;
 };
 
 struct socket_packet {
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [B.A.T.M.A.N.] [PATCH 4/5] Staging: batman-adv: always reply batman icmp packets with primary mac
  2010-08-09 21:56 [B.A.T.M.A.N.] Staging: batman-adv for 2.6.36 (6: fixes) Sven Eckelmann
                   ` (2 preceding siblings ...)
  2010-08-09 21:56 ` [B.A.T.M.A.N.] [PATCH 3/5] Staging: batman-adv: fix batman icmp originating from secondary interface Sven Eckelmann
@ 2010-08-09 21:56 ` Sven Eckelmann
  2010-08-09 21:56 ` [B.A.T.M.A.N.] [PATCH 5/5] Staging: batman-adv: fix own mac address detection Sven Eckelmann
  4 siblings, 0 replies; 6+ messages in thread
From: Sven Eckelmann @ 2010-08-09 21:56 UTC (permalink / raw)
  To: greg; +Cc: Marek Lindner, b.a.t.m.a.n

From: Marek Lindner <lindner_marek@yahoo.de>

When receiving an batman icmp echo request or in case of a time-to-live
exceeded batman would reply with the mac address of the outgoing
interface which might be a secondary interface. Because secondary
interfaces are not globally known this might lead to confusion.
Now, replies are sent with the mac address of the primary interface.

Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 drivers/staging/batman-adv/routing.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/batman-adv/routing.c b/drivers/staging/batman-adv/routing.c
index 066cc91..032195e 100644
--- a/drivers/staging/batman-adv/routing.c
+++ b/drivers/staging/batman-adv/routing.c
@@ -783,6 +783,8 @@ int recv_bat_packet(struct sk_buff *skb,
 
 static int recv_my_icmp_packet(struct sk_buff *skb, size_t icmp_len)
 {
+	/* FIXME: each batman_if will be attached to a softif */
+	struct bat_priv *bat_priv = netdev_priv(soft_device);
 	struct orig_node *orig_node;
 	struct icmp_packet_rr *icmp_packet;
 	struct ethhdr *ethhdr;
@@ -801,6 +803,9 @@ static int recv_my_icmp_packet(struct sk_buff *skb, size_t icmp_len)
 		return NET_RX_DROP;
 	}
 
+	if (!bat_priv->primary_if)
+		return NET_RX_DROP;
+
 	/* answer echo request (ping) */
 	/* get routing information */
 	spin_lock_irqsave(&orig_hash_lock, flags);
@@ -830,7 +835,8 @@ static int recv_my_icmp_packet(struct sk_buff *skb, size_t icmp_len)
 		}
 
 		memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
-		memcpy(icmp_packet->orig, ethhdr->h_dest, ETH_ALEN);
+		memcpy(icmp_packet->orig,
+		       bat_priv->primary_if->net_dev->dev_addr, ETH_ALEN);
 		icmp_packet->msg_type = ECHO_REPLY;
 		icmp_packet->ttl = TTL;
 
@@ -845,6 +851,8 @@ static int recv_my_icmp_packet(struct sk_buff *skb, size_t icmp_len)
 
 static int recv_icmp_ttl_exceeded(struct sk_buff *skb, size_t icmp_len)
 {
+	/* FIXME: each batman_if will be attached to a softif */
+	struct bat_priv *bat_priv = netdev_priv(soft_device);
 	struct orig_node *orig_node;
 	struct icmp_packet *icmp_packet;
 	struct ethhdr *ethhdr;
@@ -865,6 +873,9 @@ static int recv_icmp_ttl_exceeded(struct sk_buff *skb, size_t icmp_len)
 		return NET_RX_DROP;
 	}
 
+	if (!bat_priv->primary_if)
+		return NET_RX_DROP;
+
 	/* get routing information */
 	spin_lock_irqsave(&orig_hash_lock, flags);
 	orig_node = ((struct orig_node *)
@@ -892,7 +903,8 @@ static int recv_icmp_ttl_exceeded(struct sk_buff *skb, size_t icmp_len)
 		}
 
 		memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
-		memcpy(icmp_packet->orig, ethhdr->h_dest, ETH_ALEN);
+		memcpy(icmp_packet->orig,
+		       bat_priv->primary_if->net_dev->dev_addr, ETH_ALEN);
 		icmp_packet->msg_type = TTL_EXCEEDED;
 		icmp_packet->ttl = TTL;
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [B.A.T.M.A.N.] [PATCH 5/5] Staging: batman-adv: fix own mac address detection
  2010-08-09 21:56 [B.A.T.M.A.N.] Staging: batman-adv for 2.6.36 (6: fixes) Sven Eckelmann
                   ` (3 preceding siblings ...)
  2010-08-09 21:56 ` [B.A.T.M.A.N.] [PATCH 4/5] Staging: batman-adv: always reply batman icmp packets with primary mac Sven Eckelmann
@ 2010-08-09 21:56 ` Sven Eckelmann
  4 siblings, 0 replies; 6+ messages in thread
From: Sven Eckelmann @ 2010-08-09 21:56 UTC (permalink / raw)
  To: greg; +Cc: Marek Lindner, b.a.t.m.a.n

From: Marek Lindner <lindner_marek@yahoo.de>

Earlier batman-adv versions would only create a batman_if struct after
a corresponding interface had been activated by a user. Now each
existing system interface has a batman_if struct and has to be checked
by verifying the IF_ACTIVE flag.

Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 drivers/staging/batman-adv/main.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/batman-adv/main.c b/drivers/staging/batman-adv/main.c
index 2686019..ef7c20a 100644
--- a/drivers/staging/batman-adv/main.c
+++ b/drivers/staging/batman-adv/main.c
@@ -250,10 +250,13 @@ int choose_orig(void *data, int32_t size)
 int is_my_mac(uint8_t *addr)
 {
 	struct batman_if *batman_if;
+
 	rcu_read_lock();
 	list_for_each_entry_rcu(batman_if, &if_list, list) {
-		if ((batman_if->net_dev) &&
-		    (compare_orig(batman_if->net_dev->dev_addr, addr))) {
+		if (batman_if->if_status != IF_ACTIVE)
+			continue;
+
+		if (compare_orig(batman_if->net_dev->dev_addr, addr)) {
 			rcu_read_unlock();
 			return 1;
 		}
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-08-09 21:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-09 21:56 [B.A.T.M.A.N.] Staging: batman-adv for 2.6.36 (6: fixes) Sven Eckelmann
2010-08-09 21:56 ` [B.A.T.M.A.N.] [PATCH 1/5] Staging: batman-adv: Fix merge of linus tree Sven Eckelmann
2010-08-09 21:56 ` [B.A.T.M.A.N.] [PATCH 2/5] Staging: batman-adv: unify orig_hash_lock spinlock handling to avoid deadlocks Sven Eckelmann
2010-08-09 21:56 ` [B.A.T.M.A.N.] [PATCH 3/5] Staging: batman-adv: fix batman icmp originating from secondary interface Sven Eckelmann
2010-08-09 21:56 ` [B.A.T.M.A.N.] [PATCH 4/5] Staging: batman-adv: always reply batman icmp packets with primary mac Sven Eckelmann
2010-08-09 21:56 ` [B.A.T.M.A.N.] [PATCH 5/5] Staging: batman-adv: fix own mac address detection Sven Eckelmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).