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

Message ID 20191008163350.20779-2-stephen@networkplumber.org
State Accepted
Delegated to: David Marchand
Headers show
Series
  • mbuf: copy/cloning enhancements
Related show

Checks

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

Commit Message

Stephen Hemminger Oct. 8, 2019, 4:33 p.m.
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>
---
 app/test/test_mbuf.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

David Marchand Oct. 17, 2019, 5:01 a.m. | #1
On Tue, Oct 8, 2019 at 6:34 PM Stephen Hemminger
<stephen@networkplumber.org> 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.

It could be interesting to add calls to rte_mbuf_check() (not
dependent on the debug build option) at key points in this test.

>
> Fixes: f1022aba76a5 ("app/test: rename mbuf variable")

Wrong Fixes: tag.

Fixes: 4ccd2bb3a9e2 ("app/test: enhance mbuf refcnt check")
Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Acked-by: Olivier Matz <olivier.matz@6wind.com>
> ---
>  app/test/test_mbuf.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> 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;
>
> --
> 2.20.1
>

Applied, thanks.


--
David Marchand

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;