@@ -831,6 +831,15 @@ static struct tc_cookie *nla_memdup_cookie(struct nlattr **tb)
831
831
return c ;
832
832
}
833
833
834
+ static const struct nla_policy tcf_action_policy [TCA_ACT_MAX + 1 ] = {
835
+ [TCA_ACT_KIND ] = { .type = NLA_NUL_STRING ,
836
+ .len = IFNAMSIZ - 1 },
837
+ [TCA_ACT_INDEX ] = { .type = NLA_U32 },
838
+ [TCA_ACT_COOKIE ] = { .type = NLA_BINARY ,
839
+ .len = TC_COOKIE_MAX_SIZE },
840
+ [TCA_ACT_OPTIONS ] = { .type = NLA_NESTED },
841
+ };
842
+
834
843
struct tc_action * tcf_action_init_1 (struct net * net , struct tcf_proto * tp ,
835
844
struct nlattr * nla , struct nlattr * est ,
836
845
char * name , int ovr , int bind ,
@@ -846,8 +855,8 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
846
855
int err ;
847
856
848
857
if (name == NULL ) {
849
- err = nla_parse_nested_deprecated (tb , TCA_ACT_MAX , nla , NULL ,
850
- extack );
858
+ err = nla_parse_nested_deprecated (tb , TCA_ACT_MAX , nla ,
859
+ tcf_action_policy , extack );
851
860
if (err < 0 )
852
861
goto err_out ;
853
862
err = - EINVAL ;
@@ -856,18 +865,9 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
856
865
NL_SET_ERR_MSG (extack , "TC action kind must be specified" );
857
866
goto err_out ;
858
867
}
859
- if (nla_strlcpy (act_name , kind , IFNAMSIZ ) >= IFNAMSIZ ) {
860
- NL_SET_ERR_MSG (extack , "TC action name too long" );
861
- goto err_out ;
862
- }
863
- if (tb [TCA_ACT_COOKIE ]) {
864
- int cklen = nla_len (tb [TCA_ACT_COOKIE ]);
865
-
866
- if (cklen > TC_COOKIE_MAX_SIZE ) {
867
- NL_SET_ERR_MSG (extack , "TC cookie size above the maximum" );
868
- goto err_out ;
869
- }
868
+ nla_strlcpy (act_name , kind , IFNAMSIZ );
870
869
870
+ if (tb [TCA_ACT_COOKIE ]) {
871
871
cookie = nla_memdup_cookie (tb );
872
872
if (!cookie ) {
873
873
NL_SET_ERR_MSG (extack , "No memory to generate TC cookie" );
@@ -1098,7 +1098,8 @@ static struct tc_action *tcf_action_get_1(struct net *net, struct nlattr *nla,
1098
1098
int index ;
1099
1099
int err ;
1100
1100
1101
- err = nla_parse_nested_deprecated (tb , TCA_ACT_MAX , nla , NULL , extack );
1101
+ err = nla_parse_nested_deprecated (tb , TCA_ACT_MAX , nla ,
1102
+ tcf_action_policy , extack );
1102
1103
if (err < 0 )
1103
1104
goto err_out ;
1104
1105
@@ -1152,7 +1153,8 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
1152
1153
1153
1154
b = skb_tail_pointer (skb );
1154
1155
1155
- err = nla_parse_nested_deprecated (tb , TCA_ACT_MAX , nla , NULL , extack );
1156
+ err = nla_parse_nested_deprecated (tb , TCA_ACT_MAX , nla ,
1157
+ tcf_action_policy , extack );
1156
1158
if (err < 0 )
1157
1159
goto err_out ;
1158
1160
@@ -1440,7 +1442,7 @@ static struct nlattr *find_dump_kind(struct nlattr **nla)
1440
1442
1441
1443
if (tb [1 ] == NULL )
1442
1444
return NULL ;
1443
- if (nla_parse_nested_deprecated (tb2 , TCA_ACT_MAX , tb [1 ], NULL , NULL ) < 0 )
1445
+ if (nla_parse_nested_deprecated (tb2 , TCA_ACT_MAX , tb [1 ], tcf_action_policy , NULL ) < 0 )
1444
1446
return NULL ;
1445
1447
kind = tb2 [TCA_ACT_KIND ];
1446
1448
0 commit comments