]> git.droids-corp.org - dpdk.git/blobdiff - lib/librte_net/rte_ether.h
net: forbid VLAN insert in shared mbuf
[dpdk.git] / lib / librte_net / rte_ether.h
index 7be9b4890af7266cc616875c09685ad299f511de..1868cb7077d2eccf139b97233d190c2cfe87ee84 100644 (file)
@@ -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 *)