@@ -38,14 +38,14 @@ static DEFINE_RWLOCK(cls_mod_lock);
3838
3939/* Find classifier type by string name */
4040
41- static struct tcf_proto_ops * tcf_proto_lookup_ops (struct rtattr * kind )
41+ static struct tcf_proto_ops * tcf_proto_lookup_ops (struct nlattr * kind )
4242{
4343 struct tcf_proto_ops * t = NULL ;
4444
4545 if (kind ) {
4646 read_lock (& cls_mod_lock );
4747 for (t = tcf_proto_base ; t ; t = t -> next ) {
48- if (rtattr_strcmp (kind , t -> kind ) == 0 ) {
48+ if (nla_strcmp (kind , t -> kind ) == 0 ) {
4949 if (!try_module_get (t -> owner ))
5050 t = NULL ;
5151 break ;
@@ -118,7 +118,7 @@ static inline u32 tcf_auto_prio(struct tcf_proto *tp)
118118static int tc_ctl_tfilter (struct sk_buff * skb , struct nlmsghdr * n , void * arg )
119119{
120120 struct net * net = skb -> sk -> sk_net ;
121- struct rtattr * * tca ;
121+ struct nlattr * tca [ TCA_MAX + 1 ] ;
122122 struct tcmsg * t ;
123123 u32 protocol ;
124124 u32 prio ;
@@ -138,7 +138,6 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
138138 return - EINVAL ;
139139
140140replay :
141- tca = arg ;
142141 t = NLMSG_DATA (n );
143142 protocol = TC_H_MIN (t -> tcm_info );
144143 prio = TC_H_MAJ (t -> tcm_info );
@@ -160,6 +159,10 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
160159 if (dev == NULL )
161160 return - ENODEV ;
162161
162+ err = nlmsg_parse (n , sizeof (* t ), tca , TCA_MAX , NULL );
163+ if (err < 0 )
164+ return err ;
165+
163166 /* Find qdisc */
164167 if (!parent ) {
165168 q = dev -> qdisc_sleeping ;
@@ -202,7 +205,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
202205 if (tp == NULL ) {
203206 /* Proto-tcf does not exist, create new one */
204207
205- if (tca [TCA_KIND - 1 ] == NULL || !protocol )
208+ if (tca [TCA_KIND ] == NULL || !protocol )
206209 goto errout ;
207210
208211 err = - ENOENT ;
@@ -217,14 +220,14 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
217220 if (tp == NULL )
218221 goto errout ;
219222 err = - EINVAL ;
220- tp_ops = tcf_proto_lookup_ops (tca [TCA_KIND - 1 ]);
223+ tp_ops = tcf_proto_lookup_ops (tca [TCA_KIND ]);
221224 if (tp_ops == NULL ) {
222225#ifdef CONFIG_KMOD
223- struct rtattr * kind = tca [TCA_KIND - 1 ];
226+ struct nlattr * kind = tca [TCA_KIND ];
224227 char name [IFNAMSIZ ];
225228
226229 if (kind != NULL &&
227- rtattr_strlcpy (name , kind , IFNAMSIZ ) < IFNAMSIZ ) {
230+ nla_strlcpy (name , kind , IFNAMSIZ ) < IFNAMSIZ ) {
228231 rtnl_unlock ();
229232 request_module ("cls_%s" , name );
230233 rtnl_lock ();
@@ -263,7 +266,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
263266 * back = tp ;
264267 qdisc_unlock_tree (dev );
265268
266- } else if (tca [TCA_KIND - 1 ] && rtattr_strcmp (tca [TCA_KIND - 1 ], tp -> ops -> kind ))
269+ } else if (tca [TCA_KIND ] && nla_strcmp (tca [TCA_KIND ], tp -> ops -> kind ))
267270 goto errout ;
268271
269272 fh = tp -> ops -> get (tp , t -> tcm_handle );
@@ -333,18 +336,18 @@ static int tcf_fill_node(struct sk_buff *skb, struct tcf_proto *tp,
333336 tcm -> tcm_ifindex = tp -> q -> dev -> ifindex ;
334337 tcm -> tcm_parent = tp -> classid ;
335338 tcm -> tcm_info = TC_H_MAKE (tp -> prio , tp -> protocol );
336- RTA_PUT (skb , TCA_KIND , IFNAMSIZ , tp -> ops -> kind );
339+ NLA_PUT (skb , TCA_KIND , IFNAMSIZ , tp -> ops -> kind );
337340 tcm -> tcm_handle = fh ;
338341 if (RTM_DELTFILTER != event ) {
339342 tcm -> tcm_handle = 0 ;
340343 if (tp -> ops -> dump && tp -> ops -> dump (tp , fh , skb , tcm ) < 0 )
341- goto rtattr_failure ;
344+ goto nla_put_failure ;
342345 }
343346 nlh -> nlmsg_len = skb_tail_pointer (skb ) - b ;
344347 return skb -> len ;
345348
346349nlmsg_failure :
347- rtattr_failure :
350+ nla_put_failure :
348351 nlmsg_trim (skb , b );
349352 return -1 ;
350353}
@@ -476,8 +479,8 @@ void tcf_exts_destroy(struct tcf_proto *tp, struct tcf_exts *exts)
476479}
477480EXPORT_SYMBOL (tcf_exts_destroy );
478481
479- int tcf_exts_validate (struct tcf_proto * tp , struct rtattr * * tb ,
480- struct rtattr * rate_tlv , struct tcf_exts * exts ,
482+ int tcf_exts_validate (struct tcf_proto * tp , struct nlattr * * tb ,
483+ struct nlattr * rate_tlv , struct tcf_exts * exts ,
481484 struct tcf_ext_map * map )
482485{
483486 memset (exts , 0 , sizeof (* exts ));
@@ -487,17 +490,19 @@ int tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb,
487490 int err ;
488491 struct tc_action * act ;
489492
490- if (map -> police && tb [map -> police - 1 ]) {
491- act = tcf_action_init_1 (tb [map -> police - 1 ], rate_tlv ,
493+ if (map -> police && tb [map -> police ]) {
494+ act = tcf_action_init_1 ((struct rtattr * )tb [map -> police ],
495+ (struct rtattr * )rate_tlv ,
492496 "police" , TCA_ACT_NOREPLACE ,
493497 TCA_ACT_BIND , & err );
494498 if (act == NULL )
495499 return err ;
496500
497501 act -> type = TCA_OLD_COMPAT ;
498502 exts -> action = act ;
499- } else if (map -> action && tb [map -> action - 1 ]) {
500- act = tcf_action_init (tb [map -> action - 1 ], rate_tlv , NULL ,
503+ } else if (map -> action && tb [map -> action ]) {
504+ act = tcf_action_init ((struct rtattr * )tb [map -> action ],
505+ (struct rtattr * )rate_tlv , NULL ,
501506 TCA_ACT_NOREPLACE , TCA_ACT_BIND , & err );
502507 if (act == NULL )
503508 return err ;
@@ -506,8 +511,8 @@ int tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb,
506511 }
507512 }
508513#else
509- if ((map -> action && tb [map -> action - 1 ]) ||
510- (map -> police && tb [map -> police - 1 ]))
514+ if ((map -> action && tb [map -> action ]) ||
515+ (map -> police && tb [map -> police ]))
511516 return - EOPNOTSUPP ;
512517#endif
513518
@@ -541,23 +546,23 @@ int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts,
541546 * to work with both old and new modes of entering
542547 * tc data even if iproute2 was newer - jhs
543548 */
544- struct rtattr * p_rta = (struct rtattr * )skb_tail_pointer (skb );
549+ struct nlattr * p_rta = (struct nlattr * )skb_tail_pointer (skb );
545550
546551 if (exts -> action -> type != TCA_OLD_COMPAT ) {
547- RTA_PUT (skb , map -> action , 0 , NULL );
552+ NLA_PUT (skb , map -> action , 0 , NULL );
548553 if (tcf_action_dump (skb , exts -> action , 0 , 0 ) < 0 )
549- goto rtattr_failure ;
550- p_rta -> rta_len = skb_tail_pointer (skb ) - (u8 * )p_rta ;
554+ goto nla_put_failure ;
555+ p_rta -> nla_len = skb_tail_pointer (skb ) - (u8 * )p_rta ;
551556 } else if (map -> police ) {
552- RTA_PUT (skb , map -> police , 0 , NULL );
557+ NLA_PUT (skb , map -> police , 0 , NULL );
553558 if (tcf_action_dump_old (skb , exts -> action , 0 , 0 ) < 0 )
554- goto rtattr_failure ;
555- p_rta -> rta_len = skb_tail_pointer (skb ) - (u8 * )p_rta ;
559+ goto nla_put_failure ;
560+ p_rta -> nla_len = skb_tail_pointer (skb ) - (u8 * )p_rta ;
556561 }
557562 }
558563#endif
559564 return 0 ;
560- rtattr_failure : __attribute__ ((unused ))
565+ nla_put_failure : __attribute__ ((unused ))
561566 return -1 ;
562567}
563568EXPORT_SYMBOL (tcf_exts_dump );
@@ -569,10 +574,10 @@ int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts,
569574#ifdef CONFIG_NET_CLS_ACT
570575 if (exts -> action )
571576 if (tcf_action_copy_stats (skb , exts -> action , 1 ) < 0 )
572- goto rtattr_failure ;
577+ goto nla_put_failure ;
573578#endif
574579 return 0 ;
575- rtattr_failure : __attribute__ ((unused ))
580+ nla_put_failure : __attribute__ ((unused ))
576581 return -1 ;
577582}
578583EXPORT_SYMBOL (tcf_exts_dump_stats );
0 commit comments