提交 57f0c07c 编写于 作者: L Linus Lüssing 提交者: Sven Eckelmann

batman-adv: Simplify gw_check_election(), use gw_get_selected()

gw_get_selected() can get us the desired orig_node directly, therefore
reusing that function in gw_check_election().
Signed-off-by: NLinus Lüssing <linus.luessing@web.de>
Signed-off-by: NMarek Lindner <lindner_marek@yahoo.de>
Signed-off-by: NSven Eckelmann <sven@narfation.org>
上级 4c804850
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "gateway_client.h" #include "gateway_client.h"
#include "gateway_common.h" #include "gateway_common.h"
#include "hard-interface.h" #include "hard-interface.h"
#include "originator.h"
#include <linux/ip.h> #include <linux/ip.h>
#include <linux/ipv6.h> #include <linux/ipv6.h>
#include <linux/udp.h> #include <linux/udp.h>
...@@ -203,28 +204,25 @@ void gw_election(struct bat_priv *bat_priv) ...@@ -203,28 +204,25 @@ void gw_election(struct bat_priv *bat_priv)
void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node) void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node)
{ {
struct gw_node *curr_gateway_tmp; struct orig_node *curr_gw_orig;
uint8_t gw_tq_avg, orig_tq_avg; uint8_t gw_tq_avg, orig_tq_avg;
rcu_read_lock(); curr_gw_orig = gw_get_selected(bat_priv);
curr_gateway_tmp = rcu_dereference(bat_priv->curr_gw); if (!curr_gw_orig)
if (!curr_gateway_tmp) goto deselect;
goto out_rcu;
if (!curr_gateway_tmp->orig_node)
goto deselect_rcu;
if (!curr_gateway_tmp->orig_node->router) rcu_read_lock();
if (!curr_gw_orig->router)
goto deselect_rcu; goto deselect_rcu;
/* this node already is the gateway */ /* this node already is the gateway */
if (curr_gateway_tmp->orig_node == orig_node) if (curr_gw_orig == orig_node)
goto out_rcu; goto out_rcu;
if (!orig_node->router) if (!orig_node->router)
goto out_rcu; goto out_rcu;
gw_tq_avg = curr_gateway_tmp->orig_node->router->tq_avg; gw_tq_avg = curr_gw_orig->router->tq_avg;
rcu_read_unlock(); rcu_read_unlock();
orig_tq_avg = orig_node->router->tq_avg; orig_tq_avg = orig_node->router->tq_avg;
...@@ -255,6 +253,9 @@ void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node) ...@@ -255,6 +253,9 @@ void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node)
deselect: deselect:
gw_deselect(bat_priv); gw_deselect(bat_priv);
out: out:
if (curr_gw_orig)
orig_node_free_ref(curr_gw_orig);
return; return;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册