@@ -188,6 +188,12 @@ static const struct nla_policy tcindex_policy[TCA_TCINDEX_MAX + 1] = {
188
188
[TCA_TCINDEX_CLASSID ] = { .type = NLA_U32 },
189
189
};
190
190
191
+ static 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
+
191
197
static int
192
198
tcindex_set_parms (struct net * net , struct tcf_proto * tp , unsigned long base ,
193
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
213
return err ;
208
214
209
215
memcpy (& cp , p , sizeof (cp ));
210
- memset (& new_filter_result , 0 , sizeof (new_filter_result ));
211
- tcf_exts_init (& new_filter_result .exts , TCA_TCINDEX_ACT , TCA_TCINDEX_POLICE );
216
+ tcindex_filter_result_init (& new_filter_result );
212
217
218
+ tcindex_filter_result_init (& cr );
213
219
if (old_r )
214
- memcpy (& cr , r , sizeof (cr ));
215
- else {
216
- memset (& cr , 0 , sizeof (cr ));
217
- tcf_exts_init (& cr .exts , TCA_TCINDEX_ACT , TCA_TCINDEX_POLICE );
218
- }
220
+ cr .res = r -> res ;
219
221
220
222
if (tb [TCA_TCINDEX_HASH ])
221
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
269
err = - ENOMEM ;
268
270
if (!cp .perfect && !cp .h ) {
269
271
if (valid_perfect_hash (& cp )) {
272
+ int i ;
273
+
270
274
cp .perfect = kcalloc (cp .hash , sizeof (* r ), GFP_KERNEL );
271
275
if (!cp .perfect )
272
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
280
balloc = 1 ;
274
281
} else {
275
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
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
310
tcf_tree_lock (tp );
301
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
314
memcpy (p , & cp , sizeof (cp ));
305
- memcpy ( r , & cr , sizeof ( cr )) ;
315
+ r -> res = cr . res ;
306
316
307
317
if (r == & new_filter_result ) {
308
318
struct tcindex_filter * * fp ;
0 commit comments