net_sched: unify the init logic for act_police
Jamal reported a crash when we create a police action
with a specific index, this is because the init logic
is not correct, we should always create one for this
case. Just unify the logic with other tc actions.
Fixes: a03e6fe569
("act_police: fix a crash during removal")
Reported-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
22dc13c837
commit
0852e45523
@ -125,6 +125,7 @@ static int tcf_act_police_init(struct net *net, struct nlattr *nla,
|
|||||||
struct tcf_police *police;
|
struct tcf_police *police;
|
||||||
struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL;
|
struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL;
|
||||||
struct tc_action_net *tn = net_generic(net, police_net_id);
|
struct tc_action_net *tn = net_generic(net, police_net_id);
|
||||||
|
bool exists = false;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
if (nla == NULL)
|
if (nla == NULL)
|
||||||
@ -139,24 +140,24 @@ static int tcf_act_police_init(struct net *net, struct nlattr *nla,
|
|||||||
size = nla_len(tb[TCA_POLICE_TBF]);
|
size = nla_len(tb[TCA_POLICE_TBF]);
|
||||||
if (size != sizeof(*parm) && size != sizeof(struct tc_police_compat))
|
if (size != sizeof(*parm) && size != sizeof(struct tc_police_compat))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
parm = nla_data(tb[TCA_POLICE_TBF]);
|
|
||||||
|
|
||||||
if (parm->index) {
|
parm = nla_data(tb[TCA_POLICE_TBF]);
|
||||||
if (tcf_hash_check(tn, parm->index, a, bind)) {
|
exists = tcf_hash_check(tn, parm->index, a, bind);
|
||||||
if (ovr)
|
if (exists && bind)
|
||||||
goto override;
|
return 0;
|
||||||
/* not replacing */
|
|
||||||
return -EEXIST;
|
if (!exists) {
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ret = tcf_hash_create(tn, parm->index, NULL, a,
|
ret = tcf_hash_create(tn, parm->index, NULL, a,
|
||||||
&act_police_ops, bind, false);
|
&act_police_ops, bind, false);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
ret = ACT_P_CREATED;
|
ret = ACT_P_CREATED;
|
||||||
|
} else {
|
||||||
|
tcf_hash_release(*a, bind);
|
||||||
|
if (!ovr)
|
||||||
|
return -EEXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
override:
|
|
||||||
police = to_police(*a);
|
police = to_police(*a);
|
||||||
if (parm->rate.rate) {
|
if (parm->rate.rate) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
|
Loading…
Reference in New Issue
Block a user