Subject: Re: [PATCH net 6/8] net/mlx5e: Properly match IPsec subnet addresses

From: Leon Romanovsky <[email-masked]>
Date: Wed, 15 Jan 2025 10:39:55 +0200

On Tue, Jan 14, 2025 at 06:37:35PM -0800, Jakub Kicinski wrote:
> On Mon, 13 Jan 2025 17:40:52 +0200 Tariq Toukan wrote:
> > +static void addr4_to_mask(__be32 *addr, __be32 *mask)
> > +{
> > +	int i;
> > +
> > +	*mask = 0;
> > +	for (i = 0; i < 4; i++)
> > +		*mask |= ((*addr >> 8 * i) & 0xFF) ? (0xFF << 8 * i) : 0;
> 
> sparse is unimpressed with the lack of byteswaps here.
> 
> drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c:1159:28: warning: restricted __be32 degrades to integer
> drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c:1159:23: warning: invalid assignment: |=
> drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c:1159:23:    left side has type restricted __be32
> drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c:1159:23:    right side has type int

Strange that I didn't get such errors from kbuild, I kept this patch in
my tree for approximately month, before we sent it.

> 
> 
> Maybe just force cast to u32 inside the helper, and add a comment why?
> Or just byte swap.

Thanks, will try.

> 
> Also from the word mask and subnet in the commit message it sounds like
> you are shooting for a prefix. But this does "byte enable" kind of
> thing :S Think 10.0.55.0/24. Maybe mention if this is intentional in
> a comment, too.

It is not essential, I need to take into account subnet too.

Tariq, please drop this patch for now.

Thanks