From: Simon Wunderlich <sw@simonwunderlich.de>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: Re: [B.A.T.M.A.N.] [PATCHv2 2/8] batman-adv: split tq information in neigh_node struct
Date: Tue, 5 Nov 2013 12:16:30 +0100 [thread overview]
Message-ID: <201311051216.30588.sw@simonwunderlich.de> (raw)
In-Reply-To: <20131101055333.GD15496@Linus-Debian>
Hey Linus,
Thanks for the comments! I applied your proposed changes/fixes and will include
them in the next patchset, a few comments below:
> > @@ -1171,15 +1232,19 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr
> > *ethhdr,
> >
> > }
> >
> > rcu_read_lock();
> >
> > - hlist_for_each_entry_rcu(tmp_neigh_node,
> > - &orig_node->neigh_list, list) {
> > - neigh_addr = tmp_neigh_node->addr;
> > - is_dup = batadv_test_bit(tmp_neigh_node->bat_iv.real_bits,
> > + hlist_for_each_entry_rcu(neigh_node, &orig_node->neigh_list, list) {
> > + neigh_ifinfo = batadv_neigh_ifinfo_new(neigh_node,
> > + if_outgoing);
>
> hm, not quite sure, but would a batadv_neigh_ifinfo_get() be
> sufficient here?
I don't think so. batadv_iv_ogm_update_seqnos() is called before
batadv_iv_ogm_orig_update() which is the other function to call _new(). We
need batadv_iv_ogm_update_seqnos() to call _new to create the ifinfo and put
the first mark in the bitfield.
> > +static void batadv_neigh_node_free_rcu(struct rcu_head *rcu)
> > +{
> > + struct hlist_node *node_tmp;
> > + struct batadv_neigh_node *neigh_node;
> > + struct batadv_neigh_ifinfo *neigh_ifinfo;
> > +
> > + neigh_node = container_of(rcu, struct batadv_neigh_node, rcu);
> > +
> > + hlist_for_each_entry_safe(neigh_ifinfo, node_tmp,
> > + &neigh_node->ifinfo_list, list) {
> > + batadv_neigh_ifinfo_free_ref_now(neigh_ifinfo);
> > + }
>
> two things are missing here: orig_node and if_incoming refcounters
> need to be decreased
>
This appears to be broken in the current code already:
* batadv_iv_ogm_neigh_new() calls batadv_neigh_node_new() and increases the
if_incoming refcount (shouldn't be that in batadv_neigh_node_new() instead?)
* orig_node does not get its refcounter increased in both functions
* both functions set hard_iface and orig_node within the neigh_node struct
(that seems to be redundant)
* the current code does not free_ref neigh->if_incoming
As we have a cyclic dependency here (neigh_node -> orig_node and vice versa),
I'm not sure if we add more problems by adding refcounting to the orig_node
here (when cleaning up, that is).
I'll therefore add the free_ref for if_incoming and keep the orig_node
refcounting as it is.
>
> why not simply using a "break" within the if-case here instead of the
> "!best" check and continuing to iterate over the list?
>
because we could have found a better neighbor then the previous "best", but
not yet the "best" of the whole list. We need to check the whole list to find
the best.
Thanks,
Simon
next prev parent reply other threads:[~2013-11-05 11:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-30 14:01 [B.A.T.M.A.N.] [PATCHv2 0/8] add network wide multi interface optimization Simon Wunderlich
2013-10-30 14:01 ` [B.A.T.M.A.N.] [PATCHv2 1/8] batman-adv: remove bonding and interface alternating Simon Wunderlich
2013-10-30 14:01 ` [B.A.T.M.A.N.] [PATCHv2 2/8] batman-adv: split tq information in neigh_node struct Simon Wunderlich
2013-10-30 16:33 ` Marek Lindner
2013-11-01 5:53 ` Linus Lüssing
2013-11-05 11:16 ` Simon Wunderlich [this message]
2013-11-05 0:13 ` Linus Lüssing
2013-10-30 14:01 ` [B.A.T.M.A.N.] [PATCHv2 3/8] batman-adv: split out router from orig_node Simon Wunderlich
2013-11-05 0:03 ` Linus Lüssing
2013-11-05 13:14 ` Simon Wunderlich
2013-11-05 0:17 ` Linus Lüssing
2013-10-30 14:01 ` [B.A.T.M.A.N.] [PATCHv2 4/8] batman-adv: add WiFi penalty Simon Wunderlich
2013-10-30 14:01 ` [B.A.T.M.A.N.] [PATCHv2 5/8] batman-adv: consider outgoing interface in OGM sending Simon Wunderlich
2013-10-30 14:01 ` [B.A.T.M.A.N.] [PATCHv2 6/8] batman-adv: add bonding again Simon Wunderlich
2013-10-30 14:01 ` [B.A.T.M.A.N.] [PATCHv2 7/8] batman-adv: add debugfs structure for information per interface Simon Wunderlich
2013-10-30 14:01 ` [B.A.T.M.A.N.] [PATCHv2 8/8] batman-adv: add debugfs support to view multiif tables Simon Wunderlich
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=201311051216.30588.sw@simonwunderlich.de \
--to=sw@simonwunderlich.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox