[PATCH v2 1/6] ip_frag: remove use of unaligned variable
Bruce Richardson
bruce.richardson at intel.com
Fri Oct 25 18:50:14 CEST 2024
If compiling with -Waddress-of-packed-member, we get a warning about the
use of the unaligned uint64_t value which is used to copy 8 bytes from
ip_hdr to the key. Replace this unaligned assignment with an equivalent
8-byte constant-sized memcpy, allowing the compiler to choose optimal
instructions to do the assignment.
Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
Acked-by: Stephen Hemminger <stephen at networkplumber.org>
Acked-by: Konstantin Ananyev <konstantin.ananyev at huawei.com>
Acked-by: Morten Brørup <mb at smartsharesystems.com>
---
lib/ip_frag/rte_ipv4_reassembly.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/lib/ip_frag/rte_ipv4_reassembly.c b/lib/ip_frag/rte_ipv4_reassembly.c
index 4a89a5f536..5818f50f40 100644
--- a/lib/ip_frag/rte_ipv4_reassembly.c
+++ b/lib/ip_frag/rte_ipv4_reassembly.c
@@ -101,7 +101,6 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
{
struct ip_frag_pkt *fp;
struct ip_frag_key key;
- const unaligned_uint64_t *psd;
uint16_t flag_offset, ip_ofs, ip_flag;
int32_t ip_len;
int32_t trim;
@@ -110,9 +109,8 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
ip_ofs = (uint16_t)(flag_offset & RTE_IPV4_HDR_OFFSET_MASK);
ip_flag = (uint16_t)(flag_offset & RTE_IPV4_HDR_MF_FLAG);
- psd = (unaligned_uint64_t *)&ip_hdr->src_addr;
/* use first 8 bytes only */
- key.src_dst[0] = psd[0];
+ memcpy(&key.src_dst[0], &ip_hdr->src_addr, 8);
key.id = ip_hdr->packet_id;
key.key_len = IPV4_KEYLEN;
--
2.43.0
More information about the dev
mailing list