All of lore.kernel.org
 help / color / mirror / Atom feed
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.] [PATCHv3 2/9] batman-adv: make struct batadv_orig_node algorithm agnostic
Date: Fri, 16 Aug 2013 12:01:36 +0800	[thread overview]
Message-ID: <201308161201.36653.lindner_marek@yahoo.de> (raw)
In-Reply-To: <1376376232-2178-3-git-send-email-ordex@autistici.org>

On Tuesday, August 13, 2013 14:43:45 Antonio Quartulli wrote:
> From: Antonio Quartulli <antonio@open-mesh.com>
> 
> some of the struct batadv_orig_node members are B.A.T.M.A.N. IV
> specific and therefore they are moved in a algorithm specific
> substruct in order to make batadv_orig_node routing algorithm
> agnostic
> 
> Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
> ---
>  bat_iv_ogm.c | 93
> ++++++++++++++++++++++++++++++++++++++++++------------------ originator.c
> | 77 ++++++++++++++++++------------------------------- originator.h |  2
> +-
>  types.h      | 30 +++++++++++++-------
>  4 files changed, 114 insertions(+), 88 deletions(-)
> 
> diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
> index a0b11b0..b8114d6 100644
> --- a/bat_iv_ogm.c
> +++ b/bat_iv_ogm.c
> @@ -87,6 +87,42 @@ static uint8_t batadv_ring_buffer_avg(const uint8_t
> lq_recv[]) return (uint8_t)(sum / count);
>  }
> 
> +static struct batadv_orig_node *
> +batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const uint8_t *addr)
> +{
> +	struct batadv_orig_node *orig_node;
> +	int size;
> +
> +	orig_node = batadv_orig_hash_find(bat_priv, addr);
> +	if (orig_node)
> +		return orig_node;
> +
> +	orig_node = batadv_orig_node_new(bat_priv, addr);
> +	if (!orig_node)
> +		return NULL;
> +
> +	spin_lock_init(&orig_node->bat_iv.ogm_cnt_lock);
> +
> +	size = bat_priv->num_ifaces * sizeof(unsigned long) * BATADV_NUM_WORDS;
> +	orig_node->bat_iv.bcast_own = kzalloc(size, GFP_ATOMIC);
> +	if (!orig_node->bat_iv.bcast_own)
> +		goto free_orig_node;
> +
> +	size = bat_priv->num_ifaces * sizeof(uint8_t);
> +	orig_node->bat_iv.bcast_own_sum = kzalloc(size, GFP_ATOMIC);
> +	if (!orig_node->bat_iv.bcast_own_sum)
> +		goto free_bcast_own;
> +
> +	return orig_node;
> +
> +free_bcast_own:
> +	kfree(orig_node->bat_iv.bcast_own);
> +free_orig_node:
> +	batadv_orig_node_free_ref(orig_node);
> +
> +	return NULL;
> +}

Kernel doc ?


> @@ -297,18 +297,13 @@ void batadv_originator_free(struct batadv_priv
> *bat_priv) /* this function finds or creates an originator entry for the
> given * address if it does not exits
>   */
> -struct batadv_orig_node *batadv_get_orig_node(struct batadv_priv
> *bat_priv, +struct batadv_orig_node *batadv_orig_node_new(struct
> batadv_priv *bat_priv, const uint8_t *addr)

When you are writing the kernel doc don't forget that you changed the behavior 
of this function.


> @@ -356,37 +350,21 @@ struct batadv_orig_node *batadv_get_orig_node(struct
> batadv_priv *bat_priv, */
>  	batadv_orig_node_vlan_free_ref(vlan);
> 
> -	size = bat_priv->num_ifaces * sizeof(unsigned long) * BATADV_NUM_WORDS;
> -
> -	orig_node->bcast_own = kzalloc(size, GFP_ATOMIC);
> -	if (!orig_node->bcast_own)
> -		goto free_vlan;
> -
> -	size = bat_priv->num_ifaces * sizeof(uint8_t);
> -	orig_node->bcast_own_sum = kzalloc(size, GFP_ATOMIC);
> -
>  	for (i = 0; i < BATADV_FRAG_BUFFER_COUNT; i++) {
>  		INIT_HLIST_HEAD(&orig_node->fragments[i].head);
>  		spin_lock_init(&orig_node->fragments[i].lock);
>  		orig_node->fragments[i].size = 0;
>  	}
> 
> -	if (!orig_node->bcast_own_sum)
> -		goto free_bcast_own;
> -
>  	hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig,
>  				     batadv_choose_orig, orig_node,
>  				     &orig_node->hash_entry);
> -	if (hash_added != 0)
> -		goto free_bcast_own_sum;
> +	if (hash_added != 0) {
> +		kfree(orig_node);
> +		return NULL;
> +	}

Why not go to free_orig_node ?

Cheers,
Marek

  reply	other threads:[~2013-08-16  4:01 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-13  6:43 [B.A.T.M.A.N.] [PATCHv3 0/9] Improving the routing protocol abstraction Antonio Quartulli
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 1/9] batman-adv: make struct batadv_neigh_node algorithm agnostic Antonio Quartulli
2013-08-16  3:46   ` Marek Lindner
2013-08-16  6:27     ` Antonio Quartulli
2013-08-16  9:27       ` Marek Lindner
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 2/9] batman-adv: make struct batadv_orig_node " Antonio Quartulli
2013-08-16  4:01   ` Marek Lindner [this message]
2013-08-16  6:29     ` Antonio Quartulli
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 3/9] batman-adv: add bat_orig_print function API Antonio Quartulli
2013-08-16  4:05   ` Marek Lindner
2013-08-16  6:30     ` Antonio Quartulli
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 4/9] batman-adv: add bat_metric_get API function Antonio Quartulli
2013-08-26  1:44   ` Marek Lindner
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 5/9] batman-adv: add bat_metric_is_equiv_or_better " Antonio Quartulli
2013-08-26  1:49   ` Marek Lindner
2013-08-26  6:37     ` Antonio Quartulli
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 6/9] batman-adv: adapt bonding to use the new API functions Antonio Quartulli
2013-08-26  3:11   ` Marek Lindner
2013-08-27 16:33     ` Antonio Quartulli
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 7/9] batman-adv: adapt the neighbor purging routine " Antonio Quartulli
2013-08-26  3:29   ` Marek Lindner
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 8/9] batman-adv: provide orig_node routing API Antonio Quartulli
2013-08-26  3:31   ` Marek Lindner
2013-08-13  6:43 ` [B.A.T.M.A.N.] [PATCHv3 9/9] batman-adv: adapt the TT component to use the new API functions 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=201308161201.36653.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 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.