From: Sven Eckelmann <sven-KaDOiPu9UxWEi8DpZVb4nw@public.gmane.org>
To: davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
b.a.t.m.a.n-ZwoEplunGu2X36UT3dwllkB+6BGkLq7r@public.gmane.org,
Marek Lindner <lindner_marek-LWAfsSFWpa4@public.gmane.org>
Subject: [PATCH 3/8] batman-adv: Simplify gw_check_election(), use gw_get_selected()
Date: Sun, 17 Apr 2011 21:30:13 +0200 [thread overview]
Message-ID: <1303068618-27928-4-git-send-email-sven@narfation.org> (raw)
In-Reply-To: <1303068618-27928-1-git-send-email-sven-KaDOiPu9UxWEi8DpZVb4nw@public.gmane.org>
From: Linus Lüssing <linus.luessing-S0/GAf8tV78@public.gmane.org>
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-S0/GAf8tV78@public.gmane.org>
Signed-off-by: Marek Lindner <lindner_marek-LWAfsSFWpa4@public.gmane.org>
Signed-off-by: Sven Eckelmann <sven-KaDOiPu9UxWEi8DpZVb4nw@public.gmane.org>
---
net/batman-adv/gateway_client.c | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index 27b87ad..879ac15 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -23,6 +23,7 @@
#include "gateway_client.h"
#include "gateway_common.h"
#include "hard-interface.h"
+#include "originator.h"
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/udp.h>
@@ -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)
{
- struct gw_node *curr_gateway_tmp;
+ struct orig_node *curr_gw_orig;
uint8_t gw_tq_avg, orig_tq_avg;
+ curr_gw_orig = gw_get_selected(bat_priv);
+ if (!curr_gw_orig)
+ goto deselect;
+
rcu_read_lock();
- curr_gateway_tmp = rcu_dereference(bat_priv->curr_gw);
- if (!curr_gateway_tmp)
- goto out_rcu;
-
- if (!curr_gateway_tmp->orig_node)
- goto deselect_rcu;
-
- if (!curr_gateway_tmp->orig_node->router)
+ if (!curr_gw_orig->router)
goto deselect_rcu;
/* this node already is the gateway */
- if (curr_gateway_tmp->orig_node == orig_node)
+ if (curr_gw_orig == orig_node)
goto out_rcu;
if (!orig_node->router)
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();
orig_tq_avg = orig_node->router->tq_avg;
@@ -255,6 +253,9 @@ deselect_rcu:
deselect:
gw_deselect(bat_priv);
out:
+ if (curr_gw_orig)
+ orig_node_free_ref(curr_gw_orig);
+
return;
}
--
1.7.4.4
next prev parent reply other threads:[~2011-04-17 19:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-17 19:30 pull request: batman-adv 2011-04-17 Sven Eckelmann
[not found] ` <1303068618-27928-1-git-send-email-sven-KaDOiPu9UxWEi8DpZVb4nw@public.gmane.org>
2011-04-17 19:30 ` [PATCH 1/8] batman-adv: Move bonding / iface alternating router search to own functions Sven Eckelmann
2011-04-17 19:30 ` [PATCH 2/8] batman-adv: Make gateway_get_selected type safe Sven Eckelmann
2011-04-17 19:30 ` Sven Eckelmann [this message]
2011-04-17 19:30 ` [PATCH 4/8] batman-adv: Make orig_node->router an rcu protected pointer Sven Eckelmann
2011-04-17 19:30 ` [PATCH 5/8] batman-adv: Protect global TQ window with a spinlock Sven Eckelmann
2011-04-17 19:30 ` [PATCH 6/8] batman-adv: concentrate all curr_gw related rcu operations in select/deselect functions Sven Eckelmann
2011-04-17 19:30 ` [PATCH 7/8] batman-adv: protect softif_neigh by rcu Sven Eckelmann
2011-04-17 19:30 ` [PATCH 8/8] batman-adv: Set the txqueuelen to zero when creating soft interface Sven Eckelmann
2011-04-18 0:38 ` pull request: batman-adv 2011-04-17 David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1303068618-27928-4-git-send-email-sven@narfation.org \
--to=sven-kadoipu9uxwei8dpzvb4nw@public.gmane.org \
--cc=b.a.t.m.a.n-ZwoEplunGu2X36UT3dwllkB+6BGkLq7r@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=lindner_marek-LWAfsSFWpa4@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).