From 15a74163b12ed9b8b980b1576bdd8de16d60612b Mon Sep 17 00:00:00 2001 From: Ferruh Yigit Date: Tue, 16 Apr 2019 16:51:26 +0100 Subject: [PATCH] net: forbid VLAN insert in shared mbuf The vlan_insert() is buggy when it tries 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 Acked-by: Olivier Matz --- 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 7be9b4890a..1868cb7077 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -393,15 +393,8 @@ static inline int rte_vlan_insert(struct rte_mbuf **m) struct rte_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 rte_ether_hdr *); nh = (struct rte_ether_hdr *) -- 2.20.1