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 5CCD5A00BE for ; Sat, 13 Jun 2020 00:20:16 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 45ABA1C0D9; Sat, 13 Jun 2020 00:20:16 +0200 (CEST) Received: from stargate.chelsio.com (stargate.chelsio.com [12.32.117.8]) by dpdk.org (Postfix) with ESMTP id 9B2F31BFB2; Sat, 13 Jun 2020 00:20:13 +0200 (CEST) Received: from localhost (scalar.blr.asicdesigners.com [10.193.185.94]) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id 05CMKB5Q009569; Fri, 12 Jun 2020 15:20:11 -0700 From: Rahul Lakkireddy To: dev@dpdk.org Cc: stable@dpdk.org, nirranjan@chelsio.com Date: Sat, 13 Jun 2020 03:37:23 +0530 Message-Id: <0cc7858681242446d4e0b2430fd749936e0c9020.1591998771.git.rahul.lakkireddy@chelsio.com> X-Mailer: git-send-email 2.5.3 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-stable] [PATCH 1/5] net/cxgbe: fix CLIP leak in filter error path 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" 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 --- 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 27e96c73e..45602d468 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) 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. */ @@ -583,7 +599,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; @@ -631,7 +647,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; @@ -661,33 +677,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 @@ -1070,16 +1068,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 @@ -1090,6 +1078,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; + } + } + 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, } cxgbe_free_atid(t, ftid); + clear_filter(f); t4_os_free(f); } @@ -1416,13 +1415,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.24.0