Fix the IPsec IPv6 tunnel address bytes swap during SA configurations in session create/update.
Fixes: 78d03027f2c ("common/cnxk: add IPsec common code") Signed-off-by: Rahul Bhansali <rbhans...@marvell.com> --- drivers/common/cnxk/cnxk_security.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/common/cnxk/cnxk_security.c b/drivers/common/cnxk/cnxk_security.c index 79427d48fe..13ca2c7791 100644 --- a/drivers/common/cnxk/cnxk_security.c +++ b/drivers/common/cnxk/cnxk_security.c @@ -274,6 +274,14 @@ ot_ipsec_inb_ctx_size(struct roc_ot_ipsec_inb_sa *sa) return size; } +static void +ot_ipsec_update_ipv6_addr_endianness(uint64_t *addr) +{ + *addr = rte_be_to_cpu_64(*addr); + addr++; + *addr = rte_be_to_cpu_64(*addr); +} + static int ot_ipsec_inb_tunnel_hdr_fill(struct roc_ot_ipsec_inb_sa *sa, struct rte_security_ipsec_xform *ipsec_xfrm) @@ -310,6 +318,10 @@ ot_ipsec_inb_tunnel_hdr_fill(struct roc_ot_ipsec_inb_sa *sa, memcpy(&sa->outer_hdr.ipv6.dst_addr, &tunnel->ipv6.dst_addr, sizeof(struct in6_addr)); + /* IP Source and Dest are in LE/CPU endian */ + ot_ipsec_update_ipv6_addr_endianness((uint64_t *)&sa->outer_hdr.ipv6.src_addr); + ot_ipsec_update_ipv6_addr_endianness((uint64_t *)&sa->outer_hdr.ipv6.dst_addr); + break; default: return -EINVAL; @@ -499,6 +511,10 @@ cnxk_ot_ipsec_outb_sa_fill(struct roc_ot_ipsec_outb_sa *sa, memcpy(&sa->outer_hdr.ipv6.dst_addr, &tunnel->ipv6.dst_addr, sizeof(struct in6_addr)); + /* IP Source and Dest are in LE/CPU endian */ + ot_ipsec_update_ipv6_addr_endianness((uint64_t *)&sa->outer_hdr.ipv6.src_addr); + ot_ipsec_update_ipv6_addr_endianness((uint64_t *)&sa->outer_hdr.ipv6.dst_addr); + /* Outer header flow label source */ if (!ipsec_xfrm->options.copy_flabel) { sa->w2.s.ipv4_df_src_or_ipv6_flw_lbl_src = -- 2.25.1