diff options
author | Antonio Quartulli <antonio@open-mesh.com> | 2013-09-02 06:15:06 -0400 |
---|---|---|
committer | Antonio Quartulli <antonio@meshcoding.com> | 2013-10-23 09:33:12 -0400 |
commit | 6680a1249f76c28e19fc24b0c85f671b019c8bc7 (patch) | |
tree | 7bd955c882eeb7c3f33760d162c32544d17b58c4 /net/batman-adv | |
parent | c43c981e50f47bdd0f1eb400dc30ff13472c7be6 (diff) |
batman-adv: adapt bonding to use the new API functions
Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/bat_iv_ogm.c | 2 | ||||
-rw-r--r-- | net/batman-adv/routing.c | 42 | ||||
-rw-r--r-- | net/batman-adv/routing.h | 3 |
3 files changed, 32 insertions, 15 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 4376fe75eeec..7cdc3943103a 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c | |||
@@ -853,7 +853,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv, | |||
853 | neigh_node->last_ttl = batadv_ogm_packet->header.ttl; | 853 | neigh_node->last_ttl = batadv_ogm_packet->header.ttl; |
854 | } | 854 | } |
855 | 855 | ||
856 | batadv_bonding_candidate_add(orig_node, neigh_node); | 856 | batadv_bonding_candidate_add(bat_priv, orig_node, neigh_node); |
857 | 857 | ||
858 | /* if this neighbor already is our next hop there is nothing | 858 | /* if this neighbor already is our next hop there is nothing |
859 | * to change | 859 | * to change |
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 5b78a71c1b02..71fba146ddf1 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -115,11 +115,21 @@ out: | |||
115 | return; | 115 | return; |
116 | } | 116 | } |
117 | 117 | ||
118 | void batadv_bonding_candidate_add(struct batadv_orig_node *orig_node, | 118 | /** |
119 | * batadv_bonding_candidate_add - consider a new link for bonding mode towards | ||
120 | * the given originator | ||
121 | * @bat_priv: the bat priv with all the soft interface information | ||
122 | * @orig_node: the target node | ||
123 | * @neigh_node: the neighbor representing the new link to consider for bonding | ||
124 | * mode | ||
125 | */ | ||
126 | void batadv_bonding_candidate_add(struct batadv_priv *bat_priv, | ||
127 | struct batadv_orig_node *orig_node, | ||
119 | struct batadv_neigh_node *neigh_node) | 128 | struct batadv_neigh_node *neigh_node) |
120 | { | 129 | { |
130 | struct batadv_algo_ops *bao = bat_priv->bat_algo_ops; | ||
121 | struct batadv_neigh_node *tmp_neigh_node, *router = NULL; | 131 | struct batadv_neigh_node *tmp_neigh_node, *router = NULL; |
122 | uint8_t interference_candidate = 0, tq; | 132 | uint8_t interference_candidate = 0; |
123 | 133 | ||
124 | spin_lock_bh(&orig_node->neigh_list_lock); | 134 | spin_lock_bh(&orig_node->neigh_list_lock); |
125 | 135 | ||
@@ -134,8 +144,7 @@ void batadv_bonding_candidate_add(struct batadv_orig_node *orig_node, | |||
134 | 144 | ||
135 | 145 | ||
136 | /* ... and is good enough to be considered */ | 146 | /* ... and is good enough to be considered */ |
137 | tq = router->bat_iv.tq_avg - BATADV_BONDING_TQ_THRESHOLD; | 147 | if (bao->bat_neigh_is_equiv_or_better(neigh_node, router)) |
138 | if (neigh_node->bat_iv.tq_avg < tq) | ||
139 | goto candidate_del; | 148 | goto candidate_del; |
140 | 149 | ||
141 | /* check if we have another candidate with the same mac address or | 150 | /* check if we have another candidate with the same mac address or |
@@ -481,18 +490,25 @@ out: | |||
481 | return router; | 490 | return router; |
482 | } | 491 | } |
483 | 492 | ||
484 | /* Interface Alternating: Use the best of the | 493 | /** |
485 | * remaining candidates which are not using | 494 | * batadv_find_ifalter_router - find the best of the remaining candidates which |
486 | * this interface. | 495 | * are not using this interface |
496 | * @bat_priv: the bat priv with all the soft interface information | ||
497 | * @primary_orig: the destination | ||
498 | * @recv_if: the interface that the router returned by this function has to not | ||
499 | * use | ||
487 | * | 500 | * |
488 | * Increases the returned router's refcount | 501 | * Returns the best candidate towards primary_orig that is not using recv_if. |
502 | * Increases the returned neighbor's refcount | ||
489 | */ | 503 | */ |
490 | static struct batadv_neigh_node * | 504 | static struct batadv_neigh_node * |
491 | batadv_find_ifalter_router(struct batadv_orig_node *primary_orig, | 505 | batadv_find_ifalter_router(struct batadv_priv *bat_priv, |
506 | struct batadv_orig_node *primary_orig, | ||
492 | const struct batadv_hard_iface *recv_if) | 507 | const struct batadv_hard_iface *recv_if) |
493 | { | 508 | { |
494 | struct batadv_neigh_node *tmp_neigh_node; | ||
495 | struct batadv_neigh_node *router = NULL, *first_candidate = NULL; | 509 | struct batadv_neigh_node *router = NULL, *first_candidate = NULL; |
510 | struct batadv_algo_ops *bao = bat_priv->bat_algo_ops; | ||
511 | struct batadv_neigh_node *tmp_neigh_node; | ||
496 | 512 | ||
497 | rcu_read_lock(); | 513 | rcu_read_lock(); |
498 | list_for_each_entry_rcu(tmp_neigh_node, &primary_orig->bond_list, | 514 | list_for_each_entry_rcu(tmp_neigh_node, &primary_orig->bond_list, |
@@ -504,8 +520,7 @@ batadv_find_ifalter_router(struct batadv_orig_node *primary_orig, | |||
504 | if (tmp_neigh_node->if_incoming == recv_if) | 520 | if (tmp_neigh_node->if_incoming == recv_if) |
505 | continue; | 521 | continue; |
506 | 522 | ||
507 | if (router && | 523 | if (router && bao->bat_neigh_cmp(tmp_neigh_node, router)) |
508 | tmp_neigh_node->bat_iv.tq_avg <= router->bat_iv.tq_avg) | ||
509 | continue; | 524 | continue; |
510 | 525 | ||
511 | if (!atomic_inc_not_zero(&tmp_neigh_node->refcount)) | 526 | if (!atomic_inc_not_zero(&tmp_neigh_node->refcount)) |
@@ -639,7 +654,8 @@ batadv_find_router(struct batadv_priv *bat_priv, | |||
639 | if (bonding_enabled) | 654 | if (bonding_enabled) |
640 | router = batadv_find_bond_router(primary_orig_node, recv_if); | 655 | router = batadv_find_bond_router(primary_orig_node, recv_if); |
641 | else | 656 | else |
642 | router = batadv_find_ifalter_router(primary_orig_node, recv_if); | 657 | router = batadv_find_ifalter_router(bat_priv, primary_orig_node, |
658 | recv_if); | ||
643 | 659 | ||
644 | return_router: | 660 | return_router: |
645 | if (router && router->if_incoming->if_status != BATADV_IF_ACTIVE) | 661 | if (router && router->if_incoming->if_status != BATADV_IF_ACTIVE) |
diff --git a/net/batman-adv/routing.h b/net/batman-adv/routing.h index 55d637a90621..19544ddb81b5 100644 --- a/net/batman-adv/routing.h +++ b/net/batman-adv/routing.h | |||
@@ -48,7 +48,8 @@ batadv_find_router(struct batadv_priv *bat_priv, | |||
48 | const struct batadv_hard_iface *recv_if); | 48 | const struct batadv_hard_iface *recv_if); |
49 | void batadv_bonding_candidate_del(struct batadv_orig_node *orig_node, | 49 | void batadv_bonding_candidate_del(struct batadv_orig_node *orig_node, |
50 | struct batadv_neigh_node *neigh_node); | 50 | struct batadv_neigh_node *neigh_node); |
51 | void batadv_bonding_candidate_add(struct batadv_orig_node *orig_node, | 51 | void batadv_bonding_candidate_add(struct batadv_priv *bat_priv, |
52 | struct batadv_orig_node *orig_node, | ||
52 | struct batadv_neigh_node *neigh_node); | 53 | struct batadv_neigh_node *neigh_node); |
53 | void batadv_bonding_save_primary(const struct batadv_orig_node *orig_node, | 54 | void batadv_bonding_save_primary(const struct batadv_orig_node *orig_node, |
54 | struct batadv_orig_node *orig_neigh_node, | 55 | struct batadv_orig_node *orig_neigh_node, |