diff options
author | Simon Wunderlich <siwu@hrz.tu-chemnitz.de> | 2010-02-19 16:18:05 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-03 16:43:02 -0800 |
commit | eb50081d8fb76d5de9d65628d7f41977ece7044b (patch) | |
tree | 027e1ac8c400ad402a871e68df7ab00e04a292d4 /drivers/staging/batman-adv | |
parent | 0fce64362d4f2144586e3ffcff6f259bf8abc2f8 (diff) | |
download | op-kernel-dev-eb50081d8fb76d5de9d65628d7f41977ece7044b.zip op-kernel-dev-eb50081d8fb76d5de9d65628d7f41977ece7044b.tar.gz |
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.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/staging/batman-adv/device.c b/drivers/staging/batman-adv/device.c index a3e7429..451898c 100644 --- a/drivers/staging/batman-adv/device.c +++ b/drivers/staging/batman-adv/device.c @@ -25,6 +25,7 @@ #include "send.h" #include "types.h" #include "hash.h" +#include "hard-interface.h" static struct class *batman_class; @@ -206,6 +207,7 @@ ssize_t bat_device_write(struct file *file, const char __user *buff, struct icmp_packet icmp_packet; struct orig_node *orig_node; struct batman_if *batman_if; + uint8_t dstaddr[ETH_ALEN]; unsigned long flags; if (len < sizeof(struct icmp_packet)) { @@ -251,9 +253,15 @@ ssize_t bat_device_write(struct file *file, const char __user *buff, goto unlock; batman_if = orig_node->batman_if; + memcpy(dstaddr, orig_node->router->addr, ETH_ALEN); + + spin_unlock_irqrestore(&orig_hash_lock, flags); if (!batman_if) - goto unlock; + goto dst_unreach; + + if (batman_if->if_active != IF_ACTIVE) + goto dst_unreach; memcpy(icmp_packet.orig, batman_if->net_dev->dev_addr, @@ -261,9 +269,8 @@ ssize_t bat_device_write(struct file *file, const char __user *buff, send_raw_packet((unsigned char *)&icmp_packet, sizeof(struct icmp_packet), - batman_if, orig_node->router->addr); + batman_if, dstaddr); - spin_unlock_irqrestore(&orig_hash_lock, flags); goto out; unlock: |