Commit eb50081d authored by Simon Wunderlich's avatar Simon Wunderlich Committed by Greg Kroah-Hartman

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: default avatarSimon Wunderlich <siwu@hrz.tu-chemnitz.de>
Acked-by: default avatarMarek Lindner <lindner_marek@yahoo.de>
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 0fce6436
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "send.h" #include "send.h"
#include "types.h" #include "types.h"
#include "hash.h" #include "hash.h"
#include "hard-interface.h"
static struct class *batman_class; static struct class *batman_class;
...@@ -206,6 +207,7 @@ ssize_t bat_device_write(struct file *file, const char __user *buff, ...@@ -206,6 +207,7 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
struct icmp_packet icmp_packet; struct icmp_packet icmp_packet;
struct orig_node *orig_node; struct orig_node *orig_node;
struct batman_if *batman_if; struct batman_if *batman_if;
uint8_t dstaddr[ETH_ALEN];
unsigned long flags; unsigned long flags;
if (len < sizeof(struct icmp_packet)) { if (len < sizeof(struct icmp_packet)) {
...@@ -251,9 +253,15 @@ ssize_t bat_device_write(struct file *file, const char __user *buff, ...@@ -251,9 +253,15 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
goto unlock; goto unlock;
batman_if = orig_node->batman_if; batman_if = orig_node->batman_if;
memcpy(dstaddr, orig_node->router->addr, ETH_ALEN);
spin_unlock_irqrestore(&orig_hash_lock, flags);
if (!batman_if) if (!batman_if)
goto unlock; goto dst_unreach;
if (batman_if->if_active != IF_ACTIVE)
goto dst_unreach;
memcpy(icmp_packet.orig, memcpy(icmp_packet.orig,
batman_if->net_dev->dev_addr, batman_if->net_dev->dev_addr,
...@@ -261,9 +269,8 @@ ssize_t bat_device_write(struct file *file, const char __user *buff, ...@@ -261,9 +269,8 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
send_raw_packet((unsigned char *)&icmp_packet, send_raw_packet((unsigned char *)&icmp_packet,
sizeof(struct icmp_packet), sizeof(struct icmp_packet),
batman_if, orig_node->router->addr); batman_if, dstaddr);
spin_unlock_irqrestore(&orig_hash_lock, flags);
goto out; goto out;
unlock: unlock:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment