app/test: fix data length of each packet segment
PATCH 1/1 app/test: fix data length of each packet segment
Assign correct data length to each segments according to the given pkt_len and nb_pkt_segs, instead of using pkt_len as the data_len of every packet segment
--- .mailmap | 1 + app/test/packet_burst_generator.c | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-)
.mailmap +1 -0
@@ -1576,6 +1576,7 @@ Zhipeng Lu <[email protected]> Zhirun Yan <[email protected]> Zhiwei He <[email protected]> Zhiyong Yang <[email protected]> +Zhuobin Huang <[email protected]> Zi Hu <[email protected]> Zijie Pan <[email protected]> Ziyang Xuan <[email protected]>
app/test/packet_burst_generator.c +14 -4
@@ -269,6 +269,8 @@ generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,struct rte_mbuf *pkt_seg;struct rte_mbuf *pkt; +const uint8_t pkt_seg_data_len = pkt_len / nb_pkt_segs; +for (nb_pkt =0 ; nb_pkt < nb_pkt_per_burst; nb_pkt++) { pkt =rte_pktmbuf_alloc (mp);if (pkt ==NULL ) {
@@ -278,7 +280,7 @@ generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,break ; } - pkt->data_len = pkt_len; + pkt->data_len = pkt_seg_data_len; pkt_seg = pkt;for (i =1 ; i < nb_pkt_segs; i++) { pkt_seg->next =rte_pktmbuf_alloc (mp);
@@ -288,7 +290,10 @@ generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst, goto nomore_mbuf; } pkt_seg = pkt_seg->next; - pkt_seg->data_len = pkt_len; +if (i != nb_pkt_segs -1 ) + pkt_seg->data_len = pkt_seg_data_len; +else + pkt_seg->data_len = pkt_seg_data_len + pkt_len % nb_pkt_segs; } pkt_seg->next =NULL ;/* Last segment of packet. */
@@ -350,6 +355,8 @@ generate_packet_burst_proto(struct rte_mempool *mp,struct rte_mbuf *pkt_seg;struct rte_mbuf *pkt; +const uint8_t pkt_seg_data_len = pkt_len / nb_pkt_segs; +for (nb_pkt =0 ; nb_pkt < nb_pkt_per_burst; nb_pkt++) { pkt =rte_pktmbuf_alloc (mp);if (pkt ==NULL ) {
@@ -359,7 +366,7 @@ generate_packet_burst_proto(struct rte_mempool *mp,break ; } - pkt->data_len = pkt_len; + pkt->data_len = pkt_seg_data_len; pkt_seg = pkt;for (i =1 ; i < nb_pkt_segs; i++) { pkt_seg->next =rte_pktmbuf_alloc (mp);
@@ -369,7 +376,10 @@ generate_packet_burst_proto(struct rte_mempool *mp, goto nomore_mbuf; } pkt_seg = pkt_seg->next; - pkt_seg->data_len = pkt_len; +if (i != nb_pkt_segs -1 ) + pkt_seg->data_len = pkt_seg_data_len; +else + pkt_seg->data_len = pkt_seg_data_len + pkt_len % nb_pkt_segs; } pkt_seg->next =NULL ;/* Last segment of packet. */
Signature · 1 line
2.34.1
Quoted 9 lines · Zhuobin Huang
Assign correct data length to each segments according to the given
pkt_lenandnb_pkt_segs, instead of usingpkt_lenas thedata_lenof every packet segmentFixes a9c9e9698d5e ("app/test: allow to create packets of different sizes")Signed-off-by Zhuobin Huang <[email protected]>
Good catch.
I am curious to know how you noticed the issue since I see no in-tree code asking for multiseg.
For the record, to check this patch, I compiled with -DRTE_LIBRTE_MBUF_DEBUG and a small modification:
app/test/test_pmd_perf.c +1 -1
@@ -209,7 +209,7 @@ init_traffic(struct rte_mempool *mp,return generate_packet_burst (mp, pkts_burst, &pkt_eth_hdr,0 , &pkt_ipv4_hdr,1 , &pkt_udp_hdr, burst_size, -PACKET_BURST_GEN_PKT_LEN ,1 ); +PACKET_BURST_GEN_PKT_LEN ,2 ); } static int
Before the fix:
DPDK_TEST=pmd_perf_autotest ./build-gcc/app/test/dpdk-test --no-huge -m 2048 --vdev=net_null0 --vdev=net_null1
...
Generate 4096 packets @socket 0
inject 2048 packet to port 0
PANIC in rte_mbuf_sanity_check():
bad pkt_len
Cc: ci@ in general, we should have more tests run with debug/check options enabled.
Signature · 1 line
David Marchand
David Marchand
AppliedQuoted 10 lines · David Marchand
Quoted 8 lines · Zhuobin Huang
Assign correct data length to each segments according to the given
pkt_lenandnb_pkt_segs, instead of usingpkt_lenas thedata_lenof every packet segmentFixes a9c9e9698d5e ("app/test: allow to create packets of different sizes")Signed-off-by Zhuobin Huang <[email protected]>Reviewed-by David Marchand <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand