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 85D69A0518 for ; Fri, 24 Jul 2020 14:03:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7D6D01C02A; Fri, 24 Jul 2020 14:03:05 +0200 (CEST) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by dpdk.org (Postfix) with ESMTP id 6205F1C010 for ; Fri, 24 Jul 2020 14:03:04 +0200 (CEST) Received: by mail-wm1-f65.google.com with SMTP id x5so7175744wmi.2 for ; Fri, 24 Jul 2020 05:03:04 -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=od1+ri4kl40HadbwrAig+WI1yvAuWVLiLR1LhNY7520=; b=kpGtiiDJ62Cmnkz332s4KnvogksVePPKnivdkqh5AixK2J16OdAeACM0nd/E191Ik/ JY+7YjdLOZNMCZWKk5iTQGjnqttuJaOTFPg+N/NEmDzi2Fbo4Bv8//EVH7ZklM4lnYM4 1BhpGCsHMz+YU0mOmCeHPZfYiQZodUtO36Jx6h++AO4arWb/ROa++7bQLr6D5xbH0miB Ka9+K/51ZtV+zogFYwcWMXDxpW5fW3Hg1jlOzWldaGpxoKXnq5nG6mlgP43BFzcOXqCV QbuAx4TfBCJVig6NV2nc4s4zDnbmY7Au5BWdNUK8i5whIuE9N62yEiuH3rdUzgzcUScC lMIQ== 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=od1+ri4kl40HadbwrAig+WI1yvAuWVLiLR1LhNY7520=; b=mLBkH2//ICslvBY0xWXKvVoDZVZg74sWK9gBViOGtu5XKV8hN1ason1BwVra8NZ04I VqyROeh90w+ARBWQjUAE8xme5KvIcbHDJIXSFlo/QSyLmZmEy2mVkkEkggvsapJ1TfLL XiS/SYuGuzmxGAYGbqU0GrIco+f19z6HS/ggsALAumNd030vOx5jTdRBx3AVC1dRiYid vc0C2JKrIaPGqRc46giyUUMI2uAwp6CF/6YFGcZUPlQbWyokPwAB/v4ePTBBtGNlcPRq JxCbNud33NW8ut1FGPLDKftmaMj0kOGhSFU7kNilDfpdjIexMDHtaYE6rjbd/xRBEOe8 qreQ== X-Gm-Message-State: AOAM5336murZwvDJ5VJRP6t2iT5CVb6YbEbPqWN1SQhQvWrd5sOuasAX wdfv68o87KpbJmTgSp1kbG2ykZJPZnkmaQ== X-Google-Smtp-Source: ABdhPJwf3fOom7iUnqHZIfIx/gOoxp5JFtlEJFwD1a3D5CYWgSbK/E9GIuAqPin4xtxRcNxVXwGITg== X-Received: by 2002:a7b:cb47:: with SMTP id v7mr8086004wmj.57.1595592184092; Fri, 24 Jul 2020 05:03:04 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id q7sm1075152wra.56.2020.07.24.05.03.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jul 2020 05:03:02 -0700 (PDT) From: luca.boccassi@gmail.com To: Rahul Lakkireddy Cc: dpdk stable Date: Fri, 24 Jul 2020 12:57:57 +0100 Message-Id: <20200724120030.1863487-39-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200724120030.1863487-1-luca.boccassi@gmail.com> References: <20200724120030.1863487-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/cxgbe: fix CLIP leak in filter error path' has been queued to stable release 19.11.4 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.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/26/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 3c1368a539cc4353188cb73bdb1dbcba0d654b47 Mon Sep 17 00:00:00 2001 From: Rahul Lakkireddy Date: Sat, 13 Jun 2020 03:37:23 +0530 Subject: [PATCH] net/cxgbe: fix CLIP leak in filter error path [ upstream commit 844b21299f1a10ac350528365dc761e2934512ee ] Free up Compressed Local IP (CLIP) entry properly during filter creation failure path. Also consolidate all various tables cleanup to a common function and invoke it from both wild-card and exact-match filter paths. Fixes: af44a577988b ("net/cxgbe: support to offload flows to HASH region") Signed-off-by: Rahul Lakkireddy --- drivers/net/cxgbe/cxgbe_filter.c | 68 +++++++++++++++----------------- 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/drivers/net/cxgbe/cxgbe_filter.c b/drivers/net/cxgbe/cxgbe_filter.c index b9d9d5d39..8a8031cb9 100644 --- a/drivers/net/cxgbe/cxgbe_filter.c +++ b/drivers/net/cxgbe/cxgbe_filter.c @@ -269,6 +269,22 @@ int cxgbe_alloc_ftid(struct adapter *adap, u8 nentries) return pos < size ? pos : -1; } +/** + * Clear a filter and release any of its resources that we own. This also + * clears the filter's "pending" status. + */ +static void clear_filter(struct filter_entry *f) +{ + if (f->clipt) + cxgbe_clip_release(f->dev, f->clipt); + + /* The zeroing of the filter rule below clears the filter valid, + * pending, locked flags etc. so it's all we need for + * this operation. + */ + memset(f, 0, sizeof(*f)); +} + /** * Construct hash filter ntuple. */ @@ -555,7 +571,7 @@ static int cxgbe_set_hash_filter(struct rte_eth_dev *dev, f = t4_os_alloc(sizeof(*f)); if (!f) - goto out_err; + return -ENOMEM; f->fs = *fs; f->ctx = ctx; @@ -592,7 +608,7 @@ static int cxgbe_set_hash_filter(struct rte_eth_dev *dev, mbuf = rte_pktmbuf_alloc(ctrlq->mb_pool); if (!mbuf) { ret = -ENOMEM; - goto free_clip; + goto free_atid; } mbuf->data_len = size; @@ -622,33 +638,15 @@ static int cxgbe_set_hash_filter(struct rte_eth_dev *dev, t4_mgmt_tx(ctrlq, mbuf); return 0; -free_clip: - cxgbe_clip_release(f->dev, f->clipt); free_atid: cxgbe_free_atid(t, atid); out_err: + clear_filter(f); t4_os_free(f); return ret; } -/** - * Clear a filter and release any of its resources that we own. This also - * clears the filter's "pending" status. - */ -static void clear_filter(struct filter_entry *f) -{ - if (f->clipt) - cxgbe_clip_release(f->dev, f->clipt); - - /* - * The zeroing of the filter rule below clears the filter valid, - * pending, locked flags etc. so it's all we need for - * this operation. - */ - memset(f, 0, sizeof(*f)); -} - /** * t4_mk_filtdelwr - create a delete filter WR * @adap: adapter context @@ -1007,16 +1005,6 @@ int cxgbe_set_filter(struct rte_eth_dev *dev, unsigned int filter_id, return ret; } - /* - * Allocate a clip table entry only if we have non-zero IPv6 address - */ - if (chip_ver > CHELSIO_T5 && fs->type && - memcmp(fs->val.lip, bitoff, sizeof(bitoff))) { - f->clipt = cxgbe_clip_alloc(dev, (u32 *)&fs->val.lip); - if (!f->clipt) - goto free_tid; - } - /* * Convert the filter specification into our internal format. * We copy the PF/VF specification into the Outer VLAN field @@ -1027,6 +1015,16 @@ int cxgbe_set_filter(struct rte_eth_dev *dev, unsigned int filter_id, f->fs.iq = iq; f->dev = dev; + /* Allocate a clip table entry only if we have non-zero IPv6 address. */ + if (chip_ver > CHELSIO_T5 && f->fs.type && + memcmp(f->fs.val.lip, bitoff, sizeof(bitoff))) { + f->clipt = cxgbe_clip_alloc(dev, (u32 *)&f->fs.val.lip); + if (!f->clipt) { + ret = -ENOMEM; + goto free_tid; + } + } + /* * Attempt to set the filter. If we don't succeed, we clear * it and return the failure. @@ -1107,6 +1105,7 @@ void cxgbe_hash_filter_rpl(struct adapter *adap, } cxgbe_free_atid(t, ftid); + clear_filter(f); t4_os_free(f); } @@ -1331,13 +1330,8 @@ void cxgbe_hash_del_filter_rpl(struct adapter *adap, } ctx = f->ctx; - f->ctx = NULL; - - f->valid = 0; - - if (f->clipt) - cxgbe_clip_release(f->dev, f->clipt); + clear_filter(f); cxgbe_remove_tid(t, 0, tid, 0); t4_os_free(f); -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-07-24 12:53:50.121429259 +0100 +++ 0039-net-cxgbe-fix-CLIP-leak-in-filter-error-path.patch 2020-07-24 12:53:48.251005789 +0100 @@ -1,15 +1,16 @@ -From 844b21299f1a10ac350528365dc761e2934512ee Mon Sep 17 00:00:00 2001 +From 3c1368a539cc4353188cb73bdb1dbcba0d654b47 Mon Sep 17 00:00:00 2001 From: Rahul Lakkireddy Date: Sat, 13 Jun 2020 03:37:23 +0530 Subject: [PATCH] net/cxgbe: fix CLIP leak in filter error path +[ upstream commit 844b21299f1a10ac350528365dc761e2934512ee ] + Free up Compressed Local IP (CLIP) entry properly during filter creation failure path. Also consolidate all various tables cleanup to a common function and invoke it from both wild-card and exact-match filter paths. Fixes: af44a577988b ("net/cxgbe: support to offload flows to HASH region") -Cc: stable@dpdk.org Signed-off-by: Rahul Lakkireddy --- @@ -17,10 +18,10 @@ 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/drivers/net/cxgbe/cxgbe_filter.c b/drivers/net/cxgbe/cxgbe_filter.c -index 27e96c73e..45602d468 100644 +index b9d9d5d39..8a8031cb9 100644 --- a/drivers/net/cxgbe/cxgbe_filter.c +++ b/drivers/net/cxgbe/cxgbe_filter.c -@@ -284,6 +284,22 @@ int cxgbe_alloc_ftid(struct adapter *adap, u8 nentries) +@@ -269,6 +269,22 @@ int cxgbe_alloc_ftid(struct adapter *adap, u8 nentries) return pos < size ? pos : -1; } @@ -43,7 +44,7 @@ /** * Construct hash filter ntuple. */ -@@ -583,7 +599,7 @@ static int cxgbe_set_hash_filter(struct rte_eth_dev *dev, +@@ -555,7 +571,7 @@ static int cxgbe_set_hash_filter(struct rte_eth_dev *dev, f = t4_os_alloc(sizeof(*f)); if (!f) @@ -52,7 +53,7 @@ f->fs = *fs; f->ctx = ctx; -@@ -631,7 +647,7 @@ static int cxgbe_set_hash_filter(struct rte_eth_dev *dev, +@@ -592,7 +608,7 @@ static int cxgbe_set_hash_filter(struct rte_eth_dev *dev, mbuf = rte_pktmbuf_alloc(ctrlq->mb_pool); if (!mbuf) { ret = -ENOMEM; @@ -61,7 +62,7 @@ } mbuf->data_len = size; -@@ -661,33 +677,15 @@ static int cxgbe_set_hash_filter(struct rte_eth_dev *dev, +@@ -622,33 +638,15 @@ static int cxgbe_set_hash_filter(struct rte_eth_dev *dev, t4_mgmt_tx(ctrlq, mbuf); return 0; @@ -96,7 +97,7 @@ /** * t4_mk_filtdelwr - create a delete filter WR * @adap: adapter context -@@ -1070,16 +1068,6 @@ int cxgbe_set_filter(struct rte_eth_dev *dev, unsigned int filter_id, +@@ -1007,16 +1005,6 @@ int cxgbe_set_filter(struct rte_eth_dev *dev, unsigned int filter_id, return ret; } @@ -113,7 +114,7 @@ /* * Convert the filter specification into our internal format. * We copy the PF/VF specification into the Outer VLAN field -@@ -1090,6 +1078,16 @@ int cxgbe_set_filter(struct rte_eth_dev *dev, unsigned int filter_id, +@@ -1027,6 +1015,16 @@ int cxgbe_set_filter(struct rte_eth_dev *dev, unsigned int filter_id, f->fs.iq = iq; f->dev = dev; @@ -127,10 +128,10 @@ + } + } + - iconf = adapter->params.tp.ingress_config; - - /* Either PFVF or OVLAN can be active, but not both -@@ -1192,6 +1190,7 @@ void cxgbe_hash_filter_rpl(struct adapter *adap, + /* + * Attempt to set the filter. If we don't succeed, we clear + * it and return the failure. +@@ -1107,6 +1105,7 @@ void cxgbe_hash_filter_rpl(struct adapter *adap, } cxgbe_free_atid(t, ftid); @@ -138,7 +139,7 @@ t4_os_free(f); } -@@ -1416,13 +1415,8 @@ void cxgbe_hash_del_filter_rpl(struct adapter *adap, +@@ -1331,13 +1330,8 @@ void cxgbe_hash_del_filter_rpl(struct adapter *adap, } ctx = f->ctx;