aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/cls_tcindex.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sched/cls_tcindex.c')
-rw-r--r--net/sched/cls_tcindex.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
index eed8404443d8..f435a88d899a 100644
--- a/net/sched/cls_tcindex.c
+++ b/net/sched/cls_tcindex.c
@@ -188,6 +188,12 @@ static const struct nla_policy tcindex_policy[TCA_TCINDEX_MAX + 1] = {
188 [TCA_TCINDEX_CLASSID] = { .type = NLA_U32 }, 188 [TCA_TCINDEX_CLASSID] = { .type = NLA_U32 },
189}; 189};
190 190
191static void tcindex_filter_result_init(struct tcindex_filter_result *r)
192{
193 memset(r, 0, sizeof(*r));
194 tcf_exts_init(&r->exts, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE);
195}
196
191static int 197static int
192tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, 198tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
193 u32 handle, struct tcindex_data *p, 199 u32 handle, struct tcindex_data *p,
@@ -207,15 +213,11 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
207 return err; 213 return err;
208 214
209 memcpy(&cp, p, sizeof(cp)); 215 memcpy(&cp, p, sizeof(cp));
210 memset(&new_filter_result, 0, sizeof(new_filter_result)); 216 tcindex_filter_result_init(&new_filter_result);
211 tcf_exts_init(&new_filter_result.exts, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE);
212 217
218 tcindex_filter_result_init(&cr);
213 if (old_r) 219 if (old_r)
214 memcpy(&cr, r, sizeof(cr)); 220 cr.res = r->res;
215 else {
216 memset(&cr, 0, sizeof(cr));
217 tcf_exts_init(&cr.exts, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE);
218 }
219 221
220 if (tb[TCA_TCINDEX_HASH]) 222 if (tb[TCA_TCINDEX_HASH])
221 cp.hash = nla_get_u32(tb[TCA_TCINDEX_HASH]); 223 cp.hash = nla_get_u32(tb[TCA_TCINDEX_HASH]);
@@ -267,9 +269,14 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
267 err = -ENOMEM; 269 err = -ENOMEM;
268 if (!cp.perfect && !cp.h) { 270 if (!cp.perfect && !cp.h) {
269 if (valid_perfect_hash(&cp)) { 271 if (valid_perfect_hash(&cp)) {
272 int i;
273
270 cp.perfect = kcalloc(cp.hash, sizeof(*r), GFP_KERNEL); 274 cp.perfect = kcalloc(cp.hash, sizeof(*r), GFP_KERNEL);
271 if (!cp.perfect) 275 if (!cp.perfect)
272 goto errout; 276 goto errout;
277 for (i = 0; i < cp.hash; i++)
278 tcf_exts_init(&cp.perfect[i].exts, TCA_TCINDEX_ACT,
279 TCA_TCINDEX_POLICE);
273 balloc = 1; 280 balloc = 1;
274 } else { 281 } else {
275 cp.h = kcalloc(cp.hash, sizeof(f), GFP_KERNEL); 282 cp.h = kcalloc(cp.hash, sizeof(f), GFP_KERNEL);
@@ -295,14 +302,17 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
295 tcf_bind_filter(tp, &cr.res, base); 302 tcf_bind_filter(tp, &cr.res, base);
296 } 303 }
297 304
298 tcf_exts_change(tp, &cr.exts, &e); 305 if (old_r)
306 tcf_exts_change(tp, &r->exts, &e);
307 else
308 tcf_exts_change(tp, &cr.exts, &e);
299 309
300 tcf_tree_lock(tp); 310 tcf_tree_lock(tp);
301 if (old_r && old_r != r) 311 if (old_r && old_r != r)
302 memset(old_r, 0, sizeof(*old_r)); 312 tcindex_filter_result_init(old_r);
303 313
304 memcpy(p, &cp, sizeof(cp)); 314 memcpy(p, &cp, sizeof(cp));
305 memcpy(r, &cr, sizeof(cr)); 315 r->res = cr.res;
306 316
307 if (r == &new_filter_result) { 317 if (r == &new_filter_result) {
308 struct tcindex_filter **fp; 318 struct tcindex_filter **fp;