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.] [PATCHv2 1/4] batman-adv: add reference counting for type batadv_tt_orig_list_entry
Date: Sat, 30 Jun 2012 11:55:25 +0200 [thread overview]
Message-ID: <201206301155.25761.lindner_marek@yahoo.de> (raw)
In-Reply-To: <1340785387-3821-2-git-send-email-ordex@autistici.org>
On Wednesday, June 27, 2012 10:23:04 Antonio Quartulli wrote:
> @@ -639,12 +641,17 @@ batadv_tt_global_entry_has_orig(const struct
> batadv_tt_global_entry *entry, rcu_read_lock();
> head = &entry->orig_list;
> hlist_for_each_entry_rcu(tmp_orig_entry, node, head, list) {
> - if (tmp_orig_entry->orig_node == orig_node) {
> - found = true;
> - break;
> - }
> + if (tmp_orig_entry->orig_node != orig_node)
> + continue;
> + if (!atomic_inc_not_zero(&tmp_orig_entry->refcount))
> + continue;
> +
> + found = true;
> + batadv_tt_orig_list_entry_free_ref(tmp_orig_entry);
Instead of having this weird increment and immediate decrement this patch
should add a general "orig_entry_get" / "orig_entry_find" function like we do
everywhere else. Check the following functions to get an idea:
* batadv_primary_if_get_selected()
* batadv_orig_node_get_router()
* batadv_tt_hash_find()
> @@ -663,6 +670,7 @@ batadv_tt_global_add_orig_entry(struct
> batadv_tt_global_entry *tt_global_entry, atomic_inc(&orig_node->tt_size);
> orig_entry->orig_node = orig_node;
> orig_entry->ttvn = ttvn;
> + atomic_set(&orig_entry->refcount, 0);
This looks extremely broken. We init with 0, never increase the counter and
when we should free, we decrease first before checking if it is 0 ?
Cheers,
Marek
next prev parent reply other threads:[~2012-06-30 9:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-27 8:23 [B.A.T.M.A.N.] [PATCHv2 0/5] new feature: Speedy Join 2012-06-27 Antonio Quartulli
2012-06-27 8:23 ` [B.A.T.M.A.N.] [PATCHv2 1/4] batman-adv: add reference counting for type batadv_tt_orig_list_entry Antonio Quartulli
2012-06-30 9:55 ` Marek Lindner [this message]
2012-06-30 12:08 ` Antonio Quartulli
2012-06-27 8:23 ` [B.A.T.M.A.N.] [PATCHv2 2/4] batman-adv: implement batadv_tt_global_entry_get_orig() Antonio Quartulli
2012-06-30 9:56 ` Marek Lindner
2012-06-27 8:23 ` [B.A.T.M.A.N.] [PATCHv2 3/4] batman-adv: detect not yet announced clients Antonio Quartulli
2012-06-30 10:01 ` Marek Lindner
2012-06-30 12:12 ` Antonio Quartulli
2012-06-27 8:23 ` [B.A.T.M.A.N.] [PATCHv2 4/4] batman-adv: change interface_rx to get orig node 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=201206301155.25761.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox