b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Antonio Quartulli <a@unstable.cc>
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.] [PATCH v2 5/5] batman-adv: B.A.T.M.A.N. V - implement GW selection logic
Date: Fri, 13 May 2016 21:26:14 +0800	[thread overview]
Message-ID: <20160513132614.GK21549@prodigo.lan> (raw)
In-Reply-To: <2772485.VzmroEUk53@voltaire>

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

On Fri, May 13, 2016 at 07:31:01PM +0800, Marek Lindner wrote:
> On Tuesday, May 10, 2016 18:06:09 Antonio Quartulli wrote:
> > +static int batadv_v_gw_throughput_get(struct batadv_gw_node *gw_node, u32
> > *bw)
> 
> > +static struct batadv_gw_node *
> > +batadv_v_gw_get_best_gw_node(struct batadv_priv *bat_priv)
> 
> Kernel doc ?

ok :)

> 
> 
> > +	struct batadv_gw_node *gw_node, *curr_gw = NULL;
> > +	u32 max_bw = 0, bw, threshold;
> > +
> > +	threshold = atomic_read(&bat_priv->gw.sel_class);
> > +
> > +	rcu_read_lock();
> > +	hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.list, list) {
> > +		if (!kref_get_unless_zero(&gw_node->refcount))
> > +			continue;
> > +
> > +		if (batadv_v_gw_throughput_get(gw_node, &bw) < 0)
> > +			goto next;
> > +
> > +		if (curr_gw && (bw <= (max_bw + threshold)))
> > +			goto next;
> > +
> > +		if (curr_gw)
> > +			batadv_gw_node_put(curr_gw);
> > +
> > +		curr_gw = gw_node;
> > +		kref_get(&curr_gw->refcount);
> > +		max_bw = bw;
> > +
> > +next:
> > +		batadv_gw_node_put(gw_node);
> > +	}
> > +	rcu_read_unlock();
> > +
> > +	return curr_gw;
> > +}
> 
> I don't quite follow the use of 'threshold' in this function. The threshold is 
> meant to decide whether the switch to another gateway is worth breaking the 
> existing stateful connections. Here, the code is retrieving the best gateway 
> of all - no need for the threshold ? Moreover, the threshold might lead to 
> unpredictable results. If the threshold is 5 MBit/s and the first gateway in 
> the list offers 1 MBit/s while the second offers 5 MBit/s the better gateway 
> is never chosen. 

You are right. I will re-work this part.

> 
> 
> > +static bool batadv_v_gw_is_eligible(struct batadv_priv *bat_priv,
> > +				    struct batadv_orig_node *curr_gw_orig,
> > +				    struct batadv_orig_node *orig_node)
> 
> > +/* fails if orig_node has no router */
> > +static int batadv_v_gw_write_buffer_text(struct batadv_priv *bat_priv,
> > +					 struct seq_file *seq,
> > +					 const struct batadv_gw_node *gw_node)
> 
> > +static void batadv_v_gw_print(struct batadv_priv *bat_priv,
> > +			      struct seq_file *seq)
> 
> More room for kernel doc ..

there is always room for kerneldoc..

> 
> 
> > @@ -387,7 +569,16 @@ static struct batadv_algo_ops batadv_batman_v
> > __read_mostly = { */
> >  int batadv_v_mesh_init(struct batadv_priv *bat_priv)
> >  {
> > -	return batadv_v_ogm_init(bat_priv);
> > +	int ret = 0;
> > +
> > +	ret = batadv_v_ogm_init(bat_priv);
> > +	if (ret < 0)
> > +		return ret;
> > +
> > +	/* set default throughput difference threshold to 5Mbps */
> > +	atomic_set(&bat_priv->gw.sel_class, 50);
> > +
> > +	return 0;
> >  }
> 
> There is no need to initial 'ret' if the next line is setting a proper value.
> If you moved the atomic_set() above the batadv_v_ogm_init() call most of the 
> chachacha would go away.
> 

mhhh ok!

> In batadv_softif_init_late() bat_priv->gw.sel_class is initialized for 
> B.A.T.M.A.N. IV. Do you intend to keep it there ? If not, a per-routing 
> algorithm init might be cleaner ..  :)
> 

I do agree :)

I'll rework this part too.

Thanks !

Cheers,




-- 
Antonio Quartulli

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

  reply	other threads:[~2016-05-13 13:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-10 10:06 [B.A.T.M.A.N.] [PATCH v2 1/5] batman-adv: make the GW selection class algorithm specific Antonio Quartulli
2016-05-10 10:06 ` [B.A.T.M.A.N.] [PATCH v2 2/5] batman-adv: split routing API data structure in subobjects Antonio Quartulli
2016-05-10 10:06 ` [B.A.T.M.A.N.] [PATCH v2 3/5] batman-adv: statically print gateway table header Antonio Quartulli
2016-05-10 10:06 ` [B.A.T.M.A.N.] [PATCH v2 4/5] batman-adv: make GW election code protocol specific Antonio Quartulli
2016-05-13 11:07   ` Marek Lindner
2016-05-13 13:23     ` Antonio Quartulli
2016-05-10 10:06 ` [B.A.T.M.A.N.] [PATCH v2 5/5] batman-adv: B.A.T.M.A.N. V - implement GW selection logic Antonio Quartulli
2016-05-13 11:31   ` Marek Lindner
2016-05-13 13:26     ` Antonio Quartulli [this message]
2016-05-13 10:44 ` [B.A.T.M.A.N.] [PATCH v2 1/5] batman-adv: make the GW selection class algorithm specific Marek Lindner
2016-05-13 13:21   ` Antonio Quartulli
2016-05-23  9:00 [B.A.T.M.A.N.] [PATCH v2 0/5] GW code: make it algorithm-agnostic and add B.A.T.M.A.N. V Antonio Quartulli
2016-05-23  9:00 ` [B.A.T.M.A.N.] [PATCH v2 5/5] batman-adv: B.A.T.M.A.N. V - implement GW selection logic 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=20160513132614.GK21549@prodigo.lan \
    --to=a@unstable.cc \
    --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 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).