]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
tc: replace magic constant 16 with #define
authorStephen Hemminger <stephen@networkplumber.org>
Fri, 24 Nov 2017 19:18:31 +0000 (11:18 -0800)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 24 Nov 2017 19:19:18 +0000 (11:19 -0800)
For places where tc is expecting device name use IFNAMSIZ.
For others where it is a filter name, introduce a new constant.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
tc/m_action.c
tc/m_ipt.c
tc/m_mirred.c
tc/m_pedit.c
tc/m_xt.c
tc/m_xt_old.c
tc/tc_class.c
tc/tc_exec.c
tc/tc_filter.c
tc/tc_qdisc.c
tc/tc_util.h

index 0dce97f08ba694dcf82d9312107856bdbf441c43..85f9e27bf89b97fb10111cfb055592dc615bbd52 100644 (file)
@@ -154,7 +154,7 @@ int parse_action(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n)
        int argc = *argc_p;
        char **argv = *argv_p;
        struct rtattr *tail, *tail2;
-       char k[16];
+       char k[FILTER_NAMESZ];
        int act_ck_len = 0;
        int ok = 0;
        int eap = 0; /* expect action parameters */
@@ -431,7 +431,7 @@ int print_action(const struct sockaddr_nl *who,
 
 static int tc_action_gd(int cmd, unsigned int flags, int *argc_p, char ***argv_p)
 {
-       char k[16];
+       char k[FILTER_NAMESZ];
        struct action_util *a = NULL;
        int argc = *argc_p;
        char **argv = *argv_p;
@@ -581,7 +581,7 @@ static int tc_act_list_or_flush(int *argc_p, char ***argv_p, int event)
        char **argv = *argv_p;
        __u32 msec_since = 0;
        int argc = *argc_p;
-       char k[16];
+       char k[FILTER_NAMESZ];
        struct {
                struct nlmsghdr         n;
                struct tcamsg           t;
index 942b4f23be830fc27b1da06d0306c5f98fc23b84..1c3c240f6fc3ab4c679470a5e6655cf263e232b6 100644 (file)
@@ -286,7 +286,7 @@ static int parse_ipt(struct action_util *a, int *argc_p,
        int rargc = *argc_p;
        char **argv = *argv_p;
        int argc = 0, iargc = 0;
-       char k[16];
+       char k[FILTER_NAMESZ];
        int size = 0;
        int iok = 0, ok = 0;
        __u32 hook = 0, index = 0;
index d0b7a46ab28a30c87c00882665bc80a2c8d49e7b..33c915d6804217f71c9ce7f5bc1209108c2bd501 100644 (file)
@@ -70,7 +70,7 @@ parse_direction(struct action_util *a, int *argc_p, char ***argv_p,
        int ok = 0, iok = 0, mirror = 0, redir = 0, ingress = 0, egress = 0;
        struct tc_mirred p = {};
        struct rtattr *tail;
-       char d[16] = {};
+       char d[IFNAMSIZ] = {};
 
        while (argc > 0) {
 
index a6da953658a3579ba1a83a66db7070b257dc7fb2..26549eeea8995a001d51a02826dcbf63a0068f9e 100644 (file)
@@ -524,7 +524,7 @@ static int parse_munge(int *argc_p, char ***argv_p, struct m_pedit_sel *sel)
                res = parse_offset(&argc, &argv, sel, &tkey);
                goto done;
        } else {
-               char k[16];
+               char k[FILTER_NAMESZ];
                struct m_pedit_util *p = NULL;
 
                strncpy(k, *argv, sizeof(k) - 1);
index 0baea33c91e6835d3dbbc0c0c169d1e8bbb4056f..a1137be9614f1f28636882292433f0bb16fc45a1 100644 (file)
--- a/tc/m_xt.c
+++ b/tc/m_xt.c
@@ -154,7 +154,7 @@ static int parse_ipt(struct action_util *a, int *argc_p,
        int c;
        char **argv = *argv_p;
        int argc;
-       char k[16];
+       char k[FILTER_NAMESZ];
        int size = 0;
        int iok = 0, ok = 0;
        __u32 hook = 0, index = 0;
index 4e56e26730a162265264f7c4160db3a802fad125..21d90877357c595eaa07048d486923bb5febf385 100644 (file)
@@ -213,7 +213,7 @@ static int parse_ipt(struct action_util *a, int *argc_p,
        int rargc = *argc_p;
        char **argv = *argv_p;
        int argc = 0, iargc = 0;
-       char k[16];
+       char k[FILTER_NAMESZ];
        int size = 0;
        int iok = 0, ok = 0;
        __u32 hook = 0, index = 0;
index c4a6a250545c2636abea3948032db40550f0fa94..507864ad8ac01240f5d6dda7e26470a4532aa9e8 100644 (file)
@@ -67,8 +67,8 @@ static int tc_class_modify(int cmd, unsigned int flags, int argc, char **argv)
        };
        struct qdisc_util *q = NULL;
        struct tc_estimator est = {};
-       char  d[16] = {};
-       char  k[16] = {};
+       char  d[IFNAMSIZ] = {};
+       char  k[FILTER_NAMESZ] = {};
 
        while (argc > 0) {
                if (strcmp(*argv, "dev") == 0) {
@@ -388,7 +388,7 @@ int print_class(const struct sockaddr_nl *who,
 static int tc_class_list(int argc, char **argv)
 {
        struct tcmsg t = { .tcm_family = AF_UNSPEC };
-       char d[16] = {};
+       char d[IFNAMSIZ] = {};
        char buf[1024] = {0};
 
        filter_qdisc = 0;
index d23a825dbddf92c9364f13ccc0935bdf78aec825..0151af7be23b9f5382a6d8d5c9bfd5042225dfec 100644 (file)
@@ -84,7 +84,7 @@ noexist:
 int do_exec(int argc, char **argv)
 {
        struct exec_util *eu;
-       char kind[16] = {};
+       char kind[FILTER_NAMESZ] = {};
 
        if (argc < 1) {
                fprintf(stderr, "No command given, try \"tc exec help\".\n");
index d0c967a9633a794cde2c551cec2f7dd0451956e4..276a66cb0b4d47751f15a980f607cec5ba85a00e 100644 (file)
@@ -61,8 +61,8 @@ static int tc_filter_modify(int cmd, unsigned int flags, int argc, char **argv)
        __u32 chain_index;
        int chain_index_set = 0;
        char *fhandle = NULL;
-       char  d[16] = {};
-       char  k[16] = {};
+       char  d[IFNAMSIZ] = {};
+       char  k[FILTER_NAMESZ] = {};
        struct tc_estimator est = {};
 
        if (cmd == RTM_NEWTFILTER && flags & NLM_F_CREATE)
@@ -339,8 +339,8 @@ static int tc_filter_get(int cmd, unsigned int flags, int argc, char **argv)
        int chain_index_set = 0;
        __u32 parent_handle = 0;
        char *fhandle = NULL;
-       char  d[16] = {};
-       char  k[16] = {};
+       char  d[IFNAMSIZ] = {};
+       char  k[FILTER_NAMESZ] = {};
 
        while (argc > 0) {
                if (strcmp(*argv, "dev") == 0) {
@@ -507,7 +507,7 @@ static int tc_filter_list(int argc, char **argv)
                .t.tcm_parent = TC_H_UNSPEC,
                .t.tcm_family = AF_UNSPEC,
        };
-       char d[16] = {};
+       char d[IFNAMSIZ] = {};
        __u32 prio = 0;
        __u32 protocol = 0;
        __u32 chain_index;
index fcb75f29128e1a5a74fe5e1be70fec8a79b37b6a..56034b59921373cf7167b39000fa07741c8550f8 100644 (file)
@@ -49,8 +49,8 @@ static int tc_qdisc_modify(int cmd, unsigned int flags, int argc, char **argv)
                struct tc_sizespec      szopts;
                __u16                   *data;
        } stab = {};
-       char  d[16] = {};
-       char  k[16] = {};
+       char  d[IFNAMSIZ] = {};
+       char  k[FILTER_NAMESZ] = {};
        struct {
                struct nlmsghdr n;
                struct tcmsg            t;
@@ -300,7 +300,7 @@ int print_qdisc(const struct sockaddr_nl *who,
 static int tc_qdisc_list(int argc, char **argv)
 {
        struct tcmsg t = { .tcm_family = AF_UNSPEC };
-       char d[16] = {};
+       char d[IFNAMSIZ] = {};
        bool dump_invisible = false;
 
        while (argc > 0) {
index 583a21a828ded9f950f52d264109d40b9ce76c21..3d3d4f1d8de4a8783619396177a2a891e738243f 100644 (file)
@@ -3,9 +3,12 @@
 
 #define MAX_MSG 16384
 #include <limits.h>
+#include <linux/if.h>
+
 #include <linux/pkt_sched.h>
 #include <linux/pkt_cls.h>
 #include <linux/gen_stats.h>
+
 #include "tc_core.h"
 
 /* This is the deprecated multiqueue interface */
@@ -20,6 +23,8 @@ enum
 #define TCA_PRIO_MAX    (__TCA_PRIO_MAX - 1)
 #endif
 
+#define FILTER_NAMESZ  16
+
 struct qdisc_util {
        struct  qdisc_util *next;
        const char *id;
@@ -38,7 +43,7 @@ struct qdisc_util {
 extern __u16 f_proto;
 struct filter_util {
        struct filter_util *next;
-       char id[16];
+       char id[FILTER_NAMESZ];
        int (*parse_fopt)(struct filter_util *qu, char *fhandle,
                          int argc, char **argv, struct nlmsghdr *n);
        int (*print_fopt)(struct filter_util *qu,
@@ -47,7 +52,7 @@ struct filter_util {
 
 struct action_util {
        struct action_util *next;
-       char id[16];
+       char id[FILTER_NAMESZ];
        int (*parse_aopt)(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);
@@ -57,7 +62,7 @@ struct action_util {
 
 struct exec_util {
        struct exec_util *next;
-       char id[16];
+       char id[FILTER_NAMESZ];
        int (*parse_eopt)(struct exec_util *eu, int argc, char **argv);
 };