From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <3chas3@gmail.com> Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by dpdk.org (Postfix) with ESMTP id 6F7531B550 for ; Tue, 16 Apr 2019 20:22:40 +0200 (CEST) Received: by mail-qt1-f193.google.com with SMTP id t28so24447475qte.6 for ; Tue, 16 Apr 2019 11:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=u1EwEzuicVpNd4wWOT6TJ1hp9mA7OoMapJ4aehJuZzY=; b=EmL+cf0rL3j7e4g9S2J7jjRDhFL12b9LHn9GtwrvNEmpKoNA6fCrFqtjKx7CJ3Kdd6 ZRARzQCBFFdohtLQijK4FoWHacI9CmQ1+Ok9emkUAIZPy/1cgg0MTEg3vkKGG6tltkOi epvV5C1FDnTK+f1oHDn2hZjV2IifF8SgRKgx3lwXMtEaXlBU2VaGMBZh4H1Qfhki5Yje swgbviqNxW1po3Y9JEnvCrICfDuVo56N4uE8CeW4PC3fE06bXI2gFYe4PlMvu8careMk mvK3+Yx9+9fxwjUy52bmszERfvAu8lqi1dt29x0zJimFicNXGQM1Il6X890N3n3+H3ov DCZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=u1EwEzuicVpNd4wWOT6TJ1hp9mA7OoMapJ4aehJuZzY=; b=TYJUA8UQOLktWYxaMeA1qcrpCRsUF7efm/XLFrMFrbOUZAwbbFfgRMrWvJr3MRsMdT UixsHIxPVns/9LABS6i6V5dt2xIOYngblSpf+R1QCRQizbWB2JV1oSaEOFcK7lfWuXWn 1A6rof67sJCQ+eOes++x1BpZeUKEPUQiuituv9vkWhCwyuPZDHj/5P+dhCZPjiA1efP8 oDoj0S0GjJg4KHf0EVK3ATxbYgTPfRJVGPpkmmSFrCcpp8j/BPcRlQu22QLm4LMyLIAp S+ZTMTCND1HSrgjvJguvkFQb6EJbkxuzY2efW0h/IOImSGgvzNeJ/UGudsz9EWFySgHJ 68eA== X-Gm-Message-State: APjAAAUaBPulHaVpotChdNBFYaY0OycqSG4bpNEU3qyK2VLbqHj0DXBi VawoPLzRVVVGmcWo5ApEngw= X-Google-Smtp-Source: APXvYqzAPGZ4k1wHuuspXZtD+3ILMTu7tsoAwRQ0zQl5dZeZ6wj0Z0iR3GPrpmZCNH8C3BwGHqk1gA== X-Received: by 2002:ac8:3782:: with SMTP id d2mr65465453qtc.170.1555438959185; Tue, 16 Apr 2019 11:22:39 -0700 (PDT) Received: from [192.168.1.10] (pool-96-255-82-34.washdc.fios.verizon.net. [96.255.82.34]) by smtp.gmail.com with ESMTPSA id x28sm35487352qtx.71.2019.04.16.11.22.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Apr 2019 11:22:38 -0700 (PDT) To: Ferruh Yigit , Olivier Matz Cc: dev@dpdk.org, Stephen Hemminger , Chas Williams References: <20190416155126.26438-1-ferruh.yigit@intel.com> From: Chas Williams <3chas3@gmail.com> Message-ID: <3fd9b596-6ce7-f5a8-a7cc-1e53e0c9196f@gmail.com> Date: Tue, 16 Apr 2019 14:22:37 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190416155126.26438-1-ferruh.yigit@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] net: do not insert VLAN tag to shared mbufs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Apr 2019 18:22:40 -0000 On 4/16/19 11:51 AM, Ferruh Yigit wrote: > The vlan_insert() is buggy when it tires to handle the shared mbufs, s/tries/tries/ > instead don't support inserting VLAN tag into shared mbufs and return > an error for that case. > > Signed-off-by: Ferruh Yigit > --- > Cc: Stephen Hemminger > Cc: Chas Williams > > This is another approach to RFC to fix the vlan_insert: > https://patches.dpdk.org/patch/51870/ > > vlan_insert() mostly used by drivers to insert VLAN tag into packet > data in Tx path, drivers creating new copies of mbufs in Tx path may > result unexpected behavior, like not freed or double freed mbufs. > --- > lib/librte_net/rte_ether.h | 11 ++--------- > 1 file changed, 2 insertions(+), 9 deletions(-) > > diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h > index 3a87ff184..a1df911b6 100644 > --- a/lib/librte_net/rte_ether.h > +++ b/lib/librte_net/rte_ether.h > @@ -388,15 +388,8 @@ static inline int rte_vlan_insert(struct rte_mbuf **m) > struct vlan_hdr *vh; > > /* Can't insert header if mbuf is shared */ > - if (rte_mbuf_refcnt_read(*m) > 1) { > - struct rte_mbuf *copy; > - > - copy = rte_pktmbuf_clone(*m, (*m)->pool); > - if (unlikely(copy == NULL)) > - return -ENOMEM; > - rte_pktmbuf_free(*m); > - *m = copy; > - } > + if (!RTE_MBUF_DIRECT(*m) || rte_mbuf_refcnt_read(*m) > 1) > + return -EINVAL; > > oh = rte_pktmbuf_mtod(*m, struct ether_hdr *); > nh = (struct ether_hdr *) > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 1AE26A00E6 for ; Tue, 16 Apr 2019 20:22:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8E2F31B555; Tue, 16 Apr 2019 20:22:41 +0200 (CEST) Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by dpdk.org (Postfix) with ESMTP id 6F7531B550 for ; Tue, 16 Apr 2019 20:22:40 +0200 (CEST) Received: by mail-qt1-f193.google.com with SMTP id t28so24447475qte.6 for ; Tue, 16 Apr 2019 11:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=u1EwEzuicVpNd4wWOT6TJ1hp9mA7OoMapJ4aehJuZzY=; b=EmL+cf0rL3j7e4g9S2J7jjRDhFL12b9LHn9GtwrvNEmpKoNA6fCrFqtjKx7CJ3Kdd6 ZRARzQCBFFdohtLQijK4FoWHacI9CmQ1+Ok9emkUAIZPy/1cgg0MTEg3vkKGG6tltkOi epvV5C1FDnTK+f1oHDn2hZjV2IifF8SgRKgx3lwXMtEaXlBU2VaGMBZh4H1Qfhki5Yje swgbviqNxW1po3Y9JEnvCrICfDuVo56N4uE8CeW4PC3fE06bXI2gFYe4PlMvu8careMk mvK3+Yx9+9fxwjUy52bmszERfvAu8lqi1dt29x0zJimFicNXGQM1Il6X890N3n3+H3ov DCZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=u1EwEzuicVpNd4wWOT6TJ1hp9mA7OoMapJ4aehJuZzY=; b=TYJUA8UQOLktWYxaMeA1qcrpCRsUF7efm/XLFrMFrbOUZAwbbFfgRMrWvJr3MRsMdT UixsHIxPVns/9LABS6i6V5dt2xIOYngblSpf+R1QCRQizbWB2JV1oSaEOFcK7lfWuXWn 1A6rof67sJCQ+eOes++x1BpZeUKEPUQiuituv9vkWhCwyuPZDHj/5P+dhCZPjiA1efP8 oDoj0S0GjJg4KHf0EVK3ATxbYgTPfRJVGPpkmmSFrCcpp8j/BPcRlQu22QLm4LMyLIAp S+ZTMTCND1HSrgjvJguvkFQb6EJbkxuzY2efW0h/IOImSGgvzNeJ/UGudsz9EWFySgHJ 68eA== X-Gm-Message-State: APjAAAUaBPulHaVpotChdNBFYaY0OycqSG4bpNEU3qyK2VLbqHj0DXBi VawoPLzRVVVGmcWo5ApEngw= X-Google-Smtp-Source: APXvYqzAPGZ4k1wHuuspXZtD+3ILMTu7tsoAwRQ0zQl5dZeZ6wj0Z0iR3GPrpmZCNH8C3BwGHqk1gA== X-Received: by 2002:ac8:3782:: with SMTP id d2mr65465453qtc.170.1555438959185; Tue, 16 Apr 2019 11:22:39 -0700 (PDT) Received: from [192.168.1.10] (pool-96-255-82-34.washdc.fios.verizon.net. [96.255.82.34]) by smtp.gmail.com with ESMTPSA id x28sm35487352qtx.71.2019.04.16.11.22.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Apr 2019 11:22:38 -0700 (PDT) To: Ferruh Yigit , Olivier Matz Cc: dev@dpdk.org, Stephen Hemminger , Chas Williams References: <20190416155126.26438-1-ferruh.yigit@intel.com> From: Chas Williams <3chas3@gmail.com> Message-ID: <3fd9b596-6ce7-f5a8-a7cc-1e53e0c9196f@gmail.com> Date: Tue, 16 Apr 2019 14:22:37 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190416155126.26438-1-ferruh.yigit@intel.com> Content-Type: text/plain; charset="UTF-8"; format="flowed" Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] net: do not insert VLAN tag to shared mbufs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190416182237.kq8zp5I1AnFeyoOVYcmgO-PPFwWhw4umxQfSDESegvA@z> On 4/16/19 11:51 AM, Ferruh Yigit wrote: > The vlan_insert() is buggy when it tires to handle the shared mbufs, s/tries/tries/ > instead don't support inserting VLAN tag into shared mbufs and return > an error for that case. > > Signed-off-by: Ferruh Yigit > --- > Cc: Stephen Hemminger > Cc: Chas Williams > > This is another approach to RFC to fix the vlan_insert: > https://patches.dpdk.org/patch/51870/ > > vlan_insert() mostly used by drivers to insert VLAN tag into packet > data in Tx path, drivers creating new copies of mbufs in Tx path may > result unexpected behavior, like not freed or double freed mbufs. > --- > lib/librte_net/rte_ether.h | 11 ++--------- > 1 file changed, 2 insertions(+), 9 deletions(-) > > diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h > index 3a87ff184..a1df911b6 100644 > --- a/lib/librte_net/rte_ether.h > +++ b/lib/librte_net/rte_ether.h > @@ -388,15 +388,8 @@ static inline int rte_vlan_insert(struct rte_mbuf **m) > struct vlan_hdr *vh; > > /* Can't insert header if mbuf is shared */ > - if (rte_mbuf_refcnt_read(*m) > 1) { > - struct rte_mbuf *copy; > - > - copy = rte_pktmbuf_clone(*m, (*m)->pool); > - if (unlikely(copy == NULL)) > - return -ENOMEM; > - rte_pktmbuf_free(*m); > - *m = copy; > - } > + if (!RTE_MBUF_DIRECT(*m) || rte_mbuf_refcnt_read(*m) > 1) > + return -EINVAL; > > oh = rte_pktmbuf_mtod(*m, struct ether_hdr *); > nh = (struct ether_hdr *) >