originator.c (f097e25dbe9144447f46b6b61ca3da1a2ba432d4) originator.c (610bfc6bc99bc83680d190ebc69359a05fc7f605)
1/* Copyright (C) 2009-2013 B.A.T.M.A.N. contributors:
2 *
3 * Marek Lindner, Simon Wunderlich
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public
7 * License as published by the Free Software Foundation.
8 *

--- 14 unchanged lines hidden (view full) ---

23#include "hash.h"
24#include "translation-table.h"
25#include "routing.h"
26#include "gateway_client.h"
27#include "hard-interface.h"
28#include "soft-interface.h"
29#include "bridge_loop_avoidance.h"
30#include "network-coding.h"
1/* Copyright (C) 2009-2013 B.A.T.M.A.N. contributors:
2 *
3 * Marek Lindner, Simon Wunderlich
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public
7 * License as published by the Free Software Foundation.
8 *

--- 14 unchanged lines hidden (view full) ---

23#include "hash.h"
24#include "translation-table.h"
25#include "routing.h"
26#include "gateway_client.h"
27#include "hard-interface.h"
28#include "soft-interface.h"
29#include "bridge_loop_avoidance.h"
30#include "network-coding.h"
31#include "fragmentation.h"
31
32/* hash class keys */
33static struct lock_class_key batadv_orig_hash_lock_class_key;
34
35static void batadv_purge_orig(struct work_struct *work);
36
37/* returns 1 if they are the same originator */
38static int batadv_compare_orig(const struct hlist_node *node, const void *data2)

--- 101 unchanged lines hidden (view full) ---

140 batadv_neigh_node_free_ref(neigh_node);
141 }
142
143 spin_unlock_bh(&orig_node->neigh_list_lock);
144
145 /* Free nc_nodes */
146 batadv_nc_purge_orig(orig_node->bat_priv, orig_node, NULL);
147
32
33/* hash class keys */
34static struct lock_class_key batadv_orig_hash_lock_class_key;
35
36static void batadv_purge_orig(struct work_struct *work);
37
38/* returns 1 if they are the same originator */
39static int batadv_compare_orig(const struct hlist_node *node, const void *data2)

--- 101 unchanged lines hidden (view full) ---

141 batadv_neigh_node_free_ref(neigh_node);
142 }
143
144 spin_unlock_bh(&orig_node->neigh_list_lock);
145
146 /* Free nc_nodes */
147 batadv_nc_purge_orig(orig_node->bat_priv, orig_node, NULL);
148
149 batadv_frag_purge_orig(orig_node, NULL);
150
148 batadv_tt_global_del_orig(orig_node->bat_priv, orig_node,
149 "originator timed out");
150
151 kfree(orig_node->tt_buff);
152 kfree(orig_node->bcast_own);
153 kfree(orig_node->bcast_own_sum);
154 kfree(orig_node);
155}

--- 54 unchanged lines hidden (view full) ---

210
211/* this function finds or creates an originator entry for the given
212 * address if it does not exits
213 */
214struct batadv_orig_node *batadv_get_orig_node(struct batadv_priv *bat_priv,
215 const uint8_t *addr)
216{
217 struct batadv_orig_node *orig_node;
151 batadv_tt_global_del_orig(orig_node->bat_priv, orig_node,
152 "originator timed out");
153
154 kfree(orig_node->tt_buff);
155 kfree(orig_node->bcast_own);
156 kfree(orig_node->bcast_own_sum);
157 kfree(orig_node);
158}

--- 54 unchanged lines hidden (view full) ---

213
214/* this function finds or creates an originator entry for the given
215 * address if it does not exits
216 */
217struct batadv_orig_node *batadv_get_orig_node(struct batadv_priv *bat_priv,
218 const uint8_t *addr)
219{
220 struct batadv_orig_node *orig_node;
218 int size;
221 int size, i;
219 int hash_added;
220 unsigned long reset_time;
221
222 orig_node = batadv_orig_hash_find(bat_priv, addr);
223 if (orig_node)
224 return orig_node;
225
226 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,

--- 35 unchanged lines hidden (view full) ---

262
263 orig_node->bcast_own = kzalloc(size, GFP_ATOMIC);
264 if (!orig_node->bcast_own)
265 goto free_orig_node;
266
267 size = bat_priv->num_ifaces * sizeof(uint8_t);
268 orig_node->bcast_own_sum = kzalloc(size, GFP_ATOMIC);
269
222 int hash_added;
223 unsigned long reset_time;
224
225 orig_node = batadv_orig_hash_find(bat_priv, addr);
226 if (orig_node)
227 return orig_node;
228
229 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,

--- 35 unchanged lines hidden (view full) ---

265
266 orig_node->bcast_own = kzalloc(size, GFP_ATOMIC);
267 if (!orig_node->bcast_own)
268 goto free_orig_node;
269
270 size = bat_priv->num_ifaces * sizeof(uint8_t);
271 orig_node->bcast_own_sum = kzalloc(size, GFP_ATOMIC);
272
273 for (i = 0; i < BATADV_FRAG_BUFFER_COUNT; i++) {
274 INIT_HLIST_HEAD(&orig_node->fragments[i].head);
275 spin_lock_init(&orig_node->fragments[i].lock);
276 orig_node->fragments[i].size = 0;
277 }
278
270 if (!orig_node->bcast_own_sum)
271 goto free_bcast_own;
272
273 hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig,
274 batadv_choose_orig, orig_node,
275 &orig_node->hash_entry);
276 if (hash_added != 0)
277 goto free_bcast_own_sum;

--- 105 unchanged lines hidden (view full) ---

383 hlist_for_each_entry_safe(orig_node, node_tmp,
384 head, hash_entry) {
385 if (batadv_purge_orig_node(bat_priv, orig_node)) {
386 batadv_gw_node_delete(bat_priv, orig_node);
387 hlist_del_rcu(&orig_node->hash_entry);
388 batadv_orig_node_free_ref(orig_node);
389 continue;
390 }
279 if (!orig_node->bcast_own_sum)
280 goto free_bcast_own;
281
282 hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig,
283 batadv_choose_orig, orig_node,
284 &orig_node->hash_entry);
285 if (hash_added != 0)
286 goto free_bcast_own_sum;

--- 105 unchanged lines hidden (view full) ---

392 hlist_for_each_entry_safe(orig_node, node_tmp,
393 head, hash_entry) {
394 if (batadv_purge_orig_node(bat_priv, orig_node)) {
395 batadv_gw_node_delete(bat_priv, orig_node);
396 hlist_del_rcu(&orig_node->hash_entry);
397 batadv_orig_node_free_ref(orig_node);
398 continue;
399 }
400
401 batadv_frag_purge_orig(orig_node,
402 batadv_frag_check_entry);
391 }
392 spin_unlock_bh(list_lock);
393 }
394
395 batadv_gw_node_purge(bat_priv);
396 batadv_gw_election(bat_priv);
397}
398

--- 257 unchanged lines hidden ---
403 }
404 spin_unlock_bh(list_lock);
405 }
406
407 batadv_gw_node_purge(bat_priv);
408 batadv_gw_election(bat_priv);
409}
410

--- 257 unchanged lines hidden ---