diff mbox series

[iproute2,2/4] tc: make filter_util args const

Message ID 20240312221422.81253-3-stephen@networkplumber.org (mailing list archive)
State Accepted
Commit fa740c21b441e3f3828abe859444119dce2c9cab
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 filter_util should not be modifying underlying
qdisc operations structure.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/f_basic.c    | 4 ++--
 tc/f_bpf.c      | 4 ++--
 tc/f_cgroup.c   | 4 ++--
 tc/f_flow.c     | 4 ++--
 tc/f_flower.c   | 4 ++--
 tc/f_fw.c       | 4 ++--
 tc/f_matchall.c | 4 ++--
 tc/f_route.c    | 4 ++--
 tc/f_u32.c      | 4 ++--
 tc/tc.c         | 6 +++---
 tc/tc_filter.c  | 6 +++---
 tc/tc_util.h    | 6 +++---
 12 files changed, 27 insertions(+), 27 deletions(-)
diff mbox series

Patch

diff --git a/tc/f_basic.c b/tc/f_basic.c
index 1ceb15d404f3..a1db5ba5dbc0 100644
--- a/tc/f_basic.c
+++ b/tc/f_basic.c
@@ -32,7 +32,7 @@  static void explain(void)
 		"NOTE: CLASSID is parsed as hexadecimal input.\n");
 }
 
-static int basic_parse_opt(struct filter_util *qu, char *handle,
+static int basic_parse_opt(const struct filter_util *qu, char *handle,
 			   int argc, char **argv, struct nlmsghdr *n)
 {
 	struct tcmsg *t = NLMSG_DATA(n);
@@ -103,7 +103,7 @@  static int basic_parse_opt(struct filter_util *qu, char *handle,
 	return 0;
 }
 
-static int basic_print_opt(struct filter_util *qu, FILE *f,
+static int basic_print_opt(const struct filter_util *qu, FILE *f,
 			   struct rtattr *opt, __u32 handle)
 {
 	struct rtattr *tb[TCA_BASIC_MAX+1];
diff --git a/tc/f_bpf.c b/tc/f_bpf.c
index a6d4875fc057..3e53c56ab7c3 100644
--- a/tc/f_bpf.c
+++ b/tc/f_bpf.c
@@ -71,7 +71,7 @@  static const struct bpf_cfg_ops bpf_cb_ops = {
 	.ebpf_cb = bpf_ebpf_cb,
 };
 
-static int bpf_parse_opt(struct filter_util *qu, char *handle,
+static int bpf_parse_opt(const struct filter_util *qu, char *handle,
 			 int argc, char **argv, struct nlmsghdr *n)
 {
 	const char *bpf_obj = NULL, *bpf_uds_name = NULL;
@@ -187,7 +187,7 @@  opt_bpf:
 	return ret;
 }
 
-static int bpf_print_opt(struct filter_util *qu, FILE *f,
+static int bpf_print_opt(const struct filter_util *qu, FILE *f,
 			 struct rtattr *opt, __u32 handle)
 {
 	struct rtattr *tb[TCA_BPF_MAX + 1];
diff --git a/tc/f_cgroup.c b/tc/f_cgroup.c
index 291d6e7ebe33..4aba4bacaf09 100644
--- a/tc/f_cgroup.c
+++ b/tc/f_cgroup.c
@@ -17,7 +17,7 @@  static void explain(void)
 	fprintf(stderr, "                  [ action ACTION_SPEC ]\n");
 }
 
-static int cgroup_parse_opt(struct filter_util *qu, char *handle,
+static int cgroup_parse_opt(const struct filter_util *qu, char *handle,
 			   int argc, char **argv, struct nlmsghdr *n)
 {
 	struct tcmsg *t = NLMSG_DATA(n);
@@ -75,7 +75,7 @@  static int cgroup_parse_opt(struct filter_util *qu, char *handle,
 	return 0;
 }
 
-static int cgroup_print_opt(struct filter_util *qu, FILE *f,
+static int cgroup_print_opt(const struct filter_util *qu, FILE *f,
 			   struct rtattr *opt, __u32 handle)
 {
 	struct rtattr *tb[TCA_CGROUP_MAX+1];
diff --git a/tc/f_flow.c b/tc/f_flow.c
index 4a29af22e99d..07ecb84cf905 100644
--- a/tc/f_flow.c
+++ b/tc/f_flow.c
@@ -126,7 +126,7 @@  out:
 	return 0;
 }
 
-static int flow_parse_opt(struct filter_util *fu, char *handle,
+static int flow_parse_opt(const struct filter_util *fu, char *handle,
 			  int argc, char **argv, struct nlmsghdr *n)
 {
 	struct tcmsg *t = NLMSG_DATA(n);
@@ -273,7 +273,7 @@  static const char *flow_mode2str(__u32 mode)
 	}
 }
 
-static int flow_print_opt(struct filter_util *fu, FILE *f, struct rtattr *opt,
+static int flow_print_opt(const struct filter_util *fu, FILE *f, struct rtattr *opt,
 			  __u32 handle)
 {
 	struct rtattr *tb[TCA_FLOW_MAX+1];
diff --git a/tc/f_flower.c b/tc/f_flower.c
index 53188f1cd87a..cfcd7b2f6ddf 100644
--- a/tc/f_flower.c
+++ b/tc/f_flower.c
@@ -1535,7 +1535,7 @@  static int flower_parse_cfm(int *argc_p, char ***argv_p, __be16 eth_type,
 	return 0;
 }
 
-static int flower_parse_opt(struct filter_util *qu, char *handle,
+static int flower_parse_opt(const struct filter_util *qu, char *handle,
 			    int argc, char **argv, struct nlmsghdr *n)
 {
 	int ret;
@@ -2882,7 +2882,7 @@  static void flower_print_cfm(struct rtattr *attr)
 	close_json_object();
 }
 
-static int flower_print_opt(struct filter_util *qu, FILE *f,
+static int flower_print_opt(const struct filter_util *qu, FILE *f,
 			    struct rtattr *opt, __u32 handle)
 {
 	struct rtattr *tb[TCA_FLOWER_MAX + 1];
diff --git a/tc/f_fw.c b/tc/f_fw.c
index 5e72e526b175..cf4abe122d8c 100644
--- a/tc/f_fw.c
+++ b/tc/f_fw.c
@@ -29,7 +29,7 @@  static void explain(void)
 		"		FWMASK is 0xffffffff by default.\n");
 }
 
-static int fw_parse_opt(struct filter_util *qu, char *handle, int argc, char **argv, struct nlmsghdr *n)
+static int fw_parse_opt(const struct filter_util *qu, char *handle, int argc, char **argv, struct nlmsghdr *n)
 {
 	struct tcmsg *t = NLMSG_DATA(n);
 	struct rtattr *tail;
@@ -112,7 +112,7 @@  static int fw_parse_opt(struct filter_util *qu, char *handle, int argc, char **a
 	return 0;
 }
 
-static int fw_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 handle)
+static int fw_print_opt(const struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 handle)
 {
 	struct rtattr *tb[TCA_FW_MAX+1];
 
diff --git a/tc/f_matchall.c b/tc/f_matchall.c
index 38b68d7e2450..e595ac38d6f9 100644
--- a/tc/f_matchall.c
+++ b/tc/f_matchall.c
@@ -31,7 +31,7 @@  static void explain(void)
 		"NOTE: CLASSID is parsed as hexadecimal input.\n");
 }
 
-static int matchall_parse_opt(struct filter_util *qu, char *handle,
+static int matchall_parse_opt(const struct filter_util *qu, char *handle,
 			   int argc, char **argv, struct nlmsghdr *n)
 {
 	struct tcmsg *t = NLMSG_DATA(n);
@@ -107,7 +107,7 @@  static int matchall_parse_opt(struct filter_util *qu, char *handle,
 	return 0;
 }
 
-static int matchall_print_opt(struct filter_util *qu, FILE *f,
+static int matchall_print_opt(const struct filter_util *qu, FILE *f,
 			   struct rtattr *opt, __u32 handle)
 {
 	struct rtattr *tb[TCA_MATCHALL_MAX+1];
diff --git a/tc/f_route.c b/tc/f_route.c
index ca8a8dddc2aa..87d865b7182b 100644
--- a/tc/f_route.c
+++ b/tc/f_route.c
@@ -30,7 +30,7 @@  static void explain(void)
 		"NOTE: CLASSID is parsed as hexadecimal input.\n");
 }
 
-static int route_parse_opt(struct filter_util *qu, char *handle, int argc, char **argv, struct nlmsghdr *n)
+static int route_parse_opt(const struct filter_util *qu, char *handle, int argc, char **argv, struct nlmsghdr *n)
 {
 	struct tcmsg *t = NLMSG_DATA(n);
 	struct rtattr *tail;
@@ -134,7 +134,7 @@  static int route_parse_opt(struct filter_util *qu, char *handle, int argc, char
 	return 0;
 }
 
-static int route_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 handle)
+static int route_print_opt(const struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 handle)
 {
 	struct rtattr *tb[TCA_ROUTE4_MAX+1];
 
diff --git a/tc/f_u32.c b/tc/f_u32.c
index 59aa4e3a2b50..a06996363b07 100644
--- a/tc/f_u32.c
+++ b/tc/f_u32.c
@@ -1018,7 +1018,7 @@  static __u32 u32_hash_fold(struct tc_u32_key *key)
 	return ntohl(key->val & key->mask) >> fshift;
 }
 
-static int u32_parse_opt(struct filter_util *qu, char *handle,
+static int u32_parse_opt(const struct filter_util *qu, char *handle,
 			 int argc, char **argv, struct nlmsghdr *n)
 {
 	struct {
@@ -1232,7 +1232,7 @@  static int u32_parse_opt(struct filter_util *qu, char *handle,
 	return 0;
 }
 
-static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
+static int u32_print_opt(const struct filter_util *qu, FILE *f, struct rtattr *opt,
 			 __u32 handle)
 {
 	struct rtattr *tb[TCA_U32_MAX + 1];
diff --git a/tc/tc.c b/tc/tc.c
index 5191b4bd8cde..7edff7e39166 100644
--- a/tc/tc.c
+++ b/tc/tc.c
@@ -69,7 +69,7 @@  static int parse_noqopt(const struct qdisc_util *qu, int argc, char **argv,
 	return 0;
 }
 
-static int print_nofopt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 fhandle)
+static int print_nofopt(const struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 fhandle)
 {
 	if (opt && RTA_PAYLOAD(opt))
 		fprintf(f, "fh %08x [Unknown filter, optlen=%u] ",
@@ -79,7 +79,7 @@  static int print_nofopt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u
 	return 0;
 }
 
-static int parse_nofopt(struct filter_util *qu, char *fhandle,
+static int parse_nofopt(const struct filter_util *qu, char *fhandle,
 			int argc, char **argv, struct nlmsghdr *n)
 {
 	__u32 handle;
@@ -146,7 +146,7 @@  noexist:
 }
 
 
-struct filter_util *get_filter_kind(const char *str)
+const struct filter_util *get_filter_kind(const char *str)
 {
 	void *dlh;
 	char buf[256];
diff --git a/tc/tc_filter.c b/tc/tc_filter.c
index 54790ddc6cdf..7db850bda11a 100644
--- a/tc/tc_filter.c
+++ b/tc/tc_filter.c
@@ -65,7 +65,7 @@  static int tc_filter_modify(int cmd, unsigned int flags, int argc, char **argv)
 		.n.nlmsg_type = cmd,
 		.t.tcm_family = AF_UNSPEC,
 	};
-	struct filter_util *q = NULL;
+	const struct filter_util *q = NULL;
 	__u32 prio = 0;
 	__u32 protocol = 0;
 	int protocol_set = 0;
@@ -250,7 +250,7 @@  int print_filter(struct nlmsghdr *n, void *arg)
 	struct tcmsg *t = NLMSG_DATA(n);
 	int len = n->nlmsg_len;
 	struct rtattr *tb[TCA_MAX+1];
-	struct filter_util *q;
+	const struct filter_util *q;
 	char abuf[256];
 
 	if (n->nlmsg_type != RTM_NEWTFILTER &&
@@ -398,7 +398,7 @@  static int tc_filter_get(int cmd, unsigned int flags, int argc, char **argv)
 		.t.tcm_family = AF_UNSPEC,
 	};
 	struct nlmsghdr *answer;
-	struct filter_util *q = NULL;
+	const struct filter_util *q = NULL;
 	__u32 prio = 0;
 	__u32 protocol = 0;
 	int protocol_set = 0;
diff --git a/tc/tc_util.h b/tc/tc_util.h
index bcd661ea4626..51f9effc27b1 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -49,9 +49,9 @@  extern __u16 f_proto;
 struct filter_util {
 	struct filter_util *next;
 	char id[FILTER_NAMESZ];
-	int (*parse_fopt)(struct filter_util *qu, char *fhandle,
+	int (*parse_fopt)(const struct filter_util *qu, char *fhandle,
 			  int argc, char **argv, struct nlmsghdr *n);
-	int (*print_fopt)(struct filter_util *qu,
+	int (*print_fopt)(const struct filter_util *qu,
 			  FILE *f, struct rtattr *opt, __u32 fhandle);
 };
 
@@ -74,7 +74,7 @@  struct exec_util {
 const char *get_tc_lib(void);
 
 const struct qdisc_util *get_qdisc_kind(const char *str);
-struct filter_util *get_filter_kind(const char *str);
+const struct filter_util *get_filter_kind(const char *str);
 
 int get_qdisc_handle(__u32 *h, const char *str);
 int get_percent_rate(unsigned int *rate, const char *str, const char *dev);