All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Lindner <lindner_marek@yahoo.de>
To: The list for a Better Approach To Mobile Ad-hoc Networking
	<b.a.t.m.a.n@lists.open-mesh.org>
Subject: Re: [B.A.T.M.A.N.] [PATCHv3 6/9] batman-adv: adapt bonding to use the new API functions
Date: Mon, 26 Aug 2013 11:11:37 +0800	[thread overview]
Message-ID: <201308261111.37380.lindner_marek@yahoo.de> (raw)
In-Reply-To: <1376376232-2178-7-git-send-email-ordex@autistici.org>

On Tuesday, August 13, 2013 14:43:49 Antonio Quartulli wrote:
> -void batadv_bonding_candidate_add(struct batadv_orig_node *orig_node,
> +void batadv_bonding_candidate_add(struct batadv_priv *bat_priv,
> +				  struct batadv_orig_node *orig_node,
>  				  struct batadv_neigh_node *neigh_node)
>  {

Kernel doc ?


> @@ -133,8 +136,9 @@ void batadv_bonding_candidate_add(struct
> batadv_orig_node *orig_node, goto candidate_del;
> 
>  	/* ... and is good enough to be considered */
> -	if (neigh_node->bat_iv.tq_avg <
> -	    router->bat_iv.tq_avg - BATADV_BONDING_TQ_THRESHOLD)
> +	router_metric = bao->bat_metric_get(router);
> +	neigh_metric = bao->bat_metric_get(neigh_node);
> +	if (bao->bat_metric_is_equiv_or_better(neigh_metric, router_metric))
>  		goto candidate_del;

[..]


>  	/* check if we have another candidate with the same mac address or
> @@ -486,11 +490,14 @@ out:
>   * Increases the returned router's refcount
>   */
>  static struct batadv_neigh_node *
> -batadv_find_ifalter_router(struct batadv_orig_node *primary_orig,
> +batadv_find_ifalter_router(struct batadv_priv *bat_priv,
> +			   struct batadv_orig_node *primary_orig,
>  			   const struct batadv_hard_iface *recv_if)
>  {

Kernel doc ?


> -	struct batadv_neigh_node *tmp_neigh_node;
>  	struct batadv_neigh_node *router = NULL, *first_candidate = NULL;
> +	struct batadv_algo_ops *bao = bat_priv->bat_algo_ops;
> +	struct batadv_neigh_node *tmp_neigh_node;
> +	uint32_t tmp_metric, router_metric = UINT_MAX;
> 
>  	rcu_read_lock();
>  	list_for_each_entry_rcu(tmp_neigh_node, &primary_orig->bond_list,
> @@ -502,8 +509,8 @@ batadv_find_ifalter_router(struct batadv_orig_node
> *primary_orig, if (tmp_neigh_node->if_incoming == recv_if)
>  			continue;
> 
> -		if (router &&
> -		    tmp_neigh_node->bat_iv.tq_avg <= router->bat_iv.tq_avg)
> +		tmp_metric = bao->bat_metric_get(tmp_neigh_node);
> +		if (router && (tmp_metric <= router_metric))
>  			continue;

This last comparison looks horribly wrong. Isn't that what we have the API 
for?

Besides, it seems to me the bat_metric_is_equiv_or_better() call has been 
misdesigned. Instead of passing the metric and having each function store + 
process the metric this call should accept 2 neighbor nodes as argument. This 
should save 2 out of 3 API calls (2 * bao->bat_metric_get()) and some code in 
all the functions needing the bat_metric_is_equiv_or_better() API. Moreover, 
it should reduce the impact on performance because each callback will cost us 
a little bit ..

Cheers,
Marek

  reply	other threads:[~2013-08-26  3:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-13  6:43 [B.A.T.M.A.N.] [PATCHv3 0/9] Improving the routing protocol abstraction Antonio Quartulli
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 1/9] batman-adv: make struct batadv_neigh_node algorithm agnostic Antonio Quartulli
2013-08-16  3:46   ` Marek Lindner
2013-08-16  6:27     ` Antonio Quartulli
2013-08-16  9:27       ` Marek Lindner
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 2/9] batman-adv: make struct batadv_orig_node " Antonio Quartulli
2013-08-16  4:01   ` Marek Lindner
2013-08-16  6:29     ` Antonio Quartulli
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 3/9] batman-adv: add bat_orig_print function API Antonio Quartulli
2013-08-16  4:05   ` Marek Lindner
2013-08-16  6:30     ` Antonio Quartulli
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 4/9] batman-adv: add bat_metric_get API function Antonio Quartulli
2013-08-26  1:44   ` Marek Lindner
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 5/9] batman-adv: add bat_metric_is_equiv_or_better " Antonio Quartulli
2013-08-26  1:49   ` Marek Lindner
2013-08-26  6:37     ` Antonio Quartulli
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 6/9] batman-adv: adapt bonding to use the new API functions Antonio Quartulli
2013-08-26  3:11   ` Marek Lindner [this message]
2013-08-27 16:33     ` Antonio Quartulli
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 7/9] batman-adv: adapt the neighbor purging routine " Antonio Quartulli
2013-08-26  3:29   ` Marek Lindner
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 8/9] batman-adv: provide orig_node routing API Antonio Quartulli
2013-08-26  3:31   ` Marek Lindner
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 9/9] batman-adv: adapt the TT component to use the new API functions 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=201308261111.37380.lindner_marek@yahoo.de \
    --to=lindner_marek@yahoo.de \
    --cc=b.a.t.m.a.n@lists.open-mesh.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 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.