diff mbox series

[iproute2,3/4] tc: make action_util arg const

Message ID 20240312221422.81253-4-stephen@networkplumber.org (mailing list archive)
State Accepted
Commit 38b0e6c120a8fff487745926b7a5e9146a06cb8f
Delegated to: Stephen Hemminger
Headers show
Series constify tc XXX_util structures | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Stephen Hemminger March 12, 2024, 10:12 p.m. UTC
The callbacks in action_util should not be modifying underlying
qdisc operations structure.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/m_action.c     | 4 ++--
 tc/m_bpf.c        | 4 ++--
 tc/m_connmark.c   | 4 ++--
 tc/m_csum.c       | 4 ++--
 tc/m_ct.c         | 4 ++--
 tc/m_ctinfo.c     | 4 ++--
 tc/m_gact.c       | 4 ++--
 tc/m_gate.c       | 8 ++++----
 tc/m_ife.c        | 4 ++--
 tc/m_mirred.c     | 6 +++---
 tc/m_mpls.c       | 4 ++--
 tc/m_nat.c        | 4 ++--
 tc/m_pedit.c      | 4 ++--
 tc/m_police.c     | 8 ++++----
 tc/m_sample.c     | 4 ++--
 tc/m_simple.c     | 4 ++--
 tc/m_skbedit.c    | 4 ++--
 tc/m_skbmod.c     | 4 ++--
 tc/m_tunnel_key.c | 4 ++--
 tc/m_vlan.c       | 4 ++--
 tc/tc_util.h      | 8 ++++----
 21 files changed, 49 insertions(+), 49 deletions(-)
diff mbox series

Patch

diff --git a/tc/m_action.c b/tc/m_action.c
index e0b9ebeedf5e..36bb59edcdde 100644
--- a/tc/m_action.c
+++ b/tc/m_action.c
@@ -59,7 +59,7 @@  static void act_usage(void)
 	exit(-1);
 }
 
-static int print_noaopt(struct action_util *au, FILE *f, struct rtattr *opt)
+static int print_noaopt(const struct action_util *au, FILE *f, struct rtattr *opt)
 {
 	if (opt && RTA_PAYLOAD(opt))
 		fprintf(stderr, "[Unknown action, optlen=%u] ",
@@ -67,7 +67,7 @@  static int print_noaopt(struct action_util *au, FILE *f, struct rtattr *opt)
 	return 0;
 }
 
-static int parse_noaopt(struct action_util *au, int *argc_p,
+static int parse_noaopt(const struct action_util *au, int *argc_p,
 			char ***argv_p, int code, struct nlmsghdr *n)
 {
 	int argc = *argc_p;
diff --git a/tc/m_bpf.c b/tc/m_bpf.c
index da50c05e1529..9dba4be58118 100644
--- a/tc/m_bpf.c
+++ b/tc/m_bpf.c
@@ -69,7 +69,7 @@  static const struct bpf_cfg_ops bpf_cb_ops = {
 	.ebpf_cb = bpf_ebpf_cb,
 };
 
-static int bpf_parse_opt(struct action_util *a, int *ptr_argc, char ***ptr_argv,
+static int bpf_parse_opt(const struct action_util *a, int *ptr_argc, char ***ptr_argv,
 			 int tca_id, struct nlmsghdr *n)
 {
 	const char *bpf_obj = NULL, *bpf_uds_name = NULL;
@@ -151,7 +151,7 @@  opt_bpf:
 	return ret;
 }
 
-static int bpf_print_opt(struct action_util *au, FILE *f, struct rtattr *arg)
+static int bpf_print_opt(const struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	struct rtattr *tb[TCA_ACT_BPF_MAX + 1];
 	struct tc_act_bpf *parm;
diff --git a/tc/m_connmark.c b/tc/m_connmark.c
index 8506d95af5ec..8b5630f66c5e 100644
--- a/tc/m_connmark.c
+++ b/tc/m_connmark.c
@@ -32,7 +32,7 @@  usage(void)
 }
 
 static int
-parse_connmark(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
+parse_connmark(const struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
 	      struct nlmsghdr *n)
 {
 	struct tc_connmark sel = {};
@@ -94,7 +94,7 @@  parse_connmark(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
 	return 0;
 }
 
-static int print_connmark(struct action_util *au, FILE *f, struct rtattr *arg)
+static int print_connmark(const struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	struct rtattr *tb[TCA_CONNMARK_MAX + 1];
 	struct tc_connmark *ci;
diff --git a/tc/m_csum.c b/tc/m_csum.c
index f5fe8f550a06..21204e5bf7b6 100644
--- a/tc/m_csum.c
+++ b/tc/m_csum.c
@@ -81,7 +81,7 @@  parse_csum_args(int *argc_p, char ***argv_p, struct tc_csum *sel)
 }
 
 static int
-parse_csum(struct action_util *a, int *argc_p,
+parse_csum(const struct action_util *a, int *argc_p,
 	   char ***argv_p, int tca_id, struct nlmsghdr *n)
 {
 	struct tc_csum sel = {};
@@ -148,7 +148,7 @@  skip_args:
 }
 
 static int
-print_csum(struct action_util *au, FILE *f, struct rtattr *arg)
+print_csum(const struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	struct tc_csum *sel;
 
diff --git a/tc/m_ct.c b/tc/m_ct.c
index 8c471489778a..4b7d322c8d4f 100644
--- a/tc/m_ct.c
+++ b/tc/m_ct.c
@@ -225,7 +225,7 @@  static int ct_parse_labels(char *str, struct nlmsghdr *n)
 }
 
 static int
-parse_ct(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
+parse_ct(const struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
 		struct nlmsghdr *n)
 {
 	struct tc_ct sel = {};
@@ -488,7 +488,7 @@  static void ct_print_helper(struct rtattr *family, struct rtattr *proto, struct
 	print_string(PRINT_ANY, "helper", " helper %s", helper);
 }
 
-static int print_ct(struct action_util *au, FILE *f, struct rtattr *arg)
+static int print_ct(const struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	struct rtattr *tb[TCA_CT_MAX + 1];
 	const char *commit;
diff --git a/tc/m_ctinfo.c b/tc/m_ctinfo.c
index 996a36217dfe..dbd5c0b32c50 100644
--- a/tc/m_ctinfo.c
+++ b/tc/m_ctinfo.c
@@ -35,7 +35,7 @@  usage(void)
 }
 
 static int
-parse_ctinfo(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
+parse_ctinfo(const struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
 	     struct nlmsghdr *n)
 {
 	unsigned int cpmarkmask = 0, dscpmask = 0, dscpstatemask = 0;
@@ -181,7 +181,7 @@  static void print_ctinfo_stats(FILE *f, struct rtattr *tb[TCA_CTINFO_MAX + 1])
 			     rta_getattr_u64(tb[TCA_CTINFO_STATS_CPMARK_SET]));
 }
 
-static int print_ctinfo(struct action_util *au, FILE *f, struct rtattr *arg)
+static int print_ctinfo(const struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	unsigned int cpmarkmask = ~0, dscpmask = 0, dscpstatemask = 0;
 	struct rtattr *tb[TCA_CTINFO_MAX + 1];
diff --git a/tc/m_gact.c b/tc/m_gact.c
index 225ffce41412..670d59f03ee6 100644
--- a/tc/m_gact.c
+++ b/tc/m_gact.c
@@ -66,7 +66,7 @@  usage(void)
 }
 
 static int
-parse_gact(struct action_util *a, int *argc_p, char ***argv_p,
+parse_gact(const struct action_util *a, int *argc_p, char ***argv_p,
 	   int tca_id, struct nlmsghdr *n)
 {
 	int argc = *argc_p;
@@ -157,7 +157,7 @@  skip_args:
 }
 
 static int
-print_gact(struct action_util *au, FILE *f, struct rtattr *arg)
+print_gact(const struct action_util *au, FILE *f, struct rtattr *arg)
 {
 #ifdef CONFIG_GACT_PROB
 	struct tc_gact_p *pp = NULL;
diff --git a/tc/m_gate.c b/tc/m_gate.c
index 37afa426a2c8..33ee63bb316c 100644
--- a/tc/m_gate.c
+++ b/tc/m_gate.c
@@ -56,9 +56,9 @@  static void explain_entry_format(void)
 	fprintf(stderr, "Usage: sched-entry <open | close> <interval> [ <interval ipv> <octets max bytes> ]\n");
 }
 
-static int parse_gate(struct action_util *a, int *argc_p, char ***argv_p,
+static int parse_gate(const struct action_util *a, int *argc_p, char ***argv_p,
 		      int tca_id, struct nlmsghdr *n);
-static int print_gate(struct action_util *au, FILE *f, struct rtattr *arg);
+static int print_gate(const struct action_util *au, FILE *f, struct rtattr *arg);
 
 struct action_util gate_action_util = {
 	.id = "gate",
@@ -135,7 +135,7 @@  static void free_entries(struct list_head *gate_entries)
 	}
 }
 
-static int parse_gate(struct action_util *a, int *argc_p, char ***argv_p,
+static int parse_gate(const struct action_util *a, int *argc_p, char ***argv_p,
 		      int tca_id, struct nlmsghdr *n)
 {
 	struct tc_gate parm = {.action = TC_ACT_PIPE};
@@ -441,7 +441,7 @@  static int print_gate_list(struct rtattr *list)
 	return 0;
 }
 
-static int print_gate(struct action_util *au, FILE *f, struct rtattr *arg)
+static int print_gate(const struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	struct tc_gate *parm;
 	struct rtattr *tb[TCA_GATE_MAX + 1];
diff --git a/tc/m_ife.c b/tc/m_ife.c
index 162607ce7415..dfd85561e1c1 100644
--- a/tc/m_ife.c
+++ b/tc/m_ife.c
@@ -44,7 +44,7 @@  static void ife_usage(void)
 	exit(-1);
 }
 
-static int parse_ife(struct action_util *a, int *argc_p, char ***argv_p,
+static int parse_ife(const struct action_util *a, int *argc_p, char ***argv_p,
 		     int tca_id, struct nlmsghdr *n)
 {
 	int argc = *argc_p;
@@ -211,7 +211,7 @@  skip_encode:
 	return 0;
 }
 
-static int print_ife(struct action_util *au, FILE *f, struct rtattr *arg)
+static int print_ife(const struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	struct tc_ife *p;
 	struct rtattr *tb[TCA_IFE_MAX + 1];
diff --git a/tc/m_mirred.c b/tc/m_mirred.c
index 60bd90452ccb..cfecd59c7551 100644
--- a/tc/m_mirred.c
+++ b/tc/m_mirred.c
@@ -88,7 +88,7 @@  static const char *mirred_action(int action)
 }
 
 static int
-parse_direction(struct action_util *a, int *argc_p, char ***argv_p,
+parse_direction(const struct action_util *a, int *argc_p, char ***argv_p,
 		int tca_id, struct nlmsghdr *n)
 {
 
@@ -258,7 +258,7 @@  parse_direction(struct action_util *a, int *argc_p, char ***argv_p,
 
 
 static int
-parse_mirred(struct action_util *a, int *argc_p, char ***argv_p,
+parse_mirred(const struct action_util *a, int *argc_p, char ***argv_p,
 	     int tca_id, struct nlmsghdr *n)
 {
 
@@ -299,7 +299,7 @@  parse_mirred(struct action_util *a, int *argc_p, char ***argv_p,
 }
 
 static int
-print_mirred(struct action_util *au, FILE *f, struct rtattr *arg)
+print_mirred(const struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	struct tc_mirred *p;
 	struct rtattr *tb[TCA_MIRRED_MAX + 1];
diff --git a/tc/m_mpls.c b/tc/m_mpls.c
index dda4680509a9..ca3a18a9a1ef 100644
--- a/tc/m_mpls.c
+++ b/tc/m_mpls.c
@@ -72,7 +72,7 @@  static bool check_double_action(unsigned int action, const char *arg)
 	return true;
 }
 
-static int parse_mpls(struct action_util *a, int *argc_p, char ***argv_p,
+static int parse_mpls(const struct action_util *a, int *argc_p, char ***argv_p,
 		      int tca_id, struct nlmsghdr *n)
 {
 	struct tc_mpls parm = {};
@@ -211,7 +211,7 @@  skip_args:
 	return 0;
 }
 
-static int print_mpls(struct action_util *au, FILE *f, struct rtattr *arg)
+static int print_mpls(const struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	struct rtattr *tb[TCA_MPLS_MAX + 1];
 	struct tc_mpls *parm;
diff --git a/tc/m_nat.c b/tc/m_nat.c
index 95b35584a23e..a3f86e190166 100644
--- a/tc/m_nat.c
+++ b/tc/m_nat.c
@@ -76,7 +76,7 @@  bad_val:
 }
 
 static int
-parse_nat(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n)
+parse_nat(const struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n)
 {
 	struct tc_nat sel = {};
 
@@ -136,7 +136,7 @@  skip_args:
 }
 
 static int
-print_nat(struct action_util *au, FILE * f, struct rtattr *arg)
+print_nat(const struct action_util *au, FILE * f, struct rtattr *arg)
 {
 	struct tc_nat *sel;
 	struct rtattr *tb[TCA_NAT_MAX + 1];
diff --git a/tc/m_pedit.c b/tc/m_pedit.c
index 32f03415d61c..83a0c42e58aa 100644
--- a/tc/m_pedit.c
+++ b/tc/m_pedit.c
@@ -620,7 +620,7 @@  static int pedit_keys_ex_addattr(struct m_pedit_sel *sel, struct nlmsghdr *n)
 	return 0;
 }
 
-static int parse_pedit(struct action_util *a, int *argc_p, char ***argv_p,
+static int parse_pedit(const struct action_util *a, int *argc_p, char ***argv_p,
 		       int tca_id, struct nlmsghdr *n)
 {
 	struct m_pedit_sel sel = {};
@@ -745,7 +745,7 @@  static int print_pedit_location(FILE *f,
 	return 0;
 }
 
-static int print_pedit(struct action_util *au, FILE *f, struct rtattr *arg)
+static int print_pedit(const struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	struct tc_pedit_sel *sel;
 	struct rtattr *tb[TCA_PEDIT_MAX + 1];
diff --git a/tc/m_police.c b/tc/m_police.c
index 46c39a818761..8d6887eefc7d 100644
--- a/tc/m_police.c
+++ b/tc/m_police.c
@@ -17,9 +17,9 @@ 
 #include "utils.h"
 #include "tc_util.h"
 
-static int act_parse_police(struct action_util *a, int *argc_p,
+static int act_parse_police(const struct action_util *a, int *argc_p,
 			    char ***argv_p, int tca_id, struct nlmsghdr *n);
-static int print_police(struct action_util *a, FILE *f, struct rtattr *tb);
+static int print_police(const struct action_util *a, FILE *f, struct rtattr *tb);
 
 struct action_util police_action_util = {
 	.id = "police",
@@ -42,7 +42,7 @@  static void usage(void)
 	exit(-1);
 }
 
-static int act_parse_police(struct action_util *a, int *argc_p, char ***argv_p,
+static int act_parse_police(const struct action_util *a, int *argc_p, char ***argv_p,
 			    int tca_id, struct nlmsghdr *n)
 {
 	int argc = *argc_p;
@@ -260,7 +260,7 @@  int parse_police(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n)
 	return act_parse_police(NULL, argc_p, argv_p, tca_id, n);
 }
 
-static int print_police(struct action_util *a, FILE *f, struct rtattr *arg)
+static int print_police(const struct action_util *a, FILE *f, struct rtattr *arg)
 {
 	SPRINT_BUF(b2);
 	struct tc_police *p;
diff --git a/tc/m_sample.c b/tc/m_sample.c
index 769de144cbe0..642ec3a6ea7e 100644
--- a/tc/m_sample.c
+++ b/tc/m_sample.c
@@ -31,7 +31,7 @@  static void usage(void)
 	exit(-1);
 }
 
-static int parse_sample(struct action_util *a, int *argc_p, char ***argv_p,
+static int parse_sample(const struct action_util *a, int *argc_p, char ***argv_p,
 			int tca_id, struct nlmsghdr *n)
 {
 	struct tc_sample p = { 0 };
@@ -133,7 +133,7 @@  static int parse_sample(struct action_util *a, int *argc_p, char ***argv_p,
 	return 0;
 }
 
-static int print_sample(struct action_util *au, FILE *f, struct rtattr *arg)
+static int print_sample(const struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	struct rtattr *tb[TCA_SAMPLE_MAX + 1];
 	struct tc_sample *p;
diff --git a/tc/m_simple.c b/tc/m_simple.c
index fe2bca21ae46..9715955e0187 100644
--- a/tc/m_simple.c
+++ b/tc/m_simple.c
@@ -90,7 +90,7 @@  static void usage(void)
 }
 
 static int
-parse_simple(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
+parse_simple(const struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
 	     struct nlmsghdr *n)
 {
 	struct tc_defact sel = {};
@@ -155,7 +155,7 @@  parse_simple(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
 	return 0;
 }
 
-static int print_simple(struct action_util *au, FILE *f, struct rtattr *arg)
+static int print_simple(const struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	struct tc_defact *sel;
 	struct rtattr *tb[TCA_DEF_MAX + 1];
diff --git a/tc/m_skbedit.c b/tc/m_skbedit.c
index d55a6128494e..b55c3249e6fa 100644
--- a/tc/m_skbedit.c
+++ b/tc/m_skbedit.c
@@ -41,7 +41,7 @@  usage(void)
 }
 
 static int
-parse_skbedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
+parse_skbedit(const struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
 	      struct nlmsghdr *n)
 {
 	int argc = *argc_p;
@@ -177,7 +177,7 @@  parse_skbedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
 	return 0;
 }
 
-static int print_skbedit(struct action_util *au, FILE *f, struct rtattr *arg)
+static int print_skbedit(const struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	struct rtattr *tb[TCA_SKBEDIT_MAX + 1];
 
diff --git a/tc/m_skbmod.c b/tc/m_skbmod.c
index b1c8d00dfe47..c467f3f005ac 100644
--- a/tc/m_skbmod.c
+++ b/tc/m_skbmod.c
@@ -40,7 +40,7 @@  static void skbmod_usage(void)
 	exit(-1);
 }
 
-static int parse_skbmod(struct action_util *a, int *argc_p, char ***argv_p,
+static int parse_skbmod(const struct action_util *a, int *argc_p, char ***argv_p,
 			int tca_id, struct nlmsghdr *n)
 {
 	int argc = *argc_p;
@@ -156,7 +156,7 @@  static int parse_skbmod(struct action_util *a, int *argc_p, char ***argv_p,
 	return 0;
 }
 
-static int print_skbmod(struct action_util *au, FILE *f, struct rtattr *arg)
+static int print_skbmod(const struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	struct tc_skbmod *p;
 	struct rtattr *tb[TCA_SKBMOD_MAX + 1];
diff --git a/tc/m_tunnel_key.c b/tc/m_tunnel_key.c
index ff699cc8917d..2032a72194cd 100644
--- a/tc/m_tunnel_key.c
+++ b/tc/m_tunnel_key.c
@@ -311,7 +311,7 @@  static int tunnel_key_parse_tos_ttl(char *str, int type, struct nlmsghdr *n)
 	return 0;
 }
 
-static int parse_tunnel_key(struct action_util *a, int *argc_p, char ***argv_p,
+static int parse_tunnel_key(const struct action_util *a, int *argc_p, char ***argv_p,
 			    int tca_id, struct nlmsghdr *n)
 {
 	struct tc_tunnel_key parm = {};
@@ -688,7 +688,7 @@  static void tunnel_key_print_tos_ttl(FILE *f, char *name,
 	}
 }
 
-static int print_tunnel_key(struct action_util *au, FILE *f, struct rtattr *arg)
+static int print_tunnel_key(const struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	struct rtattr *tb[TCA_TUNNEL_KEY_MAX + 1];
 	struct tc_tunnel_key *parm;
diff --git a/tc/m_vlan.c b/tc/m_vlan.c
index c1dc8b428e61..40d62fa0f282 100644
--- a/tc/m_vlan.c
+++ b/tc/m_vlan.c
@@ -56,7 +56,7 @@  static void unexpected(const char *arg)
 	explain();
 }
 
-static int parse_vlan(struct action_util *a, int *argc_p, char ***argv_p,
+static int parse_vlan(const struct action_util *a, int *argc_p, char ***argv_p,
 		      int tca_id, struct nlmsghdr *n)
 {
 	int argc = *argc_p;
@@ -227,7 +227,7 @@  static int parse_vlan(struct action_util *a, int *argc_p, char ***argv_p,
 	return 0;
 }
 
-static int print_vlan(struct action_util *au, FILE *f, struct rtattr *arg)
+static int print_vlan(const struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	SPRINT_BUF(b1);
 	struct rtattr *tb[TCA_VLAN_MAX + 1];
diff --git a/tc/tc_util.h b/tc/tc_util.h
index 51f9effc27b1..5ae3fafd2dd2 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -58,10 +58,10 @@  struct filter_util {
 struct action_util {
 	struct action_util *next;
 	char id[FILTER_NAMESZ];
-	int (*parse_aopt)(struct action_util *a, int *argc,
+	int (*parse_aopt)(const struct action_util *a, int *argc,
 			  char ***argv, int code, struct nlmsghdr *n);
-	int (*print_aopt)(struct action_util *au, FILE *f, struct rtattr *opt);
-	int (*print_xstats)(struct action_util *au,
+	int (*print_aopt)(const struct action_util *au, FILE *f, struct rtattr *opt);
+	int (*print_xstats)(const struct action_util *au,
 			    FILE *f, struct rtattr *xstats);
 };
 
@@ -112,7 +112,7 @@  int parse_action_control_slash(int *argc_p, char ***argv_p,
 			       int *result1_p, int *result2_p, bool allow_num);
 void print_action_control(FILE *f, const char *prefix,
 			  int action, const char *suffix);
-int police_print_xstats(struct action_util *a, FILE *f, struct rtattr *tb);
+int police_print_xstats(const struct action_util *a, FILE *f, struct rtattr *tb);
 int tc_print_action(FILE *f, const struct rtattr *tb, unsigned short tot_acts);
 int parse_action(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n);
 void print_tm(FILE *f, const struct tcf_t *tm);