History

net/sched: introduce ACT_P_BOUND return code

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'.

Pedro Tammela committed 2 years ago

Commit c2a67de1 parent d3d344a21 files · +22 −21Browse files

Unified · Split

21 files
  1. include/net/act_api.h +1 −0
  2. net/sched/act_api.c +1 −1
  3. net/sched/act_bpf.c +1 −1
  4. net/sched/act_connmark.c +1 −1
  5. net/sched/act_csum.c +2 −2
  6. net/sched/act_ct.c +1 −1
  7. net/sched/act_ctinfo.c +1 −1
  8. net/sched/act_gact.c +1 −1
  9. net/sched/act_gate.c +1 −1
  10. net/sched/act_ife.c +1 −1
  11. net/sched/act_mirred.c +1 −1
  12. net/sched/act_mpls.c +1 −1
  13. net/sched/act_nat.c +1 −1
  14. net/sched/act_pedit.c +1 −1
  15. net/sched/act_police.c +1 −1
  16. net/sched/act_sample.c +1 −1
  17. net/sched/act_simple.c +1 −1
  18. net/sched/act_skbedit.c +1 −1
  19. net/sched/act_skbmod.c +1 −1
  20. net/sched/act_tunnel_key.c +1 −1
  21. net/sched/act_vlan.c +1 −1
include/net/act_api.h+1−0
@@ -137,6 +137,7 @@ struct tc_action_ops { · 136 unmodified lines
137137
138138 #ifdef CONFIG_NET_CLS_ACT
139139
140+#define ACT_P_BOUND 0
140141 #define ACT_P_CREATED 1
141142 #define ACT_P_DELETED 1
142143
net/sched/act_api.c+1−1
@@ -1313,7 +1313,7 @@ void tcf_idr_insert_many(struct tc_action *actions[], int init_res[]) · 1312 unmodified lines
13131313 tcf_act_for_each_action(i, a, actions) {
13141314 struct tcf_idrinfo *idrinfo;
13151315
1316− if (init_res[i] == 0) /* Bound */
1316+ if (init_res[i] == ACT_P_BOUND)
13171317 continue;
13181318
13191319 idrinfo = a->idrinfo;
net/sched/act_bpf.c+1−1
@@ -318,7 +318,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, · 317 unmodified lines
318318 } else if (ret > 0) {
319319 /* Don't override defaults. */
320320 if (bind)
321− return 0;
321+ return ACT_P_BOUND;
322322
323323 if (!(flags & TCA_ACT_FLAGS_REPLACE)) {
324324 tcf_idr_release(*act, bind);
net/sched/act_connmark.c+1−1
@@ -146,7 +146,7 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla, · 145 unmodified lines
146146 } else if (ret > 0) {
147147 ci = to_connmark(*a);
148148 if (bind) {
149− err = 0;
149+ err = ACT_P_BOUND;
150150 goto out_free;
151151 }
152152 if (!(flags & TCA_ACT_FLAGS_REPLACE)) {
net/sched/act_csum.c+2−2
@@ -77,8 +77,8 @@ static int tcf_csum_init(struct net *net, struct nlattr *nla, · 76 unmodified lines
7777 }
7878 ret = ACT_P_CREATED;
7979 } else if (err > 0) {
80− if (bind)/* dont override defaults */
81− return 0;
80+ if (bind) /* dont override defaults */
81+ return ACT_P_BOUND;
8282 if (!(flags & TCA_ACT_FLAGS_REPLACE)) {
8383 tcf_idr_release(*a, bind);
8484 return -EEXIST;
net/sched/act_ct.c+1−1
@@ -1349,7 +1349,7 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla, · 1348 unmodified lines
13491349 res = ACT_P_CREATED;
13501350 } else {
13511351 if (bind)
1352− return 0;
1352+ return ACT_P_BOUND;
13531353
13541354 if (!(flags & TCA_ACT_FLAGS_REPLACE)) {
13551355 tcf_idr_release(*a, bind);
net/sched/act_ctinfo.c+1−1
@@ -221,7 +221,7 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla, · 220 unmodified lines
221221 ret = ACT_P_CREATED;
222222 } else if (err > 0) {
223223 if (bind) /* don't override defaults */
224− return 0;
224+ return ACT_P_BOUND;
225225 if (!(flags & TCA_ACT_FLAGS_REPLACE)) {
226226 tcf_idr_release(*a, bind);
227227 return -EEXIST;
net/sched/act_gact.c+1−1
@@ -108,7 +108,7 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla, · 107 unmodified lines
108108 ret = ACT_P_CREATED;
109109 } else if (err > 0) {
110110 if (bind)/* dont override defaults */
111− return 0;
111+ return ACT_P_BOUND;
112112 if (!(flags & TCA_ACT_FLAGS_REPLACE)) {
113113 tcf_idr_release(*a, bind);
114114 return -EEXIST;
net/sched/act_gate.c+1−1
@@ -356,7 +356,7 @@ static int tcf_gate_init(struct net *net, struct nlattr *nla, · 355 unmodified lines
356356 return err;
357357
358358 if (err && bind)
359− return 0;
359+ return ACT_P_BOUND;
360360
361361 if (!err) {
362362 ret = tcf_idr_create_from_flags(tn, index, est, a,
net/sched/act_ife.c+1−1
@@ -548,7 +548,7 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, · 547 unmodified lines
548548 exists = err;
549549 if (exists && bind) {
550550 kfree(p);
551− return 0;
551+ return ACT_P_BOUND;
552552 }
553553
554554 if (!exists) {
net/sched/act_mirred.c+1−1
@@ -135,7 +135,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, · 134 unmodified lines
135135 return err;
136136 exists = err;
137137 if (exists && bind)
138− return 0;
138+ return ACT_P_BOUND;
139139
140140 if (tb[TCA_MIRRED_BLOCKID] && parm->ifindex) {
141141 NL_SET_ERR_MSG_MOD(extack,
net/sched/act_mpls.c+1−1
@@ -195,7 +195,7 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla, · 194 unmodified lines
195195 return err;
196196 exists = err;
197197 if (exists && bind)
198− return 0;
198+ return ACT_P_BOUND;
199199
200200 if (!exists) {
201201 ret = tcf_idr_create(tn, index, est, a, &act_mpls_ops, bind,
net/sched/act_nat.c+1−1
@@ -69,7 +69,7 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, · 68 unmodified lines
6969 ret = ACT_P_CREATED;
7070 } else if (err > 0) {
7171 if (bind)
72− return 0;
72+ return ACT_P_BOUND;
7373 if (!(flags & TCA_ACT_FLAGS_REPLACE)) {
7474 tcf_idr_release(*a, bind);
7575 return -EEXIST;
net/sched/act_pedit.c+1−1
@@ -202,7 +202,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, · 201 unmodified lines
202202 ret = ACT_P_CREATED;
203203 } else if (err > 0) {
204204 if (bind)
205− return 0;
205+ return ACT_P_BOUND;
206206 if (!(flags & TCA_ACT_FLAGS_REPLACE)) {
207207 ret = -EEXIST;
208208 goto out_release;
net/sched/act_police.c+1−1
@@ -77,7 +77,7 @@ static int tcf_police_init(struct net *net, struct nlattr *nla, · 76 unmodified lines
7777 return err;
7878 exists = err;
7979 if (exists && bind)
80− return 0;
80+ return ACT_P_BOUND;
8181
8282 if (!exists) {
8383 ret = tcf_idr_create(tn, index, NULL, a,
net/sched/act_sample.c+1−1
@@ -66,7 +66,7 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla, · 65 unmodified lines
6666 return err;
6767 exists = err;
6868 if (exists && bind)
69− return 0;
69+ return ACT_P_BOUND;
7070
7171 if (!exists) {
7272 ret = tcf_idr_create(tn, index, est, a,
net/sched/act_simple.c+1−1
@@ -118,7 +118,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, · 117 unmodified lines
118118 return err;
119119 exists = err;
120120 if (exists && bind)
121− return 0;
121+ return ACT_P_BOUND;
122122
123123 if (tb[TCA_DEF_DATA] == NULL) {
124124 if (exists)
net/sched/act_skbedit.c+1−1
@@ -209,7 +209,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, · 208 unmodified lines
209209 return err;
210210 exists = err;
211211 if (exists && bind)
212− return 0;
212+ return ACT_P_BOUND;
213213
214214 if (!flags) {
215215 if (exists)
net/sched/act_skbmod.c+1−1
@@ -157,7 +157,7 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla, · 156 unmodified lines
157157 return err;
158158 exists = err;
159159 if (exists && bind)
160− return 0;
160+ return ACT_P_BOUND;
161161
162162 if (!lflags) {
163163 if (exists)
net/sched/act_tunnel_key.c+1−1
@@ -401,7 +401,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, · 400 unmodified lines
401401 return err;
402402 exists = err;
403403 if (exists && bind)
404− return 0;
404+ return ACT_P_BOUND;
405405
406406 switch (parm->t_action) {
407407 case TCA_TUNNEL_KEY_ACT_RELEASE:
net/sched/act_vlan.c+1−1
@@ -151,7 +151,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, · 150 unmodified lines
151151 return err;
152152 exists = err;
153153 if (exists && bind)
154− return 0;
154+ return ACT_P_BOUND;
155155
156156 switch (parm->v_action) {
157157 case TCA_VLAN_ACT_POP: