From: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
To: dev@dpdk.org
Cc: stable@dpdk.org, nirranjan@chelsio.com
Subject: [dpdk-dev] [PATCH 1/5] net/cxgbe: fix CLIP leak in filter error path
Date: Sat, 13 Jun 2020 03:37:23 +0530 [thread overview]
Message-ID: <0cc7858681242446d4e0b2430fd749936e0c9020.1591998771.git.rahul.lakkireddy@chelsio.com> (raw)
In-Reply-To: <cover.1591998771.git.rahul.lakkireddy@chelsio.com>
In-Reply-To: <cover.1591998771.git.rahul.lakkireddy@chelsio.com>
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 <rahul.lakkireddy@chelsio.com>
---
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
next prev parent reply other threads:[~2020-06-12 22:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-12 22:07 [dpdk-dev] [PATCH 0/5] net/cxgbe: fix rte_flow related hardware resource leaks Rahul Lakkireddy
2020-06-12 22:07 ` Rahul Lakkireddy [this message]
2020-06-12 22:07 ` [dpdk-dev] [PATCH 2/5] net/cxgbe: fix L2T leak in filter error and free path Rahul Lakkireddy
2020-06-12 22:07 ` [dpdk-dev] [PATCH 3/5] net/cxgbe: fix double MPS alloc due to flow validate and create Rahul Lakkireddy
2020-06-12 22:07 ` [dpdk-dev] [PATCH 4/5] net/cxgbe: fix SMT leak in filter error and free path Rahul Lakkireddy
2020-06-12 22:07 ` [dpdk-dev] [PATCH 5/5] net/cxgbe: ignore flow default masks for unrequested fields Rahul Lakkireddy
2020-06-17 13:33 ` [dpdk-dev] [dpdk-stable] [PATCH 0/5] net/cxgbe: fix rte_flow related hardware resource leaks Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0cc7858681242446d4e0b2430fd749936e0c9020.1591998771.git.rahul.lakkireddy@chelsio.com \
--to=rahul.lakkireddy@chelsio.com \
--cc=dev@dpdk.org \
--cc=nirranjan@chelsio.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).