Bound actions always return '0' and as of today we rely on '0' being returned in order to properly skip bound actions in tcf_idr_insert_many. In order to further improve maintainability, introduce the ACT_P_BOUND return code. Actions are updated to return 'ACT_P_BOUND' instead of plain '0'. tcf_idr_insert_many is then updated to check for 'ACT_P_BOUND'.
Unified · Split
| @@ -137,6 +137,7 @@ struct tc_action_ops { · 136 unmodified lines | |||
| 137 | 137 | ||
| 138 | #ifdef CONFIG_NET_CLS_ACT | 138 | #ifdef CONFIG_NET_CLS_ACT |
| 139 | 139 | ||
| 140 | #define ACT_P_BOUND 0 | ||
| 140 | #define ACT_P_CREATED 1 | 141 | #define ACT_P_CREATED 1 |
| 141 | #define ACT_P_DELETED 1 | 142 | #define ACT_P_DELETED 1 |
| 142 | 143 | ||
| @@ -1313,7 +1313,7 @@ void tcf_idr_insert_many(struct tc_action *actions[], int init_res[]) · 1312 unmodified lines | |||
| 1313 | tcf_act_for_each_action(i, a, actions) { | 1313 | tcf_act_for_each_action(i, a, actions) { |
| 1314 | struct tcf_idrinfo *idrinfo; | 1314 | struct tcf_idrinfo *idrinfo; |
| 1315 | 1315 | ||
| 1316 | if (init_res[i] == 0) /* Bound */ | 1316 | if (init_res[i] == ACT_P_BOUND) |
| 1317 | continue; | 1317 | continue; |
| 1318 | 1318 | ||
| 1319 | idrinfo = a->idrinfo; | 1319 | idrinfo = a->idrinfo; |
| @@ -318,7 +318,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, · 317 unmodified lines | |||
| 318 | } else if (ret > 0) { | 318 | } else if (ret > 0) { |
| 319 | /* Don't override defaults. */ | 319 | /* Don't override defaults. */ |
| 320 | if (bind) | 320 | if (bind) |
| 321 | return 0; | 321 | return ACT_P_BOUND; |
| 322 | 322 | ||
| 323 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { | 323 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { |
| 324 | tcf_idr_release(*act, bind); | 324 | tcf_idr_release(*act, bind); |
| @@ -146,7 +146,7 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla, · 145 unmodified lines | |||
| 146 | } else if (ret > 0) { | 146 | } else if (ret > 0) { |
| 147 | ci = to_connmark(*a); | 147 | ci = to_connmark(*a); |
| 148 | if (bind) { | 148 | if (bind) { |
| 149 | err = 0; | 149 | err = ACT_P_BOUND; |
| 150 | goto out_free; | 150 | goto out_free; |
| 151 | } | 151 | } |
| 152 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { | 152 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { |
| @@ -77,8 +77,8 @@ static int tcf_csum_init(struct net *net, struct nlattr *nla, · 76 unmodified lines | |||
| 77 | } | 77 | } |
| 78 | ret = ACT_P_CREATED; | 78 | ret = ACT_P_CREATED; |
| 79 | } else if (err > 0) { | 79 | } else if (err > 0) { |
| 80 | if (bind)/* dont override defaults */ | 80 | if (bind) /* dont override defaults */ |
| 81 | return 0; | 81 | return ACT_P_BOUND; |
| 82 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { | 82 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { |
| 83 | tcf_idr_release(*a, bind); | 83 | tcf_idr_release(*a, bind); |
| 84 | return -EEXIST; | 84 | return -EEXIST; |
| @@ -1349,7 +1349,7 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla, · 1348 unmodified lines | |||
| 1349 | res = ACT_P_CREATED; | 1349 | res = ACT_P_CREATED; |
| 1350 | } else { | 1350 | } else { |
| 1351 | if (bind) | 1351 | if (bind) |
| 1352 | return 0; | 1352 | return ACT_P_BOUND; |
| 1353 | 1353 | ||
| 1354 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { | 1354 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { |
| 1355 | tcf_idr_release(*a, bind); | 1355 | tcf_idr_release(*a, bind); |
| @@ -221,7 +221,7 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla, · 220 unmodified lines | |||
| 221 | ret = ACT_P_CREATED; | 221 | ret = ACT_P_CREATED; |
| 222 | } else if (err > 0) { | 222 | } else if (err > 0) { |
| 223 | if (bind) /* don't override defaults */ | 223 | if (bind) /* don't override defaults */ |
| 224 | return 0; | 224 | return ACT_P_BOUND; |
| 225 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { | 225 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { |
| 226 | tcf_idr_release(*a, bind); | 226 | tcf_idr_release(*a, bind); |
| 227 | return -EEXIST; | 227 | return -EEXIST; |
| @@ -108,7 +108,7 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla, · 107 unmodified lines | |||
| 108 | ret = ACT_P_CREATED; | 108 | ret = ACT_P_CREATED; |
| 109 | } else if (err > 0) { | 109 | } else if (err > 0) { |
| 110 | if (bind)/* dont override defaults */ | 110 | if (bind)/* dont override defaults */ |
| 111 | return 0; | 111 | return ACT_P_BOUND; |
| 112 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { | 112 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { |
| 113 | tcf_idr_release(*a, bind); | 113 | tcf_idr_release(*a, bind); |
| 114 | return -EEXIST; | 114 | return -EEXIST; |
| @@ -356,7 +356,7 @@ static int tcf_gate_init(struct net *net, struct nlattr *nla, · 355 unmodified lines | |||
| 356 | return err; | 356 | return err; |
| 357 | 357 | ||
| 358 | if (err && bind) | 358 | if (err && bind) |
| 359 | return 0; | 359 | return ACT_P_BOUND; |
| 360 | 360 | ||
| 361 | if (!err) { | 361 | if (!err) { |
| 362 | ret = tcf_idr_create_from_flags(tn, index, est, a, | 362 | ret = tcf_idr_create_from_flags(tn, index, est, a, |
| @@ -548,7 +548,7 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, · 547 unmodified lines | |||
| 548 | exists = err; | 548 | exists = err; |
| 549 | if (exists && bind) { | 549 | if (exists && bind) { |
| 550 | kfree(p); | 550 | kfree(p); |
| 551 | return 0; | 551 | return ACT_P_BOUND; |
| 552 | } | 552 | } |
| 553 | 553 | ||
| 554 | if (!exists) { | 554 | if (!exists) { |
| @@ -135,7 +135,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, · 134 unmodified lines | |||
| 135 | return err; | 135 | return err; |
| 136 | exists = err; | 136 | exists = err; |
| 137 | if (exists && bind) | 137 | if (exists && bind) |
| 138 | return 0; | 138 | return ACT_P_BOUND; |
| 139 | 139 | ||
| 140 | if (tb[TCA_MIRRED_BLOCKID] && parm->ifindex) { | 140 | if (tb[TCA_MIRRED_BLOCKID] && parm->ifindex) { |
| 141 | NL_SET_ERR_MSG_MOD(extack, | 141 | NL_SET_ERR_MSG_MOD(extack, |
| @@ -195,7 +195,7 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla, · 194 unmodified lines | |||
| 195 | return err; | 195 | return err; |
| 196 | exists = err; | 196 | exists = err; |
| 197 | if (exists && bind) | 197 | if (exists && bind) |
| 198 | return 0; | 198 | return ACT_P_BOUND; |
| 199 | 199 | ||
| 200 | if (!exists) { | 200 | if (!exists) { |
| 201 | ret = tcf_idr_create(tn, index, est, a, &act_mpls_ops, bind, | 201 | ret = tcf_idr_create(tn, index, est, a, &act_mpls_ops, bind, |
| @@ -69,7 +69,7 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, · 68 unmodified lines | |||
| 69 | ret = ACT_P_CREATED; | 69 | ret = ACT_P_CREATED; |
| 70 | } else if (err > 0) { | 70 | } else if (err > 0) { |
| 71 | if (bind) | 71 | if (bind) |
| 72 | return 0; | 72 | return ACT_P_BOUND; |
| 73 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { | 73 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { |
| 74 | tcf_idr_release(*a, bind); | 74 | tcf_idr_release(*a, bind); |
| 75 | return -EEXIST; | 75 | return -EEXIST; |
| @@ -202,7 +202,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, · 201 unmodified lines | |||
| 202 | ret = ACT_P_CREATED; | 202 | ret = ACT_P_CREATED; |
| 203 | } else if (err > 0) { | 203 | } else if (err > 0) { |
| 204 | if (bind) | 204 | if (bind) |
| 205 | return 0; | 205 | return ACT_P_BOUND; |
| 206 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { | 206 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { |
| 207 | ret = -EEXIST; | 207 | ret = -EEXIST; |
| 208 | goto out_release; | 208 | goto out_release; |
| @@ -77,7 +77,7 @@ static int tcf_police_init(struct net *net, struct nlattr *nla, · 76 unmodified lines | |||
| 77 | return err; | 77 | return err; |
| 78 | exists = err; | 78 | exists = err; |
| 79 | if (exists && bind) | 79 | if (exists && bind) |
| 80 | return 0; | 80 | return ACT_P_BOUND; |
| 81 | 81 | ||
| 82 | if (!exists) { | 82 | if (!exists) { |
| 83 | ret = tcf_idr_create(tn, index, NULL, a, | 83 | ret = tcf_idr_create(tn, index, NULL, a, |
| @@ -66,7 +66,7 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla, · 65 unmodified lines | |||
| 66 | return err; | 66 | return err; |
| 67 | exists = err; | 67 | exists = err; |
| 68 | if (exists && bind) | 68 | if (exists && bind) |
| 69 | return 0; | 69 | return ACT_P_BOUND; |
| 70 | 70 | ||
| 71 | if (!exists) { | 71 | if (!exists) { |
| 72 | ret = tcf_idr_create(tn, index, est, a, | 72 | ret = tcf_idr_create(tn, index, est, a, |
| @@ -118,7 +118,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, · 117 unmodified lines | |||
| 118 | return err; | 118 | return err; |
| 119 | exists = err; | 119 | exists = err; |
| 120 | if (exists && bind) | 120 | if (exists && bind) |
| 121 | return 0; | 121 | return ACT_P_BOUND; |
| 122 | 122 | ||
| 123 | if (tb[TCA_DEF_DATA] == NULL) { | 123 | if (tb[TCA_DEF_DATA] == NULL) { |
| 124 | if (exists) | 124 | if (exists) |
| @@ -209,7 +209,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, · 208 unmodified lines | |||
| 209 | return err; | 209 | return err; |
| 210 | exists = err; | 210 | exists = err; |
| 211 | if (exists && bind) | 211 | if (exists && bind) |
| 212 | return 0; | 212 | return ACT_P_BOUND; |
| 213 | 213 | ||
| 214 | if (!flags) { | 214 | if (!flags) { |
| 215 | if (exists) | 215 | if (exists) |
| @@ -157,7 +157,7 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla, · 156 unmodified lines | |||
| 157 | return err; | 157 | return err; |
| 158 | exists = err; | 158 | exists = err; |
| 159 | if (exists && bind) | 159 | if (exists && bind) |
| 160 | return 0; | 160 | return ACT_P_BOUND; |
| 161 | 161 | ||
| 162 | if (!lflags) { | 162 | if (!lflags) { |
| 163 | if (exists) | 163 | if (exists) |
| @@ -401,7 +401,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, · 400 unmodified lines | |||
| 401 | return err; | 401 | return err; |
| 402 | exists = err; | 402 | exists = err; |
| 403 | if (exists && bind) | 403 | if (exists && bind) |
| 404 | return 0; | 404 | return ACT_P_BOUND; |
| 405 | 405 | ||
| 406 | switch (parm->t_action) { | 406 | switch (parm->t_action) { |
| 407 | case TCA_TUNNEL_KEY_ACT_RELEASE: | 407 | case TCA_TUNNEL_KEY_ACT_RELEASE: |
| @@ -151,7 +151,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, · 150 unmodified lines | |||
| 151 | return err; | 151 | return err; |
| 152 | exists = err; | 152 | exists = err; |
| 153 | if (exists && bind) | 153 | if (exists && bind) |
| 154 | return 0; | 154 | return ACT_P_BOUND; |
| 155 | 155 | ||
| 156 | switch (parm->v_action) { | 156 | switch (parm->v_action) { |
| 157 | case TCA_VLAN_ACT_POP: | 157 | case TCA_VLAN_ACT_POP: |