Skip to contentSkip to conversation

raw/skeleton: fix selftest

PATCH In review David Marchand 3 participants 7 messages Mar 10, 2023 – Mar 16, 2023 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 raw/skeleton: fix selftest

ASan reported issues in this driver.

rte_rawdev_obj_t context object points at a uint16_t. skeleton_rawdev_enqueue_bufs() and skeleton_rawdev_dequeue_bufs() were incorrectly casting to an int.

The enqueue/dequeue selftest had a leak on the enqueued string and was wrong in passing a rte_rawdev_buf pointer array.
Fix this by allocating buffers on the stack and check that returned string is the expected one.

Bugzilla ID: 1175

Fixes 61c592a8d035 ("raw/skeleton: introduce skeleton rawdev driver")
Fixes 55ca1b0f2151 ("raw/skeleton: add test cases")
---
 drivers/raw/skeleton/skeleton_rawdev.c      |  4 +-
 drivers/raw/skeleton/skeleton_rawdev_test.c | 46 +++++++++------------
 2 files changed, 22 insertions(+), 28 deletions(-)
drivers/raw/skeleton/skeleton_rawdev.c +2 -2
index 53fe49f936..6e99d35536 100644
@@ -428,7 +428,7 @@ static int skeleton_rawdev_enqueue_bufs(struct rte_rawdev *dev,
 	 * help in complex implementation which require more information than
 	 * just an integer - for example, a queue-pair.
 	 */
-	q_id = *((int *)context);
+	q_id = *((uint16_t *)context);
 
 	for (i = 0; i < count; i++)
 		queue_buf[q_id].bufs[i] = buffers[i]->buf_addr;
@@ -450,7 +450,7 @@ static int skeleton_rawdev_dequeue_bufs(struct rte_rawdev *dev,
 	 * help in complex implementation which require more information than
 	 * just an integer - for example, a queue-pair.
 	 */
-	q_id = *((int *)context);
+	q_id = *((uint16_t *)context);
 
 	for (i = 0; i < count; i++)
 		buffers[i]->buf_addr = queue_buf[q_id].bufs[i];
drivers/raw/skeleton/skeleton_rawdev_test.c +20 -26

60 lines not on this page · raw message

Signature · 1 line
2.39.2
#1 lore raw

PATCH 2/2 test: add rawdev to fast tests

The rawdev unit test can be run in the CI.

---
 app/test/meson.build | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
app/test/meson.build +4 -1
index 5d78814878..6624b478b4 100644
@@ -315,7 +315,6 @@ driver_test_names = [
         'cryptodev_sw_zuc_autotest',
         'cryptodev_uadk_autotest',
         'dmadev_autotest',
-        'rawdev_autotest',
 ]
 
 dump_test_names = []
@@ -418,6 +417,10 @@ if dpdk_conf.has('RTE_NET_NULL')
     test_sources += 'test_vdev.c'
     fast_tests += [['vdev_autotest', true, true]]
 endif
+if dpdk_conf.has('RTE_RAW_SKELETON')
+    test_deps += 'raw_skeleton'
+    fast_tests += [['rawdev_autotest', true, true]]
+endif
 
 if dpdk_conf.has('RTE_HAS_LIBPCAP')
     ext_deps += pcap_dep
Signature · 1 line
2.39.2
Tested-by on v1 1/2
#3 lore raw
In reply to David Marchand
Quoted 20 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Friday, March 10, 2023 10:26 PM
To: [email protected]
Cc: [email protected]; Sachin Saxena <[email protected]>; Hemant Agrawal <[email protected]>; Shreyansh Jain <[email protected]>
Subject: [PATCH 1/2] raw/skeleton: fix selftest

ASan reported issues in this driver.

rte_rawdev_obj_t context object points at a uint16_t. skeleton_rawdev_enqueue_bufs() and skeleton_rawdev_dequeue_bufs() were incorrectly casting to an int.

The enqueue/dequeue selftest had a leak on the enqueued string and was wrong in passing a rte_rawdev_buf pointer array.
Fix this by allocating buffers on the stack and check that returned string is the expected one.

Quoted 7 lines

Bugzilla ID: 1175

Fixes 61c592a8d035 ("raw/skeleton: introduce skeleton rawdev driver")
Fixes 55ca1b0f2151 ("raw/skeleton: add test cases")

---

Best regards,
Yu Jiang

#4 lore raw
In reply to David Marchand
Quoted 7 lines · David Marchand

ASan reported issues in this driver.

rte_rawdev_obj_t context object points at a uint16_t. skeleton_rawdev_enqueue_bufs() and skeleton_rawdev_dequeue_bufs() were incorrectly casting to an int.

Quoted 6 lines

The enqueue/dequeue selftest had a leak on the enqueued string and was wrong in passing a rte_rawdev_buf pointer array.
Fix this by allocating buffers on the stack and check that returned string is the expected one.

Bugzilla ID: 1175

Thomas, just a note if you are the one to apply this one. I was looking at bugzilla, and this issue was actually reported a while back, as bz 999, so the commitlog needs some update before applying.

Quoted 5 lines
Fixes 61c592a8d035 ("raw/skeleton: introduce skeleton rawdev driver")
Fixes 55ca1b0f2151 ("raw/skeleton: add test cases")
Signature · 1 line
David Marchand
#6 lore raw
In reply to David Marchand
Quoted 12 lines · David Marchand

ASan reported issues in this driver.

rte_rawdev_obj_t context object points at a uint16_t. skeleton_rawdev_enqueue_bufs() and skeleton_rawdev_dequeue_bufs() were incorrectly casting to an int.

The enqueue/dequeue selftest had a leak on the enqueued string and was wrong in passing a rte_rawdev_buf pointer array.
Fix this by allocating buffers on the stack and check that returned string is the expected one.

Bugzilla ID: 999

Quoted 5 lines
Fixes 61c592a8d035 ("raw/skeleton: introduce skeleton rawdev driver")
Fixes 55ca1b0f2151 ("raw/skeleton: add test cases")

Series applied.

Signature · 1 line
David Marchand