diff mbox series

[ovs-dev,v2,02/11] netdev-dpdk: Enforce mono-segment mbufs.

Message ID 20251112170420.3155127-3-david.marchand@redhat.com
State Under Review
Headers show
Series Outer UDP checksum optimisations. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

David Marchand Nov. 12, 2025, 5:04 p.m. UTC
A bug in the vhost library for VDUSE devices resulted in multi-segments
mbufs being treated by OVS.

This hard to debug situation resulted in incorrectly segmented packets
with mlx5 nics, as the DPDK driver handles multi-segments mbufs fine
even without requiring RTE_ETH_TX_OFFLOAD_MULTI_SEGS.

While the bug is fixed in the vhost library, we could still hit similar
situations with "normal" DPDK ports: for example,
RTE_ETH_RX_OFFLOAD_SCATTER is requested for jumbo frames and a bug could
be hidden there.

Enforce only mono-segment mbufs are received.

Link: https://patchwork.dpdk.org/project/dpdk/patch/20251028123453.4127525-1-david.marchand@redhat.com/
Reported-at: https://issues.redhat.com/browse/FDP-2121
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 lib/netdev-dpdk.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Mike Pattrick Dec. 1, 2025, 5:26 a.m. UTC | #1
On Wed, Nov 12, 2025 at 12:04 PM David Marchand <david.marchand@redhat.com>
wrote:

> A bug in the vhost library for VDUSE devices resulted in multi-segments
> mbufs being treated by OVS.
>
> This hard to debug situation resulted in incorrectly segmented packets
> with mlx5 nics, as the DPDK driver handles multi-segments mbufs fine
> even without requiring RTE_ETH_TX_OFFLOAD_MULTI_SEGS.
>
> While the bug is fixed in the vhost library, we could still hit similar
> situations with "normal" DPDK ports: for example,
> RTE_ETH_RX_OFFLOAD_SCATTER is requested for jumbo frames and a bug could
> be hidden there.
>
> Enforce only mono-segment mbufs are received.
>
> Link:
> https://patchwork.dpdk.org/project/dpdk/patch/20251028123453.4127525-1-david.marchand@redhat.com/
> Reported-at
> <https://patchwork.dpdk.org/project/dpdk/patch/20251028123453.4127525-1-david.marchand@redhat.com/Reported-at>:
> https://issues.redhat.com/browse/FDP-2121
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
>  lib/netdev-dpdk.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index 3704145a57..0cb9fae9f0 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -2598,6 +2598,9 @@ netdev_dpdk_batch_init_packet_fields(struct
> dp_packet_batch *batch)
>      struct dp_packet *packet;
>
>      DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
> +        /* Datapath does not support multi-segment buffers. */
> +        ovs_assert(packet->mbuf.nb_segs == 1);
>

Would this assert ever be hit in a case that wasn't a bug in a DPDK driver?

-M

+
>          dp_packet_reset_cutlen(packet);
>          packet->packet_type = htonl(PT_ETH);
>          packet->has_hash = !!(packet->mbuf.ol_flags &
> RTE_MBUF_F_RX_RSS_HASH);
> --
> 2.51.0
>
>
David Marchand Dec. 3, 2025, 12:16 p.m. UTC | #2
On Mon, 1 Dec 2025 at 06:27, Mike Pattrick <mkp@redhat.com> wrote:
>
> On Wed, Nov 12, 2025 at 12:04 PM David Marchand <david.marchand@redhat.com> wrote:
>>
>> A bug in the vhost library for VDUSE devices resulted in multi-segments
>> mbufs being treated by OVS.
>>
>> This hard to debug situation resulted in incorrectly segmented packets
>> with mlx5 nics, as the DPDK driver handles multi-segments mbufs fine
>> even without requiring RTE_ETH_TX_OFFLOAD_MULTI_SEGS.
>>
>> While the bug is fixed in the vhost library, we could still hit similar
>> situations with "normal" DPDK ports: for example,
>> RTE_ETH_RX_OFFLOAD_SCATTER is requested for jumbo frames and a bug could
>> be hidden there.
>>
>> Enforce only mono-segment mbufs are received.
>>
>> Link: https://patchwork.dpdk.org/project/dpdk/patch/20251028123453.4127525-1-david.marchand@redhat.com/
>> Reported-at: https://issues.redhat.com/browse/FDP-2121
>> Signed-off-by: David Marchand <david.marchand@redhat.com>
>> ---
>>  lib/netdev-dpdk.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
>> index 3704145a57..0cb9fae9f0 100644
>> --- a/lib/netdev-dpdk.c
>> +++ b/lib/netdev-dpdk.c
>> @@ -2598,6 +2598,9 @@ netdev_dpdk_batch_init_packet_fields(struct dp_packet_batch *batch)
>>      struct dp_packet *packet;
>>
>>      DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
>> +        /* Datapath does not support multi-segment buffers. */
>> +        ovs_assert(packet->mbuf.nb_segs == 1);
>
>
> Would this assert ever be hit in a case that wasn't a bug in a DPDK driver?

Nothing in OVS touches nb_segs, so it would be a bug coming from a
DPDK component: a driver, the vhost library, the mempool/mbuf
library..
diff mbox series

Patch

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 3704145a57..0cb9fae9f0 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2598,6 +2598,9 @@  netdev_dpdk_batch_init_packet_fields(struct dp_packet_batch *batch)
     struct dp_packet *packet;
 
     DP_PACKET_BATCH_FOR_EACH (i, packet, batch) {
+        /* Datapath does not support multi-segment buffers. */
+        ovs_assert(packet->mbuf.nb_segs == 1);
+
         dp_packet_reset_cutlen(packet);
         packet->packet_type = htonl(PT_ETH);
         packet->has_hash = !!(packet->mbuf.ol_flags & RTE_MBUF_F_RX_RSS_HASH);