提交 9d1045ad 编写于 作者: J Jamal Hadi Salim 提交者: David S. Miller

net_cls_act: act_simple dont ignore realloc code

reallocation of the policy data was being ignored. It could fail.
Simplify so that there is no need for reallocating.
Signed-off-by: NJamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 1da5ea1a
...@@ -79,10 +79,14 @@ static int alloc_defdata(struct tcf_defact *d, char *defdata) ...@@ -79,10 +79,14 @@ static int alloc_defdata(struct tcf_defact *d, char *defdata)
return 0; return 0;
} }
static int realloc_defdata(struct tcf_defact *d, char *defdata) static void reset_policy(struct tcf_defact *d, char *defdata,
struct tc_defact *p)
{ {
kfree(d->tcfd_defdata); spin_lock_bh(&d->tcf_lock);
return alloc_defdata(d, defdata); d->tcf_action = p->action;
memset(d->tcfd_defdata, 0, SIMP_MAX_DATA);
strlcpy(d->tcfd_defdata, defdata, SIMP_MAX_DATA);
spin_unlock_bh(&d->tcf_lock);
} }
static const struct nla_policy simple_policy[TCA_DEF_MAX + 1] = { static const struct nla_policy simple_policy[TCA_DEF_MAX + 1] = {
...@@ -129,6 +133,7 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est, ...@@ -129,6 +133,7 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est,
kfree(pc); kfree(pc);
return ret; return ret;
} }
d->tcf_action = parm->action;
ret = ACT_P_CREATED; ret = ACT_P_CREATED;
} else { } else {
d = to_defact(pc); d = to_defact(pc);
...@@ -136,13 +141,9 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est, ...@@ -136,13 +141,9 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est,
tcf_simp_release(d, bind); tcf_simp_release(d, bind);
return -EEXIST; return -EEXIST;
} }
realloc_defdata(d, defdata); reset_policy(d, defdata, parm);
} }
spin_lock_bh(&d->tcf_lock);
d->tcf_action = parm->action;
spin_unlock_bh(&d->tcf_lock);
if (ret == ACT_P_CREATED) if (ret == ACT_P_CREATED)
tcf_hash_insert(pc, &simp_hash_info); tcf_hash_insert(pc, &simp_hash_info);
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册