MCPcopy Create free account
hub / github.com/F-Stack/f-stack / testclone_testupdate_testdetach

Function testclone_testupdate_testdetach

dpdk/app/test/test_mbuf.c:319–422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317}
318
319static int
320testclone_testupdate_testdetach(struct rte_mempool *pktmbuf_pool,
321 struct rte_mempool *clone_pool)
322{
323 struct rte_mbuf *m = NULL;
324 struct rte_mbuf *clone = NULL;
325 struct rte_mbuf *clone2 = NULL;
326 unaligned_uint32_t *data;
327
328 /* alloc a mbuf */
329 m = rte_pktmbuf_alloc(pktmbuf_pool);
330 if (m == NULL)
331 GOTO_FAIL("ooops not allocating mbuf");
332
333 if (rte_pktmbuf_pkt_len(m) != 0)
334 GOTO_FAIL("Bad length");
335
336 rte_pktmbuf_append(m, sizeof(uint32_t));
337 data = rte_pktmbuf_mtod(m, unaligned_uint32_t *);
338 *data = MAGIC_DATA;
339
340 /* clone the allocated mbuf */
341 clone = rte_pktmbuf_clone(m, clone_pool);
342 if (clone == NULL)
343 GOTO_FAIL("cannot clone data\n");
344
345 data = rte_pktmbuf_mtod(clone, unaligned_uint32_t *);
346 if (*data != MAGIC_DATA)
347 GOTO_FAIL("invalid data in clone\n");
348
349 if (testclone_refcnt_read(m) != 2)
350 GOTO_FAIL("invalid refcnt in m\n");
351
352 /* free the clone */
353 rte_pktmbuf_free(clone);
354 clone = NULL;
355
356 /* same test with a chained mbuf */
357 m->next = rte_pktmbuf_alloc(pktmbuf_pool);
358 if (m->next == NULL)
359 GOTO_FAIL("Next Pkt Null\n");
360 m->nb_segs = 2;
361
362 rte_pktmbuf_append(m->next, sizeof(uint32_t));
363 m->pkt_len = 2 * sizeof(uint32_t);
364
365 data = rte_pktmbuf_mtod(m->next, unaligned_uint32_t *);
366 *data = MAGIC_DATA;
367
368 clone = rte_pktmbuf_clone(m, clone_pool);
369 if (clone == NULL)
370 GOTO_FAIL("cannot clone data\n");
371
372 data = rte_pktmbuf_mtod(clone, unaligned_uint32_t *);
373 if (*data != MAGIC_DATA)
374 GOTO_FAIL("invalid data in clone\n");
375
376 data = rte_pktmbuf_mtod(clone->next, unaligned_uint32_t *);

Callers 2

test_mbufFunction · 0.85

Calls 6

rte_pktmbuf_allocFunction · 0.85
rte_pktmbuf_appendFunction · 0.85
rte_pktmbuf_cloneFunction · 0.85
testclone_refcnt_readFunction · 0.85
rte_pktmbuf_freeFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected