diff options
author | Jamal Hadi Salim <hadi@cyberus.ca> | 2008-05-06 03:10:24 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-05-06 03:10:24 -0400 |
commit | 9d1045ad68fcccfaf1393cc463ab6357693e8d1d (patch) | |
tree | d34347a568ab3723022350dd6e11ec73a41f380b /net/sched/act_simple.c | |
parent | 1da5ea1a8bf4ddb82831528223c853821cb1c9ab (diff) |
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: Jamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/act_simple.c')
-rw-r--r-- | net/sched/act_simple.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c index 269ab51cd9b2..1d421d059caf 100644 --- a/net/sched/act_simple.c +++ b/net/sched/act_simple.c | |||
@@ -79,10 +79,14 @@ static int alloc_defdata(struct tcf_defact *d, char *defdata) | |||
79 | return 0; | 79 | return 0; |
80 | } | 80 | } |
81 | 81 | ||
82 | static int realloc_defdata(struct tcf_defact *d, char *defdata) | 82 | static void reset_policy(struct tcf_defact *d, char *defdata, |
83 | struct tc_defact *p) | ||
83 | { | 84 | { |
84 | kfree(d->tcfd_defdata); | 85 | spin_lock_bh(&d->tcf_lock); |
85 | return alloc_defdata(d, defdata); | 86 | d->tcf_action = p->action; |
87 | memset(d->tcfd_defdata, 0, SIMP_MAX_DATA); | ||
88 | strlcpy(d->tcfd_defdata, defdata, SIMP_MAX_DATA); | ||
89 | spin_unlock_bh(&d->tcf_lock); | ||
86 | } | 90 | } |
87 | 91 | ||
88 | static const struct nla_policy simple_policy[TCA_DEF_MAX + 1] = { | 92 | 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 | kfree(pc); | 133 | kfree(pc); |
130 | return ret; | 134 | return ret; |
131 | } | 135 | } |
136 | d->tcf_action = parm->action; | ||
132 | ret = ACT_P_CREATED; | 137 | ret = ACT_P_CREATED; |
133 | } else { | 138 | } else { |
134 | d = to_defact(pc); | 139 | d = to_defact(pc); |
@@ -136,13 +141,9 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est, | |||
136 | tcf_simp_release(d, bind); | 141 | tcf_simp_release(d, bind); |
137 | return -EEXIST; | 142 | return -EEXIST; |
138 | } | 143 | } |
139 | realloc_defdata(d, defdata); | 144 | reset_policy(d, defdata, parm); |
140 | } | 145 | } |
141 | 146 | ||
142 | spin_lock_bh(&d->tcf_lock); | ||
143 | d->tcf_action = parm->action; | ||
144 | spin_unlock_bh(&d->tcf_lock); | ||
145 | |||
146 | if (ret == ACT_P_CREATED) | 147 | if (ret == ACT_P_CREATED) |
147 | tcf_hash_insert(pc, &simp_hash_info); | 148 | tcf_hash_insert(pc, &simp_hash_info); |
148 | return ret; | 149 | return ret; |