[v5,1/5] mbuf: don't generate invalid mbuf in clone test

Message ID 20191007154343.8556-2-stephen@networkplumber.org (mailing list archive)
State Superseded, archived
Headers
Series mbuf copy/cloning enhancements |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-compilation success Compile Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Stephen Hemminger Oct. 7, 2019, 3:43 p.m. UTC
  The test for cloning changed mbuf would generate an mbuf
whose length and segments were invalid. This would cause a crash
if test was run with mbuf debugging enabled.

Fixes: f1022aba76a5 ("app/test: rename mbuf variable")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_mbuf.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Olivier Matz Oct. 8, 2019, 8:13 a.m. UTC | #1
On Mon, Oct 07, 2019 at 08:43:39AM -0700, Stephen Hemminger wrote:
> The test for cloning changed mbuf would generate an mbuf
> whose length and segments were invalid. This would cause a crash
> if test was run with mbuf debugging enabled.
> 
> Fixes: f1022aba76a5 ("app/test: rename mbuf variable")
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Acked-by: Olivier Matz <olivier.matz@6wind.com>
  

Patch

diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c
index 2a97afe2044a..aafad0cf6206 100644
--- a/app/test/test_mbuf.c
+++ b/app/test/test_mbuf.c
@@ -332,8 +332,11 @@  testclone_testupdate_testdetach(struct rte_mempool *pktmbuf_pool)
 	m->next = rte_pktmbuf_alloc(pktmbuf_pool);
 	if (m->next == NULL)
 		GOTO_FAIL("Next Pkt Null\n");
+	m->nb_segs = 2;
 
 	rte_pktmbuf_append(m->next, sizeof(uint32_t));
+	m->pkt_len = 2 * sizeof(uint32_t);
+
 	data = rte_pktmbuf_mtod(m->next, unaligned_uint32_t *);
 	*data = MAGIC_DATA;