From e1522b328c6a86d0c04b368961cfeb87fae95237 Mon Sep 17 00:00:00 2001 From: Huichao Cai Date: Sat, 18 Jun 2022 22:09:40 +0800 Subject: [PATCH] ip_frag: fix build with GCC 12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 12 raises warnings on usage of rte_memcpy with IPv4 options handling in fragments for both the ip_frag library and unit tests. For example in the library: In function ‘_mm256_storeu_si256’, inlined from ‘rte_mov32’ at ../lib/eal/x86/include/rte_memcpy.h:347:2, inlined from ‘rte_mov128’ at ../lib/eal/x86/include/rte_memcpy.h:369:2, inlined from ‘rte_memcpy_generic’ at ../lib/eal/x86/include/rte_memcpy.h:445:4, inlined from ‘rte_memcpy’ at ../lib/eal/x86/include/rte_memcpy.h:851:10, inlined from ‘__create_ipopt_frag_hdr’ at ../lib/ip_frag/rte_ipv4_fragmentation.c:68:4, inlined from ‘rte_ipv4_fragment_packet’ at ../lib/ip_frag/rte_ipv4_fragmentation.c:242:16: /usr/lib/gcc/x86_64-redhat-linux/12/include/avxintrin.h:935:8: error: array subscript ‘__m256i_u[1]’ is partly outside array bounds of ‘uint8_t[60]’ {aka ‘unsigned char[60]’} [-Werror=array-bounds] 935 | *__P = __A; | ~~~~~^~~~~ ../lib/ip_frag/rte_ipv4_fragmentation.c: In function ‘rte_ipv4_fragment_packet’: ../lib/ip_frag/rte_ipv4_fragmentation.c:122:17: note: at offset [52, 60] into object ‘ipopt_frag_hdr’ of size 60 122 | uint8_t ipopt_frag_hdr[IPV4_HDR_MAX_LEN]; | ^~~~~~~~~~~~~~ To resolve the compilation warning, replace the rte_memcpy with memcpy. Fixes: b50a14a853aa ("ip_frag: add IPv4 options fragment") Signed-off-by: Huichao Cai --- app/test/test_ipfrag.c | 13 ++++++------- lib/ip_frag/rte_ipv4_fragmentation.c | 7 +++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/test/test_ipfrag.c b/app/test/test_ipfrag.c index dc62b0e547..ba0ffd0806 100644 --- a/app/test/test_ipfrag.c +++ b/app/test/test_ipfrag.c @@ -23,7 +23,6 @@ test_ipfrag(void) #include #include -#include #include #define NUM_MBUFS 128 @@ -147,13 +146,13 @@ test_get_ipv4_opt(bool is_first_frag, bool opt_copied, if (opt_copied) { expected_opt->len = sizeof(expected_first_frag_ipv4_opts_copied); - rte_memcpy(expected_opt->data, + memcpy(expected_opt->data, expected_first_frag_ipv4_opts_copied, sizeof(expected_first_frag_ipv4_opts_copied)); } else { expected_opt->len = sizeof(expected_first_frag_ipv4_opts_nocopied); - rte_memcpy(expected_opt->data, + memcpy(expected_opt->data, expected_first_frag_ipv4_opts_nocopied, sizeof(expected_first_frag_ipv4_opts_nocopied)); } @@ -161,13 +160,13 @@ test_get_ipv4_opt(bool is_first_frag, bool opt_copied, if (opt_copied) { expected_opt->len = sizeof(expected_sub_frag_ipv4_opts_copied); - rte_memcpy(expected_opt->data, + memcpy(expected_opt->data, expected_sub_frag_ipv4_opts_copied, sizeof(expected_sub_frag_ipv4_opts_copied)); } else { expected_opt->len = sizeof(expected_sub_frag_ipv4_opts_nocopied); - rte_memcpy(expected_opt->data, + memcpy(expected_opt->data, expected_sub_frag_ipv4_opts_nocopied, sizeof(expected_sub_frag_ipv4_opts_nocopied)); } @@ -227,7 +226,7 @@ v4_allocate_packet_of(struct rte_mbuf *b, int fill, size_t s, hdr->src_addr = rte_cpu_to_be_32(0x8080808); hdr->dst_addr = rte_cpu_to_be_32(0x8080404); - rte_memcpy(hdr + 1, opt.data, opt.len); + memcpy(hdr + 1, opt.data, opt.len); } static void @@ -312,7 +311,7 @@ test_get_frag_opt(struct rte_mbuf **mb, int32_t num, char *iph_opt = rte_pktmbuf_mtod_offset(mb[i], char *, sizeof(struct rte_ipv4_hdr)); opt->len = opt_len; - rte_memcpy(opt->data, iph_opt, opt_len); + memcpy(opt->data, iph_opt, opt_len); } else { opt->len = RTE_IPV4_HDR_OPT_MAX_LEN; memset(opt->data, RTE_IPV4_HDR_OPT_EOL, diff --git a/lib/ip_frag/rte_ipv4_fragmentation.c b/lib/ip_frag/rte_ipv4_fragmentation.c index a19f6fda64..27a8ad224d 100644 --- a/lib/ip_frag/rte_ipv4_fragmentation.c +++ b/lib/ip_frag/rte_ipv4_fragmentation.c @@ -5,7 +5,6 @@ #include #include -#include #include #include "ip_frag_common.h" @@ -26,7 +25,7 @@ static inline void __fill_ipv4hdr_frag(struct rte_ipv4_hdr *dst, const struct rte_ipv4_hdr *src, uint16_t header_len, uint16_t len, uint16_t fofs, uint16_t dofs, uint32_t mf) { - rte_memcpy(dst, src, header_len); + memcpy(dst, src, header_len); fofs = (uint16_t)(fofs + (dofs >> RTE_IPV4_HDR_FO_SHIFT)); fofs = (uint16_t)(fofs | mf << RTE_IPV4_HDR_MF_SHIFT); dst->fragment_offset = rte_cpu_to_be_16(fofs); @@ -48,7 +47,7 @@ static inline uint16_t __create_ipopt_frag_hdr(uint8_t *iph, struct rte_ipv4_hdr *iph_opt = (struct rte_ipv4_hdr *)ipopt_frag_hdr; ipopt_len = 0; - rte_memcpy(ipopt_frag_hdr, iph, sizeof(struct rte_ipv4_hdr)); + memcpy(ipopt_frag_hdr, iph, sizeof(struct rte_ipv4_hdr)); ipopt_frag_hdr += sizeof(struct rte_ipv4_hdr); uint8_t *p_opt = iph + sizeof(struct rte_ipv4_hdr); @@ -65,7 +64,7 @@ static inline uint16_t __create_ipopt_frag_hdr(uint8_t *iph, break; if (RTE_IPV4_HDR_OPT_COPIED(*p_opt)) { - rte_memcpy(ipopt_frag_hdr + ipopt_len, + memcpy(ipopt_frag_hdr + ipopt_len, p_opt, p_opt[1]); ipopt_len += p_opt[1]; }