From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: Packet Cloning Date: Thu, 28 May 2015 07:52:44 -0700 Message-ID: <20150528075244.469b8557@urahara> References: <57F6A61F-5629-4D11-A78C-397DBB4E8381@inventum.net> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: "dev@dpdk.org" To: Padam Jeet Singh Return-path: Received: from mail-pd0-f172.google.com (mail-pd0-f172.google.com [209.85.192.172]) by dpdk.org (Postfix) with ESMTP id 2F7A05A8B for ; Thu, 28 May 2015 16:52:41 +0200 (CEST) Received: by pdea3 with SMTP id a3so43371828pde.2 for ; Thu, 28 May 2015 07:52:40 -0700 (PDT) In-Reply-To: <57F6A61F-5629-4D11-A78C-397DBB4E8381@inventum.net> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, 28 May 2015 17:15:42 +0530 Padam Jeet Singh 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)