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 | 138 | #ifdef CONFIG_NET_CLS_ACT |
| 139 | 139 | |
| 140 | +#define ACT_P_BOUND 0 | |
| 140 | 141 | #define ACT_P_CREATED 1 |
| 141 | 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 | 1313 | tcf_act_for_each_action(i, a, actions) { |
| 1314 | 1314 | struct tcf_idrinfo *idrinfo; |
| 1315 | 1315 | |
| 1316 | − if (init_res[i] == 0) /* Bound */ | |
| 1316 | + if (init_res[i] == ACT_P_BOUND) | |
| 1317 | 1317 | continue; |
| 1318 | 1318 | |
| 1319 | 1319 | idrinfo = a->idrinfo; |
| @@ -318,7 +318,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, · 317 unmodified lines | ||
| 318 | 318 | } else if (ret > 0) { |
| 319 | 319 | /* Don't override defaults. */ |
| 320 | 320 | if (bind) |
| 321 | − return 0; | |
| 321 | + return ACT_P_BOUND; | |
| 322 | 322 | |
| 323 | 323 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { |
| 324 | 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 | 146 | } else if (ret > 0) { |
| 147 | 147 | ci = to_connmark(*a); |
| 148 | 148 | if (bind) { |
| 149 | − err = 0; | |
| 149 | + err = ACT_P_BOUND; | |
| 150 | 150 | goto out_free; |
| 151 | 151 | } |
| 152 | 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 | 78 | ret = ACT_P_CREATED; |
| 79 | 79 | } else if (err > 0) { |
| 80 | − if (bind)/* dont override defaults */ | |
| 81 | − return 0; | |
| 80 | + if (bind) /* dont override defaults */ | |
| 81 | + return ACT_P_BOUND; | |
| 82 | 82 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { |
| 83 | 83 | tcf_idr_release(*a, bind); |
| 84 | 84 | return -EEXIST; |
| @@ -1349,7 +1349,7 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla, · 1348 unmodified lines | ||
| 1349 | 1349 | res = ACT_P_CREATED; |
| 1350 | 1350 | } else { |
| 1351 | 1351 | if (bind) |
| 1352 | − return 0; | |
| 1352 | + return ACT_P_BOUND; | |
| 1353 | 1353 | |
| 1354 | 1354 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { |
| 1355 | 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 | 221 | ret = ACT_P_CREATED; |
| 222 | 222 | } else if (err > 0) { |
| 223 | 223 | if (bind) /* don't override defaults */ |
| 224 | − return 0; | |
| 224 | + return ACT_P_BOUND; | |
| 225 | 225 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { |
| 226 | 226 | tcf_idr_release(*a, bind); |
| 227 | 227 | return -EEXIST; |
| @@ -108,7 +108,7 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla, · 107 unmodified lines | ||
| 108 | 108 | ret = ACT_P_CREATED; |
| 109 | 109 | } else if (err > 0) { |
| 110 | 110 | if (bind)/* dont override defaults */ |
| 111 | − return 0; | |
| 111 | + return ACT_P_BOUND; | |
| 112 | 112 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { |
| 113 | 113 | tcf_idr_release(*a, bind); |
| 114 | 114 | return -EEXIST; |
| @@ -356,7 +356,7 @@ static int tcf_gate_init(struct net *net, struct nlattr *nla, · 355 unmodified lines | ||
| 356 | 356 | return err; |
| 357 | 357 | |
| 358 | 358 | if (err && bind) |
| 359 | − return 0; | |
| 359 | + return ACT_P_BOUND; | |
| 360 | 360 | |
| 361 | 361 | if (!err) { |
| 362 | 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 | 548 | exists = err; |
| 549 | 549 | if (exists && bind) { |
| 550 | 550 | kfree(p); |
| 551 | − return 0; | |
| 551 | + return ACT_P_BOUND; | |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | if (!exists) { |
| @@ -135,7 +135,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, · 134 unmodified lines | ||
| 135 | 135 | return err; |
| 136 | 136 | exists = err; |
| 137 | 137 | if (exists && bind) |
| 138 | − return 0; | |
| 138 | + return ACT_P_BOUND; | |
| 139 | 139 | |
| 140 | 140 | if (tb[TCA_MIRRED_BLOCKID] && parm->ifindex) { |
| 141 | 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 | 195 | return err; |
| 196 | 196 | exists = err; |
| 197 | 197 | if (exists && bind) |
| 198 | − return 0; | |
| 198 | + return ACT_P_BOUND; | |
| 199 | 199 | |
| 200 | 200 | if (!exists) { |
| 201 | 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 | 69 | ret = ACT_P_CREATED; |
| 70 | 70 | } else if (err > 0) { |
| 71 | 71 | if (bind) |
| 72 | − return 0; | |
| 72 | + return ACT_P_BOUND; | |
| 73 | 73 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { |
| 74 | 74 | tcf_idr_release(*a, bind); |
| 75 | 75 | return -EEXIST; |
| @@ -202,7 +202,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, · 201 unmodified lines | ||
| 202 | 202 | ret = ACT_P_CREATED; |
| 203 | 203 | } else if (err > 0) { |
| 204 | 204 | if (bind) |
| 205 | − return 0; | |
| 205 | + return ACT_P_BOUND; | |
| 206 | 206 | if (!(flags & TCA_ACT_FLAGS_REPLACE)) { |
| 207 | 207 | ret = -EEXIST; |
| 208 | 208 | goto out_release; |
| @@ -77,7 +77,7 @@ static int tcf_police_init(struct net *net, struct nlattr *nla, · 76 unmodified lines | ||
| 77 | 77 | return err; |
| 78 | 78 | exists = err; |
| 79 | 79 | if (exists && bind) |
| 80 | − return 0; | |
| 80 | + return ACT_P_BOUND; | |
| 81 | 81 | |
| 82 | 82 | if (!exists) { |
| 83 | 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 | 66 | return err; |
| 67 | 67 | exists = err; |
| 68 | 68 | if (exists && bind) |
| 69 | − return 0; | |
| 69 | + return ACT_P_BOUND; | |
| 70 | 70 | |
| 71 | 71 | if (!exists) { |
| 72 | 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 | 118 | return err; |
| 119 | 119 | exists = err; |
| 120 | 120 | if (exists && bind) |
| 121 | − return 0; | |
| 121 | + return ACT_P_BOUND; | |
| 122 | 122 | |
| 123 | 123 | if (tb[TCA_DEF_DATA] == NULL) { |
| 124 | 124 | if (exists) |
| @@ -209,7 +209,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, · 208 unmodified lines | ||
| 209 | 209 | return err; |
| 210 | 210 | exists = err; |
| 211 | 211 | if (exists && bind) |
| 212 | − return 0; | |
| 212 | + return ACT_P_BOUND; | |
| 213 | 213 | |
| 214 | 214 | if (!flags) { |
| 215 | 215 | if (exists) |
| @@ -157,7 +157,7 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla, · 156 unmodified lines | ||
| 157 | 157 | return err; |
| 158 | 158 | exists = err; |
| 159 | 159 | if (exists && bind) |
| 160 | − return 0; | |
| 160 | + return ACT_P_BOUND; | |
| 161 | 161 | |
| 162 | 162 | if (!lflags) { |
| 163 | 163 | if (exists) |
| @@ -401,7 +401,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, · 400 unmodified lines | ||
| 401 | 401 | return err; |
| 402 | 402 | exists = err; |
| 403 | 403 | if (exists && bind) |
| 404 | − return 0; | |
| 404 | + return ACT_P_BOUND; | |
| 405 | 405 | |
| 406 | 406 | switch (parm->t_action) { |
| 407 | 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 | 151 | return err; |
| 152 | 152 | exists = err; |
| 153 | 153 | if (exists && bind) |
| 154 | − return 0; | |
| 154 | + return ACT_P_BOUND; | |
| 155 | 155 | |
| 156 | 156 | switch (parm->v_action) { |
| 157 | 157 | case TCA_VLAN_ACT_POP: |