DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] examples/ipsec-secgw: fix zero address in ethernet header
@ 2023-03-30 10:09 Rahul Bhansali
  2023-05-16  4:16 ` Rahul Bhansali
  2023-05-16  7:02 ` Akhil Goyal
  0 siblings, 2 replies; 4+ messages in thread
From: Rahul Bhansali @ 2023-03-30 10:09 UTC (permalink / raw)
  To: dev, Radu Nicolau, Akhil Goyal; +Cc: Rahul Bhansali

During port init, src address stored in ethaddr_tbl is typecast
which violates the stric-aliasing rule and not reflecting
the updated source address in processed packets too.

Fixes: 6eb3ba0399 ("examples/ipsec-secgw: support poll mode NEON LPM lookup")

Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
---
 examples/ipsec-secgw/ipsec-secgw.c | 20 ++++++++++----------
 examples/ipsec-secgw/ipsec-secgw.h |  2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index d2d9d85b4a..029749e522 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -99,10 +99,10 @@ uint32_t qp_desc_nb = 2048;
 #define MTU_TO_FRAMELEN(x)	((x) + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)
 
 struct ethaddr_info ethaddr_tbl[RTE_MAX_ETHPORTS] = {
-	{ 0, ETHADDR(0x00, 0x16, 0x3e, 0x7e, 0x94, 0x9a) },
-	{ 0, ETHADDR(0x00, 0x16, 0x3e, 0x22, 0xa1, 0xd9) },
-	{ 0, ETHADDR(0x00, 0x16, 0x3e, 0x08, 0x69, 0x26) },
-	{ 0, ETHADDR(0x00, 0x16, 0x3e, 0x49, 0x9e, 0xdd) }
+	{ {{0}}, {{0x00, 0x16, 0x3e, 0x7e, 0x94, 0x9a}} },
+	{ {{0}}, {{0x00, 0x16, 0x3e, 0x22, 0xa1, 0xd9}} },
+	{ {{0}}, {{0x00, 0x16, 0x3e, 0x08, 0x69, 0x26}} },
+	{ {{0}}, {{0x00, 0x16, 0x3e, 0x49, 0x9e, 0xdd}} }
 };
 
 struct offloads tx_offloads;
@@ -1427,9 +1427,8 @@ add_dst_ethaddr(uint16_t port, const struct rte_ether_addr *addr)
 	if (port >= RTE_DIM(ethaddr_tbl))
 		return -EINVAL;
 
-	ethaddr_tbl[port].dst = ETHADDR_TO_UINT64(addr);
-	rte_ether_addr_copy((struct rte_ether_addr *)&ethaddr_tbl[port].dst,
-			    (struct rte_ether_addr *)(val_eth + port));
+	rte_ether_addr_copy(addr, &ethaddr_tbl[port].dst);
+	rte_ether_addr_copy(addr, (struct rte_ether_addr *)(val_eth + port));
 	return 0;
 }
 
@@ -1907,11 +1906,12 @@ port_init(uint16_t portid, uint64_t req_rx_offloads, uint64_t req_tx_offloads,
 			"Error getting MAC address (port %u): %s\n",
 			portid, rte_strerror(-ret));
 
-	ethaddr_tbl[portid].src = ETHADDR_TO_UINT64(&ethaddr);
+	rte_ether_addr_copy(&ethaddr, &ethaddr_tbl[portid].src);
 
-	rte_ether_addr_copy((struct rte_ether_addr *)&ethaddr_tbl[portid].dst,
+	rte_ether_addr_copy(&ethaddr_tbl[portid].dst,
 			    (struct rte_ether_addr *)(val_eth + portid));
-	rte_ether_addr_copy((struct rte_ether_addr *)&ethaddr_tbl[portid].src,
+
+	rte_ether_addr_copy(&ethaddr_tbl[portid].src,
 			    (struct rte_ether_addr *)(val_eth + portid) + 1);
 
 	print_ethaddr("Address: ", &ethaddr);
diff --git a/examples/ipsec-secgw/ipsec-secgw.h b/examples/ipsec-secgw/ipsec-secgw.h
index 0e0012d058..53665adf03 100644
--- a/examples/ipsec-secgw/ipsec-secgw.h
+++ b/examples/ipsec-secgw/ipsec-secgw.h
@@ -84,7 +84,7 @@ struct ipsec_traffic_nb {
 
 /* port/source ethernet addr and destination ethernet addr */
 struct ethaddr_info {
-	uint64_t src, dst;
+	struct rte_ether_addr src, dst;
 };
 
 struct ipsec_spd_stats {
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] examples/ipsec-secgw: fix zero address in ethernet header
  2023-03-30 10:09 [PATCH] examples/ipsec-secgw: fix zero address in ethernet header Rahul Bhansali
@ 2023-05-16  4:16 ` Rahul Bhansali
  2023-05-16  7:02 ` Akhil Goyal
  1 sibling, 0 replies; 4+ messages in thread
From: Rahul Bhansali @ 2023-05-16  4:16 UTC (permalink / raw)
  To: dev, Radu Nicolau, Akhil Goyal

Ping.

> -----Original Message-----
> From: Rahul Bhansali <rbhansali@marvell.com>
> Sent: Thursday, March 30, 2023 3:39 PM
> To: dev@dpdk.org; Radu Nicolau <radu.nicolau@intel.com>; Akhil Goyal
> <gakhil@marvell.com>
> Cc: Rahul Bhansali <rbhansali@marvell.com>
> Subject: [PATCH] examples/ipsec-secgw: fix zero address in ethernet header
> 
> During port init, src address stored in ethaddr_tbl is typecast which violates the
> stric-aliasing rule and not reflecting the updated source address in processed
> packets too.
> 
> Fixes: 6eb3ba0399 ("examples/ipsec-secgw: support poll mode NEON LPM
> lookup")
> 
> Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
> ---
>  examples/ipsec-secgw/ipsec-secgw.c | 20 ++++++++++----------
> examples/ipsec-secgw/ipsec-secgw.h |  2 +-
>  2 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-
> secgw/ipsec-secgw.c
> index d2d9d85b4a..029749e522 100644
> --- a/examples/ipsec-secgw/ipsec-secgw.c
> +++ b/examples/ipsec-secgw/ipsec-secgw.c
> @@ -99,10 +99,10 @@ uint32_t qp_desc_nb = 2048;
>  #define MTU_TO_FRAMELEN(x)	((x) + RTE_ETHER_HDR_LEN +
> RTE_ETHER_CRC_LEN)
> 
>  struct ethaddr_info ethaddr_tbl[RTE_MAX_ETHPORTS] = {
> -	{ 0, ETHADDR(0x00, 0x16, 0x3e, 0x7e, 0x94, 0x9a) },
> -	{ 0, ETHADDR(0x00, 0x16, 0x3e, 0x22, 0xa1, 0xd9) },
> -	{ 0, ETHADDR(0x00, 0x16, 0x3e, 0x08, 0x69, 0x26) },
> -	{ 0, ETHADDR(0x00, 0x16, 0x3e, 0x49, 0x9e, 0xdd) }
> +	{ {{0}}, {{0x00, 0x16, 0x3e, 0x7e, 0x94, 0x9a}} },
> +	{ {{0}}, {{0x00, 0x16, 0x3e, 0x22, 0xa1, 0xd9}} },
> +	{ {{0}}, {{0x00, 0x16, 0x3e, 0x08, 0x69, 0x26}} },
> +	{ {{0}}, {{0x00, 0x16, 0x3e, 0x49, 0x9e, 0xdd}} }
>  };
> 
>  struct offloads tx_offloads;
> @@ -1427,9 +1427,8 @@ add_dst_ethaddr(uint16_t port, const struct
> rte_ether_addr *addr)
>  	if (port >= RTE_DIM(ethaddr_tbl))
>  		return -EINVAL;
> 
> -	ethaddr_tbl[port].dst = ETHADDR_TO_UINT64(addr);
> -	rte_ether_addr_copy((struct rte_ether_addr *)&ethaddr_tbl[port].dst,
> -			    (struct rte_ether_addr *)(val_eth + port));
> +	rte_ether_addr_copy(addr, &ethaddr_tbl[port].dst);
> +	rte_ether_addr_copy(addr, (struct rte_ether_addr *)(val_eth + port));
>  	return 0;
>  }
> 
> @@ -1907,11 +1906,12 @@ port_init(uint16_t portid, uint64_t req_rx_offloads,
> uint64_t req_tx_offloads,
>  			"Error getting MAC address (port %u): %s\n",
>  			portid, rte_strerror(-ret));
> 
> -	ethaddr_tbl[portid].src = ETHADDR_TO_UINT64(&ethaddr);
> +	rte_ether_addr_copy(&ethaddr, &ethaddr_tbl[portid].src);
> 
> -	rte_ether_addr_copy((struct rte_ether_addr *)&ethaddr_tbl[portid].dst,
> +	rte_ether_addr_copy(&ethaddr_tbl[portid].dst,
>  			    (struct rte_ether_addr *)(val_eth + portid));
> -	rte_ether_addr_copy((struct rte_ether_addr *)&ethaddr_tbl[portid].src,
> +
> +	rte_ether_addr_copy(&ethaddr_tbl[portid].src,
>  			    (struct rte_ether_addr *)(val_eth + portid) + 1);
> 
>  	print_ethaddr("Address: ", &ethaddr);
> diff --git a/examples/ipsec-secgw/ipsec-secgw.h b/examples/ipsec-
> secgw/ipsec-secgw.h
> index 0e0012d058..53665adf03 100644
> --- a/examples/ipsec-secgw/ipsec-secgw.h
> +++ b/examples/ipsec-secgw/ipsec-secgw.h
> @@ -84,7 +84,7 @@ struct ipsec_traffic_nb {
> 
>  /* port/source ethernet addr and destination ethernet addr */  struct
> ethaddr_info {
> -	uint64_t src, dst;
> +	struct rte_ether_addr src, dst;
>  };
> 
>  struct ipsec_spd_stats {
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] examples/ipsec-secgw: fix zero address in ethernet header
  2023-03-30 10:09 [PATCH] examples/ipsec-secgw: fix zero address in ethernet header Rahul Bhansali
  2023-05-16  4:16 ` Rahul Bhansali
@ 2023-05-16  7:02 ` Akhil Goyal
  2023-05-24  9:25   ` Akhil Goyal
  1 sibling, 1 reply; 4+ messages in thread
From: Akhil Goyal @ 2023-05-16  7:02 UTC (permalink / raw)
  To: Rahul Bhansali, dev, Radu Nicolau; +Cc: Rahul Bhansali

> Subject: [PATCH] examples/ipsec-secgw: fix zero address in ethernet header
> 
> During port init, src address stored in ethaddr_tbl is typecast
> which violates the stric-aliasing rule and not reflecting
> the updated source address in processed packets too.
> 
> Fixes: 6eb3ba0399 ("examples/ipsec-secgw: support poll mode NEON LPM
> lookup")
> 
> Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] examples/ipsec-secgw: fix zero address in ethernet header
  2023-05-16  7:02 ` Akhil Goyal
@ 2023-05-24  9:25   ` Akhil Goyal
  0 siblings, 0 replies; 4+ messages in thread
From: Akhil Goyal @ 2023-05-24  9:25 UTC (permalink / raw)
  To: Akhil Goyal, Rahul Bhansali, dev, Radu Nicolau; +Cc: Rahul Bhansali, stable

> > Subject: [PATCH] examples/ipsec-secgw: fix zero address in ethernet header
> >
> > During port init, src address stored in ethaddr_tbl is typecast
> > which violates the stric-aliasing rule and not reflecting
> > the updated source address in processed packets too.
> >
> > Fixes: 6eb3ba0399 ("examples/ipsec-secgw: support poll mode NEON LPM
> > lookup")
Cc: stable@dpdk.org
> >
> > Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
> Acked-by: Akhil Goyal <gakhil@marvell.com>

Applied to dpdk-next-crypto

Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-24  9:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-30 10:09 [PATCH] examples/ipsec-secgw: fix zero address in ethernet header Rahul Bhansali
2023-05-16  4:16 ` Rahul Bhansali
2023-05-16  7:02 ` Akhil Goyal
2023-05-24  9:25   ` Akhil Goyal

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).