From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EF484A04B5; Thu, 1 Oct 2020 12:37:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EC0D91DB0E; Thu, 1 Oct 2020 12:22:54 +0200 (CEST) Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) by dpdk.org (Postfix) with ESMTP id 067921DB02 for ; Thu, 1 Oct 2020 12:22:53 +0200 (CEST) Received: by mail-qv1-f49.google.com with SMTP id j10so2602090qvk.11 for ; Thu, 01 Oct 2020 03:22:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QsNSmj8dHOEqvPCitDXTJm/kWCYlAG7sGv/g1y2H5uc=; b=MhVVFkV7ox/AFi8/EL7IreiD3Dbzld126PHa2iKEDoJWb3Bxmm3wOn9R4O/iiDq7A7 i0KjXPpxrpCdTZSTjTOWe7BQSPGpQgQdatOb8GYSzDQyrUmGnHdokVj3U44Z/n9eX7fY y4K7bcIyPU4EIju/HbT1aXD+343IuH6SkqGiW05iD+fPUBEUWIlA5CZu61sk2wEOGcxN M1ERy2dPd13BVgocWTZW8QvClz34Ql+4btIgvk9hKurkxWj+MornWjj5ms9IevTc7byp 2pdRzdSX8ySt6bFGvMQtt5dHELOG6sObR0LlUeqCDfwn9gonvz/c68XOkFn6rmUvsHdm Namg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QsNSmj8dHOEqvPCitDXTJm/kWCYlAG7sGv/g1y2H5uc=; b=h/JBfop4bWquwelcNPrVWCczBmogK0v9xrHXcCR7yOqH5TiHCsXd52wQ0nDwgWmDN/ 9jG/MzWlg6pjEdkto8yYklJIg/Q+JvPFJmzcWovgu0Xff5H2KsOFbd+W1ibipKAB/Bm1 38G2W2QzEg5+SB8ybaYztn2++CH4FH/rd5RBwEljCYEfmJcCehC42JoKr6RSnHiRFSgA W4vOLdG9ydAhUL7laGR4/G9Z84DFQTua0qhZiYE6vac0vwBrRVvyqtfyEREj69IHEuRU A4xw0Zlw/XDRWWNHK/qF/H1E+P9dgBjhBJThxyj/IoyYE072t1YlhxAJGkmp+CgOeFqa qCXg== X-Gm-Message-State: AOAM532Zj6aBMUd4XotyvqqeAPZMJHkp15ghI4hAfJI/rJOTWEEnAE8l YGpKhJrqg+5rZytpyV74tXBEWlP+ZTKVRA== X-Google-Smtp-Source: ABdhPJylZR8LvD/JuDjX0dnYBdgKzQ70y8iBQqn2SVMttGl8BoCUUJUTJJhfqyoskH1MxUN9C+UniQ== X-Received: by 2002:a0c:b60c:: with SMTP id f12mr7129606qve.2.1601547772366; Thu, 01 Oct 2020 03:22:52 -0700 (PDT) Received: from monolith.fios-router.home (pool-96-255-60-31.washdc.fios.verizon.net. [96.255.60.31]) by smtp.googlemail.com with ESMTPSA id q185sm5662399qke.25.2020.10.01.03.22.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 03:22:51 -0700 (PDT) From: Chas Williams <3chas3@gmail.com> To: dev@dpdk.org Cc: olivier.matz@6wind.com, Chas Williams <3chas3@gmail.com> Date: Thu, 1 Oct 2020 06:22:45 -0400 Message-Id: <20201001102245.326223-2-3chas3@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201001102245.326223-1-3chas3@gmail.com> References: <20200928153219.285343-1-3chas3@gmail.com> <20201001102245.326223-1-3chas3@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 2/2] net/virtio: check return from rte_raw_cksum_mbuf X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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") Signed-off-by: Chas Williams <3chas3@gmail.com> --- drivers/net/virtio/virtio_rxtx.c | 5 +++-- drivers/net/virtio/virtio_rxtx_packed_avx.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 0ade35215..019187bf9 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -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; diff --git a/drivers/net/virtio/virtio_rxtx_packed_avx.c b/drivers/net/virtio/virtio_rxtx_packed_avx.c index 6a8214725..67a55abce 100644 --- a/drivers/net/virtio/virtio_rxtx_packed_avx.c +++ b/drivers/net/virtio/virtio_rxtx_packed_avx.c @@ -328,9 +328,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; -- 2.26.2