diff options
author | Zoltan Balogh <zoltan.balogh@ericsson.com> | 2017-09-25 19:01:36 -0700 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2017-09-26 15:49:02 -0700 |
commit | 35ab152175bfb7d95a3a4938d583c9f1651a1e9c (patch) | |
tree | 2d5dc5bc20b97225b94c94141561738c126a3ceb | |
parent | b9ba6b4b2c87d58477b2c1eaba5ca1b63fe1bade (diff) | |
download | openvswitch-35ab152175bfb7d95a3a4938d583c9f1651a1e9c.tar.gz |
netdev-dpdk: reset packet_type for reused dp_packets.
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
data.
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>
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
-rw-r--r-- | lib/dp-packet.c | 1 | ||||
-rw-r--r-- | lib/dp-packet.h | 3 | ||||
-rw-r--r-- | lib/netdev-dpdk.c | 7 |
3 files changed, 6 insertions, 5 deletions
diff --git a/lib/dp-packet.c b/lib/dp-packet.c index 312f63a81..945b81ab4 100644 --- a/lib/dp-packet.c +++ b/lib/dp-packet.c @@ -103,7 +103,6 @@ dp_packet_init_dpdk(struct dp_packet *b, size_t allocated) { dp_packet_set_allocated(b, allocated); b->source = DPBUF_DPDK; - b->packet_type = htonl(PT_ETH); } /* Initializes 'b' as an empty dp_packet with an initial capacity of 'size' diff --git a/lib/dp-packet.h b/lib/dp-packet.h index 75ec3051c..980ef7852 100644 --- a/lib/dp-packet.h +++ b/lib/dp-packet.h @@ -801,12 +801,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) { dp_packet_reset_cutlen(packet); + packet->packet_type = htonl(PT_ETH); } } diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 1f1688a20..41acb5b62 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); rte_spinlock_unlock(&dev->stats_lock); - 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) rte_spinlock_unlock(&dev->stats_lock); } - dp_packet_batch_init_cutlen(batch); batch->count = nb_rx; + dp_packet_batch_init_packet_fields(batch); return 0; } |