Commit c2a67de9 authored by Pedro Tammela's avatar Pedro Tammela Committed by Jakub Kicinski
Browse files

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

Signed-off-by: default avatarPedro Tammela <pctammela@mojatatu.com>
Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Link: https://lore.kernel.org/r/20231229132642.1489088-1-pctammela@mojatatu.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent d3d344a1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ struct tc_action_ops {

#ifdef CONFIG_NET_CLS_ACT

#define ACT_P_BOUND 0
#define ACT_P_CREATED 1
#define ACT_P_DELETED 1

+1 −1
Original line number Diff line number Diff line
@@ -1313,7 +1313,7 @@ void tcf_idr_insert_many(struct tc_action *actions[], int init_res[])
	tcf_act_for_each_action(i, a, actions) {
		struct tcf_idrinfo *idrinfo;

		if (init_res[i] == 0) /* Bound */
		if (init_res[i] == ACT_P_BOUND)
			continue;

		idrinfo = a->idrinfo;
+1 −1
Original line number Diff line number Diff line
@@ -318,7 +318,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla,
	} else if (ret > 0) {
		/* Don't override defaults. */
		if (bind)
			return 0;
			return ACT_P_BOUND;

		if (!(flags & TCA_ACT_FLAGS_REPLACE)) {
			tcf_idr_release(*act, bind);
+1 −1
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla,
	} else if (ret > 0) {
		ci = to_connmark(*a);
		if (bind) {
			err = 0;
			err = ACT_P_BOUND;
			goto out_free;
		}
		if (!(flags & TCA_ACT_FLAGS_REPLACE)) {
+2 −2
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ static int tcf_csum_init(struct net *net, struct nlattr *nla,
		ret = ACT_P_CREATED;
	} else if (err > 0) {
		if (bind) /* dont override defaults */
			return 0;
			return ACT_P_BOUND;
		if (!(flags & TCA_ACT_FLAGS_REPLACE)) {
			tcf_idr_release(*a, bind);
			return -EEXIST;
Loading