Author: marek Date: 2010-01-09 15:44:04 +0100 (Sat, 09 Jan 2010) New Revision: 1543
Modified: trunk/batman-adv-kernelland/device.c Log: 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 locked time 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
Modified: trunk/batman-adv-kernelland/device.c =================================================================== --- trunk/batman-adv-kernelland/device.c 2010-01-09 14:44:01 UTC (rev 1542) +++ trunk/batman-adv-kernelland/device.c 2010-01-09 14:44:04 UTC (rev 1543) @@ -25,6 +25,7 @@ #include "send.h" #include "types.h" #include "hash.h" +#include "hard-interface.h"
#include "compat.h"
@@ -208,6 +209,7 @@ 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)) { @@ -253,19 +255,24 @@ 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, ETH_ALEN);
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: