@@ -193,6 +193,14 @@ valid_perfect_hash(struct tcindex_data *p)
193193 return p -> hash > (p -> mask >> p -> shift );
194194}
195195
196+ static const struct nla_policy tcindex_policy [TCA_TCINDEX_MAX + 1 ] = {
197+ [TCA_TCINDEX_HASH ] = { .type = NLA_U32 },
198+ [TCA_TCINDEX_MASK ] = { .type = NLA_U16 },
199+ [TCA_TCINDEX_SHIFT ] = { .type = NLA_U32 },
200+ [TCA_TCINDEX_FALL_THROUGH ] = { .type = NLA_U32 },
201+ [TCA_TCINDEX_CLASSID ] = { .type = NLA_U32 },
202+ };
203+
196204static int
197205tcindex_set_parms (struct tcf_proto * tp , unsigned long base , u32 handle ,
198206 struct tcindex_data * p , struct tcindex_filter_result * r ,
@@ -217,24 +225,14 @@ tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle,
217225 else
218226 memset (& cr , 0 , sizeof (cr ));
219227
220- err = - EINVAL ;
221- if (tb [TCA_TCINDEX_HASH ]) {
222- if (nla_len (tb [TCA_TCINDEX_HASH ]) < sizeof (u32 ))
223- goto errout ;
228+ if (tb [TCA_TCINDEX_HASH ])
224229 cp .hash = nla_get_u32 (tb [TCA_TCINDEX_HASH ]);
225- }
226230
227- if (tb [TCA_TCINDEX_MASK ]) {
228- if (nla_len (tb [TCA_TCINDEX_MASK ]) < sizeof (u16 ))
229- goto errout ;
231+ if (tb [TCA_TCINDEX_MASK ])
230232 cp .mask = nla_get_u16 (tb [TCA_TCINDEX_MASK ]);
231- }
232233
233- if (tb [TCA_TCINDEX_SHIFT ]) {
234- if (nla_len (tb [TCA_TCINDEX_SHIFT ]) < sizeof (int ))
235- goto errout ;
234+ if (tb [TCA_TCINDEX_SHIFT ])
236235 cp .shift = nla_get_u32 (tb [TCA_TCINDEX_SHIFT ]);
237- }
238236
239237 err = - EBUSY ;
240238 /* Hash already allocated, make sure that we still meet the
@@ -248,11 +246,8 @@ tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle,
248246 goto errout ;
249247
250248 err = - EINVAL ;
251- if (tb [TCA_TCINDEX_FALL_THROUGH ]) {
252- if (nla_len (tb [TCA_TCINDEX_FALL_THROUGH ]) < sizeof (u32 ))
253- goto errout ;
249+ if (tb [TCA_TCINDEX_FALL_THROUGH ])
254250 cp .fall_through = nla_get_u32 (tb [TCA_TCINDEX_FALL_THROUGH ]);
255- }
256251
257252 if (!cp .hash ) {
258253 /* Hash not specified, use perfect hash if the upper limit
@@ -358,7 +353,7 @@ tcindex_change(struct tcf_proto *tp, unsigned long base, u32 handle,
358353 if (!opt )
359354 return 0 ;
360355
361- err = nla_parse_nested (tb , TCA_TCINDEX_MAX , opt , NULL );
356+ err = nla_parse_nested (tb , TCA_TCINDEX_MAX , opt , tcindex_policy );
362357 if (err < 0 )
363358 return err ;
364359
0 commit comments