net: adjust layer 2 length on soft VLAN insertion
diff mbox series

Message ID
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show
  • net: adjust layer 2 length on soft VLAN insertion
Related show


Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

Andrew Rybchenko June 16, 2019, 10:10 a.m. UTC
From: Dilshod Urazov <>

Layer 2 length must be updated after the prepend to mbuf to keep
the length right to be used by other Tx offloads.

If the packet has tunnel encapsulation, outer_l2_len should be
updated. Otherwise l2_len should be updated.

Fixes: c974021a5949 ("ether: add soft vlan encap/decap")

Signed-off-by: Dilshod Urazov <>
Signed-off-by: Andrew Rybchenko <>
The fix is required for net/virtio which supports both VLAN
insertion (using the function) and Tx checksum offloads.

Condition to decide which layer 2 length to update is chosen in accordance
with [1], but could be ((*m)->ol_flags & PKT_TX_TUNNEL_MASK) != 0.


 lib/librte_net/rte_ether.h | 5 +++++
 1 file changed, 5 insertions(+)

diff mbox series

diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h
index 7be9b4890..194570019 100644
--- a/lib/librte_net/rte_ether.h
+++ b/lib/librte_net/rte_ether.h
@@ -417,6 +417,11 @@  static inline int rte_vlan_insert(struct rte_mbuf **m)
 	(*m)->ol_flags &= ~(PKT_RX_VLAN_STRIPPED | PKT_TX_VLAN);
+	if ((*m)->outer_l2_len != 0)
+		(*m)->outer_l2_len += sizeof(struct rte_vlan_hdr);
+	else
+		(*m)->l2_len += sizeof(struct rte_vlan_hdr);
 	return 0;