Commit 0fca55ed authored by Vlad Buslov's avatar Vlad Buslov Committed by Jakub Kicinski

net: sched: remove redundant 'rtnl_held' argument

Functions tfilter_notify_chain() and tcf_get_next_proto() are always called
with rtnl lock held in current implementation. Moreover, attempting to call
them without rtnl lock would cause a warning down the call chain in
function __tcf_get_next_proto() that requires the lock to be held by
callers. Remove the 'rtnl_held' argument in order to simplify the code and
make rtnl lock requirement explicit.
Signed-off-by: default avatarVlad Buslov <vladbu@nvidia.com>
Link: https://lore.kernel.org/r/20201127151205.23492-1-vladbu@nvidia.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent cb7fb043
...@@ -48,7 +48,7 @@ void tcf_chain_put_by_act(struct tcf_chain *chain); ...@@ -48,7 +48,7 @@ void tcf_chain_put_by_act(struct tcf_chain *chain);
struct tcf_chain *tcf_get_next_chain(struct tcf_block *block, struct tcf_chain *tcf_get_next_chain(struct tcf_block *block,
struct tcf_chain *chain); struct tcf_chain *chain);
struct tcf_proto *tcf_get_next_proto(struct tcf_chain *chain, struct tcf_proto *tcf_get_next_proto(struct tcf_chain *chain,
struct tcf_proto *tp, bool rtnl_held); struct tcf_proto *tp);
void tcf_block_netif_keep_dst(struct tcf_block *block); void tcf_block_netif_keep_dst(struct tcf_block *block);
int tcf_block_get(struct tcf_block **p_block, int tcf_block_get(struct tcf_block **p_block,
struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q, struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q,
......
...@@ -991,13 +991,12 @@ __tcf_get_next_proto(struct tcf_chain *chain, struct tcf_proto *tp) ...@@ -991,13 +991,12 @@ __tcf_get_next_proto(struct tcf_chain *chain, struct tcf_proto *tp)
*/ */
struct tcf_proto * struct tcf_proto *
tcf_get_next_proto(struct tcf_chain *chain, struct tcf_proto *tp, tcf_get_next_proto(struct tcf_chain *chain, struct tcf_proto *tp)
bool rtnl_held)
{ {
struct tcf_proto *tp_next = __tcf_get_next_proto(chain, tp); struct tcf_proto *tp_next = __tcf_get_next_proto(chain, tp);
if (tp) if (tp)
tcf_proto_put(tp, rtnl_held, NULL); tcf_proto_put(tp, true, NULL);
return tp_next; return tp_next;
} }
...@@ -1924,15 +1923,14 @@ static int tfilter_del_notify(struct net *net, struct sk_buff *oskb, ...@@ -1924,15 +1923,14 @@ static int tfilter_del_notify(struct net *net, struct sk_buff *oskb,
static void tfilter_notify_chain(struct net *net, struct sk_buff *oskb, static void tfilter_notify_chain(struct net *net, struct sk_buff *oskb,
struct tcf_block *block, struct Qdisc *q, struct tcf_block *block, struct Qdisc *q,
u32 parent, struct nlmsghdr *n, u32 parent, struct nlmsghdr *n,
struct tcf_chain *chain, int event, struct tcf_chain *chain, int event)
bool rtnl_held)
{ {
struct tcf_proto *tp; struct tcf_proto *tp;
for (tp = tcf_get_next_proto(chain, NULL, rtnl_held); for (tp = tcf_get_next_proto(chain, NULL);
tp; tp = tcf_get_next_proto(chain, tp, rtnl_held)) tp; tp = tcf_get_next_proto(chain, tp))
tfilter_notify(net, oskb, n, tp, block, tfilter_notify(net, oskb, n, tp, block,
q, parent, NULL, event, false, rtnl_held); q, parent, NULL, event, false, true);
} }
static void tfilter_put(struct tcf_proto *tp, void *fh) static void tfilter_put(struct tcf_proto *tp, void *fh)
...@@ -2262,7 +2260,7 @@ static int tc_del_tfilter(struct sk_buff *skb, struct nlmsghdr *n, ...@@ -2262,7 +2260,7 @@ static int tc_del_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
if (prio == 0) { if (prio == 0) {
tfilter_notify_chain(net, skb, block, q, parent, n, tfilter_notify_chain(net, skb, block, q, parent, n,
chain, RTM_DELTFILTER, rtnl_held); chain, RTM_DELTFILTER);
tcf_chain_flush(chain, rtnl_held); tcf_chain_flush(chain, rtnl_held);
err = 0; err = 0;
goto errout; goto errout;
...@@ -2895,7 +2893,7 @@ static int tc_ctl_chain(struct sk_buff *skb, struct nlmsghdr *n, ...@@ -2895,7 +2893,7 @@ static int tc_ctl_chain(struct sk_buff *skb, struct nlmsghdr *n,
break; break;
case RTM_DELCHAIN: case RTM_DELCHAIN:
tfilter_notify_chain(net, skb, block, q, parent, n, tfilter_notify_chain(net, skb, block, q, parent, n,
chain, RTM_DELTFILTER, true); chain, RTM_DELTFILTER);
/* Flush the chain first as the user requested chain removal. */ /* Flush the chain first as the user requested chain removal. */
tcf_chain_flush(chain, true); tcf_chain_flush(chain, true);
/* In case the chain was successfully deleted, put a reference /* In case the chain was successfully deleted, put a reference
......
...@@ -1943,8 +1943,8 @@ static int tc_bind_class_walker(struct Qdisc *q, unsigned long cl, ...@@ -1943,8 +1943,8 @@ static int tc_bind_class_walker(struct Qdisc *q, unsigned long cl,
chain = tcf_get_next_chain(block, chain)) { chain = tcf_get_next_chain(block, chain)) {
struct tcf_proto *tp; struct tcf_proto *tp;
for (tp = tcf_get_next_proto(chain, NULL, true); for (tp = tcf_get_next_proto(chain, NULL);
tp; tp = tcf_get_next_proto(chain, tp, true)) { tp; tp = tcf_get_next_proto(chain, tp)) {
struct tcf_bind_args arg = {}; struct tcf_bind_args arg = {};
arg.w.fn = tcf_node_bind; arg.w.fn = tcf_node_bind;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment