Skip to content

Commit

Permalink
net: sched: act_gact: remove dependency on rtnl lock
Browse files Browse the repository at this point in the history
Use tcf spinlock to protect gact action private state from concurrent
modification during dump and init. Remove rtnl assertion that is no longer
necessary.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
w1ldptr authored and davem330 committed Aug 11, 2018
1 parent b6a2b97 commit e8917f4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions net/sched/act_gact.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla,

gact = to_gact(*a);

ASSERT_RTNL();
spin_lock(&gact->tcf_lock);
gact->tcf_action = parm->action;
#ifdef CONFIG_GACT_PROB
if (p_parm) {
Expand All @@ -126,6 +126,8 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla,
gact->tcfg_ptype = p_parm->ptype;
}
#endif
spin_unlock(&gact->tcf_lock);

if (ret == ACT_P_CREATED)
tcf_idr_insert(tn, *a);
return ret;
Expand Down Expand Up @@ -178,10 +180,11 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a,
.index = gact->tcf_index,
.refcnt = refcount_read(&gact->tcf_refcnt) - ref,
.bindcnt = atomic_read(&gact->tcf_bindcnt) - bind,
.action = gact->tcf_action,
};
struct tcf_t t;

spin_lock(&gact->tcf_lock);
opt.action = gact->tcf_action;
if (nla_put(skb, TCA_GACT_PARMS, sizeof(opt), &opt))
goto nla_put_failure;
#ifdef CONFIG_GACT_PROB
Expand All @@ -199,9 +202,12 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a,
tcf_tm_dump(&t, &gact->tcf_tm);
if (nla_put_64bit(skb, TCA_GACT_TM, sizeof(t), &t, TCA_GACT_PAD))
goto nla_put_failure;
spin_unlock(&gact->tcf_lock);

return skb->len;

nla_put_failure:
spin_unlock(&gact->tcf_lock);
nlmsg_trim(skb, b);
return -1;
}
Expand Down

0 comments on commit e8917f4

Please sign in to comment.