[ovs-dev,v4] netdev-dpdk: reset packet_type for reused dp_packets

Message ID AM2PR07MB1042552ED8BD006484DB700C8A950@AM2PR07MB1042.eurprd07.prod.outlook.com
State New
Headers show
  • [ovs-dev,v4] netdev-dpdk: reset packet_type for reused dp_packets
Related show

Commit Message

Zoltán Balogh Sept. 8, 2017, 2:12 p.m.
DPDK uses dp-packet pool for storing received packets. The pool is
reused by rxq_recv funcions of the DPDK netdevs. The datapath is
capable to modify the packet_type property of packets. For instance
when encapsulated L3 packets are received on a ptap gre port.
In this case the packet_type property of struct dp_packet can be
modified and later the same dp_packet with the modified packet_type
can be reused in the rxq_rec function, so it can contain corrupted

The dp_packet_batch_init_cutlen() in the rxq_recv functions iterates
over dp_packets and sets their cutlen. So I modified this function
to set packet_type to Ethernet for the dp_packets as well. I also
renamed this function because of the added functionality.

The dp_packet_batch_init_cutlen() iterates over batch->count dp_packet.
Therefore setting of batch->count = nb_rx needs to be done before the
former function is invoked. This is an additional fix.

Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Laszlo Suru <laszlo.suru@ericsson.com>
Co-authored-by: Laszlo Suru <laszlo.suru@ericsson.com>
CC: Jan Scheurich <jan.scheurich@ericsson.com>
CC: Sugesh Chandran <sugesh.chandran@intel.com>
CC: Darrell Ball <dlu998@gmail.com>
 lib/dp-packet.h   | 3 ++-
 lib/netdev-dpdk.c | 7 ++++---
 2 files changed, 6 insertions(+), 4 deletions(-)


diff --git a/lib/dp-packet.h b/lib/dp-packet.h
index 046f3ab..b4b721c 100644
--- a/lib/dp-packet.h
+++ b/lib/dp-packet.h
@@ -805,12 +805,13 @@  dp_packet_delete_batch(struct dp_packet_batch *batch, bool may_steal)
 static inline void
-dp_packet_batch_init_cutlen(struct dp_packet_batch *batch)
+dp_packet_batch_init_packet_fields(struct dp_packet_batch *batch)
     struct dp_packet *packet;
     DP_PACKET_BATCH_FOR_EACH (packet, batch) {
+        packet->packet_type = htonl(PT_ETH);
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index f58e9be..ccccb9a 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1644,8 +1644,9 @@  netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
                                          nb_rx, dropped);
-    dp_packet_batch_init_cutlen(batch);
-    batch->count = (int) nb_rx;
+    batch->count = nb_rx;
+    dp_packet_batch_init_packet_fields(batch);
     return 0;
@@ -1684,8 +1685,8 @@  netdev_dpdk_rxq_recv(struct netdev_rxq *rxq, struct dp_packet_batch *batch)
-    dp_packet_batch_init_cutlen(batch);
     batch->count = nb_rx;
+    dp_packet_batch_init_packet_fields(batch);
     return 0;