[dpdk-dev] Packet Cloning

Stephen Hemminger stephen at networkplumber.org
Thu May 28 16:52:44 CEST 2015


On Thu, 28 May 2015 17:15:42 +0530
Padam Jeet Singh <padam.singh at inventum.net> wrote:

> Hello,
> 
> Is there a function in DPDK to completely clone a pkt_mbuf including the segments? 
> 
> I am trying to build a packet mirroring application which sends packet out through two separate interfaces, but the packet payload needs to be altered before send.
> 
> Thanks,
> Padam
> 
> 

Isn't this what you want?

/**
 * Creates a "clone" of the given packet mbuf.
 *
 * Walks through all segments of the given packet mbuf, and for each of them:
 *  - Creates a new packet mbuf from the given pool.
 *  - Attaches newly created mbuf to the segment.
 * Then updates pkt_len and nb_segs of the "clone" packet mbuf to match values
 * from the original packet mbuf.
 *
 * @param md
 *   The packet mbuf to be cloned.
 * @param mp
 *   The mempool from which the "clone" mbufs are allocated.
 * @return
 *   - The pointer to the new "clone" mbuf on success.
 *   - NULL if allocation fails.
 */
static inline struct rte_mbuf *rte_pktmbuf_clone(struct rte_mbuf *md,
		struct rte_mempool *mp)


More information about the dev mailing list