mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2026-01-04 20:43:01 +00:00
tc: replace magic constant 16 with #define
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>
This commit is contained in:
parent
a03c704b2f
commit
b317557f58
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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) {
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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) {
|
||||
|
||||
11
tc/tc_util.h
11
tc/tc_util.h
@ -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);
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user