netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <simon.horman@corigine.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Jakub Kicinski <kuba@kernel.org>, Emeel Hakim <ehakim@nvidia.com>,
	Eric Dumazet <edumazet@google.com>,
	netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
	Raed Salem <raeds@nvidia.com>, Saeed Mahameed <saeedm@nvidia.com>,
	Steffen Klassert <steffen.klassert@secunet.com>
Subject: Re: [PATCH net-next 3/5] net/mlx5e: Compare all fields in IPv6 address
Date: Thu, 20 Apr 2023 16:35:53 +0200	[thread overview]
Message-ID: <ZEFNyb4zAA/2rh9s@corigine.com> (raw)
In-Reply-To: <ZEEqbUinuteJ148u@corigine.com>

On Thu, Apr 20, 2023 at 02:05:01PM +0200, Simon Horman wrote:
> On Thu, Apr 20, 2023 at 02:52:43PM +0300, Leon Romanovsky wrote:
> > On Thu, Apr 20, 2023 at 01:09:23PM +0200, Simon Horman wrote:
> > > On Thu, Apr 20, 2023 at 11:02:49AM +0300, Leon Romanovsky wrote:
> > > > From: Leon Romanovsky <leonro@nvidia.com>
> > > > 
> > > > Fix size argument in memcmp to compare whole IPv6 address.
> > > > 
> > > > Fixes: b3beba1fb404 ("net/mlx5e: Allow policies with reqid 0, to support IKE policy holes")
> > > > Reviewed-by: Raed Salem <raeds@nvidia.com>
> > > > Reviewed-by: Emeel Hakim <ehakim@nvidia.com>
> > > > Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> > > > ---
> > > >  drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h
> > > > index f7f7c09d2b32..4e9887171508 100644
> > > > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h
> > > > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h
> > > > @@ -287,7 +287,7 @@ static inline bool addr6_all_zero(__be32 *addr6)
> > > >  {
> > > >  	static const __be32 zaddr6[4] = {};
> > > >  
> > > > -	return !memcmp(addr6, zaddr6, sizeof(*zaddr6));
> > > > +	return !memcmp(addr6, zaddr6, sizeof(zaddr6));
> > > 
> > > 1. Perhaps array_size() is appropriate here?
> > 
> > It is overkill here, sizeof(zaddr6) is constant and can't overflow.
> 
> Maybe, but the original code had a bug because using sizeof()
> directly is error prone.

Sorry, just to clarify.
I now realise that ARRAY_SIZE() is what I meant to suggest earlier.

> >   238 /**
> >   239  * array_size() - Calculate size of 2-dimensional array.
> >   240  * @a: dimension one
> >   241  * @b: dimension two
> >   242  *
> >   243  * Calculates size of 2-dimensional array: @a * @b.
> >   244  *
> >   245  * Returns: number of bytes needed to represent the array or SIZE_MAX on
> >   246  * overflow.
> >   247  */
> >   248 #define array_size(a, b)        size_mul(a, b)
> > 
> > > 2. It's a shame that ipv6_addr_any() or some other common helper
> > >    can't be used.
> > 
> > I didn't use ipv6_addr_any() as it required from me to cast "__be32 *addr6"
> > to be "struct in6_addr *" just to replace one line memcmp to another one
> > line function.
> > 
> > Do you want me to post this code instead?
> 
> No :)
> 
> I don't have a strong desire for churn.
> Just for correct code.
> 
> As your patch is correct, it is fine by me in the current form.
> 
> Reviewed-by: Simon Horman <simon.horman@corigine.com>
> 

  reply	other threads:[~2023-04-20 14:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-20  8:02 [PATCH net-next 0/5] Fixes to mlx5 IPsec implementation Leon Romanovsky
2023-04-20  8:02 ` [PATCH net-next 1/5] net/mlx5e: Fix FW error while setting IPsec policy block action Leon Romanovsky
2023-04-20 11:23   ` Simon Horman
2023-04-20  8:02 ` [PATCH net-next 2/5] net/mlx5e: Don't overwrite extack message returned from IPsec SA validator Leon Romanovsky
2023-04-20 11:24   ` Simon Horman
2023-04-20  8:02 ` [PATCH net-next 3/5] net/mlx5e: Compare all fields in IPv6 address Leon Romanovsky
2023-04-20 11:09   ` Simon Horman
2023-04-20 11:52     ` Leon Romanovsky
2023-04-20 12:05       ` Simon Horman
2023-04-20 14:35         ` Simon Horman [this message]
2023-04-20 17:13           ` Leon Romanovsky
2023-04-21  9:04             ` Simon Horman
2023-04-20  8:02 ` [PATCH net-next 4/5] net/mlx5e: Properly release work data structure Leon Romanovsky
2023-04-20 11:23   ` Simon Horman
2023-04-20  8:02 ` [PATCH net-next 5/5] net/mlx5e: Refactor duplicated code in mlx5e_ipsec_init_macs Leon Romanovsky
2023-04-20 11:22   ` Simon Horman
2023-04-21 11:00 ` [PATCH net-next 0/5] Fixes to mlx5 IPsec implementation patchwork-bot+netdevbpf

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=ZEFNyb4zAA/2rh9s@corigine.com \
    --to=simon.horman@corigine.com \
    --cc=edumazet@google.com \
    --cc=ehakim@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=raeds@nvidia.com \
    --cc=saeedm@nvidia.com \
    --cc=steffen.klassert@secunet.com \
    /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;
as well as URLs for NNTP newsgroup(s).