aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv
diff options
context:
space:
mode:
authorLinus Lüssing <linus.luessing@web.de>2011-03-14 18:43:33 -0400
committerSven Eckelmann <sven@narfation.org>2011-04-17 15:11:01 -0400
commit57f0c07c4d0da8bcc23e21c330fe9c7c5cf776b5 (patch)
tree116da9bca37ef83067054dd613222da8f78f33bc /net/batman-adv
parent4c804850572f70a2350e4d1e79d6659392b07733 (diff)
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: Linus Lüssing <linus.luessing@web.de> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de> Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/gateway_client.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index 27b87add044b..879ac1594869 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -23,6 +23,7 @@
23#include "gateway_client.h" 23#include "gateway_client.h"
24#include "gateway_common.h" 24#include "gateway_common.h"
25#include "hard-interface.h" 25#include "hard-interface.h"
26#include "originator.h"
26#include <linux/ip.h> 27#include <linux/ip.h>
27#include <linux/ipv6.h> 28#include <linux/ipv6.h>
28#include <linux/udp.h> 29#include <linux/udp.h>
@@ -203,28 +204,25 @@ void gw_election(struct bat_priv *bat_priv)
203 204
204void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node) 205void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node)
205{ 206{
206 struct gw_node *curr_gateway_tmp; 207 struct orig_node *curr_gw_orig;
207 uint8_t gw_tq_avg, orig_tq_avg; 208 uint8_t gw_tq_avg, orig_tq_avg;
208 209
209 rcu_read_lock(); 210 curr_gw_orig = gw_get_selected(bat_priv);
210 curr_gateway_tmp = rcu_dereference(bat_priv->curr_gw); 211 if (!curr_gw_orig)
211 if (!curr_gateway_tmp) 212 goto deselect;
212 goto out_rcu;
213 213
214 if (!curr_gateway_tmp->orig_node) 214 rcu_read_lock();
215 goto deselect_rcu; 215 if (!curr_gw_orig->router)
216
217 if (!curr_gateway_tmp->orig_node->router)
218 goto deselect_rcu; 216 goto deselect_rcu;
219 217
220 /* this node already is the gateway */ 218 /* this node already is the gateway */
221 if (curr_gateway_tmp->orig_node == orig_node) 219 if (curr_gw_orig == orig_node)
222 goto out_rcu; 220 goto out_rcu;
223 221
224 if (!orig_node->router) 222 if (!orig_node->router)
225 goto out_rcu; 223 goto out_rcu;
226 224
227 gw_tq_avg = curr_gateway_tmp->orig_node->router->tq_avg; 225 gw_tq_avg = curr_gw_orig->router->tq_avg;
228 rcu_read_unlock(); 226 rcu_read_unlock();
229 227
230 orig_tq_avg = orig_node->router->tq_avg; 228 orig_tq_avg = orig_node->router->tq_avg;
@@ -255,6 +253,9 @@ deselect_rcu:
255deselect: 253deselect:
256 gw_deselect(bat_priv); 254 gw_deselect(bat_priv);
257out: 255out:
256 if (curr_gw_orig)
257 orig_node_free_ref(curr_gw_orig);
258
258 return; 259 return;
259} 260}
260 261