All of lore.kernel.org
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@meshcoding.com>
To: The list for a Better Approach To Mobile Ad-hoc Networking
	<b.a.t.m.a.n@lists.open-mesh.org>
Cc: Simon Wunderlich <simon@open-mesh.com>
Subject: Re: [B.A.T.M.A.N.] [PATCH 2/7] batman-adv: split tq information in neigh_node struct
Date: Sun, 13 Oct 2013 01:52:20 +0200	[thread overview]
Message-ID: <20131012235220.GK576@neomailbox.net> (raw)
In-Reply-To: <1381323938-26931-3-git-send-email-siwu@hrz.tu-chemnitz.de>

[-- Attachment #1: Type: text/plain, Size: 2448 bytes --]

On Wed, Oct 09, 2013 at 03:05:33PM +0200, Simon Wunderlich wrote:
> From: Simon Wunderlich <simon@open-mesh.com>
> 
> For the network wide multi interface optimization it is required to save
> metrics per outgoing interface in one neighbor. Therefore a new type is
> introduced to keep interface-specific information. This also requires
> some changes in access and list management.
> 
> Signed-off-by: Simon Wunderlich <simon@open-mesh.com>
> ---

[...]

>  void batadv_gw_check_election(struct batadv_priv *bat_priv,
>  			      struct batadv_orig_node *orig_node)
>  {
> +	struct batadv_neigh_node_ifinfo *router_orig_tq = NULL;
> +	struct batadv_neigh_node_ifinfo *router_gw_tq = NULL;
>  	struct batadv_orig_node *curr_gw_orig;
>  	struct batadv_neigh_node *router_gw = NULL, *router_orig = NULL;
>  	uint8_t gw_tq_avg, orig_tq_avg;
>  
> +	rcu_read_lock();
>  	curr_gw_orig = batadv_gw_get_selected_orig(bat_priv);
>  	if (!curr_gw_orig)
>  		goto deselect;
> @@ -297,6 +316,10 @@ void batadv_gw_check_election(struct batadv_priv *bat_priv,
>  	if (!router_gw)
>  		goto deselect;
>  
> +	router_gw_tq = batadv_neigh_node_get_ifinfo(router_gw, NULL);
> +	if (!router_gw_tq)
> +		goto deselect;
> +
>  	/* this node already is the gateway */
>  	if (curr_gw_orig == orig_node)
>  		goto out;
> @@ -305,8 +328,15 @@ void batadv_gw_check_election(struct batadv_priv *bat_priv,
>  	if (!router_orig)
>  		goto out;
>  
> -	gw_tq_avg = router_gw->bat_iv.tq_avg;
> -	orig_tq_avg = router_orig->bat_iv.tq_avg;
> +	router_orig_tq = batadv_neigh_node_get_ifinfo(router_orig, NULL);
> +	if (!router_orig_tq) {
> +		batadv_gw_deselect(bat_priv);
> +		goto out;
> +	}
> +
> +
> +	gw_tq_avg = router_gw_tq->bat_iv.tq_avg;
> +	orig_tq_avg = router_orig_tq->bat_iv.tq_avg;
>  
>  	/* the TQ value has to be better */
>  	if (orig_tq_avg < gw_tq_avg)
> @@ -324,6 +354,7 @@ void batadv_gw_check_election(struct batadv_priv *bat_priv,
>  		   gw_tq_avg, orig_tq_avg);
>  
>  deselect:
> +	rcu_read_unlock();
>  	batadv_gw_deselect(bat_priv);
>  out:

there are several "goto out;" after having acquired the rcu_read_lock.....
maybe they should be converted to "goto deselect;"? Otherwise this
rcu_read_unlock() has been misplaced.

Next time use C=2 when compiling your code: sparse would have told you about
this mistake :-) (this is how I found it).


Cheers,

-- 
Antonio Quartulli

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2013-10-12 23:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-09 13:05 [B.A.T.M.A.N.] [PATCH 0/7] add network wide multi interface optimization Simon Wunderlich
2013-10-09 13:05 ` [B.A.T.M.A.N.] [PATCH 1/7] batman-adv: remove bonding and interface alternating Simon Wunderlich
2013-10-09 13:05 ` [B.A.T.M.A.N.] [PATCH 2/7] batman-adv: split tq information in neigh_node struct Simon Wunderlich
2013-10-12 23:52   ` Antonio Quartulli [this message]
2013-10-19  9:59   ` Marek Lindner
2013-10-19 14:53     ` Simon Wunderlich
2013-10-09 13:05 ` [B.A.T.M.A.N.] [PATCH 3/7] batman-adv: split out router from orig_node Simon Wunderlich
2013-10-26 15:04   ` Marek Lindner
2013-10-09 13:05 ` [B.A.T.M.A.N.] [PATCH 4/7] batman-adv: add WiFi penalty Simon Wunderlich
2013-10-09 13:05 ` [B.A.T.M.A.N.] [PATCH 5/7] batman-adv: consider outgoing interface in OGM sending Simon Wunderlich
2013-10-27 10:12   ` Marek Lindner
2013-10-09 13:05 ` [B.A.T.M.A.N.] [PATCH 6/7] batman-adv: add bonding again Simon Wunderlich
2013-10-27 10:27   ` Marek Lindner
2013-10-09 13:05 ` [B.A.T.M.A.N.] [PATCH 7/7] batman-adv: add debugfs support to view multiif tables Simon Wunderlich
2013-10-27 10:55   ` Marek Lindner
2013-10-27 12:49   ` Antonio Quartulli

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=20131012235220.GK576@neomailbox.net \
    --to=antonio@meshcoding.com \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=simon@open-mesh.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.