diff options
author | Marek Lindner <lindner_marek@yahoo.de> | 2012-03-01 02:35:21 -0500 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2012-05-11 07:55:57 -0400 |
commit | 7ae8b2852f946c71fdbd910156baa605a4ae3cee (patch) | |
tree | d5d436a84baa564adaddc498e94d5e4b5a40816b /net/batman-adv/bat_iv_ogm.c | |
parent | 0b0094e000840115b5baece2293c5fb1aab4fded (diff) |
batman-adv: split neigh_new function into generic and batman iv specific parts
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Acked-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'net/batman-adv/bat_iv_ogm.c')
-rw-r--r-- | net/batman-adv/bat_iv_ogm.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 8652a7536b15..ae0a08c391ea 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c | |||
@@ -30,6 +30,32 @@ | |||
30 | #include "send.h" | 30 | #include "send.h" |
31 | #include "bat_algo.h" | 31 | #include "bat_algo.h" |
32 | 32 | ||
33 | static struct neigh_node *bat_iv_ogm_neigh_new(struct hard_iface *hard_iface, | ||
34 | const uint8_t *neigh_addr, | ||
35 | struct orig_node *orig_node, | ||
36 | struct orig_node *orig_neigh, | ||
37 | uint32_t seqno) | ||
38 | { | ||
39 | struct neigh_node *neigh_node; | ||
40 | |||
41 | neigh_node = batadv_neigh_node_new(hard_iface, neigh_addr, seqno); | ||
42 | if (!neigh_node) | ||
43 | goto out; | ||
44 | |||
45 | INIT_LIST_HEAD(&neigh_node->bonding_list); | ||
46 | spin_lock_init(&neigh_node->tq_lock); | ||
47 | |||
48 | neigh_node->orig_node = orig_neigh; | ||
49 | neigh_node->if_incoming = hard_iface; | ||
50 | |||
51 | spin_lock_bh(&orig_node->neigh_list_lock); | ||
52 | hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list); | ||
53 | spin_unlock_bh(&orig_node->neigh_list_lock); | ||
54 | |||
55 | out: | ||
56 | return neigh_node; | ||
57 | } | ||
58 | |||
33 | static int bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) | 59 | static int bat_iv_ogm_iface_enable(struct hard_iface *hard_iface) |
34 | { | 60 | { |
35 | struct batman_ogm_packet *batman_ogm_packet; | 61 | struct batman_ogm_packet *batman_ogm_packet; |
@@ -638,8 +664,9 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv, | |||
638 | if (!orig_tmp) | 664 | if (!orig_tmp) |
639 | goto unlock; | 665 | goto unlock; |
640 | 666 | ||
641 | neigh_node = create_neighbor(orig_node, orig_tmp, | 667 | neigh_node = bat_iv_ogm_neigh_new(if_incoming, ethhdr->h_source, |
642 | ethhdr->h_source, if_incoming); | 668 | orig_node, orig_tmp, |
669 | batman_ogm_packet->seqno); | ||
643 | 670 | ||
644 | orig_node_free_ref(orig_tmp); | 671 | orig_node_free_ref(orig_tmp); |
645 | if (!neigh_node) | 672 | if (!neigh_node) |
@@ -764,10 +791,11 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node, | |||
764 | rcu_read_unlock(); | 791 | rcu_read_unlock(); |
765 | 792 | ||
766 | if (!neigh_node) | 793 | if (!neigh_node) |
767 | neigh_node = create_neighbor(orig_neigh_node, | 794 | neigh_node = bat_iv_ogm_neigh_new(if_incoming, |
768 | orig_neigh_node, | 795 | orig_neigh_node->orig, |
769 | orig_neigh_node->orig, | 796 | orig_neigh_node, |
770 | if_incoming); | 797 | orig_neigh_node, |
798 | batman_ogm_packet->seqno); | ||
771 | 799 | ||
772 | if (!neigh_node) | 800 | if (!neigh_node) |
773 | goto out; | 801 | goto out; |