]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc: make filter_util args const
authorStephen Hemminger <stephen@networkplumber.org>
Mon, 11 Mar 2024 23:10:24 +0000 (16:10 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 12 Mar 2024 22:11:43 +0000 (15:11 -0700)
The callbacks in filter_util should not be modifying underlying
qdisc operations structure.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
12 files changed:
tc/f_basic.c
tc/f_bpf.c
tc/f_cgroup.c
tc/f_flow.c
tc/f_flower.c
tc/f_fw.c
tc/f_matchall.c
tc/f_route.c
tc/f_u32.c
tc/tc.c
tc/tc_filter.c
tc/tc_util.h

index 1ceb15d404f32feda7bc0193521b10e8a469f20f..a1db5ba5dbc0f68b29541e3d30711cf2f4c55f77 100644 (file)
@@ -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];
index a6d4875fc05712f807480f555e7c8508ab724374..3e53c56ab7c3c6c95543377ed7ddb5bbe571c4c6 100644 (file)
@@ -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];
index 291d6e7ebe3347218c854c81a57a06521da460ee..4aba4bacaf0965c8df9f2d32a0d65319cc10de45 100644 (file)
@@ -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];
index 4a29af22e99d4d598b4ddea7f5eafdb7bda9e362..07ecb84cf9052b3421d0ae4dc83073da81205806 100644 (file)
@@ -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];
index 53188f1cd87a64450954c8bb4f00f0ee065920f2..cfcd7b2f6ddf84b4e5077994bade6d98f3ec3d79 100644 (file)
@@ -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];
index 5e72e526b175373f15274bacf4cfc9c706ba0ee3..cf4abe122d8ce61122c5dfb1229424ebe94a8215 100644 (file)
--- 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];
 
index 38b68d7e24503f2c35a49071eee4bf9b75dcc489..e595ac38d6f9446aa6c80f9d596ec804497fb985 100644 (file)
@@ -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];
index ca8a8dddc2aa05e5dd7436c13ef0272f042693ab..87d865b7182b039b273cee969ec88e45073e04ee 100644 (file)
@@ -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];
 
index 59aa4e3a2b507a2c3796535893ec8ba7268c40e8..a06996363b078717efacb9b3507be5a2f17d92ea 100644 (file)
@@ -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 5191b4bd8cded04011b03f04b39577d7b643b150..7edff7e391664011e788beff24bbda177e3c0695 100644 (file)
--- 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];
index 54790ddc6cdfba3c9a96911b66a9567da9bb4bf7..7db850bda11a3408ec66b457c9fc590f3a734f65 100644 (file)
@@ -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;
index bcd661ea4626727feaad53f98137cdf470fd5f95..51f9effc27b18580c1a856302e4afa08eca26c0d 100644 (file)
@@ -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);