From: Vlad Buslov <vladbu@mellanox.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, jhs@mojatatu.com, xiyou.wangcong@gmail.com,
jiri@resnulli.us, pablo@netfilter.org, kadlec@blackhole.kfki.hu,
fw@strlen.de, ast@kernel.org, daniel@iogearbox.net,
edumazet@google.com, keescook@chromium.org,
marcelo.leitner@gmail.com, Vlad Buslov <vladbu@mellanox.com>
Subject: [PATCH net-next v2 12/15] net: sched: extend action ops with put_dev callback
Date: Fri, 10 Aug 2018 20:51:52 +0300 [thread overview]
Message-ID: <1533923515-5664-13-git-send-email-vladbu@mellanox.com> (raw)
In-Reply-To: <1533923515-5664-1-git-send-email-vladbu@mellanox.com>
As a preparation for removing dependency on rtnl lock from rules update
path, all users of shared objects must take reference while working with
them.
Extend action ops with put_dev() API to be used on net device returned by
get_dev().
Modify mirred action (only action that implements get_dev callback):
- Take reference to net device in get_dev.
- Implement put_dev API that releases reference to net device.
Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
---
include/net/act_api.h | 1 +
net/sched/act_mirred.c | 12 +++++++++++-
net/sched/cls_api.c | 1 +
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/net/act_api.h b/include/net/act_api.h
index 8c9bc02d05e1..1ad5b19e83a9 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -101,6 +101,7 @@ struct tc_action_ops {
void (*stats_update)(struct tc_action *, u64, u32, u64);
size_t (*get_fill_size)(const struct tc_action *act);
struct net_device *(*get_dev)(const struct tc_action *a);
+ void (*put_dev)(struct net_device *dev);
int (*delete)(struct net *net, u32 index);
};
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index b26d060da08e..7a045cc7fe3b 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -358,8 +358,17 @@ static struct notifier_block mirred_device_notifier = {
static struct net_device *tcf_mirred_get_dev(const struct tc_action *a)
{
struct tcf_mirred *m = to_mirred(a);
+ struct net_device *dev = rtnl_dereference(m->tcfm_dev);
+
+ if (dev)
+ dev_hold(dev);
- return rtnl_dereference(m->tcfm_dev);
+ return dev;
+}
+
+static void tcf_mirred_put_dev(struct net_device *dev)
+{
+ dev_put(dev);
}
static int tcf_mirred_delete(struct net *net, u32 index)
@@ -382,6 +391,7 @@ static struct tc_action_ops act_mirred_ops = {
.lookup = tcf_mirred_search,
.size = sizeof(struct tcf_mirred),
.get_dev = tcf_mirred_get_dev,
+ .put_dev = tcf_mirred_put_dev,
.delete = tcf_mirred_delete,
};
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index e8b0bbd0883f..bdabf8144e21 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -2167,6 +2167,7 @@ static int tc_exts_setup_cb_egdev_call(struct tcf_exts *exts,
if (!dev)
continue;
ret = tc_setup_cb_egdev_call(dev, type, type_data, err_stop);
+ a->ops->put_dev(dev);
if (ret < 0)
return ret;
ok_count += ret;
--
2.7.5
next prev parent reply other threads:[~2018-08-10 20:23 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-10 17:51 [PATCH net-next v2 00/15] Remove rtnl lock dependency from all action implementations Vlad Buslov
2018-08-10 17:51 ` [PATCH net-next v2 01/15] net: sched: act_bpf: remove dependency on rtnl lock Vlad Buslov
2018-08-10 17:51 ` [PATCH net-next v2 02/15] net: sched: act_csum: " Vlad Buslov
2018-08-10 17:51 ` [PATCH net-next v2 03/15] net: sched: act_gact: " Vlad Buslov
2018-08-10 17:51 ` [PATCH net-next v2 04/15] net: sched: act_ife: " Vlad Buslov
2018-08-10 17:51 ` [PATCH net-next v2 05/15] net: sched: act_ipt: " Vlad Buslov
2018-08-10 17:51 ` [PATCH net-next v2 06/15] net: sched: act_pedit: " Vlad Buslov
2018-08-10 17:51 ` [PATCH net-next v2 07/15] net: sched: act_sample: " Vlad Buslov
2018-08-10 17:51 ` [PATCH net-next v2 08/15] net: sched: act_simple: " Vlad Buslov
2018-08-10 17:51 ` [PATCH net-next v2 09/15] net: sched: act_skbmod: " Vlad Buslov
2018-08-10 17:51 ` [PATCH net-next v2 10/15] net: sched: act_tunnel_key: " Vlad Buslov
2018-08-10 17:51 ` [PATCH net-next v2 11/15] net: sched: act_vlan: " Vlad Buslov
2018-08-10 17:51 ` Vlad Buslov [this message]
2018-08-10 17:51 ` [PATCH net-next v2 13/15] net: sched: act_mirred: " Vlad Buslov
2018-08-10 17:51 ` [PATCH net-next v2 14/15] net: core: protect rate estimator statistics pointer with lock Vlad Buslov
2018-08-10 17:51 ` [PATCH net-next v2 15/15] net: sched: act_police: remove dependency on rtnl lock Vlad Buslov
2018-08-11 19:38 ` [PATCH net-next v2 00/15] Remove rtnl lock dependency from all action implementations David Miller
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=1533923515-5664-13-git-send-email-vladbu@mellanox.com \
--to=vladbu@mellanox.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kadlec@blackhole.kfki.hu \
--cc=keescook@chromium.org \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=xiyou.wangcong@gmail.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