diff mbox series

[ovs-dev,v3,2/3] dp-packet: Allocate on cacheline boundary with DPDK

Message ID 20230130192341.514178-2-mkp@redhat.com
State Superseded
Headers show
Series [ovs-dev,v3,1/3] netdev-dummy: Allocate dummy_packet_stream on cacheline boundary | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test fail github build: failed
ovsrobot/intel-ovs-compilation fail test: fail

Commit Message

Mike Pattrick Jan. 30, 2023, 7:23 p.m. UTC
UB Sanitizer report:
lib/dp-packet.h:587:22: runtime error: member access within misaligned
address 0x000001ecde10 for type 'struct dp_packet', which requires 64
byte alignment

    #0 in dp_packet_set_base lib/dp-packet.h:587
    #1 in dp_packet_use__ lib/dp-packet.c:46
    #2 in dp_packet_use lib/dp-packet.c:60
    #3 in dp_packet_init lib/dp-packet.c:126
    #4 in dp_packet_new lib/dp-packet.c:150
    [...]

Signed-off-by: Mike Pattrick <mkp@redhat.com>

---
v3:
- used proper free method for non-posix platforms

---
 lib/dp-packet.c | 4 ++++
 lib/dp-packet.h | 4 ++++
 2 files changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/lib/dp-packet.c b/lib/dp-packet.c
index 61e405460..ae8ab5800 100644
--- a/lib/dp-packet.c
+++ b/lib/dp-packet.c
@@ -146,7 +146,11 @@  dp_packet_uninit(struct dp_packet *b)
 struct dp_packet *
 dp_packet_new(size_t size)
 {
+#ifdef DPDK_NETDEV
+    struct dp_packet *b = xmalloc_cacheline(sizeof *b);
+#else
     struct dp_packet *b = xmalloc(sizeof *b);
+#endif
     dp_packet_init(b, size);
     return b;
 }
diff --git a/lib/dp-packet.h b/lib/dp-packet.h
index ed1e5b3f6..b3e6a5d10 100644
--- a/lib/dp-packet.h
+++ b/lib/dp-packet.h
@@ -257,7 +257,11 @@  dp_packet_delete(struct dp_packet *b)
         }
 
         dp_packet_uninit(b);
+#ifdef DPDK_NETDEV
+        free_cacheline(b);
+#else
         free(b);
+#endif
     }
 }