net/virtio: check raw checksum failure
authorChas Williams <3chas3@gmail.com>
Thu, 1 Oct 2020 10:22:45 +0000 (06:22 -0400)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 12 Oct 2020 21:14:06 +0000 (23:14 +0200)
rte_raw_cksum_mbuf can fail, so we should check to see if it
has. If so, return with an error.

Fixes: 96cb6711939e ("net/virtio: support Rx checksum offload")
Cc: stable@dpdk.org
Signed-off-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/net/virtio/virtio_rxtx.c
drivers/net/virtio/virtio_rxtx_packed_avx.c

index 88c03bf..77934e8 100644 (file)
@@ -910,9 +910,10 @@ virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr)
                         */
                        uint16_t csum = 0, off;
 
-                       rte_raw_cksum_mbuf(m, hdr->csum_start,
+                       if (rte_raw_cksum_mbuf(m, hdr->csum_start,
                                rte_pktmbuf_pkt_len(m) - hdr->csum_start,
-                               &csum);
+                               &csum) < 0)
+                               return -EINVAL;
                        if (likely(csum != 0xffff))
                                csum = ~csum;
                        off = hdr->csum_offset + hdr->csum_start;
index ce035b5..9bc6271 100644 (file)
@@ -336,9 +336,10 @@ virtio_vec_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr)
                         */
                        uint16_t csum = 0, off;
 
-                       rte_raw_cksum_mbuf(m, hdr->csum_start,
+                       if (rte_raw_cksum_mbuf(m, hdr->csum_start,
                                rte_pktmbuf_pkt_len(m) - hdr->csum_start,
-                               &csum);
+                               &csum) < 0)
+                               return -1;
                        if (likely(csum != 0xffff))
                                csum = ~csum;
                        off = hdr->csum_offset + hdr->csum_start;