[PATCH] app/test: use memcpy in ipsec test

Morten Brørup mb at smartsharesystems.com
Fri May 29 22:45:00 CEST 2026


> > This test has tables of data that get copied with rte_memcpy.
> > But when compiled without always inline the compiler gets confused
> > by the inlining of rte_memcpy and thinks that it is possible for AVX
> > code to reference past the input data.
> >
> > Workaround is to use memcpy() which is better for this test anyway
> > since regular memcpy has more static checking from compiler and
> > analyzers.
> >
> > Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> > ---
> >  app/test/test_ipsec.c | 13 ++++++-------
> >  1 file changed, 6 insertions(+), 7 deletions(-)
> >
> > diff --git a/app/test/test_ipsec.c b/app/test/test_ipsec.c
> > index 139c1e8dec..b5a430996d 100644
> > --- a/app/test/test_ipsec.c
> > +++ b/app/test/test_ipsec.c
> > @@ -10,7 +10,6 @@
> >  #include <rte_hexdump.h>
> >  #include <rte_mbuf.h>
> >  #include <rte_malloc.h>
> > -#include <rte_memcpy.h>
> >  #include <rte_cycles.h>
> >  #include <rte_bus_vdev.h>
> >  #include <rte_ip.h>
> > @@ -559,7 +558,7 @@ setup_test_string(struct rte_mempool *mpool,
> const
> > char *string,
> >  			return NULL;
> >  		}
> >  		if (string != NULL)
> > -			rte_memcpy(dst, string, t_len);
> > +			memcpy(dst, string, t_len);
> >  		else
> >  			memset(dst, 0, t_len);
> >  	}
> > @@ -604,22 +603,22 @@ setup_test_string_tunneled(struct rte_mempool
> > *mpool, const char *string,
> >  	/* copy outer IP and ESP header */
> >  	ipv4_outer.total_length = rte_cpu_to_be_16(t_len);
> >  	ipv4_outer.packet_id = rte_cpu_to_be_16(seq);
> > -	rte_memcpy(dst, &ipv4_outer, sizeof(ipv4_outer));
> > +	memcpy(dst, &ipv4_outer, sizeof(ipv4_outer));

How about:
*dst = ipv4_outer;

Don't know if it applies here.

> >  	dst += sizeof(ipv4_outer);
> >  	m->l3_len = sizeof(ipv4_outer);
> > -	rte_memcpy(dst, &esph, sizeof(esph));
> > +	memcpy(dst, &esph, sizeof(esph));
> >  	dst += sizeof(esph);
> >
> >  	if (string != NULL) {
> >  		/* copy payload */
> > -		rte_memcpy(dst, string, len);
> > +		memcpy(dst, string, len);
> >  		dst += len;
> >  		/* copy pad bytes */
> > -		rte_memcpy(dst, esp_pad_bytes, RTE_MIN(padlen,
> > +		memcpy(dst, esp_pad_bytes, RTE_MIN(padlen,
> >  			sizeof(esp_pad_bytes)));
> >  		dst += padlen;
> >  		/* copy ESP tail header */
> > -		rte_memcpy(dst, &espt, sizeof(espt));
> > +		memcpy(dst, &espt, sizeof(espt));

Also here:
*dst = espt;

Also don't know if it applies here.

> >  	} else
> >  		memset(dst, 0, t_len);
> >
> > --
> 
> Acked-by: Konstantin Ananyev <konstantin.ananyev at huawei.com>
> 
> > 2.53.0

With or without suggested changes:
Acked-by: Morten Brørup <mb at smartsharesystems.com>

If you are curious too...
Does the compiler still get confused about AVX rte_memcpy (without this patch), if applying the rte_memcpy patch?
https://patchwork.dpdk.org/project/dpdk/patch/20260521185631.116046-1-mb@smartsharesystems.com/



More information about the dev mailing list