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 63F9CA04DD for ; Wed, 28 Oct 2020 11:47:52 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5D3082C2A; Wed, 28 Oct 2020 11:47:51 +0100 (CET) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by dpdk.org (Postfix) with ESMTP id C7AF12C2A for ; Wed, 28 Oct 2020 11:47:49 +0100 (CET) Received: by mail-wr1-f67.google.com with SMTP id t9so5112024wrq.11 for ; Wed, 28 Oct 2020 03:47:49 -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=kPS/aBUPIcgD97DyfYWmjh8+rzUTcrz23g6fTVIBglM=; b=OAjqkm/e/Ps2B58JOHUT5IoxWw+F8ZUmgKYb55RbknGI471QRl9pXmA6pGQ6418hbZ K4RJEhsyBu24LLmyu0BB9cstxRDmbbqb74XMQKrxTGrs8Gci9+0mKlCbMG2UGkW7IhMV hBvrx606EQVfotVeN7CtH56lZgsBp83d+auwS6FzFWGyGKKg18S/P5hFezDmYAqpW4RS dHZpINYEdZK7HpCAz/w8jb1TILnlfhzhhzJ2KKuwBJPFLRU/Fnz48cHPEdKYAbnpf0NG XkB1VJooE/JIWduEjgBC2Gkf8Lyz/WKlo8gL0K3zkAo7zq0ZMPO5k1b7kNN5XOG0hC1F KzUA== 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=kPS/aBUPIcgD97DyfYWmjh8+rzUTcrz23g6fTVIBglM=; b=oU/xwwM5wHy7CqIcbWkM4HnkLGAF11Yqvd0MSVTbq2cYFRF3lvWctyjeH7wEMefCDy ux+iIiyZMOVBYLCi0SL7un9/+8BRccNST4aj+aiGJDb3p7T/uxzmLVCC84hoJeqzJRzw 8OuNnumJ2GhKmgU7v9gSwIjZnj+LzTEq4/ALZr1HTZCWF6Vbz7xv/N67ZqlXSXjQly7w ibuudc6UqZfyorIrqnY7muQm4+3YJHb71ELDwUr2Neo6qTcyRWuZkPqvzWWPlg8QUR2Q bTjghBfFKQv2MGN/SS5YT1/Ph44EL+ycY+H1dBas/eFjLUBNXCUNNtqP1wGZxV13hc/L gTYw== X-Gm-Message-State: AOAM5314unkmiNZ6kfZlpKFqv+WWNsI5KGedeRwctsGZNVcPt3X/uTBo oomhRCT4Bwk1u01nZnzOQ2iBEmNqsPQ95VhO X-Google-Smtp-Source: ABdhPJzfSgR+2SFSyGeDC0MOMWgNHhV+m2XMTdvguXfCypPIrYLSclAZ3lfP4rhR4L8lejn8EXyw4w== X-Received: by 2002:adf:bc0f:: with SMTP id s15mr8184311wrg.83.1603882069548; Wed, 28 Oct 2020 03:47:49 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id u9sm6636775wrp.65.2020.10.28.03.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 03:47:48 -0700 (PDT) From: luca.boccassi@gmail.com To: Yunjian Wang Cc: Ferruh Yigit , dpdk stable Date: Wed, 28 Oct 2020 10:43:10 +0000 Message-Id: <20201028104606.3504127-31-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201028104606.3504127-1-luca.boccassi@gmail.com> References: <20201028104606.3504127-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/tap: free mempool when closing' has been queued to stable release 19.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 10/30/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From 81230a8e0dc3cdc176e0704fb37e5bcf425c8351 Mon Sep 17 00:00:00 2001 From: Yunjian Wang Date: Sat, 8 Aug 2020 17:58:43 +0800 Subject: [PATCH] net/tap: free mempool when closing [ upstream commit 05a8e4a35d3ca9c1e5271917ad081ba78cd73fce ] When setup tx queues, we will create a mempool for the 'gso_ctx'. The mempool is not freed when closing tap device. If free the tap device and create it with different name, it will create a new mempool. This maybe cause an OOM. The snprintf function return value is not checked and the mempool name may be truncated. This patch also fix it. Fixes: 050316a88313 ("net/tap: support TSO (TCP Segment Offload)") Signed-off-by: Yunjian Wang Reviewed-by: Ferruh Yigit --- drivers/net/tap/rte_eth_tap.c | 43 +++++++++++++++++++++-------------- drivers/net/tap/rte_eth_tap.h | 1 + 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 7081ae23e9..cfbd579cd6 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -1070,6 +1070,9 @@ tap_dev_close(struct rte_eth_dev *dev) &internals->remote_initial_flags); } + rte_mempool_free(internals->gso_ctx_mp); + internals->gso_ctx_mp = NULL; + if (internals->ka_fd != -1) { close(internals->ka_fd); internals->ka_fd = -1; @@ -1317,26 +1320,31 @@ tap_gso_ctx_setup(struct rte_gso_ctx *gso_ctx, struct rte_eth_dev *dev) { uint32_t gso_types; char pool_name[64]; - - /* - * Create private mbuf pool with TAP_GSO_MBUF_SEG_SIZE bytes - * size per mbuf use this pool for both direct and indirect mbufs - */ - - struct rte_mempool *mp; /* Mempool for GSO packets */ + struct pmd_internals *pmd = dev->data->dev_private; + int ret; /* initialize GSO context */ gso_types = DEV_TX_OFFLOAD_TCP_TSO; - snprintf(pool_name, sizeof(pool_name), "mp_%s", dev->device->name); - mp = rte_mempool_lookup((const char *)pool_name); - if (!mp) { - mp = rte_pktmbuf_pool_create(pool_name, TAP_GSO_MBUFS_NUM, - TAP_GSO_MBUF_CACHE_SIZE, 0, + if (!pmd->gso_ctx_mp) { + /* + * Create private mbuf pool with TAP_GSO_MBUF_SEG_SIZE + * bytes size per mbuf use this pool for both direct and + * indirect mbufs + */ + ret = snprintf(pool_name, sizeof(pool_name), "mp_%s", + dev->device->name); + if (ret < 0 || ret >= (int)sizeof(pool_name)) { + TAP_LOG(ERR, + "%s: failed to create mbuf pool name for device %s," + "device name too long or output error, ret: %d\n", + pmd->name, dev->device->name, ret); + return -ENAMETOOLONG; + } + pmd->gso_ctx_mp = rte_pktmbuf_pool_create(pool_name, + TAP_GSO_MBUFS_NUM, TAP_GSO_MBUF_CACHE_SIZE, 0, RTE_PKTMBUF_HEADROOM + TAP_GSO_MBUF_SEG_SIZE, SOCKET_ID_ANY); - if (!mp) { - struct pmd_internals *pmd = dev->data->dev_private; - + if (!pmd->gso_ctx_mp) { TAP_LOG(ERR, "%s: failed to create mbuf pool for device %s\n", pmd->name, dev->device->name); @@ -1344,8 +1352,8 @@ tap_gso_ctx_setup(struct rte_gso_ctx *gso_ctx, struct rte_eth_dev *dev) } } - gso_ctx->direct_pool = mp; - gso_ctx->indirect_pool = mp; + gso_ctx->direct_pool = pmd->gso_ctx_mp; + gso_ctx->indirect_pool = pmd->gso_ctx_mp; gso_ctx->gso_types = gso_types; gso_ctx->gso_size = 0; /* gso_size is set in tx_burst() per packet */ gso_ctx->flag = 0; @@ -1842,6 +1850,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name, pmd->type = type; pmd->ka_fd = -1; pmd->nlsk_fd = -1; + pmd->gso_ctx_mp = NULL; pmd->ioctl_sock = socket(AF_INET, SOCK_DGRAM, 0); if (pmd->ioctl_sock == -1) { diff --git a/drivers/net/tap/rte_eth_tap.h b/drivers/net/tap/rte_eth_tap.h index 8d6d53dc0a..ba45de8409 100644 --- a/drivers/net/tap/rte_eth_tap.h +++ b/drivers/net/tap/rte_eth_tap.h @@ -91,6 +91,7 @@ struct pmd_internals { struct tx_queue txq[RTE_PMD_TAP_MAX_QUEUES]; /* List of TX queues */ struct rte_intr_handle intr_handle; /* LSC interrupt handle. */ int ka_fd; /* keep-alive file descriptor */ + struct rte_mempool *gso_ctx_mp; /* Mempool for GSO packets */ }; struct pmd_process_private { -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-10-28 10:35:12.762696151 +0000 +++ 0031-net-tap-free-mempool-when-closing.patch 2020-10-28 10:35:11.472829553 +0000 @@ -1,8 +1,10 @@ -From 05a8e4a35d3ca9c1e5271917ad081ba78cd73fce Mon Sep 17 00:00:00 2001 +From 81230a8e0dc3cdc176e0704fb37e5bcf425c8351 Mon Sep 17 00:00:00 2001 From: Yunjian Wang Date: Sat, 8 Aug 2020 17:58:43 +0800 Subject: [PATCH] net/tap: free mempool when closing +[ upstream commit 05a8e4a35d3ca9c1e5271917ad081ba78cd73fce ] + When setup tx queues, we will create a mempool for the 'gso_ctx'. The mempool is not freed when closing tap device. If free the tap device and create it with different name, it will create a new @@ -12,7 +14,6 @@ name may be truncated. This patch also fix it. Fixes: 050316a88313 ("net/tap: support TSO (TCP Segment Offload)") -Cc: stable@dpdk.org Signed-off-by: Yunjian Wang Reviewed-by: Ferruh Yigit @@ -22,10 +23,10 @@ 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c -index b19e26ba0e..df16aa4ea7 100644 +index 7081ae23e9..cfbd579cd6 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c -@@ -1105,6 +1105,9 @@ tap_dev_close(struct rte_eth_dev *dev) +@@ -1070,6 +1070,9 @@ tap_dev_close(struct rte_eth_dev *dev) &internals->remote_initial_flags); } @@ -35,7 +36,7 @@ if (internals->ka_fd != -1) { close(internals->ka_fd); internals->ka_fd = -1; -@@ -1352,26 +1355,31 @@ tap_gso_ctx_setup(struct rte_gso_ctx *gso_ctx, struct rte_eth_dev *dev) +@@ -1317,26 +1320,31 @@ tap_gso_ctx_setup(struct rte_gso_ctx *gso_ctx, struct rte_eth_dev *dev) { uint32_t gso_types; char pool_name[64]; @@ -82,7 +83,7 @@ TAP_LOG(ERR, "%s: failed to create mbuf pool for device %s\n", pmd->name, dev->device->name); -@@ -1379,8 +1387,8 @@ tap_gso_ctx_setup(struct rte_gso_ctx *gso_ctx, struct rte_eth_dev *dev) +@@ -1344,8 +1352,8 @@ tap_gso_ctx_setup(struct rte_gso_ctx *gso_ctx, struct rte_eth_dev *dev) } } @@ -93,7 +94,7 @@ gso_ctx->gso_types = gso_types; gso_ctx->gso_size = 0; /* gso_size is set in tx_burst() per packet */ gso_ctx->flag = 0; -@@ -1877,6 +1885,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name, +@@ -1842,6 +1850,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name, pmd->type = type; pmd->ka_fd = -1; pmd->nlsk_fd = -1;