Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 1 | /* |
Sven Eckelmann | 567db7b | 2012-01-01 00:41:38 +0100 | [diff] [blame] | 2 | * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 3 | * |
| 4 | * Marek Lindner, Simon Wunderlich |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of version 2 of the GNU General Public |
| 8 | * License as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 18 | * 02110-1301, USA |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #include "main.h" |
| 23 | #include "send.h" |
| 24 | #include "routing.h" |
| 25 | #include "translation-table.h" |
| 26 | #include "soft-interface.h" |
| 27 | #include "hard-interface.h" |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 28 | #include "vis.h" |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 29 | #include "gateway_common.h" |
| 30 | #include "originator.h" |
| 31 | |
| 32 | static void send_outstanding_bcast_packet(struct work_struct *work); |
| 33 | |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 34 | /* send out an already prepared packet to the given address via the |
| 35 | * specified batman interface */ |
Sven Eckelmann | 9455e34 | 2012-05-12 02:09:37 +0200 | [diff] [blame] | 36 | int batadv_send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface, |
| 37 | const uint8_t *dst_addr) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 38 | { |
| 39 | struct ethhdr *ethhdr; |
| 40 | |
Marek Lindner | e6c10f4 | 2011-02-18 12:33:20 +0000 | [diff] [blame] | 41 | if (hard_iface->if_status != IF_ACTIVE) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 42 | goto send_skb_err; |
| 43 | |
Marek Lindner | e6c10f4 | 2011-02-18 12:33:20 +0000 | [diff] [blame] | 44 | if (unlikely(!hard_iface->net_dev)) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 45 | goto send_skb_err; |
| 46 | |
Marek Lindner | e6c10f4 | 2011-02-18 12:33:20 +0000 | [diff] [blame] | 47 | if (!(hard_iface->net_dev->flags & IFF_UP)) { |
Sven Eckelmann | 6796958 | 2012-03-26 16:22:45 +0200 | [diff] [blame] | 48 | pr_warn("Interface %s is not up - can't send packet via that interface!\n", |
| 49 | hard_iface->net_dev->name); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 50 | goto send_skb_err; |
| 51 | } |
| 52 | |
| 53 | /* push to the ethernet header. */ |
Sven Eckelmann | 04b482a | 2012-05-12 02:09:38 +0200 | [diff] [blame] | 54 | if (batadv_skb_head_push(skb, ETH_HLEN) < 0) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 55 | goto send_skb_err; |
| 56 | |
| 57 | skb_reset_mac_header(skb); |
| 58 | |
Sven Eckelmann | 40e0c4f | 2012-03-07 09:07:48 +0100 | [diff] [blame] | 59 | ethhdr = (struct ethhdr *)skb_mac_header(skb); |
Marek Lindner | e6c10f4 | 2011-02-18 12:33:20 +0000 | [diff] [blame] | 60 | memcpy(ethhdr->h_source, hard_iface->net_dev->dev_addr, ETH_ALEN); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 61 | memcpy(ethhdr->h_dest, dst_addr, ETH_ALEN); |
| 62 | ethhdr->h_proto = __constant_htons(ETH_P_BATMAN); |
| 63 | |
| 64 | skb_set_network_header(skb, ETH_HLEN); |
| 65 | skb->priority = TC_PRIO_CONTROL; |
| 66 | skb->protocol = __constant_htons(ETH_P_BATMAN); |
| 67 | |
Marek Lindner | e6c10f4 | 2011-02-18 12:33:20 +0000 | [diff] [blame] | 68 | skb->dev = hard_iface->net_dev; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 69 | |
| 70 | /* dev_queue_xmit() returns a negative result on error. However on |
| 71 | * congestion and traffic shaping, it drops and returns NET_XMIT_DROP |
| 72 | * (which is > 0). This will not be treated as an error. */ |
| 73 | |
| 74 | return dev_queue_xmit(skb); |
| 75 | send_skb_err: |
| 76 | kfree_skb(skb); |
| 77 | return NET_XMIT_DROP; |
| 78 | } |
| 79 | |
Sven Eckelmann | 9455e34 | 2012-05-12 02:09:37 +0200 | [diff] [blame] | 80 | void batadv_schedule_bat_ogm(struct hard_iface *hard_iface) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 81 | { |
Marek Lindner | e6c10f4 | 2011-02-18 12:33:20 +0000 | [diff] [blame] | 82 | struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 83 | |
Marek Lindner | e6c10f4 | 2011-02-18 12:33:20 +0000 | [diff] [blame] | 84 | if ((hard_iface->if_status == IF_NOT_IN_USE) || |
| 85 | (hard_iface->if_status == IF_TO_BE_REMOVED)) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 86 | return; |
| 87 | |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 88 | /** |
| 89 | * the interface gets activated here to avoid race conditions between |
| 90 | * the moment of activating the interface in |
| 91 | * hardif_activate_interface() where the originator mac is set and |
| 92 | * outdated packets (especially uninitialized mac addresses) in the |
| 93 | * packet queue |
| 94 | */ |
Marek Lindner | e6c10f4 | 2011-02-18 12:33:20 +0000 | [diff] [blame] | 95 | if (hard_iface->if_status == IF_TO_BE_ACTIVATED) |
| 96 | hard_iface->if_status = IF_ACTIVE; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 97 | |
Marek Lindner | be9aa4c | 2012-05-07 04:22:05 +0800 | [diff] [blame] | 98 | bat_priv->bat_algo_ops->bat_ogm_schedule(hard_iface); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | static void forw_packet_free(struct forw_packet *forw_packet) |
| 102 | { |
| 103 | if (forw_packet->skb) |
| 104 | kfree_skb(forw_packet->skb); |
Sven Eckelmann | 6d5808d | 2011-05-11 20:59:06 +0200 | [diff] [blame] | 105 | if (forw_packet->if_incoming) |
| 106 | hardif_free_ref(forw_packet->if_incoming); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 107 | kfree(forw_packet); |
| 108 | } |
| 109 | |
| 110 | static void _add_bcast_packet_to_list(struct bat_priv *bat_priv, |
| 111 | struct forw_packet *forw_packet, |
| 112 | unsigned long send_time) |
| 113 | { |
| 114 | INIT_HLIST_NODE(&forw_packet->list); |
| 115 | |
| 116 | /* add new packet to packet list */ |
| 117 | spin_lock_bh(&bat_priv->forw_bcast_list_lock); |
| 118 | hlist_add_head(&forw_packet->list, &bat_priv->forw_bcast_list); |
| 119 | spin_unlock_bh(&bat_priv->forw_bcast_list_lock); |
| 120 | |
| 121 | /* start timer for this packet */ |
| 122 | INIT_DELAYED_WORK(&forw_packet->delayed_work, |
| 123 | send_outstanding_bcast_packet); |
Sven Eckelmann | 3193e8f | 2012-05-12 02:09:42 +0200 | [diff] [blame^] | 124 | queue_delayed_work(batadv_event_workqueue, &forw_packet->delayed_work, |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 125 | send_time); |
| 126 | } |
| 127 | |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 128 | /* add a broadcast packet to the queue and setup timers. broadcast packets |
Antonio Quartulli | 015758d | 2011-07-09 17:52:13 +0200 | [diff] [blame] | 129 | * are sent multiple times to increase probability for being received. |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 130 | * |
| 131 | * This function returns NETDEV_TX_OK on success and NETDEV_TX_BUSY on |
| 132 | * errors. |
| 133 | * |
| 134 | * The skb is not consumed, so the caller should make sure that the |
| 135 | * skb is freed. */ |
Sven Eckelmann | 9455e34 | 2012-05-12 02:09:37 +0200 | [diff] [blame] | 136 | int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv, |
| 137 | const struct sk_buff *skb, |
| 138 | unsigned long delay) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 139 | { |
Marek Lindner | 32ae9b2 | 2011-04-20 15:40:58 +0200 | [diff] [blame] | 140 | struct hard_iface *primary_if = NULL; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 141 | struct forw_packet *forw_packet; |
| 142 | struct bcast_packet *bcast_packet; |
Sven Eckelmann | 747e422 | 2011-05-14 23:14:50 +0200 | [diff] [blame] | 143 | struct sk_buff *newskb; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 144 | |
| 145 | if (!atomic_dec_not_zero(&bat_priv->bcast_queue_left)) { |
| 146 | bat_dbg(DBG_BATMAN, bat_priv, "bcast packet queue full\n"); |
| 147 | goto out; |
| 148 | } |
| 149 | |
Marek Lindner | 32ae9b2 | 2011-04-20 15:40:58 +0200 | [diff] [blame] | 150 | primary_if = primary_if_get_selected(bat_priv); |
| 151 | if (!primary_if) |
Marek Lindner | ca06c6e | 2011-05-14 20:01:22 +0200 | [diff] [blame] | 152 | goto out_and_inc; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 153 | |
Sven Eckelmann | 704509b | 2011-05-14 23:14:54 +0200 | [diff] [blame] | 154 | forw_packet = kmalloc(sizeof(*forw_packet), GFP_ATOMIC); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 155 | |
| 156 | if (!forw_packet) |
| 157 | goto out_and_inc; |
| 158 | |
Sven Eckelmann | 747e422 | 2011-05-14 23:14:50 +0200 | [diff] [blame] | 159 | newskb = skb_copy(skb, GFP_ATOMIC); |
| 160 | if (!newskb) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 161 | goto packet_free; |
| 162 | |
| 163 | /* as we have a copy now, it is safe to decrease the TTL */ |
Sven Eckelmann | 747e422 | 2011-05-14 23:14:50 +0200 | [diff] [blame] | 164 | bcast_packet = (struct bcast_packet *)newskb->data; |
Sven Eckelmann | 76543d1 | 2011-11-20 15:47:38 +0100 | [diff] [blame] | 165 | bcast_packet->header.ttl--; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 166 | |
Sven Eckelmann | 747e422 | 2011-05-14 23:14:50 +0200 | [diff] [blame] | 167 | skb_reset_mac_header(newskb); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 168 | |
Sven Eckelmann | 747e422 | 2011-05-14 23:14:50 +0200 | [diff] [blame] | 169 | forw_packet->skb = newskb; |
Marek Lindner | 32ae9b2 | 2011-04-20 15:40:58 +0200 | [diff] [blame] | 170 | forw_packet->if_incoming = primary_if; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 171 | |
| 172 | /* how often did we send the bcast packet ? */ |
| 173 | forw_packet->num_packets = 0; |
| 174 | |
Antonio Quartulli | 8698529 | 2011-06-25 19:09:12 +0200 | [diff] [blame] | 175 | _add_bcast_packet_to_list(bat_priv, forw_packet, delay); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 176 | return NETDEV_TX_OK; |
| 177 | |
| 178 | packet_free: |
| 179 | kfree(forw_packet); |
| 180 | out_and_inc: |
| 181 | atomic_inc(&bat_priv->bcast_queue_left); |
| 182 | out: |
Marek Lindner | 32ae9b2 | 2011-04-20 15:40:58 +0200 | [diff] [blame] | 183 | if (primary_if) |
| 184 | hardif_free_ref(primary_if); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 185 | return NETDEV_TX_BUSY; |
| 186 | } |
| 187 | |
| 188 | static void send_outstanding_bcast_packet(struct work_struct *work) |
| 189 | { |
Marek Lindner | e6c10f4 | 2011-02-18 12:33:20 +0000 | [diff] [blame] | 190 | struct hard_iface *hard_iface; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 191 | struct delayed_work *delayed_work = |
| 192 | container_of(work, struct delayed_work, work); |
| 193 | struct forw_packet *forw_packet = |
| 194 | container_of(delayed_work, struct forw_packet, delayed_work); |
| 195 | struct sk_buff *skb1; |
| 196 | struct net_device *soft_iface = forw_packet->if_incoming->soft_iface; |
| 197 | struct bat_priv *bat_priv = netdev_priv(soft_iface); |
| 198 | |
| 199 | spin_lock_bh(&bat_priv->forw_bcast_list_lock); |
| 200 | hlist_del(&forw_packet->list); |
| 201 | spin_unlock_bh(&bat_priv->forw_bcast_list_lock); |
| 202 | |
| 203 | if (atomic_read(&bat_priv->mesh_state) == MESH_DEACTIVATING) |
| 204 | goto out; |
| 205 | |
| 206 | /* rebroadcast packet */ |
| 207 | rcu_read_lock(); |
Sven Eckelmann | 3193e8f | 2012-05-12 02:09:42 +0200 | [diff] [blame^] | 208 | list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { |
Marek Lindner | e6c10f4 | 2011-02-18 12:33:20 +0000 | [diff] [blame] | 209 | if (hard_iface->soft_iface != soft_iface) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 210 | continue; |
| 211 | |
| 212 | /* send a copy of the saved skb */ |
| 213 | skb1 = skb_clone(forw_packet->skb, GFP_ATOMIC); |
| 214 | if (skb1) |
Sven Eckelmann | 9455e34 | 2012-05-12 02:09:37 +0200 | [diff] [blame] | 215 | batadv_send_skb_packet(skb1, hard_iface, |
Sven Eckelmann | 3193e8f | 2012-05-12 02:09:42 +0200 | [diff] [blame^] | 216 | batadv_broadcast_addr); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 217 | } |
| 218 | rcu_read_unlock(); |
| 219 | |
| 220 | forw_packet->num_packets++; |
| 221 | |
| 222 | /* if we still have some more bcasts to send */ |
| 223 | if (forw_packet->num_packets < 3) { |
| 224 | _add_bcast_packet_to_list(bat_priv, forw_packet, |
Marek Lindner | 0b0094e | 2012-03-01 15:35:20 +0800 | [diff] [blame] | 225 | msecs_to_jiffies(5)); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 226 | return; |
| 227 | } |
| 228 | |
| 229 | out: |
| 230 | forw_packet_free(forw_packet); |
| 231 | atomic_inc(&bat_priv->bcast_queue_left); |
| 232 | } |
| 233 | |
Sven Eckelmann | 9455e34 | 2012-05-12 02:09:37 +0200 | [diff] [blame] | 234 | void batadv_send_outstanding_bat_ogm_packet(struct work_struct *work) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 235 | { |
| 236 | struct delayed_work *delayed_work = |
| 237 | container_of(work, struct delayed_work, work); |
| 238 | struct forw_packet *forw_packet = |
| 239 | container_of(delayed_work, struct forw_packet, delayed_work); |
| 240 | struct bat_priv *bat_priv; |
| 241 | |
| 242 | bat_priv = netdev_priv(forw_packet->if_incoming->soft_iface); |
| 243 | spin_lock_bh(&bat_priv->forw_bat_list_lock); |
| 244 | hlist_del(&forw_packet->list); |
| 245 | spin_unlock_bh(&bat_priv->forw_bat_list_lock); |
| 246 | |
| 247 | if (atomic_read(&bat_priv->mesh_state) == MESH_DEACTIVATING) |
| 248 | goto out; |
| 249 | |
Marek Lindner | 01c4224 | 2011-11-28 21:31:55 +0800 | [diff] [blame] | 250 | bat_priv->bat_algo_ops->bat_ogm_emit(forw_packet); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 251 | |
| 252 | /** |
| 253 | * we have to have at least one packet in the queue |
| 254 | * to determine the queues wake up time unless we are |
| 255 | * shutting down |
| 256 | */ |
| 257 | if (forw_packet->own) |
Sven Eckelmann | 9455e34 | 2012-05-12 02:09:37 +0200 | [diff] [blame] | 258 | batadv_schedule_bat_ogm(forw_packet->if_incoming); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 259 | |
| 260 | out: |
| 261 | /* don't count own packet */ |
| 262 | if (!forw_packet->own) |
| 263 | atomic_inc(&bat_priv->batman_queue_left); |
| 264 | |
| 265 | forw_packet_free(forw_packet); |
| 266 | } |
| 267 | |
Sven Eckelmann | 9455e34 | 2012-05-12 02:09:37 +0200 | [diff] [blame] | 268 | void batadv_purge_outstanding_packets(struct bat_priv *bat_priv, |
| 269 | const struct hard_iface *hard_iface) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 270 | { |
| 271 | struct forw_packet *forw_packet; |
| 272 | struct hlist_node *tmp_node, *safe_tmp_node; |
Sven Eckelmann | 6d5808d | 2011-05-11 20:59:06 +0200 | [diff] [blame] | 273 | bool pending; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 274 | |
Marek Lindner | e6c10f4 | 2011-02-18 12:33:20 +0000 | [diff] [blame] | 275 | if (hard_iface) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 276 | bat_dbg(DBG_BATMAN, bat_priv, |
| 277 | "purge_outstanding_packets(): %s\n", |
Marek Lindner | e6c10f4 | 2011-02-18 12:33:20 +0000 | [diff] [blame] | 278 | hard_iface->net_dev->name); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 279 | else |
| 280 | bat_dbg(DBG_BATMAN, bat_priv, |
| 281 | "purge_outstanding_packets()\n"); |
| 282 | |
| 283 | /* free bcast list */ |
| 284 | spin_lock_bh(&bat_priv->forw_bcast_list_lock); |
| 285 | hlist_for_each_entry_safe(forw_packet, tmp_node, safe_tmp_node, |
| 286 | &bat_priv->forw_bcast_list, list) { |
| 287 | |
| 288 | /** |
Antonio Quartulli | 015758d | 2011-07-09 17:52:13 +0200 | [diff] [blame] | 289 | * if purge_outstanding_packets() was called with an argument |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 290 | * we delete only packets belonging to the given interface |
| 291 | */ |
Marek Lindner | e6c10f4 | 2011-02-18 12:33:20 +0000 | [diff] [blame] | 292 | if ((hard_iface) && |
| 293 | (forw_packet->if_incoming != hard_iface)) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 294 | continue; |
| 295 | |
| 296 | spin_unlock_bh(&bat_priv->forw_bcast_list_lock); |
| 297 | |
| 298 | /** |
| 299 | * send_outstanding_bcast_packet() will lock the list to |
| 300 | * delete the item from the list |
| 301 | */ |
Sven Eckelmann | 6d5808d | 2011-05-11 20:59:06 +0200 | [diff] [blame] | 302 | pending = cancel_delayed_work_sync(&forw_packet->delayed_work); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 303 | spin_lock_bh(&bat_priv->forw_bcast_list_lock); |
Sven Eckelmann | 6d5808d | 2011-05-11 20:59:06 +0200 | [diff] [blame] | 304 | |
| 305 | if (pending) { |
| 306 | hlist_del(&forw_packet->list); |
| 307 | forw_packet_free(forw_packet); |
| 308 | } |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 309 | } |
| 310 | spin_unlock_bh(&bat_priv->forw_bcast_list_lock); |
| 311 | |
| 312 | /* free batman packet list */ |
| 313 | spin_lock_bh(&bat_priv->forw_bat_list_lock); |
| 314 | hlist_for_each_entry_safe(forw_packet, tmp_node, safe_tmp_node, |
| 315 | &bat_priv->forw_bat_list, list) { |
| 316 | |
| 317 | /** |
Antonio Quartulli | 015758d | 2011-07-09 17:52:13 +0200 | [diff] [blame] | 318 | * if purge_outstanding_packets() was called with an argument |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 319 | * we delete only packets belonging to the given interface |
| 320 | */ |
Marek Lindner | e6c10f4 | 2011-02-18 12:33:20 +0000 | [diff] [blame] | 321 | if ((hard_iface) && |
| 322 | (forw_packet->if_incoming != hard_iface)) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 323 | continue; |
| 324 | |
| 325 | spin_unlock_bh(&bat_priv->forw_bat_list_lock); |
| 326 | |
| 327 | /** |
| 328 | * send_outstanding_bat_packet() will lock the list to |
| 329 | * delete the item from the list |
| 330 | */ |
Sven Eckelmann | 6d5808d | 2011-05-11 20:59:06 +0200 | [diff] [blame] | 331 | pending = cancel_delayed_work_sync(&forw_packet->delayed_work); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 332 | spin_lock_bh(&bat_priv->forw_bat_list_lock); |
Sven Eckelmann | 6d5808d | 2011-05-11 20:59:06 +0200 | [diff] [blame] | 333 | |
| 334 | if (pending) { |
| 335 | hlist_del(&forw_packet->list); |
| 336 | forw_packet_free(forw_packet); |
| 337 | } |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 338 | } |
| 339 | spin_unlock_bh(&bat_priv->forw_bat_list_lock); |
| 340 | } |