lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230413114636.GL17993@unreal>
Date:   Thu, 13 Apr 2023 14:46:36 +0300
From:   Leon Romanovsky <leon@...nel.org>
To:     Simon Horman <simon.horman@...igine.com>
Cc:     "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Steffen Klassert <steffen.klassert@...unet.com>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        netdev@...r.kernel.org, Saeed Mahameed <saeedm@...dia.com>,
        Raed Salem <raeds@...dia.com>, Emeel Hakim <ehakim@...dia.com>
Subject: Re: [PATCH net-next 05/10] net/mlx5e: Support IPsec RX packet
 offload in tunnel mode

On Tue, Apr 11, 2023 at 06:37:03PM +0200, Simon Horman wrote:
> On Mon, Apr 10, 2023 at 09:19:07AM +0300, Leon Romanovsky wrote:
> > From: Leon Romanovsky <leonro@...dia.com>
> > 
> > Extend mlx5 driver with logic to support IPsec RX packet offload
> > in tunnel mode.
> > 
> > Signed-off-by: Leon Romanovsky <leonro@...dia.com>
> 
> ...
> 
> > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c
> > index 980583fb1e52..8ecaf4100b9c 100644
> > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c
> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c
> > @@ -836,6 +836,60 @@ static int setup_modify_header(struct mlx5_core_dev *mdev, u32 val, u8 dir,
> >  	return 0;
> >  }
> >  
> > +static int
> > +setup_pkt_tunnel_reformat(struct mlx5_core_dev *mdev,
> > +			  struct mlx5_accel_esp_xfrm_attrs *attrs,
> > +			  struct mlx5_pkt_reformat_params *reformat_params)
> > +{
> > +	union {
> > +		struct {
> > +			u8 dmac[6];
> > +			u8 smac[6];
> > +			__be16 ethertype;
> > +		} __packed;
> > +		u8 raw[ETH_HLEN];
> > +	} __packed *mac_hdr;
> 
> Can struct ethhrd be used here?
> I think it has the same layout as the fields of the inner structure above.

Yes, it can, will change.

> And I don't think the union is giving us much: the raw field seems unused.

Thanks, it isn't needed here.

> 
> > +	char *reformatbf;
> > +	size_t bfflen;
> > +
> > +	bfflen = sizeof(*mac_hdr);
> > +
> > +	reformatbf = kzalloc(bfflen, GFP_KERNEL);
> 
> I'm not sure that reformatbf is providing much value.

It is more useful in next patch, where reformatbf will hold ESP, ipv4/6 and ETH
headers.

> Perhaps:
> 
> 	mac_hdr = kzalloc(bfflen, GFP_KERNEL);
> 
> > +	if (!reformatbf)
> > +		return -ENOMEM;
> > +
> > +	mac_hdr = (void *)reformatbf;
> 
> If you must cast, perhaps to the type of mac_hdr, which is not void *.

I'll change.

> 
> > +	switch (attrs->family) {
> > +	case AF_INET:
> > +		mac_hdr->ethertype = htons(ETH_P_IP);
> > +		break;
> > +	case AF_INET6:
> > +		mac_hdr->ethertype = htons(ETH_P_IPV6);
> > +		break;
> > +	default:
> > +		goto free_reformatbf;
> > +	}
> > +
> > +	ether_addr_copy(mac_hdr->dmac, attrs->dmac);
> > +	ether_addr_copy(mac_hdr->smac, attrs->smac);
> > +
> > +	switch (attrs->dir) {
> > +	case XFRM_DEV_OFFLOAD_IN:
> > +		reformat_params->type = MLX5_REFORMAT_TYPE_L3_ESP_TUNNEL_TO_L2;
> > +		break;
> > +	default:
> > +		goto free_reformatbf;
> > +	}
> > +
> > +	reformat_params->size = bfflen;
> > +	reformat_params->data = reformatbf;
> > +	return 0;
> > +
> > +free_reformatbf:
> > +	kfree(reformatbf);
> > +	return -EINVAL;
> > +}
> 
> ...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ