public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@idosch•org>
To: Jiri Pirko <jiri@resnulli•us>
Cc: netdev@vger•kernel.org, davem@davemloft•net, yotamg@mellanox•com,
	arkadis@mellanox•com, idosch@mellanox•com, eladr@mellanox•com,
	nogahf@mellanox•com, ogerlitz@mellanox•com
Subject: Re: [patch net 1/2] mlxsw: spectrum: Fix refcount bug on span entries
Date: Fri, 11 Nov 2016 14:49:28 +0200	[thread overview]
Message-ID: <20161111124928.dbxqswx6akatsjrt@splinter> (raw)
In-Reply-To: <1478859642-2918-2-git-send-email-jiri@resnulli.us>

On Fri, Nov 11, 2016 at 11:20:41AM +0100, Jiri Pirko wrote:
> From: Yotam Gigi <yotamg@mellanox•com>
> 
> When binding port to a newly created span entry, its refcount is set 0
> even though it has a bound port. That leeds to unexpected behaviour when

s/leeds/leads/

> the user tries to delete that port from the span entry.
> 
> Change the binding process to increase the refcount of the bound entry
> even if the entry is newly created, and add warning on the process of
> removing bound port from entry when its refcount is 0.
> 
> Fixes: 763b4b70afcd3 ("mlxsw: spectrum: Add support in matchall mirror TC offloading")

You only need the first 12 characters.

> Signed-off-by: Yotam Gigi <yotamg@mellanox•com>
> Signed-off-by: Jiri Pirko <jiri@mellanox•com>
> ---
>  drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
> index 1ec0a4c..d75c1ff 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
> @@ -269,17 +269,18 @@ static struct mlxsw_sp_span_entry
>  	struct mlxsw_sp_span_entry *span_entry;
>  
>  	span_entry = mlxsw_sp_span_entry_find(port);
> -	if (span_entry) {
> -		span_entry->ref_count++;
> -		return span_entry;
> -	}
> +	if (!span_entry)
> +		span_entry = mlxsw_sp_span_entry_create(port);
>  
> -	return mlxsw_sp_span_entry_create(port);
> +	span_entry->ref_count++;

mlxsw_sp_span_entry_create() can return NULL. You can look at
mlxsw_sp_fib_entry_get() for reference.

> +	return span_entry;
>  }
>  
>  static int mlxsw_sp_span_entry_put(struct mlxsw_sp *mlxsw_sp,
>  				   struct mlxsw_sp_span_entry *span_entry)
>  {
> +	WARN_ON(!span_entry->ref_count);
> +
>  	if (--span_entry->ref_count == 0)
>  		mlxsw_sp_span_entry_destroy(mlxsw_sp, span_entry);
>  	return 0;
> -- 
> 2.7.4
> 

  reply	other threads:[~2016-11-11 12:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-11 10:20 [patch net 0/2] mlxsw: Couple of fixes Jiri Pirko
2016-11-11 10:20 ` [patch net 1/2] mlxsw: spectrum: Fix refcount bug on span entries Jiri Pirko
2016-11-11 12:49   ` Ido Schimmel [this message]
2016-11-11 13:15     ` Jiri Pirko
2016-11-11 10:20 ` [patch net 2/2] mlxsw: spectrum_router: Correctly dump neighbour activity Jiri Pirko
2016-11-11 12:54   ` Ido Schimmel
2016-11-11 13:13     ` Jiri Pirko
2016-11-13 17:48 ` [patch net 0/2] mlxsw: Couple of fixes David Miller

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=20161111124928.dbxqswx6akatsjrt@splinter \
    --to=idosch@idosch$(echo .)org \
    --cc=arkadis@mellanox$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=eladr@mellanox$(echo .)com \
    --cc=idosch@mellanox$(echo .)com \
    --cc=jiri@resnulli$(echo .)us \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=nogahf@mellanox$(echo .)com \
    --cc=ogerlitz@mellanox$(echo .)com \
    --cc=yotamg@mellanox$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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