aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/batman-adv
diff options
context:
space:
mode:
authorSimon Wunderlich <siwu@hrz.tu-chemnitz.de>2010-02-19 10:18:05 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-03 19:43:02 -0500
commiteb50081d8fb76d5de9d65628d7f41977ece7044b (patch)
tree027e1ac8c400ad402a871e68df7ab00e04a292d4 /drivers/staging/batman-adv
parent0fce64362d4f2144586e3ffcff6f259bf8abc2f8 (diff)
Staging: batman-adv: don't lock while sending packets
As in other parts of batman-adv, we should not lock while sending a packet but keep the lock held for as short as possible. Additionally, we should check whether the interface is active, otherwise batman_if->net_dev might not be available ... Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de> Acked-by: Marek Lindner <lindner_marek@yahoo.de> Signed-off-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/batman-adv')
-rw-r--r--drivers/staging/batman-adv/device.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/staging/batman-adv/device.c b/drivers/staging/batman-adv/device.c
index a3e74296abf..451898cd9ec 100644
--- a/drivers/staging/batman-adv/device.c
+++ b/drivers/staging/batman-adv/device.c
@@ -25,6 +25,7 @@
25#include "send.h" 25#include "send.h"
26#include "types.h" 26#include "types.h"
27#include "hash.h" 27#include "hash.h"
28#include "hard-interface.h"
28 29
29static struct class *batman_class; 30static struct class *batman_class;
30 31
@@ -206,6 +207,7 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
206 struct icmp_packet icmp_packet; 207 struct icmp_packet icmp_packet;
207 struct orig_node *orig_node; 208 struct orig_node *orig_node;
208 struct batman_if *batman_if; 209 struct batman_if *batman_if;
210 uint8_t dstaddr[ETH_ALEN];
209 unsigned long flags; 211 unsigned long flags;
210 212
211 if (len < sizeof(struct icmp_packet)) { 213 if (len < sizeof(struct icmp_packet)) {
@@ -251,9 +253,15 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
251 goto unlock; 253 goto unlock;
252 254
253 batman_if = orig_node->batman_if; 255 batman_if = orig_node->batman_if;
256 memcpy(dstaddr, orig_node->router->addr, ETH_ALEN);
257
258 spin_unlock_irqrestore(&orig_hash_lock, flags);
254 259
255 if (!batman_if) 260 if (!batman_if)
256 goto unlock; 261 goto dst_unreach;
262
263 if (batman_if->if_active != IF_ACTIVE)
264 goto dst_unreach;
257 265
258 memcpy(icmp_packet.orig, 266 memcpy(icmp_packet.orig,
259 batman_if->net_dev->dev_addr, 267 batman_if->net_dev->dev_addr,
@@ -261,9 +269,8 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
261 269
262 send_raw_packet((unsigned char *)&icmp_packet, 270 send_raw_packet((unsigned char *)&icmp_packet,
263 sizeof(struct icmp_packet), 271 sizeof(struct icmp_packet),
264 batman_if, orig_node->router->addr); 272 batman_if, dstaddr);
265 273
266 spin_unlock_irqrestore(&orig_hash_lock, flags);
267 goto out; 274 goto out;
268 275
269unlock: 276unlock: