netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org, jiri@mellanox.com,
	john.hurley@netronome.com, jakub.kicinski@netronome.com,
	ogerlitz@mellanox.com
Subject: [PATCH net-next,RFC 5/9] net: sched: add release callback to struct tcf_block_cb
Date: Fri, 26 Apr 2019 02:33:42 +0200	[thread overview]
Message-ID: <20190426003348.30745-6-pablo@netfilter.org> (raw)
In-Reply-To: <20190426003348.30745-1-pablo@netfilter.org>

Call it on tcf_block_cb object to release the private area.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 include/net/pkt_cls.h |  3 ++-
 net/sched/cls_api.c   | 10 ++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
index d40fcd8c502b..52a6484428ce 100644
--- a/include/net/pkt_cls.h
+++ b/include/net/pkt_cls.h
@@ -72,7 +72,8 @@ static inline struct Qdisc *tcf_block_q(struct tcf_block *block)
 }
 
 struct tcf_block_cb *tcf_block_cb_alloc(tc_setup_cb_t *cb,
-					void *cb_ident, void *cb_priv);
+					void *cb_ident, void *cb_priv,
+					void (*release)(void *cb_priv));
 void tcf_block_cb_free(struct tcf_block_cb *block_cb);
 void tcf_block_cb_list_add(struct tcf_block_cb *block_cb, struct list_head *cb_list);
 void tcf_block_cb_list_move(struct tcf_block_cb *block_cb, struct list_head *cb_list);
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 3c16ac802dc4..963511ec758d 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -711,6 +711,7 @@ struct tcf_block_cb {
 	struct list_head global_list;
 	struct list_head list;
 	tc_setup_cb_t *cb;
+	void (*release)(void *cb_priv);
 	void *cb_ident;
 	void *cb_priv;
 	unsigned int refcnt;
@@ -753,7 +754,8 @@ unsigned int tcf_block_cb_decref(struct tcf_block_cb *block_cb)
 EXPORT_SYMBOL(tcf_block_cb_decref);
 
 struct tcf_block_cb *tcf_block_cb_alloc(tc_setup_cb_t *cb,
-					void *cb_ident, void *cb_priv)
+					void *cb_ident, void *cb_priv,
+					void (*release)(void *cb_priv))
 {
 	struct tcf_block_cb *block_cb;
 
@@ -763,6 +765,7 @@ struct tcf_block_cb *tcf_block_cb_alloc(tc_setup_cb_t *cb,
 
 	block_cb->cb = cb;
 	block_cb->cb_ident = cb_ident;
+	block_cb->release = release;
 	block_cb->cb_priv = cb_priv;
 
 	return block_cb;
@@ -771,6 +774,9 @@ EXPORT_SYMBOL(tcf_block_cb_alloc);
 
 void tcf_block_cb_free(struct tcf_block_cb *block_cb)
 {
+	if (block_cb->release)
+		block_cb->release(block_cb->cb_priv);
+
 	kfree(block_cb);
 }
 EXPORT_SYMBOL(tcf_block_cb_free);
@@ -804,7 +810,7 @@ struct tcf_block_cb *__tcf_block_cb_register(struct tcf_block *block,
 	if (err)
 		return ERR_PTR(err);
 
-	block_cb = tcf_block_cb_alloc(cb, cb_ident, cb_priv);
+	block_cb = tcf_block_cb_alloc(cb, cb_ident, cb_priv, NULL);
 	if (!block_cb)
 		return ERR_PTR(-ENOMEM);
 
-- 
2.11.0


  parent reply	other threads:[~2019-04-26  0:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-26  0:33 [PATCH net-next,RFC 0/9] net: sched: prepare to reuse per-block callbacks from netfilter Pablo Neira Ayuso
2019-04-26  0:33 ` [PATCH net-next,RFC 1/9] net: sched: move tcf_block_cb before indr_block Pablo Neira Ayuso
2019-04-26  0:33 ` [PATCH net-next,RFC 2/9] net: sched: add tcf_block_cb_alloc() Pablo Neira Ayuso
2019-04-26  0:33 ` [PATCH net-next,RFC 3/9] net: sched: add tcf_block_cb_free() Pablo Neira Ayuso
2019-04-26  0:33 ` [PATCH net-next,RFC 4/9] net: sched: add tcf_block_setup() Pablo Neira Ayuso
2019-04-26  0:33 ` Pablo Neira Ayuso [this message]
2019-04-26  0:33 ` [PATCH net-next,RFC 6/9] net: sched: add tcf_setup_block_offload() Pablo Neira Ayuso
2019-04-26  0:33 ` [PATCH net-next,RFC 7/9] net: use tcf_block_setup() infrastructure Pablo Neira Ayuso
2019-04-26 14:27   ` Jiri Pirko
2019-04-26 16:12     ` Pablo Neira Ayuso
2019-04-26  0:33 ` [PATCH net-next,RFC 8/9] net: cls_api: do not expose tcf_block to drivers Pablo Neira Ayuso
2019-04-26  0:33 ` [PATCH net-next,RFC 8/9] net: sched: remove tcf_block_cb_{register,unregister}() Pablo Neira Ayuso
2019-04-26  0:33 ` [PATCH net-next,RFC 9/9] net: cls_api: do not expose tcf_block to drivers Pablo Neira Ayuso
2019-04-26 14:32 ` [PATCH net-next,RFC 0/9] net: sched: prepare to reuse per-block callbacks from netfilter Jiri Pirko
2019-04-26 16:28   ` Pablo Neira Ayuso
2019-04-26 18:29     ` Jakub Kicinski
2019-04-26 18:41       ` Pablo Neira Ayuso
2019-04-26 18:55         ` Jakub Kicinski
2019-04-26 19:14           ` Pablo Neira Ayuso
2019-04-26 19:22             ` Pablo Neira Ayuso

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=20190426003348.30745-6-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=jiri@mellanox.com \
    --cc=john.hurley@netronome.com \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=ogerlitz@mellanox.com \
    /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).