public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Marek Lindner <mareklindner@neomailbox.ch>
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 next] batman-adv: avoid potential race condition when adding a new neighbour
Date: Mon, 27 Jan 2014 16:10:29 +0800	[thread overview]
Message-ID: <5373996.23YD93TvXH@diderot> (raw)
In-Reply-To: <1390553883-1940-1-git-send-email-antonio@meshcoding.com>

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

On Friday 24 January 2014 09:58:03 Antonio Quartulli wrote:
> @@ -281,14 +281,23 @@ batadv_iv_ogm_neigh_new(struct batadv_hard_iface
> *hard_iface, neigh_node->orig_node = orig_neigh;
>  	neigh_node->if_incoming = hard_iface;
> 
> -	batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
> -		   "Creating new neighbor %pM for orig_node %pM on interface %s\n",
> -		   neigh_addr, orig_node->orig, hard_iface->net_dev->name);
> -
>  	spin_lock_bh(&orig_node->neigh_list_lock);
> -	hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list);
> +	tmp_neigh_node = batadv_neigh_node_get(orig_node, hard_iface,
> +					       neigh_addr);
> +	if (!tmp_neigh_node) {
> +		hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list);
> +	} else {
> +		kfree(neigh_node);
> +		neigh_node = tmp_neigh_node;
> +	}

What about hard_iface->refcount ?


>  /**
> + * batadv_neigh_node_get - retrieve a neighbour from the list
> + * @orig_node: originator which the neighbour belongs to
> + * @hard_iface: the interface where this neighbour is connected to
> + * @addr: the address of the neighbour
> + *
> + * Looks for and possibly return a neighbour belonging to this originator
> list + * which is connected through the provided hard interface.

'Looks and return' does not work. Either 'look and return' or 'looks and 
returns'.

Cheers,
Marek

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

  reply	other threads:[~2014-01-27  8:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-24  8:58 [B.A.T.M.A.N.] [PATCH next] batman-adv: avoid potential race condition when adding a new neighbour Antonio Quartulli
2014-01-27  8:10 ` Marek Lindner [this message]
2014-01-27  8:22   ` 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=5373996.23YD93TvXH@diderot \
    --to=mareklindner@neomailbox.ch \
    --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