From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 03DE3B108 for ; Wed, 18 Jun 2014 16:50:24 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 18 Jun 2014 07:45:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,501,1400050800"; d="scan'208";a="549860543" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 18 Jun 2014 07:50:39 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s5IEocla009271 for ; Wed, 18 Jun 2014 15:50:38 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id s5IEoc3E025972 for ; Wed, 18 Jun 2014 15:50:38 +0100 Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with id s5IEocuw025967 for dev@dpdk.org; Wed, 18 Jun 2014 15:50:38 +0100 From: Anatoly Burakov To: dev@dpdk.org Date: Wed, 18 Jun 2014 15:50:33 +0100 Message-Id: <9359ed14fb16b22d9526c2dc1d5cb69f2d0ccba7.1403102825.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 06/10] ip_frag: replace memmove with custom copying X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jun 2014 14:50:25 -0000 some implementations of memmove may make a copy of src before writing to dst. we avoid that by explicitly writing from src to dst backwards. Signed-off-by: Anatoly Burakov --- lib/librte_ip_frag/rte_ipv6_reassembly.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/librte_ip_frag/rte_ipv6_reassembly.c b/lib/librte_ip_frag/rte_ipv6_reassembly.c index c622827..3f06960 100644 --- a/lib/librte_ip_frag/rte_ipv6_reassembly.c +++ b/lib/librte_ip_frag/rte_ipv6_reassembly.c @@ -45,6 +45,16 @@ * */ +static inline void +ip_frag_memmove(char *dst, char *src, int len) +{ + int i; + + /* go backwards to make sure we don't overwrite anything important */ + for (i = len - 1; i >= 0; i--) + dst[i] = src[i]; +} + /* * Reassemble fragments into one packet. */ @@ -115,7 +125,7 @@ ipv6_frag_reassemble(const struct ip_frag_pkt *fp) frag_hdr = (struct ipv6_extension_fragment *) (ip_hdr + 1); ip_hdr->proto = frag_hdr->next_header; - memmove(rte_pktmbuf_mtod(m, char*) + sizeof(*frag_hdr), + ip_frag_memmove(rte_pktmbuf_mtod(m, char*) + sizeof(*frag_hdr), rte_pktmbuf_mtod(m, char*), move_len); rte_pktmbuf_adj(m, sizeof(*frag_hdr)); -- 1.8.1.4