Skip to content

Commit e8917f4

Browse files
w1ldptrdavem330
authored andcommitted
net: sched: act_gact: remove dependency on rtnl lock
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>
1 parent b6a2b97 commit e8917f4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

net/sched/act_gact.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla,
113113

114114
gact = to_gact(*a);
115115

116-
ASSERT_RTNL();
116+
spin_lock(&gact->tcf_lock);
117117
gact->tcf_action = parm->action;
118118
#ifdef CONFIG_GACT_PROB
119119
if (p_parm) {
@@ -126,6 +126,8 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla,
126126
gact->tcfg_ptype = p_parm->ptype;
127127
}
128128
#endif
129+
spin_unlock(&gact->tcf_lock);
130+
129131
if (ret == ACT_P_CREATED)
130132
tcf_idr_insert(tn, *a);
131133
return ret;
@@ -178,10 +180,11 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a,
178180
.index = gact->tcf_index,
179181
.refcnt = refcount_read(&gact->tcf_refcnt) - ref,
180182
.bindcnt = atomic_read(&gact->tcf_bindcnt) - bind,
181-
.action = gact->tcf_action,
182183
};
183184
struct tcf_t t;
184185

186+
spin_lock(&gact->tcf_lock);
187+
opt.action = gact->tcf_action;
185188
if (nla_put(skb, TCA_GACT_PARMS, sizeof(opt), &opt))
186189
goto nla_put_failure;
187190
#ifdef CONFIG_GACT_PROB
@@ -199,9 +202,12 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a,
199202
tcf_tm_dump(&t, &gact->tcf_tm);
200203
if (nla_put_64bit(skb, TCA_GACT_TM, sizeof(t), &t, TCA_GACT_PAD))
201204
goto nla_put_failure;
205+
spin_unlock(&gact->tcf_lock);
206+
202207
return skb->len;
203208

204209
nla_put_failure:
210+
spin_unlock(&gact->tcf_lock);
205211
nlmsg_trim(skb, b);
206212
return -1;
207213
}

0 commit comments

Comments
 (0)