Skip to contentSkip to conversation

net/mlx5: fix packet type and offload flags in Rx

PATCH Applied Maxime Leroy 3 participants 3 messages Jul 7, 2016 – Jul 8, 2016 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: fix packet type and offload flags in Rx

In mlx5 rx function, the packet_type and ol_flags mbuf fields are not properly initialized when no rx offload feature is enabled (checksum, l2 tun checksum, vlan_strip, crc). Thus, these fields can have a value different of 0 depending on their value when the mbuf was freed.

This can result in an incorrect application behavior if invalid ol_flags/ptype are set, or memory corruptions if IND_ATTACHED_MBUF is set in ol_flags.

Fixes 081f7eae242e ("mlx5: process offload flags only when requested")
---
 drivers/net/mlx5/mlx5_rxtx.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/mlx5/mlx5_rxtx.c +2 -0
index 0c352f3f..4132fd74 100644
@@ -1599,6 +1599,8 @@ mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
 			pkt = seg;
 			assert(len >= (rxq->crc_present << 2));
 			/* Update packet information. */
+			pkt->packet_type = 0;
+			pkt->ol_flags = 0;
 			if (rxq->csum | rxq->csum_l2tun | rxq->vlan_strip |
 			    rxq->crc_present) {
 				if (rxq->csum) {
Signature · 1 line
2.1.4
Acked-by on v1 1/1
#1 lore raw
Quoted 32 lines · Maxime Leroy

In mlx5 rx function, the packet_type and ol_flags mbuf fields are not properly initialized when no rx offload feature is enabled (checksum, l2 tun checksum, vlan_strip, crc). Thus, these fields can have a value different of 0 depending on their value when the mbuf was freed.

This can result in an incorrect application behavior if invalid ol_flags/ptype are set, or memory corruptions if IND_ATTACHED_MBUF is set in ol_flags.

Fixes 081f7eae242e ("mlx5: process offload flags only when requested")
---
 drivers/net/mlx5/mlx5_rxtx.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/mlx5/mlx5_rxtx.c +2 -0
index 0c352f3f..4132fd74 100644
@@ -1599,6 +1599,8 @@ mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
 			pkt = seg;
 			assert(len >= (rxq->crc_present << 2));
 			/* Update packet information. */
+			pkt->packet_type = 0;
+			pkt->ol_flags = 0;
 			if (rxq->csum | rxq->csum_l2tun | rxq->vlan_strip |
 			    rxq->crc_present) {
 				if (rxq->csum) {
Signature · 1 line
2.1.4
Signature · 2 lines
Adrien Mazarguil
6WIND
#2 lore raw
Quoted 27 lines · Adrien Mazarguil
Quoted 26 lines · Maxime Leroy

In mlx5 rx function, the packet_type and ol_flags mbuf fields are not properly initialized when no rx offload feature is enabled (checksum, l2 tun checksum, vlan_strip, crc). Thus, these fields can have a value different of 0 depending on their value when the mbuf was freed.

This can result in an incorrect application behavior if invalid ol_flags/ptype are set, or memory corruptions if IND_ATTACHED_MBUF is set in ol_flags.

Fixes 081f7eae242e ("mlx5: process offload flags only when requested")
---
 drivers/net/mlx5/mlx5_rxtx.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/mlx5/mlx5_rxtx.c +2 -0
index 0c352f3f..4132fd74 100644
@@ -1599,6 +1599,8 @@ mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
 			pkt = seg;
 			assert(len >= (rxq->crc_present << 2));
 			/* Update packet information. */
+			pkt->packet_type = 0;
+			pkt->ol_flags = 0;
Quoted 9 lines
Quoted 6 lines
drivers/net/mlx5/mlx5_rxtx.c +0 -0
 			if (rxq->csum | rxq->csum_l2tun | rxq->vlan_strip |
 			    rxq->crc_present) {
 				if (rxq->csum) {
Signature · 1 line
2.1.4

Applied to dpdk-next-net/rel_16_07

/Bruce