diff options
author | Vlad Buslov <vladbu@mellanox.com> | 2018-08-10 20:51:52 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-08-11 12:37:10 -0700 |
commit | 84a75b329be84c108a21ab9c02a52a9bf9e5a919 (patch) | |
tree | 54e1878072e38345ae860567911a2b218935bf63 /net/sched/act_mirred.c | |
parent | 764e9a24480f6ffba5493fb21e6a7b030d6b8b67 (diff) | |
download | linux-84a75b329be84c108a21ab9c02a52a9bf9e5a919.tar.gz linux-84a75b329be84c108a21ab9c02a52a9bf9e5a919.tar.bz2 linux-84a75b329be84c108a21ab9c02a52a9bf9e5a919.zip |
net: sched: extend action ops with put_dev callback
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/act_mirred.c')
-rw-r--r-- | net/sched/act_mirred.c | 12 |
1 files changed, 11 insertions, 1 deletions
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, }; |