Author: marek Date: 2010-05-21 06:17:51 +0200 (Fri, 21 May 2010) New Revision: 1660
Modified: trunk/batman-adv-kernelland/send.c Log: batman-adv: fix rogue packets on shutdown
On module shutdown batman-adv would purge the internal packet queue by sending all remaining packets which could confuse other nodes. Now, the packets are silently discarded.
Signed-off-by: Marek Lindner lindner_marek@yahoo.de
Modified: trunk/batman-adv-kernelland/send.c =================================================================== --- trunk/batman-adv-kernelland/send.c 2010-05-17 08:32:46 UTC (rev 1659) +++ trunk/batman-adv-kernelland/send.c 2010-05-21 04:17:51 UTC (rev 1660) @@ -460,6 +460,9 @@ hlist_del(&forw_packet->list); spin_unlock_irqrestore(&forw_bcast_list_lock, flags);
+ if (atomic_read(&module_state) == MODULE_DEACTIVATING) + goto out; + /* rebroadcast packet */ rcu_read_lock(); list_for_each_entry_rcu(batman_if, &if_list, list) { @@ -473,15 +476,15 @@
forw_packet->num_packets++;
- /* if we still have some more bcasts to send and we are not shutting - * down */ - if ((forw_packet->num_packets < 3) && - (atomic_read(&module_state) != MODULE_DEACTIVATING)) + /* if we still have some more bcasts to send */ + if (forw_packet->num_packets < 3) { _add_bcast_packet_to_list(forw_packet, ((5 * HZ) / 1000)); - else { - forw_packet_free(forw_packet); - atomic_inc(&bat_priv->bcast_queue_left); + return; } + +out: + forw_packet_free(forw_packet); + atomic_inc(&bat_priv->bcast_queue_left); }
void send_outstanding_bat_packet(struct work_struct *work) @@ -498,6 +501,9 @@ hlist_del(&forw_packet->list); spin_unlock_irqrestore(&forw_bat_list_lock, flags);
+ if (atomic_read(&module_state) == MODULE_DEACTIVATING) + goto out; + send_packet(forw_packet);
/** @@ -505,10 +511,10 @@ * to determine the queues wake up time unless we are * shutting down */ - if ((forw_packet->own) && - (atomic_read(&module_state) != MODULE_DEACTIVATING)) + if (forw_packet->own) schedule_own_packet(forw_packet->if_incoming);
+out: /* don't count own packet */ if (!forw_packet->own) atomic_inc(&bat_priv->batman_queue_left);