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] [day] [month] [year] [list]
Message-ID: <Y6GotOCyKgxr1Xtg@praczyns-desk3>
Date:   Tue, 20 Dec 2022 13:21:08 +0100
From:   Piotr Raczynski <piotr.raczynski@...el.com>
To:     Yevhen Orlov <yevhen.orlov@...ision.eu>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        Volodymyr Mytnyk <volodymyr.mytnyk@...ision.eu>,
        Taras Chornyi <taras.chornyi@...ision.eu>,
        Mickey Rachamim <mickeyr@...vell.com>,
        Serhiy Pshyk <serhiy.pshyk@...ision.eu>,
        "David S. Miller" <davem@...emloft.net>,
        "Eric Dumazet" <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>, Andrew Lunn <andrew@...n.ch>,
        Stephen Hemminger <stephen@...workplumber.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net-next v1 1/2] net: marvell: prestera: Add router ipv6
 ABI

On Sun, Dec 18, 2022 at 11:16:40PM +0100, Yevhen Orlov wrote:
> There are only lpm add/del for ipv6 needed.
> Nexthops indexes shared with ipv4.
> 
> Limitations:
> - Only "local" and "main" tables supported
> - Only generic interfaces supported for router (no bridges or vlans)
> 
Yevhen, currently net-next is closed.

Please repost when net-next reopens after Jan 2nd.

> Co-developed-by: Taras Chornyi <taras.chornyi@...ision.eu>
> Signed-off-by: Taras Chornyi <taras.chornyi@...ision.eu>
> Co-developed-by: Elad Nachman <enachman@...vell.com>
> Signed-off-by: Elad Nachman <enachman@...vell.com>
> Signed-off-by: Yevhen Orlov <yevhen.orlov@...ision.eu>
> ---
>  .../ethernet/marvell/prestera/prestera_hw.c   | 34 +++++++++++++++++++
>  .../ethernet/marvell/prestera/prestera_hw.h   |  4 +++
>  .../marvell/prestera/prestera_router_hw.c     | 33 ++++++++++++++----
>  3 files changed, 65 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_hw.c b/drivers/net/ethernet/marvell/prestera/prestera_hw.c
> index fc6f7d2746e8..13341056599a 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera_hw.c
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_hw.c
> @@ -540,6 +540,11 @@ struct prestera_msg_iface {
>  	u8 __pad[3];
>  };
>  
> +enum prestera_msg_ip_addr_v {
> +	PRESTERA_MSG_IPV4 = 0,
> +	PRESTERA_MSG_IPV6
> +};
> +
>  struct prestera_msg_ip_addr {
>  	union {
>  		__be32 ipv4;
> @@ -2088,6 +2093,35 @@ int prestera_hw_lpm_del(struct prestera_switch *sw, u16 vr_id,
>  			    sizeof(req));
>  }
>  
> +int prestera_hw_lpm6_add(struct prestera_switch *sw, u16 vr_id,
> +			 __u8 *dst, u32 dst_len, u32 grp_id)
> +{
> +	struct prestera_msg_lpm_req req;
> +
> +	req.dst.v = PRESTERA_MSG_IPV6;
> +	memcpy(&req.dst.u.ipv6, dst, 16);
> +	req.dst_len = __cpu_to_le32(dst_len);
> +	req.vr_id = __cpu_to_le16(vr_id);
> +	req.grp_id = __cpu_to_le32(grp_id);
> +
> +	return prestera_cmd(sw, PRESTERA_CMD_TYPE_ROUTER_LPM_ADD, &req.cmd,
> +			    sizeof(req));
> +}
> +
> +int prestera_hw_lpm6_del(struct prestera_switch *sw, u16 vr_id,
> +			 __u8 *dst, u32 dst_len)
> +{
> +	struct prestera_msg_lpm_req req;
> +
> +	req.dst.v = PRESTERA_MSG_IPV6;
> +	memcpy(&req.dst.u.ipv6, dst, 16);
> +	req.dst_len = __cpu_to_le32(dst_len);
> +	req.vr_id = __cpu_to_le16(vr_id);
> +
> +	return prestera_cmd(sw, PRESTERA_CMD_TYPE_ROUTER_LPM_DELETE, &req.cmd,
> +			    sizeof(req));
> +}
> +
>  int prestera_hw_nh_entries_set(struct prestera_switch *sw, int count,
>  			       struct prestera_neigh_info *nhs, u32 grp_id)
>  {
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_hw.h b/drivers/net/ethernet/marvell/prestera/prestera_hw.h
> index 0a929279e1ce..8769be6752bc 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera_hw.h
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_hw.h
> @@ -266,6 +266,10 @@ int prestera_hw_lpm_add(struct prestera_switch *sw, u16 vr_id,
>  			__be32 dst, u32 dst_len, u32 grp_id);
>  int prestera_hw_lpm_del(struct prestera_switch *sw, u16 vr_id,
>  			__be32 dst, u32 dst_len);
> +int prestera_hw_lpm6_add(struct prestera_switch *sw, u16 vr_id,
> +			 __u8 *dst, u32 dst_len, u32 grp_id);
> +int prestera_hw_lpm6_del(struct prestera_switch *sw, u16 vr_id,
> +			 __u8 *dst, u32 dst_len);
>  
>  /* NH API */
>  int prestera_hw_nh_entries_set(struct prestera_switch *sw, int count,
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_router_hw.c b/drivers/net/ethernet/marvell/prestera/prestera_router_hw.c
> index 02faaea2aefa..1c6d0cdbdfdf 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera_router_hw.c
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_router_hw.c
> @@ -581,8 +581,16 @@ static void __prestera_fib_node_destruct(struct prestera_switch *sw,
>  	struct prestera_vr *vr;
>  
>  	vr = fib_node->info.vr;
> -	prestera_hw_lpm_del(sw, vr->hw_vr_id, fib_node->key.addr.u.ipv4,
> -			    fib_node->key.prefix_len);
> +	if (fib_node->key.addr.v == PRESTERA_IPV4)
> +		prestera_hw_lpm_del(sw, vr->hw_vr_id, fib_node->key.addr.u.ipv4,
> +				    fib_node->key.prefix_len);
> +	else if (fib_node->key.addr.v == PRESTERA_IPV6)
> +		prestera_hw_lpm6_del(sw, vr->hw_vr_id,
> +				     (u8 *)&fib_node->key.addr.u.ipv6.s6_addr,
> +				     fib_node->key.prefix_len);
> +	else
> +		WARN(1, "Invalid address version. Memory corrupted?");
> +
>  	switch (fib_node->info.type) {
>  	case PRESTERA_FIB_TYPE_UC_NH:
>  		prestera_nexthop_group_put(sw, fib_node->info.nh_grp);
> @@ -661,8 +669,16 @@ prestera_fib_node_create(struct prestera_switch *sw,
>  		goto err_nh_grp_get;
>  	}
>  
> -	err = prestera_hw_lpm_add(sw, vr->hw_vr_id, key->addr.u.ipv4,
> -				  key->prefix_len, grp_id);
> +	if (key->addr.v == PRESTERA_IPV4)
> +		err = prestera_hw_lpm_add(sw, vr->hw_vr_id, key->addr.u.ipv4,
> +					  key->prefix_len, grp_id);
> +	else if (key->addr.v == PRESTERA_IPV6)
> +		err = prestera_hw_lpm6_add(sw, vr->hw_vr_id,
> +					   (u8 *)&key->addr.u.ipv6.s6_addr,
> +					   key->prefix_len, grp_id);
> +	else
> +		WARN(1, "Invalid address version. Memory corrupted?");
> +
>  	if (err)
>  		goto err_lpm_add;
>  
> @@ -674,8 +690,13 @@ prestera_fib_node_create(struct prestera_switch *sw,
>  	return fib_node;
>  
>  err_ht_insert:
> -	prestera_hw_lpm_del(sw, vr->hw_vr_id, key->addr.u.ipv4,
> -			    key->prefix_len);
> +	if (key->addr.v == PRESTERA_IPV4)
> +		prestera_hw_lpm_del(sw, vr->hw_vr_id, key->addr.u.ipv4,
> +				    key->prefix_len);
> +	else if (key->addr.v == PRESTERA_IPV6)
> +		prestera_hw_lpm6_del(sw, vr->hw_vr_id,
> +				     (u8 *)&key->addr.u.ipv6.s6_addr,
> +				     key->prefix_len);
>  err_lpm_add:
>  	if (fib_type == PRESTERA_FIB_TYPE_UC_NH)
>  		prestera_nexthop_group_put(sw, fib_node->info.nh_grp);
> -- 
> 2.17.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ