DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Olivier Matz <olivier.matz@6wind.com>
Cc: dev@dpdk.org, Stephen Hemminger <stephen@networkplumber.org>,
	Chas Williams <chas3@att.com>
Subject: [dpdk-dev] [PATCH] net: do not insert VLAN tag to shared mbufs
Date: Tue, 16 Apr 2019 16:51:26 +0100	[thread overview]
Message-ID: <20190416155126.26438-1-ferruh.yigit@intel.com> (raw)

The vlan_insert() is buggy when it tires to handle the shared mbufs,
instead don't support inserting VLAN tag into shared mbufs and return
an error for that case.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: Chas Williams <chas3@att.com>

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 *)
-- 
2.20.1

             reply	other threads:[~2019-04-16 15:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-16 15:51 Ferruh Yigit [this message]
2019-04-16 15:51 ` Ferruh Yigit
2019-04-16 16:28 ` Bruce Richardson
2019-04-16 16:28   ` Bruce Richardson
2019-04-16 18:32   ` Chas Williams
2019-04-16 18:32     ` Chas Williams
2019-04-17  8:12     ` Bruce Richardson
2019-04-17  8:12       ` Bruce Richardson
2019-05-13 12:43       ` Olivier Matz
2019-05-13 12:43         ` Olivier Matz
2019-07-04 14:01         ` Thomas Monjalon
2019-04-16 18:22 ` Chas Williams
2019-04-16 18:22   ` Chas Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190416155126.26438-1-ferruh.yigit@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=chas3@att.com \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).