All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>
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.] [RFCv2 6/6] batman-adv: add bonding again
Date: Fri, 4 Oct 2013 00:53:17 +0200	[thread overview]
Message-ID: <20131003225317.GC9172@pandem0nium> (raw)
In-Reply-To: <20131001092419.GE1448@neomailbox.net>

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

On Tue, Oct 01, 2013 at 11:24:19AM +0200, Antonio Quartulli wrote:
> > +	/* bonding: loop through the list of possible routers found
> > +	 * for the various outgoing interfaces and find a candidate after
> > +	 * the last chosen bonding candidate (next_candidate). If no such
> > +	 * router is found, use the first candidate found (the last chosen
> > +	 * bonding candidate might have been the last one in the list).
> > +	 * If this can't be found either, return the previously choosen
> > +	 * router - obviously there are no other candidates.
> > +	 */
> > +	rcu_read_lock();
> > +	router_ifinfo = batadv_neigh_node_get_ifinfo(router, recv_if);
> > +	hlist_for_each_entry_rcu(cand, &orig_node->ifinfo_list, list) {
> > +		cand_router = rcu_dereference(cand->router);
> > +		if (!cand_router)
> > +			continue;
> > +
> > +		if (!atomic_inc_not_zero(&cand_router->refcount))
> > +			continue;
> > +
> > +		cand_ifinfo = batadv_neigh_node_get_ifinfo(cand_router,
> > +							   cand->if_outgoing);
> > +		if (!cand_ifinfo)
> > +			goto next;
> > +
> > +		/* alternative candidate should be good enough to be
> > +		 * considered
> > +		 */
> > +		if (!bao->bat_neigh_ifinfo_is_equiv_or_better(cand_ifinfo,
> > +							      router_ifinfo))
> > +			goto next;
> > +
> > +		/* don't use the same router twice */
> > +		if (orig_node->last_bonding_candidate &&
> > +		    (orig_node->last_bonding_candidate->router ==
> > +		     cand_router))
> > +				goto next;
> > +
> > +		/* mark the first possible candidate */
> > +		if (!first_candidate) {
> > +			atomic_inc(&cand_router->refcount);
> > +			first_candidate = cand;
> > +			first_candidate_router = cand_router;
> > +		}
> > +
> 
> What if you change this:
> 
> > +		/* check if already passed the next candidate ... this function
> > +		 * should get the next candidate AFTER the last used bonding
> > +		 * candidate.
> > +		 */
> > +		if (orig_node->last_bonding_candidate) {
> > +			if (orig_node->last_bonding_candidate == cand) {
> > +				last_candidate_found = true;
> > +				goto next;
> > +			}
> > +
> > +			if (!last_candidate_found)
> > +				goto next;
> > +		}
> > +
> > +		next_candidate = cand;
> > +		next_candidate_router = cand_router;
> > +		break;
> > +next:
> > +		batadv_neigh_node_free_ref(cand_router);
> 
> to this:
> 
> if (!orig_node->last_bonding_candidate || last_candidate_found) {
> 	next_candidate = cand;
> 	next_candidate_router = cand_router;
> 	break;
> }
> 
> if (orig_node->last_bonding_candidate == cand)
> 	last_candidate_found = true;
> 
> batadv_neigh_node_free_ref(cand_router);
> 
> 
> ? (I hope the two are equivalent..I took some time to fully get the flow of your
> if/else block)
> 
> Removing the "goto next" makes me look at it in a more linear way (and we also
> reduce the max indentation by one tab).
> 

Yup, that should work too, good suggestion. We need to keep the next label though.
I'll change it according to your suggestion.

> > diff --git a/types.h b/types.h
> > index 7255500..fa58a14 100644
> > --- a/types.h
> > +++ b/types.h
> > @@ -173,6 +173,7 @@ struct batadv_orig_bat_iv {
> >   * @orig: originator ethernet address
> >   * @primary_addr: hosts primary interface address
> >   * @ifinfo_list: list for routers per outgoing interface
> > + * @last_bonding_candidate: pointer to last ifinfo of last used router
> >   * @batadv_dat_addr_t:  address of the orig node in the distributed hash
> >   * @last_seen: time when last packet from this node was received
> >   * @bcast_seqno_reset: time when the broadcast seqno window was reset
> > @@ -213,6 +214,7 @@ struct batadv_orig_node {
> >  	uint8_t orig[ETH_ALEN];
> >  	uint8_t primary_addr[ETH_ALEN];
> >  	struct hlist_head ifinfo_list;
> > +	struct batadv_orig_node_ifinfo *last_bonding_candidate;
> 
> Do you think it is not needed to set this field to NULL when disabling bonding
> mode? Can an old value trigger some strange behaviour when bonding is turned on
> again? Maybe not..just wondering..

Hmm, maybe, can't say now but will look into that.

Thanks for all your suggestions!
	Simon

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

      reply	other threads:[~2013-10-03 22:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-04 16:27 [B.A.T.M.A.N.] [RFCv2 0/6] add network wide multi interface optimization Simon Wunderlich
2013-09-04 16:27 ` [B.A.T.M.A.N.] [RFCv2 1/6] batman-adv: remove bonding and interface alternating Simon Wunderlich
2013-09-04 16:27 ` [B.A.T.M.A.N.] [RFCv2 2/6] batman-adv: split tq information in neigh_node struct Simon Wunderlich
2013-09-13 13:23   ` Antonio Quartulli
2013-10-03 20:39     ` Simon Wunderlich
2013-09-04 16:27 ` [B.A.T.M.A.N.] [RFCv2 3/6] batman-adv: split out router from orig_node Simon Wunderlich
2013-09-22 20:47   ` Antonio Quartulli
2013-09-04 16:27 ` [B.A.T.M.A.N.] [RFCv2 4/6] batman-adv: add WiFi penalty Simon Wunderlich
2013-09-25 20:18   ` Antonio Quartulli
2013-09-04 16:27 ` [B.A.T.M.A.N.] [RFCv2 5/6] batman-adv: consider outgoing interface in OGM sending Simon Wunderlich
2013-10-01  9:00   ` Antonio Quartulli
2013-10-03 22:11     ` Simon Wunderlich
2013-09-04 16:27 ` [B.A.T.M.A.N.] [RFCv2 6/6] batman-adv: add bonding again Simon Wunderlich
2013-10-01  9:24   ` Antonio Quartulli
2013-10-03 22:53     ` Simon Wunderlich [this message]

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=20131003225317.GC9172@pandem0nium \
    --to=simon.wunderlich@s2003.tu-chemnitz.de \
    --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.