@@ -495,7 +495,7 @@ int tcf_idr_create(struct tc_action_net *tn, u32 index, struct nlattr *est,
495
495
p -> tcfa_tm .install = jiffies ;
496
496
p -> tcfa_tm .lastuse = jiffies ;
497
497
p -> tcfa_tm .firstuse = 0 ;
498
- p -> tcfa_flags = flags ;
498
+ p -> tcfa_flags = flags & TCA_ACT_FLAGS_USER_MASK ;
499
499
if (est ) {
500
500
err = gen_new_estimator (& p -> tcfa_bstats , p -> cpu_bstats ,
501
501
& p -> tcfa_rate_est ,
@@ -941,7 +941,7 @@ void tcf_idr_insert_many(struct tc_action *actions[])
941
941
}
942
942
}
943
943
944
- struct tc_action_ops * tc_action_load_ops (char * name , struct nlattr * nla ,
944
+ struct tc_action_ops * tc_action_load_ops (struct nlattr * nla , bool police ,
945
945
bool rtnl_held ,
946
946
struct netlink_ext_ack * extack )
947
947
{
@@ -951,7 +951,7 @@ struct tc_action_ops *tc_action_load_ops(char *name, struct nlattr *nla,
951
951
struct nlattr * kind ;
952
952
int err ;
953
953
954
- if (name == NULL ) {
954
+ if (! police ) {
955
955
err = nla_parse_nested_deprecated (tb , TCA_ACT_MAX , nla ,
956
956
tcf_action_policy , extack );
957
957
if (err < 0 )
@@ -967,7 +967,7 @@ struct tc_action_ops *tc_action_load_ops(char *name, struct nlattr *nla,
967
967
return ERR_PTR (err );
968
968
}
969
969
} else {
970
- if (strlcpy (act_name , name , IFNAMSIZ ) >= IFNAMSIZ ) {
970
+ if (strlcpy (act_name , "police" , IFNAMSIZ ) >= IFNAMSIZ ) {
971
971
NL_SET_ERR_MSG (extack , "TC action name too long" );
972
972
return ERR_PTR (- EINVAL );
973
973
}
@@ -1004,20 +1004,19 @@ struct tc_action_ops *tc_action_load_ops(char *name, struct nlattr *nla,
1004
1004
1005
1005
struct tc_action * tcf_action_init_1 (struct net * net , struct tcf_proto * tp ,
1006
1006
struct nlattr * nla , struct nlattr * est ,
1007
- char * name , int ovr , int bind ,
1008
1007
struct tc_action_ops * a_o , int * init_res ,
1009
- bool rtnl_held ,
1010
- struct netlink_ext_ack * extack )
1008
+ u32 flags , struct netlink_ext_ack * extack )
1011
1009
{
1012
- struct nla_bitfield32 flags = { 0 , 0 };
1010
+ bool police = flags & TCA_ACT_FLAGS_POLICE ;
1011
+ struct nla_bitfield32 userflags = { 0 , 0 };
1013
1012
u8 hw_stats = TCA_ACT_HW_STATS_ANY ;
1014
1013
struct nlattr * tb [TCA_ACT_MAX + 1 ];
1015
1014
struct tc_cookie * cookie = NULL ;
1016
1015
struct tc_action * a ;
1017
1016
int err ;
1018
1017
1019
1018
/* backward compatibility for policer */
1020
- if (name == NULL ) {
1019
+ if (! police ) {
1021
1020
err = nla_parse_nested_deprecated (tb , TCA_ACT_MAX , nla ,
1022
1021
tcf_action_policy , extack );
1023
1022
if (err < 0 )
@@ -1032,22 +1031,22 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
1032
1031
}
1033
1032
hw_stats = tcf_action_hw_stats_get (tb [TCA_ACT_HW_STATS ]);
1034
1033
if (tb [TCA_ACT_FLAGS ])
1035
- flags = nla_get_bitfield32 (tb [TCA_ACT_FLAGS ]);
1034
+ userflags = nla_get_bitfield32 (tb [TCA_ACT_FLAGS ]);
1036
1035
1037
- err = a_o -> init (net , tb [TCA_ACT_OPTIONS ], est , & a , ovr , bind ,
1038
- rtnl_held , tp , flags . value , extack );
1036
+ err = a_o -> init (net , tb [TCA_ACT_OPTIONS ], est , & a , tp ,
1037
+ userflags . value | flags , extack );
1039
1038
} else {
1040
- err = a_o -> init (net , nla , est , & a , ovr , bind , rtnl_held ,
1041
- tp , flags . value , extack );
1039
+ err = a_o -> init (net , nla , est , & a , tp , userflags . value | flags ,
1040
+ extack );
1042
1041
}
1043
1042
if (err < 0 )
1044
1043
goto err_out ;
1045
1044
* init_res = err ;
1046
1045
1047
- if (!name && tb [TCA_ACT_COOKIE ])
1046
+ if (!police && tb [TCA_ACT_COOKIE ])
1048
1047
tcf_set_action_cookie (& a -> act_cookie , cookie );
1049
1048
1050
- if (!name )
1049
+ if (!police )
1051
1050
a -> hw_stats = hw_stats ;
1052
1051
1053
1052
return a ;
@@ -1063,9 +1062,9 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
1063
1062
/* Returns numbers of initialized actions or negative error. */
1064
1063
1065
1064
int tcf_action_init (struct net * net , struct tcf_proto * tp , struct nlattr * nla ,
1066
- struct nlattr * est , char * name , int ovr , int bind ,
1067
- struct tc_action * actions [], int init_res [], size_t * attr_size ,
1068
- bool rtnl_held , struct netlink_ext_ack * extack )
1065
+ struct nlattr * est , struct tc_action * actions [] ,
1066
+ int init_res [], size_t * attr_size , u32 flags ,
1067
+ struct netlink_ext_ack * extack )
1069
1068
{
1070
1069
struct tc_action_ops * ops [TCA_ACT_MAX_PRIO ] = {};
1071
1070
struct nlattr * tb [TCA_ACT_MAX_PRIO + 1 ];
@@ -1082,7 +1081,9 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,
1082
1081
for (i = 1 ; i <= TCA_ACT_MAX_PRIO && tb [i ]; i ++ ) {
1083
1082
struct tc_action_ops * a_o ;
1084
1083
1085
- a_o = tc_action_load_ops (name , tb [i ], rtnl_held , extack );
1084
+ a_o = tc_action_load_ops (tb [i ], flags & TCA_ACT_FLAGS_POLICE ,
1085
+ !(flags & TCA_ACT_FLAGS_NO_RTNL ),
1086
+ extack );
1086
1087
if (IS_ERR (a_o )) {
1087
1088
err = PTR_ERR (a_o );
1088
1089
goto err_mod ;
@@ -1091,9 +1092,8 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,
1091
1092
}
1092
1093
1093
1094
for (i = 1 ; i <= TCA_ACT_MAX_PRIO && tb [i ]; i ++ ) {
1094
- act = tcf_action_init_1 (net , tp , tb [i ], est , name , ovr , bind ,
1095
- ops [i - 1 ], & init_res [i - 1 ], rtnl_held ,
1096
- extack );
1095
+ act = tcf_action_init_1 (net , tp , tb [i ], est , ops [i - 1 ],
1096
+ & init_res [i - 1 ], flags , extack );
1097
1097
if (IS_ERR (act )) {
1098
1098
err = PTR_ERR (act );
1099
1099
goto err ;
@@ -1113,7 +1113,7 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,
1113
1113
goto err_mod ;
1114
1114
1115
1115
err :
1116
- tcf_action_destroy (actions , bind );
1116
+ tcf_action_destroy (actions , flags & TCA_ACT_FLAGS_BIND );
1117
1117
err_mod :
1118
1118
for (i = 0 ; i < TCA_ACT_MAX_PRIO ; i ++ ) {
1119
1119
if (ops [i ])
@@ -1495,7 +1495,7 @@ tcf_add_notify(struct net *net, struct nlmsghdr *n, struct tc_action *actions[],
1495
1495
}
1496
1496
1497
1497
static int tcf_action_add (struct net * net , struct nlattr * nla ,
1498
- struct nlmsghdr * n , u32 portid , int ovr ,
1498
+ struct nlmsghdr * n , u32 portid , u32 flags ,
1499
1499
struct netlink_ext_ack * extack )
1500
1500
{
1501
1501
size_t attr_size = 0 ;
@@ -1504,8 +1504,8 @@ static int tcf_action_add(struct net *net, struct nlattr *nla,
1504
1504
int init_res [TCA_ACT_MAX_PRIO ] = {};
1505
1505
1506
1506
for (loop = 0 ; loop < 10 ; loop ++ ) {
1507
- ret = tcf_action_init (net , NULL , nla , NULL , NULL , ovr , 0 ,
1508
- actions , init_res , & attr_size , true , extack );
1507
+ ret = tcf_action_init (net , NULL , nla , NULL , actions , init_res ,
1508
+ & attr_size , flags , extack );
1509
1509
if (ret != - EAGAIN )
1510
1510
break ;
1511
1511
}
@@ -1535,7 +1535,8 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n,
1535
1535
struct net * net = sock_net (skb -> sk );
1536
1536
struct nlattr * tca [TCA_ROOT_MAX + 1 ];
1537
1537
u32 portid = NETLINK_CB (skb ).portid ;
1538
- int ret = 0 , ovr = 0 ;
1538
+ u32 flags = 0 ;
1539
+ int ret = 0 ;
1539
1540
1540
1541
if ((n -> nlmsg_type != RTM_GETACTION ) &&
1541
1542
!netlink_capable (skb , CAP_NET_ADMIN ))
@@ -1561,8 +1562,8 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n,
1561
1562
* is zero) then just set this
1562
1563
*/
1563
1564
if (n -> nlmsg_flags & NLM_F_REPLACE )
1564
- ovr = 1 ;
1565
- ret = tcf_action_add (net , tca [TCA_ACT_TAB ], n , portid , ovr ,
1565
+ flags = TCA_ACT_FLAGS_REPLACE ;
1566
+ ret = tcf_action_add (net , tca [TCA_ACT_TAB ], n , portid , flags ,
1566
1567
extack );
1567
1568
break ;
1568
1569
case RTM_DELACTION :
0 commit comments