Skip to contentSkip to conversation

net/virtio: fix checksum offset check in Rx path

PATCH Applied Morten Brørup 2 participants 3 messages Oct 19 – Oct 20 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/virtio: fix checksum offset check in Rx path

Writing the checksum in the packet needs room for 2 bytes, not 1 byte.

Fixes 96cb6711939e ("net/virtio: support Rx checksum offload")
Fixes 0eaf7fc2fe8e ("net/virtio: separate AVX Rx/Tx")
---
 drivers/net/virtio/virtio_rxtx.c        | 2 +-
 drivers/net/virtio/virtio_rxtx_packed.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_rxtx.c +1 -1
index edecd2011f..1afb68bc69 100644
@@ -955,7 +955,7 @@ virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr)
 			if (likely(csum != 0xffff))
 				csum = ~csum;
 			off = hdr->csum_offset + hdr->csum_start;
-			if (rte_pktmbuf_data_len(m) >= off + 1)
+			if (rte_pktmbuf_data_len(m) >= off + sizeof(uint16_t))
 				*rte_pktmbuf_mtod_offset(m, uint16_t *,
 					off) = csum;
 		}
drivers/net/virtio/virtio_rxtx_packed.h +1 -1
index f7cc60bb51..6501ede3f0 100644
@@ -185,7 +185,7 @@ virtio_vec_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr)
 			if (likely(csum != 0xffff))
 				csum = ~csum;
 			off = hdr->csum_offset + hdr->csum_start;
-			if (rte_pktmbuf_data_len(m) >= off + 1)
+			if (rte_pktmbuf_data_len(m) >= off + sizeof(uint16_t))
 				*rte_pktmbuf_mtod_offset(m, uint16_t *,
 					off) = csum;
 		}
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 40 lines · Morten Brørup

Writing the checksum in the packet needs room for 2 bytes, not 1 byte.

Fixes 96cb6711939e ("net/virtio: support Rx checksum offload")
Fixes 0eaf7fc2fe8e ("net/virtio: separate AVX Rx/Tx")
---
 drivers/net/virtio/virtio_rxtx.c        | 2 +-
 drivers/net/virtio/virtio_rxtx_packed.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_rxtx.c +1 -1
index edecd2011f..1afb68bc69 100644
@@ -955,7 +955,7 @@ virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr)
                        if (likely(csum != 0xffff))
                                csum = ~csum;
                        off = hdr->csum_offset + hdr->csum_start;
-                       if (rte_pktmbuf_data_len(m) >= off + 1)
+                       if (rte_pktmbuf_data_len(m) >= off + sizeof(uint16_t))
                                *rte_pktmbuf_mtod_offset(m, uint16_t *,
                                        off) = csum;
                }
drivers/net/virtio/virtio_rxtx_packed.h +1 -2
index f7cc60bb51..6501ede3f0 100644
@@ -185,7 +185,7 @@ virtio_vec_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr)
                        if (likely(csum != 0xffff))
                                csum = ~csum;
                        off = hdr->csum_offset + hdr->csum_start;
-                       if (rte_pktmbuf_data_len(m) >= off + 1)
+                       if (rte_pktmbuf_data_len(m) >= off + sizeof(uint16_t))
                                *rte_pktmbuf_mtod_offset(m, uint16_t *,
                                        off) = csum;
                }
--
Quoted 2 lines

2.43.0

#2 lore raw
In reply to Morten Brørup
Quoted 11 lines · Morten Brørup

Writing the checksum in the packet needs room for 2 bytes, not 1 byte.

Fixes 96cb6711939e ("net/virtio: support Rx checksum offload")
Fixes 0eaf7fc2fe8e ("net/virtio: separate AVX Rx/Tx")
---
  drivers/net/virtio/virtio_rxtx.c        | 2 +-
  drivers/net/virtio/virtio_rxtx_packed.h | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

Applied to next-virtio/for-next-net.

Thanks,

Maxime