tc: code cleanup
Use checkpatch to fix whitespace and other style issues.
This commit is contained in:
parent
4733b18a5e
commit
32a121cba2
|
|
@ -52,8 +52,8 @@ union ip_set_name_index {
|
||||||
|
|
||||||
#define IP_SET_OP_GET_BYNAME 0x00000006 /* Get set index by name */
|
#define IP_SET_OP_GET_BYNAME 0x00000006 /* Get set index by name */
|
||||||
struct ip_set_req_get_set {
|
struct ip_set_req_get_set {
|
||||||
unsigned op;
|
unsigned int op;
|
||||||
unsigned version;
|
unsigned int version;
|
||||||
union ip_set_name_index set;
|
union ip_set_name_index set;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -62,14 +62,14 @@ struct ip_set_req_get_set {
|
||||||
|
|
||||||
#define IP_SET_OP_VERSION 0x00000100 /* Ask kernel version */
|
#define IP_SET_OP_VERSION 0x00000100 /* Ask kernel version */
|
||||||
struct ip_set_req_version {
|
struct ip_set_req_version {
|
||||||
unsigned op;
|
unsigned int op;
|
||||||
unsigned version;
|
unsigned int version;
|
||||||
};
|
};
|
||||||
#endif /* IPSET_INVALID_ID */
|
#endif /* IPSET_INVALID_ID */
|
||||||
|
|
||||||
extern struct ematch_util ipset_ematch_util;
|
extern struct ematch_util ipset_ematch_util;
|
||||||
|
|
||||||
static int get_version(unsigned *version)
|
static int get_version(unsigned int *version)
|
||||||
{
|
{
|
||||||
int res, sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
|
int res, sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
|
||||||
struct ip_set_req_version req_version;
|
struct ip_set_req_version req_version;
|
||||||
|
|
@ -95,6 +95,7 @@ static int do_getsockopt(struct ip_set_req_get_set *req)
|
||||||
{
|
{
|
||||||
int sockfd, res;
|
int sockfd, res;
|
||||||
socklen_t size = sizeof(struct ip_set_req_get_set);
|
socklen_t size = sizeof(struct ip_set_req_get_set);
|
||||||
|
|
||||||
sockfd = get_version(&req->version);
|
sockfd = get_version(&req->version);
|
||||||
if (sockfd < 0)
|
if (sockfd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -107,8 +108,7 @@ static int do_getsockopt(struct ip_set_req_get_set *req)
|
||||||
|
|
||||||
if (size != sizeof(struct ip_set_req_get_set)) {
|
if (size != sizeof(struct ip_set_req_get_set)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Incorrect return size from kernel during ipset lookup, "
|
"Incorrect return size from kernel during ipset lookup, (want %zu, got %zu)\n",
|
||||||
"(want %zu, got %zu)\n",
|
|
||||||
sizeof(struct ip_set_req_get_set), (size_t)size);
|
sizeof(struct ip_set_req_get_set), (size_t)size);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ static struct meta_entry * lookup_meta_entry(struct bstr *kind)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < (sizeof(meta_table)/sizeof(meta_table[0])); i++)
|
for (i = 0; i < ARRAY_SIZE(meta_table); i++)
|
||||||
if (!bstrcmp(kind, meta_table[i].kind) &&
|
if (!bstrcmp(kind, meta_table[i].kind) &&
|
||||||
meta_table[i].id != 0)
|
meta_table[i].id != 0)
|
||||||
return &meta_table[i];
|
return &meta_table[i];
|
||||||
|
|
@ -138,7 +138,7 @@ static struct meta_entry * lookup_meta_entry_byid(int id)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < (sizeof(meta_table)/sizeof(meta_table[0])); i++)
|
for (i = 0; i < ARRAY_SIZE(meta_table); i++)
|
||||||
if (meta_table[i].id == id)
|
if (meta_table[i].id == id)
|
||||||
return &meta_table[i];
|
return &meta_table[i];
|
||||||
|
|
||||||
|
|
@ -159,6 +159,7 @@ static inline void dump_value(struct nlmsghdr *n, int tlv, unsigned long val,
|
||||||
case TCF_META_TYPE_VAR:
|
case TCF_META_TYPE_VAR:
|
||||||
if (TCF_META_ID(hdr->kind) == TCF_META_ID_VALUE) {
|
if (TCF_META_ID(hdr->kind) == TCF_META_ID_VALUE) {
|
||||||
struct bstr *a = (struct bstr *) val;
|
struct bstr *a = (struct bstr *) val;
|
||||||
|
|
||||||
addattr_l(n, MAX_MSG, tlv, a->data, a->len);
|
addattr_l(n, MAX_MSG, tlv, a->data, a->len);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -192,7 +193,7 @@ static void list_meta_ids(FILE *fd)
|
||||||
" ID Type Description\n" \
|
" ID Type Description\n" \
|
||||||
"--------------------------------------------------------");
|
"--------------------------------------------------------");
|
||||||
|
|
||||||
for (i = 0; i < (sizeof(meta_table)/sizeof(meta_table[0])); i++) {
|
for (i = 0; i < ARRAY_SIZE(meta_table); i++) {
|
||||||
if (meta_table[i].id == TCF_META_ID_SECTION) {
|
if (meta_table[i].id == TCF_META_ID_SECTION) {
|
||||||
fprintf(fd, "\n%s:\n", meta_table[i].kind);
|
fprintf(fd, "\n%s:\n", meta_table[i].kind);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ static int u32_parse_eopt(struct nlmsghdr *n, struct tcf_ematch_hdr *hdr,
|
||||||
nh_len = strlen("nexthdr+");
|
nh_len = strlen("nexthdr+");
|
||||||
if (a->len > nh_len && !memcmp(a->data, "nexthdr+", nh_len)) {
|
if (a->len > nh_len && !memcmp(a->data, "nexthdr+", nh_len)) {
|
||||||
char buf[a->len - nh_len + 1];
|
char buf[a->len - nh_len + 1];
|
||||||
|
|
||||||
offmask = -1;
|
offmask = -1;
|
||||||
memcpy(buf, a->data + nh_len, a->len - nh_len);
|
memcpy(buf, a->data + nh_len, a->len - nh_len);
|
||||||
offset = strtoul(buf, NULL, 0);
|
offset = strtoul(buf, NULL, 0);
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,8 @@ static int basic_parse_opt(struct filter_util *qu, char *handle,
|
||||||
continue;
|
continue;
|
||||||
} else if (matches(*argv, "classid") == 0 ||
|
} else if (matches(*argv, "classid") == 0 ||
|
||||||
strcmp(*argv, "flowid") == 0) {
|
strcmp(*argv, "flowid") == 0) {
|
||||||
unsigned handle;
|
unsigned int handle;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_tc_classid(&handle, *argv)) {
|
if (get_tc_classid(&handle, *argv)) {
|
||||||
fprintf(stderr, "Illegal \"classid\"\n");
|
fprintf(stderr, "Illegal \"classid\"\n");
|
||||||
|
|
|
||||||
|
|
@ -270,6 +270,7 @@ static int flow_print_opt(struct filter_util *fu, FILE *f, struct rtattr *opt,
|
||||||
__u32 handle)
|
__u32 handle)
|
||||||
{
|
{
|
||||||
struct rtattr *tb[TCA_FLOW_MAX+1];
|
struct rtattr *tb[TCA_FLOW_MAX+1];
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
__u32 mask = ~0, val = 0;
|
__u32 mask = ~0, val = 0;
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ static int flower_parse_opt(struct filter_util *qu, char *handle,
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
if (matches(*argv, "classid") == 0 ||
|
if (matches(*argv, "classid") == 0 ||
|
||||||
matches(*argv, "flowid") == 0) {
|
matches(*argv, "flowid") == 0) {
|
||||||
unsigned handle;
|
unsigned int handle;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
ret = get_tc_classid(&handle, *argv);
|
ret = get_tc_classid(&handle, *argv);
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ static int fw_parse_opt(struct filter_util *qu, char *handle, int argc, char **a
|
||||||
|
|
||||||
if (handle) {
|
if (handle) {
|
||||||
char *slash;
|
char *slash;
|
||||||
|
|
||||||
if ((slash = strchr(handle, '/')) != NULL)
|
if ((slash = strchr(handle, '/')) != NULL)
|
||||||
*slash = '\0';
|
*slash = '\0';
|
||||||
if (get_u32(&t->tcm_handle, handle, 0)) {
|
if (get_u32(&t->tcm_handle, handle, 0)) {
|
||||||
|
|
@ -70,7 +71,8 @@ static int fw_parse_opt(struct filter_util *qu, char *handle, int argc, char **a
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
if (matches(*argv, "classid") == 0 ||
|
if (matches(*argv, "classid") == 0 ||
|
||||||
matches(*argv, "flowid") == 0) {
|
matches(*argv, "flowid") == 0) {
|
||||||
unsigned handle;
|
unsigned int handle;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_tc_classid(&handle, *argv)) {
|
if (get_tc_classid(&handle, *argv)) {
|
||||||
fprintf(stderr, "Illegal \"classid\"\n");
|
fprintf(stderr, "Illegal \"classid\"\n");
|
||||||
|
|
@ -93,6 +95,7 @@ static int fw_parse_opt(struct filter_util *qu, char *handle, int argc, char **a
|
||||||
continue;
|
continue;
|
||||||
} else if (strcmp(*argv, "indev") == 0) {
|
} else if (strcmp(*argv, "indev") == 0) {
|
||||||
char d[IFNAMSIZ+1];
|
char d[IFNAMSIZ+1];
|
||||||
|
|
||||||
memset(d, 0, sizeof(d));
|
memset(d, 0, sizeof(d));
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
|
|
@ -127,6 +130,7 @@ static int fw_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u
|
||||||
|
|
||||||
if (handle || tb[TCA_FW_MASK]) {
|
if (handle || tb[TCA_FW_MASK]) {
|
||||||
__u32 mark = 0, mask = 0;
|
__u32 mark = 0, mask = 0;
|
||||||
|
|
||||||
if (handle)
|
if (handle)
|
||||||
mark = handle;
|
mark = handle;
|
||||||
if (tb[TCA_FW_MASK] &&
|
if (tb[TCA_FW_MASK] &&
|
||||||
|
|
@ -145,6 +149,7 @@ static int fw_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u
|
||||||
tc_print_police(f, tb[TCA_FW_POLICE]);
|
tc_print_police(f, tb[TCA_FW_POLICE]);
|
||||||
if (tb[TCA_FW_INDEV]) {
|
if (tb[TCA_FW_INDEV]) {
|
||||||
struct rtattr *idev = tb[TCA_FW_INDEV];
|
struct rtattr *idev = tb[TCA_FW_INDEV];
|
||||||
|
|
||||||
fprintf(f, "input dev %s ", rta_getattr_str(idev));
|
fprintf(f, "input dev %s ", rta_getattr_str(idev));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ static int route_parse_opt(struct filter_util *qu, char *handle, int argc, char
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
if (matches(*argv, "to") == 0) {
|
if (matches(*argv, "to") == 0) {
|
||||||
__u32 id;
|
__u32 id;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (rtnl_rtrealm_a2n(&id, *argv)) {
|
if (rtnl_rtrealm_a2n(&id, *argv)) {
|
||||||
fprintf(stderr, "Illegal \"to\"\n");
|
fprintf(stderr, "Illegal \"to\"\n");
|
||||||
|
|
@ -70,6 +71,7 @@ static int route_parse_opt(struct filter_util *qu, char *handle, int argc, char
|
||||||
fh |= id&0xFF;
|
fh |= id&0xFF;
|
||||||
} else if (matches(*argv, "from") == 0) {
|
} else if (matches(*argv, "from") == 0) {
|
||||||
__u32 id;
|
__u32 id;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (rtnl_rtrealm_a2n(&id, *argv)) {
|
if (rtnl_rtrealm_a2n(&id, *argv)) {
|
||||||
fprintf(stderr, "Illegal \"from\"\n");
|
fprintf(stderr, "Illegal \"from\"\n");
|
||||||
|
|
@ -80,6 +82,7 @@ static int route_parse_opt(struct filter_util *qu, char *handle, int argc, char
|
||||||
fh |= id<<16;
|
fh |= id<<16;
|
||||||
} else if (matches(*argv, "fromif") == 0) {
|
} else if (matches(*argv, "fromif") == 0) {
|
||||||
__u32 id;
|
__u32 id;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
ll_init_map(&rth);
|
ll_init_map(&rth);
|
||||||
if ((id = ll_name_to_index(*argv)) <= 0) {
|
if ((id = ll_name_to_index(*argv)) <= 0) {
|
||||||
|
|
@ -91,7 +94,8 @@ static int route_parse_opt(struct filter_util *qu, char *handle, int argc, char
|
||||||
fh |= (0x8000|id)<<16;
|
fh |= (0x8000|id)<<16;
|
||||||
} else if (matches(*argv, "classid") == 0 ||
|
} else if (matches(*argv, "classid") == 0 ||
|
||||||
strcmp(*argv, "flowid") == 0) {
|
strcmp(*argv, "flowid") == 0) {
|
||||||
unsigned handle;
|
unsigned int handle;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_tc_classid(&handle, *argv)) {
|
if (get_tc_classid(&handle, *argv)) {
|
||||||
fprintf(stderr, "Illegal \"classid\"\n");
|
fprintf(stderr, "Illegal \"classid\"\n");
|
||||||
|
|
@ -141,6 +145,7 @@ static int route_parse_opt(struct filter_util *qu, char *handle, int argc, char
|
||||||
static int route_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 handle)
|
static int route_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 handle)
|
||||||
{
|
{
|
||||||
struct rtattr *tb[TCA_ROUTE4_MAX+1];
|
struct rtattr *tb[TCA_ROUTE4_MAX+1];
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
|
|
||||||
if (opt == NULL)
|
if (opt == NULL)
|
||||||
|
|
|
||||||
18
tc/f_rsvp.c
18
tc/f_rsvp.c
|
|
@ -76,6 +76,7 @@ static int get_addr_and_pi(int *argc_p, char ***argv_p, inet_prefix * addr,
|
||||||
if (strcmp(*argv, "spi/ah") == 0 ||
|
if (strcmp(*argv, "spi/ah") == 0 ||
|
||||||
strcmp(*argv, "gpi/ah") == 0) {
|
strcmp(*argv, "gpi/ah") == 0) {
|
||||||
__u32 gpi;
|
__u32 gpi;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_u32(&gpi, *argv, 0))
|
if (get_u32(&gpi, *argv, 0))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -88,6 +89,7 @@ static int get_addr_and_pi(int *argc_p, char ***argv_p, inet_prefix * addr,
|
||||||
} else if (strcmp(*argv, "spi/esp") == 0 ||
|
} else if (strcmp(*argv, "spi/esp") == 0 ||
|
||||||
strcmp(*argv, "gpi/esp") == 0) {
|
strcmp(*argv, "gpi/esp") == 0) {
|
||||||
__u32 gpi;
|
__u32 gpi;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_u32(&gpi, *argv, 0))
|
if (get_u32(&gpi, *argv, 0))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -99,6 +101,7 @@ static int get_addr_and_pi(int *argc_p, char ***argv_p, inet_prefix * addr,
|
||||||
argc--; argv++;
|
argc--; argv++;
|
||||||
} else if (strcmp(*argv, "flowlabel") == 0) {
|
} else if (strcmp(*argv, "flowlabel") == 0) {
|
||||||
__u32 flabel;
|
__u32 flabel;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_u32(&flabel, *argv, 0))
|
if (get_u32(&flabel, *argv, 0))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -114,6 +117,7 @@ static int get_addr_and_pi(int *argc_p, char ***argv_p, inet_prefix * addr,
|
||||||
int sz = 1;
|
int sz = 1;
|
||||||
__u32 tmp;
|
__u32 tmp;
|
||||||
__u32 mask = 0xff;
|
__u32 mask = 0xff;
|
||||||
|
|
||||||
if (strcmp(*argv, "u32") == 0) {
|
if (strcmp(*argv, "u32") == 0) {
|
||||||
sz = 4;
|
sz = 4;
|
||||||
mask = 0xffff;
|
mask = 0xffff;
|
||||||
|
|
@ -194,6 +198,7 @@ static int rsvp_parse_opt(struct filter_util *qu, char *handle, int argc, char *
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
if (matches(*argv, "session") == 0) {
|
if (matches(*argv, "session") == 0) {
|
||||||
inet_prefix addr;
|
inet_prefix addr;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_addr_and_pi(&argc, &argv, &addr, &pinfo, 1, family)) {
|
if (get_addr_and_pi(&argc, &argv, &addr, &pinfo, 1, family)) {
|
||||||
fprintf(stderr, "Illegal \"session\"\n");
|
fprintf(stderr, "Illegal \"session\"\n");
|
||||||
|
|
@ -206,6 +211,7 @@ static int rsvp_parse_opt(struct filter_util *qu, char *handle, int argc, char *
|
||||||
} else if (matches(*argv, "sender") == 0 ||
|
} else if (matches(*argv, "sender") == 0 ||
|
||||||
matches(*argv, "flowspec") == 0) {
|
matches(*argv, "flowspec") == 0) {
|
||||||
inet_prefix addr;
|
inet_prefix addr;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_addr_and_pi(&argc, &argv, &addr, &pinfo, 0, family)) {
|
if (get_addr_and_pi(&argc, &argv, &addr, &pinfo, 0, family)) {
|
||||||
fprintf(stderr, "Illegal \"sender\"\n");
|
fprintf(stderr, "Illegal \"sender\"\n");
|
||||||
|
|
@ -217,6 +223,7 @@ static int rsvp_parse_opt(struct filter_util *qu, char *handle, int argc, char *
|
||||||
continue;
|
continue;
|
||||||
} else if (matches("ipproto", *argv) == 0) {
|
} else if (matches("ipproto", *argv) == 0) {
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
num = inet_proto_a2n(*argv);
|
num = inet_proto_a2n(*argv);
|
||||||
if (num < 0) {
|
if (num < 0) {
|
||||||
|
|
@ -227,7 +234,8 @@ static int rsvp_parse_opt(struct filter_util *qu, char *handle, int argc, char *
|
||||||
pinfo_ok++;
|
pinfo_ok++;
|
||||||
} else if (matches(*argv, "classid") == 0 ||
|
} else if (matches(*argv, "classid") == 0 ||
|
||||||
strcmp(*argv, "flowid") == 0) {
|
strcmp(*argv, "flowid") == 0) {
|
||||||
unsigned handle;
|
unsigned int handle;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_tc_classid(&handle, *argv)) {
|
if (get_tc_classid(&handle, *argv)) {
|
||||||
fprintf(stderr, "Illegal \"classid\"\n");
|
fprintf(stderr, "Illegal \"classid\"\n");
|
||||||
|
|
@ -235,7 +243,8 @@ static int rsvp_parse_opt(struct filter_util *qu, char *handle, int argc, char *
|
||||||
}
|
}
|
||||||
addattr_l(n, 4096, TCA_RSVP_CLASSID, &handle, 4);
|
addattr_l(n, 4096, TCA_RSVP_CLASSID, &handle, 4);
|
||||||
} else if (strcmp(*argv, "tunnelid") == 0) {
|
} else if (strcmp(*argv, "tunnelid") == 0) {
|
||||||
unsigned tid;
|
unsigned int tid;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_unsigned(&tid, *argv, 0)) {
|
if (get_unsigned(&tid, *argv, 0)) {
|
||||||
fprintf(stderr, "Illegal \"tunnelid\"\n");
|
fprintf(stderr, "Illegal \"tunnelid\"\n");
|
||||||
|
|
@ -244,7 +253,8 @@ static int rsvp_parse_opt(struct filter_util *qu, char *handle, int argc, char *
|
||||||
pinfo.tunnelid = tid;
|
pinfo.tunnelid = tid;
|
||||||
pinfo_ok++;
|
pinfo_ok++;
|
||||||
} else if (strcmp(*argv, "tunnel") == 0) {
|
} else if (strcmp(*argv, "tunnel") == 0) {
|
||||||
unsigned tid;
|
unsigned int tid;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_unsigned(&tid, *argv, 0)) {
|
if (get_unsigned(&tid, *argv, 0)) {
|
||||||
fprintf(stderr, "Illegal \"tunnel\"\n");
|
fprintf(stderr, "Illegal \"tunnel\"\n");
|
||||||
|
|
@ -351,6 +361,7 @@ static int rsvp_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, _
|
||||||
|
|
||||||
if (tb[TCA_RSVP_DST]) {
|
if (tb[TCA_RSVP_DST]) {
|
||||||
char buf[128];
|
char buf[128];
|
||||||
|
|
||||||
fprintf(f, "session ");
|
fprintf(f, "session ");
|
||||||
if (inet_ntop(family, RTA_DATA(tb[TCA_RSVP_DST]), buf, sizeof(buf)) == 0)
|
if (inet_ntop(family, RTA_DATA(tb[TCA_RSVP_DST]), buf, sizeof(buf)) == 0)
|
||||||
fprintf(f, " [INVALID DADDR] ");
|
fprintf(f, " [INVALID DADDR] ");
|
||||||
|
|
@ -377,6 +388,7 @@ static int rsvp_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, _
|
||||||
fprintf(f, "tunnelid %d ", pinfo->tunnelid);
|
fprintf(f, "tunnelid %d ", pinfo->tunnelid);
|
||||||
if (tb[TCA_RSVP_SRC]) {
|
if (tb[TCA_RSVP_SRC]) {
|
||||||
char buf[128];
|
char buf[128];
|
||||||
|
|
||||||
fprintf(f, "sender ");
|
fprintf(f, "sender ");
|
||||||
if (inet_ntop(family, RTA_DATA(tb[TCA_RSVP_SRC]), buf, sizeof(buf)) == 0) {
|
if (inet_ntop(family, RTA_DATA(tb[TCA_RSVP_SRC]), buf, sizeof(buf)) == 0) {
|
||||||
fprintf(f, "[BAD]");
|
fprintf(f, "[BAD]");
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,9 @@
|
||||||
|
|
||||||
static void explain(void)
|
static void explain(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr," Usage: ... tcindex [ hash SIZE ] [ mask MASK ]"
|
fprintf(stderr," Usage: ... tcindex [ hash SIZE ] [ mask MASK ] [ shift SHIFT ]\n");
|
||||||
" [ shift SHIFT ]\n");
|
|
||||||
fprintf(stderr, " [ pass_on | fall_through ]\n");
|
fprintf(stderr, " [ pass_on | fall_through ]\n");
|
||||||
fprintf(stderr," [ classid CLASSID ] "
|
fprintf(stderr," [ classid CLASSID ] [ action ACTION_SPEC ]\n");
|
||||||
"[ action ACTION_SPEC ]\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tcindex_parse_opt(struct filter_util *qu, char *handle, int argc,
|
static int tcindex_parse_opt(struct filter_util *qu, char *handle, int argc,
|
||||||
|
|
@ -52,8 +50,7 @@ static int tcindex_parse_opt(struct filter_util *qu, char *handle, int argc,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
addattr_l(n, 4096, TCA_TCINDEX_HASH, &hash, sizeof(hash));
|
addattr_l(n, 4096, TCA_TCINDEX_HASH, &hash, sizeof(hash));
|
||||||
}
|
} else if (!strcmp(*argv,"mask")) {
|
||||||
else if (!strcmp(*argv,"mask")) {
|
|
||||||
__u16 mask;
|
__u16 mask;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
|
|
@ -63,8 +60,7 @@ static int tcindex_parse_opt(struct filter_util *qu, char *handle, int argc,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
addattr_l(n, 4096, TCA_TCINDEX_MASK, &mask, sizeof(mask));
|
addattr_l(n, 4096, TCA_TCINDEX_MASK, &mask, sizeof(mask));
|
||||||
}
|
} else if (!strcmp(*argv,"shift")) {
|
||||||
else if (!strcmp(*argv,"shift")) {
|
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
|
|
@ -75,20 +71,17 @@ static int tcindex_parse_opt(struct filter_util *qu, char *handle, int argc,
|
||||||
}
|
}
|
||||||
addattr_l(n, 4096, TCA_TCINDEX_SHIFT, &shift,
|
addattr_l(n, 4096, TCA_TCINDEX_SHIFT, &shift,
|
||||||
sizeof(shift));
|
sizeof(shift));
|
||||||
}
|
} else if (!strcmp(*argv,"fall_through")) {
|
||||||
else if (!strcmp(*argv,"fall_through")) {
|
|
||||||
int value = 1;
|
int value = 1;
|
||||||
|
|
||||||
addattr_l(n, 4096, TCA_TCINDEX_FALL_THROUGH, &value,
|
addattr_l(n, 4096, TCA_TCINDEX_FALL_THROUGH, &value,
|
||||||
sizeof(value));
|
sizeof(value));
|
||||||
}
|
} else if (!strcmp(*argv,"pass_on")) {
|
||||||
else if (!strcmp(*argv,"pass_on")) {
|
|
||||||
int value = 0;
|
int value = 0;
|
||||||
|
|
||||||
addattr_l(n, 4096, TCA_TCINDEX_FALL_THROUGH, &value,
|
addattr_l(n, 4096, TCA_TCINDEX_FALL_THROUGH, &value,
|
||||||
sizeof(value));
|
sizeof(value));
|
||||||
}
|
} else if (!strcmp(*argv,"classid")) {
|
||||||
else if (!strcmp(*argv,"classid")) {
|
|
||||||
__u32 handle;
|
__u32 handle;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
|
|
@ -97,24 +90,21 @@ static int tcindex_parse_opt(struct filter_util *qu, char *handle, int argc,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
addattr_l(n, 4096, TCA_TCINDEX_CLASSID, &handle, 4);
|
addattr_l(n, 4096, TCA_TCINDEX_CLASSID, &handle, 4);
|
||||||
}
|
} else if (!strcmp(*argv,"police")) {
|
||||||
else if (!strcmp(*argv,"police")) {
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (parse_police(&argc, &argv, TCA_TCINDEX_POLICE, n)) {
|
if (parse_police(&argc, &argv, TCA_TCINDEX_POLICE, n)) {
|
||||||
fprintf(stderr, "Illegal \"police\"\n");
|
fprintf(stderr, "Illegal \"police\"\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
} else if (!strcmp(*argv,"action")) {
|
||||||
else if (!strcmp(*argv,"action")) {
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (parse_police(&argc, &argv, TCA_TCINDEX_ACT, n)) {
|
if (parse_police(&argc, &argv, TCA_TCINDEX_ACT, n)) {
|
||||||
fprintf(stderr, "Illegal \"action\"\n");
|
fprintf(stderr, "Illegal \"action\"\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
explain();
|
explain();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
45
tc/f_u32.c
45
tc/f_u32.c
|
|
@ -30,17 +30,14 @@ extern int show_pretty;
|
||||||
|
|
||||||
static void explain(void)
|
static void explain(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: ... u32 [ match SELECTOR ... ] [ link HTID ]"
|
fprintf(stderr, "Usage: ... u32 [ match SELECTOR ... ] [ link HTID ] [ classid CLASSID ]\n");
|
||||||
" [ classid CLASSID ]\n");
|
fprintf(stderr, " [ action ACTION_SPEC ] [ offset OFFSET_SPEC ]\n");
|
||||||
fprintf(stderr, " [ action ACTION_SPEC ]"
|
|
||||||
" [ offset OFFSET_SPEC ]\n");
|
|
||||||
fprintf(stderr, " [ ht HTID ] [ hashkey HASHKEY_SPEC ]\n");
|
fprintf(stderr, " [ ht HTID ] [ hashkey HASHKEY_SPEC ]\n");
|
||||||
fprintf(stderr, " [ sample SAMPLE ]\n");
|
fprintf(stderr, " [ sample SAMPLE ]\n");
|
||||||
fprintf(stderr, "or u32 divisor DIVISOR\n");
|
fprintf(stderr, "or u32 divisor DIVISOR\n");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, "Where: SELECTOR := SAMPLE SAMPLE ...\n");
|
fprintf(stderr, "Where: SELECTOR := SAMPLE SAMPLE ...\n");
|
||||||
fprintf(stderr, " SAMPLE := { ip | ip6 | udp | tcp | icmp |"
|
fprintf(stderr, " SAMPLE := { ip | ip6 | udp | tcp | icmp | u{32|16|8} | mark } SAMPLE_ARGS [divisor DIVISOR]\n");
|
||||||
" u{32|16|8} | mark } SAMPLE_ARGS [divisor DIVISOR]\n");
|
|
||||||
fprintf(stderr, " FILTERID := X:Y:Z\n");
|
fprintf(stderr, " FILTERID := X:Y:Z\n");
|
||||||
fprintf(stderr, "\nNOTE: CLASSID is parsed at hexadecimal input.\n");
|
fprintf(stderr, "\nNOTE: CLASSID is parsed at hexadecimal input.\n");
|
||||||
}
|
}
|
||||||
|
|
@ -94,17 +91,20 @@ static char *sprint_u32_handle(__u32 handle, char *buf)
|
||||||
}
|
}
|
||||||
if (htid) {
|
if (htid) {
|
||||||
int l = snprintf(b, bsize, "%x:", htid>>20);
|
int l = snprintf(b, bsize, "%x:", htid>>20);
|
||||||
|
|
||||||
bsize -= l;
|
bsize -= l;
|
||||||
b += l;
|
b += l;
|
||||||
}
|
}
|
||||||
if (nodeid|hash) {
|
if (nodeid|hash) {
|
||||||
if (hash) {
|
if (hash) {
|
||||||
int l = snprintf(b, bsize, "%x", hash);
|
int l = snprintf(b, bsize, "%x", hash);
|
||||||
|
|
||||||
bsize -= l;
|
bsize -= l;
|
||||||
b += l;
|
b += l;
|
||||||
}
|
}
|
||||||
if (nodeid) {
|
if (nodeid) {
|
||||||
int l = snprintf(b, bsize, ":%x", nodeid);
|
int l = snprintf(b, bsize, ":%x", nodeid);
|
||||||
|
|
||||||
bsize -= l;
|
bsize -= l;
|
||||||
b += l;
|
b += l;
|
||||||
}
|
}
|
||||||
|
|
@ -390,6 +390,7 @@ static int parse_ip6_addr(int *argc_p, char ***argv_p,
|
||||||
return -1;
|
return -1;
|
||||||
} else if (i < plen) {
|
} else if (i < plen) {
|
||||||
__u32 mask = htonl(0xFFFFFFFF << (32 - (plen - i)));
|
__u32 mask = htonl(0xFFFFFFFF << (32 - (plen - i)));
|
||||||
|
|
||||||
res = pack_key(sel, addr.data[i / 32],
|
res = pack_key(sel, addr.data[i / 32],
|
||||||
mask, off + 4 * (i / 32), offmask);
|
mask, off + 4 * (i / 32), offmask);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
|
|
@ -746,6 +747,7 @@ static int parse_offset(int *argc_p, char ***argv_p, struct tc_u32_sel *sel)
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
if (matches(*argv, "plus") == 0) {
|
if (matches(*argv, "plus") == 0) {
|
||||||
int off;
|
int off;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_integer(&off, *argv, 0))
|
if (get_integer(&off, *argv, 0))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -753,6 +755,7 @@ static int parse_offset(int *argc_p, char ***argv_p, struct tc_u32_sel *sel)
|
||||||
sel->flags |= TC_U32_OFFSET;
|
sel->flags |= TC_U32_OFFSET;
|
||||||
} else if (matches(*argv, "at") == 0) {
|
} else if (matches(*argv, "at") == 0) {
|
||||||
int off;
|
int off;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_integer(&off, *argv, 0))
|
if (get_integer(&off, *argv, 0))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -764,6 +767,7 @@ static int parse_offset(int *argc_p, char ***argv_p, struct tc_u32_sel *sel)
|
||||||
sel->flags |= TC_U32_VAROFFSET;
|
sel->flags |= TC_U32_VAROFFSET;
|
||||||
} else if (matches(*argv, "mask") == 0) {
|
} else if (matches(*argv, "mask") == 0) {
|
||||||
__u16 mask;
|
__u16 mask;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_u16(&mask, *argv, 16))
|
if (get_u16(&mask, *argv, 16))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -771,6 +775,7 @@ static int parse_offset(int *argc_p, char ***argv_p, struct tc_u32_sel *sel)
|
||||||
sel->flags |= TC_U32_VAROFFSET;
|
sel->flags |= TC_U32_VAROFFSET;
|
||||||
} else if (matches(*argv, "shift") == 0) {
|
} else if (matches(*argv, "shift") == 0) {
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_integer(&shift, *argv, 0))
|
if (get_integer(&shift, *argv, 0))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -797,12 +802,14 @@ static int parse_hashkey(int *argc_p, char ***argv_p, struct tc_u32_sel *sel)
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
if (matches(*argv, "mask") == 0) {
|
if (matches(*argv, "mask") == 0) {
|
||||||
__u32 mask;
|
__u32 mask;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_u32(&mask, *argv, 16))
|
if (get_u32(&mask, *argv, 16))
|
||||||
return -1;
|
return -1;
|
||||||
sel->hmask = htonl(mask);
|
sel->hmask = htonl(mask);
|
||||||
} else if (matches(*argv, "at") == 0) {
|
} else if (matches(*argv, "at") == 0) {
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_integer(&num, *argv, 0))
|
if (get_integer(&num, *argv, 0))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -844,6 +851,7 @@ static void print_ipv4(FILE *f, const struct tc_u32_key *key)
|
||||||
case 12:
|
case 12:
|
||||||
case 16: {
|
case 16: {
|
||||||
int bits = mask2bits(key->mask);
|
int bits = mask2bits(key->mask);
|
||||||
|
|
||||||
if (bits >= 0) {
|
if (bits >= 0) {
|
||||||
fprintf(f, "\n %s %s/%d",
|
fprintf(f, "\n %s %s/%d",
|
||||||
key->off == 12 ? "match IP src" : "match IP dst",
|
key->off == 12 ? "match IP src" : "match IP dst",
|
||||||
|
|
@ -900,6 +908,7 @@ static void print_ipv6(FILE *f, const struct tc_u32_key *key)
|
||||||
case 12:
|
case 12:
|
||||||
case 16: {
|
case 16: {
|
||||||
int bits = mask2bits(key->mask);
|
int bits = mask2bits(key->mask);
|
||||||
|
|
||||||
if (bits >= 0) {
|
if (bits >= 0) {
|
||||||
fprintf(f, "\n %s %s/%d",
|
fprintf(f, "\n %s %s/%d",
|
||||||
key->off == 12 ? "match IP src" : "match IP dst",
|
key->off == 12 ? "match IP src" : "match IP dst",
|
||||||
|
|
@ -958,7 +967,7 @@ static void show_keys(FILE *f, const struct tc_u32_key *key)
|
||||||
if (!show_pretty)
|
if (!show_pretty)
|
||||||
goto show_k;
|
goto show_k;
|
||||||
|
|
||||||
for (i = 0; i < sizeof(u32_pprinters) / sizeof(u32_pprinters[0]); i++) {
|
for (i = 0; i < ARRAY_SIZE(u32_pprinters); i++) {
|
||||||
if (u32_pprinters[i].proto == ntohs(f_proto)) {
|
if (u32_pprinters[i].proto == ntohs(f_proto)) {
|
||||||
show_k:
|
show_k:
|
||||||
u32_pprinters[i].pprinter(f, key);
|
u32_pprinters[i].pprinter(f, key);
|
||||||
|
|
@ -1022,7 +1031,8 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
|
||||||
continue;
|
continue;
|
||||||
} else if (matches(*argv, "classid") == 0 ||
|
} else if (matches(*argv, "classid") == 0 ||
|
||||||
strcmp(*argv, "flowid") == 0) {
|
strcmp(*argv, "flowid") == 0) {
|
||||||
unsigned handle;
|
unsigned int handle;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_tc_classid(&handle, *argv)) {
|
if (get_tc_classid(&handle, *argv)) {
|
||||||
fprintf(stderr, "Illegal \"classid\"\n");
|
fprintf(stderr, "Illegal \"classid\"\n");
|
||||||
|
|
@ -1031,7 +1041,8 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
|
||||||
addattr_l(n, MAX_MSG, TCA_U32_CLASSID, &handle, 4);
|
addattr_l(n, MAX_MSG, TCA_U32_CLASSID, &handle, 4);
|
||||||
sel.sel.flags |= TC_U32_TERMINAL;
|
sel.sel.flags |= TC_U32_TERMINAL;
|
||||||
} else if (matches(*argv, "divisor") == 0) {
|
} else if (matches(*argv, "divisor") == 0) {
|
||||||
unsigned divisor;
|
unsigned int divisor;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_unsigned(&divisor, *argv, 0) ||
|
if (get_unsigned(&divisor, *argv, 0) ||
|
||||||
divisor == 0 ||
|
divisor == 0 ||
|
||||||
|
|
@ -1047,7 +1058,8 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (strcmp(*argv, "link") == 0) {
|
} else if (strcmp(*argv, "link") == 0) {
|
||||||
unsigned handle;
|
unsigned int handle;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_u32_handle(&handle, *argv)) {
|
if (get_u32_handle(&handle, *argv)) {
|
||||||
fprintf(stderr, "Illegal \"link\"\n");
|
fprintf(stderr, "Illegal \"link\"\n");
|
||||||
|
|
@ -1059,7 +1071,8 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
|
||||||
}
|
}
|
||||||
addattr_l(n, MAX_MSG, TCA_U32_LINK, &handle, 4);
|
addattr_l(n, MAX_MSG, TCA_U32_LINK, &handle, 4);
|
||||||
} else if (strcmp(*argv, "ht") == 0) {
|
} else if (strcmp(*argv, "ht") == 0) {
|
||||||
unsigned handle;
|
unsigned int handle;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_u32_handle(&handle, *argv)) {
|
if (get_u32_handle(&handle, *argv)) {
|
||||||
fprintf(stderr, "Illegal \"ht\"\n");
|
fprintf(stderr, "Illegal \"ht\"\n");
|
||||||
|
|
@ -1075,7 +1088,7 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
|
||||||
htid = (handle & 0xFFFFF000);
|
htid = (handle & 0xFFFFF000);
|
||||||
} else if (strcmp(*argv, "sample") == 0) {
|
} else if (strcmp(*argv, "sample") == 0) {
|
||||||
__u32 hash;
|
__u32 hash;
|
||||||
unsigned divisor = 0x100;
|
unsigned int divisor = 0x100;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct tc_u32_sel sel;
|
struct tc_u32_sel sel;
|
||||||
|
|
@ -1088,8 +1101,7 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (sel2.sel.nkeys != 1) {
|
if (sel2.sel.nkeys != 1) {
|
||||||
fprintf(stderr, "\"sample\" must contain"
|
fprintf(stderr, "\"sample\" must contain exactly ONE key.\n");
|
||||||
" exactly ONE key.\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (*argv != 0 && strcmp(*argv, "divisor") == 0) {
|
if (*argv != 0 && strcmp(*argv, "divisor") == 0) {
|
||||||
|
|
@ -1109,6 +1121,7 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
|
||||||
continue;
|
continue;
|
||||||
} else if (strcmp(*argv, "indev") == 0) {
|
} else if (strcmp(*argv, "indev") == 0) {
|
||||||
char ind[IFNAMSIZ + 1];
|
char ind[IFNAMSIZ + 1];
|
||||||
|
|
||||||
memset(ind, 0, sizeof(ind));
|
memset(ind, 0, sizeof(ind));
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
|
|
@ -1199,6 +1212,7 @@ static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
|
||||||
fprintf(f, "ht divisor %d ", rta_getattr_u32(tb[TCA_U32_DIVISOR]));
|
fprintf(f, "ht divisor %d ", rta_getattr_u32(tb[TCA_U32_DIVISOR]));
|
||||||
} else if (tb[TCA_U32_HASH]) {
|
} else if (tb[TCA_U32_HASH]) {
|
||||||
__u32 htid = rta_getattr_u32(tb[TCA_U32_HASH]);
|
__u32 htid = rta_getattr_u32(tb[TCA_U32_HASH]);
|
||||||
|
|
||||||
fprintf(f, "key ht %x bkt %x ", TC_U32_USERHTID(htid),
|
fprintf(f, "key ht %x bkt %x ", TC_U32_USERHTID(htid),
|
||||||
TC_U32_HASH(htid));
|
TC_U32_HASH(htid));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1233,6 +1247,7 @@ static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
|
||||||
|
|
||||||
if (tb[TCA_U32_MARK]) {
|
if (tb[TCA_U32_MARK]) {
|
||||||
struct tc_u32_mark *mark = RTA_DATA(tb[TCA_U32_MARK]);
|
struct tc_u32_mark *mark = RTA_DATA(tb[TCA_U32_MARK]);
|
||||||
|
|
||||||
if (RTA_PAYLOAD(tb[TCA_U32_MARK]) < sizeof(*mark)) {
|
if (RTA_PAYLOAD(tb[TCA_U32_MARK]) < sizeof(*mark)) {
|
||||||
fprintf(f, "\n Invalid mark (kernel&iproute2 mismatch)\n");
|
fprintf(f, "\n Invalid mark (kernel&iproute2 mismatch)\n");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1244,6 +1259,7 @@ static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
|
||||||
if (sel) {
|
if (sel) {
|
||||||
if (sel->nkeys) {
|
if (sel->nkeys) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < sel->nkeys; i++) {
|
for (i = 0; i < sel->nkeys; i++) {
|
||||||
show_keys(f, sel->keys + i);
|
show_keys(f, sel->keys + i);
|
||||||
if (show_stats && NULL != pf)
|
if (show_stats && NULL != pf)
|
||||||
|
|
@ -1276,6 +1292,7 @@ static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
|
||||||
}
|
}
|
||||||
if (tb[TCA_U32_INDEV]) {
|
if (tb[TCA_U32_INDEV]) {
|
||||||
struct rtattr *idev = tb[TCA_U32_INDEV];
|
struct rtattr *idev = tb[TCA_U32_INDEV];
|
||||||
|
|
||||||
fprintf(f, "\n input dev %s\n", rta_getattr_str(idev));
|
fprintf(f, "\n input dev %s\n", rta_getattr_str(idev));
|
||||||
}
|
}
|
||||||
if (tb[TCA_U32_ACT]) {
|
if (tb[TCA_U32_ACT]) {
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,9 @@
|
||||||
|
|
||||||
static struct action_util *action_list;
|
static struct action_util *action_list;
|
||||||
#ifdef CONFIG_GACT
|
#ifdef CONFIG_GACT
|
||||||
int gact_ld = 0 ; //fuckin backward compatibility
|
int gact_ld; /* f*ckin backward compatibility */
|
||||||
#endif
|
#endif
|
||||||
int tab_flush = 0;
|
int tab_flush;
|
||||||
|
|
||||||
static void act_usage(void)
|
static void act_usage(void)
|
||||||
{
|
{
|
||||||
|
|
@ -65,7 +65,7 @@ static int print_noaopt(struct action_util *au, FILE *f, struct rtattr *opt)
|
||||||
{
|
{
|
||||||
if (opt && RTA_PAYLOAD(opt))
|
if (opt && RTA_PAYLOAD(opt))
|
||||||
fprintf(f, "[Unknown action, optlen=%u] ",
|
fprintf(f, "[Unknown action, optlen=%u] ",
|
||||||
(unsigned) RTA_PAYLOAD(opt));
|
(unsigned int) RTA_PAYLOAD(opt));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -195,6 +195,7 @@ parse_action(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n)
|
||||||
goto done0;
|
goto done0;
|
||||||
} else {
|
} else {
|
||||||
struct action_util *a = NULL;
|
struct action_util *a = NULL;
|
||||||
|
|
||||||
strncpy(k, *argv, sizeof(k) - 1);
|
strncpy(k, *argv, sizeof(k) - 1);
|
||||||
eap = 0;
|
eap = 0;
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
|
|
@ -207,7 +208,7 @@ done0:
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == a) {
|
if (a == NULL) {
|
||||||
goto bad_val;
|
goto bad_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -265,12 +266,12 @@ tc_print_one_action(FILE * f, struct rtattr *arg)
|
||||||
|
|
||||||
|
|
||||||
a = get_action_kind(RTA_DATA(tb[TCA_ACT_KIND]));
|
a = get_action_kind(RTA_DATA(tb[TCA_ACT_KIND]));
|
||||||
if (NULL == a)
|
if (a == NULL)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
err = a->print_aopt(a, f, tb[TCA_ACT_OPTIONS]);
|
err = a->print_aopt(a, f, tb[TCA_ACT_OPTIONS]);
|
||||||
|
|
||||||
if (0 > err)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (show_stats && tb[TCA_ACT_STATS]) {
|
if (show_stats && tb[TCA_ACT_STATS]) {
|
||||||
|
|
@ -299,7 +300,7 @@ tc_print_action_flush(FILE *f, const struct rtattr *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
a = get_action_kind(RTA_DATA(tb[TCA_KIND]));
|
a = get_action_kind(RTA_DATA(tb[TCA_KIND]));
|
||||||
if (NULL == a)
|
if (a == NULL)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
delete_count = RTA_DATA(tb[TCA_FCNT]);
|
delete_count = RTA_DATA(tb[TCA_FCNT]);
|
||||||
|
|
@ -326,7 +327,7 @@ tc_print_action(FILE *f, const struct rtattr *arg)
|
||||||
for (i = 0; i < TCA_ACT_MAX_PRIO; i++) {
|
for (i = 0; i < TCA_ACT_MAX_PRIO; i++) {
|
||||||
if (tb[i]) {
|
if (tb[i]) {
|
||||||
fprintf(f, "\n\taction order %d: ", i);
|
fprintf(f, "\n\taction order %d: ", i);
|
||||||
if (0 > tc_print_one_action(f, tb[i])) {
|
if (tc_print_one_action(f, tb[i]) < 0) {
|
||||||
fprintf(f, "Error printing action\n");
|
fprintf(f, "Error printing action\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -354,7 +355,7 @@ int print_action(const struct sockaddr_nl *who,
|
||||||
|
|
||||||
parse_rtattr(tb, TCAA_MAX, TA_RTA(t), len);
|
parse_rtattr(tb, TCAA_MAX, TA_RTA(t), len);
|
||||||
|
|
||||||
if (NULL == tb[TCA_ACT_TAB]) {
|
if (tb[TCA_ACT_TAB] == NULL) {
|
||||||
if (n->nlmsg_type != RTM_GETACTION)
|
if (n->nlmsg_type != RTM_GETACTION)
|
||||||
fprintf(stderr, "print_action: NULL kind\n");
|
fprintf(stderr, "print_action: NULL kind\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -376,7 +377,7 @@ int print_action(const struct sockaddr_nl *who,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tc_action_gd(int cmd, unsigned flags, int *argc_p, char ***argv_p)
|
static int tc_action_gd(int cmd, unsigned int flags, int *argc_p, char ***argv_p)
|
||||||
{
|
{
|
||||||
char k[16];
|
char k[16];
|
||||||
struct action_util *a = NULL;
|
struct action_util *a = NULL;
|
||||||
|
|
@ -424,7 +425,7 @@ static int tc_action_gd(int cmd, unsigned flags, int *argc_p, char ***argv_p)
|
||||||
|
|
||||||
strncpy(k, *argv, sizeof(k) - 1);
|
strncpy(k, *argv, sizeof(k) - 1);
|
||||||
a = get_action_kind(k);
|
a = get_action_kind(k);
|
||||||
if (NULL == a) {
|
if (a == NULL) {
|
||||||
fprintf(stderr, "Error: non existent action: %s\n", k);
|
fprintf(stderr, "Error: non existent action: %s\n", k);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto bad_val;
|
goto bad_val;
|
||||||
|
|
@ -488,7 +489,7 @@ bad_val:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tc_action_modify(int cmd, unsigned flags, int *argc_p, char ***argv_p)
|
static int tc_action_modify(int cmd, unsigned int flags, int *argc_p, char ***argv_p)
|
||||||
{
|
{
|
||||||
int argc = *argc_p;
|
int argc = *argc_p;
|
||||||
char **argv = *argv_p;
|
char **argv = *argv_p;
|
||||||
|
|
@ -557,7 +558,7 @@ static int tc_act_list_or_flush(int argc, char **argv, int event)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
a = get_action_kind(k);
|
a = get_action_kind(k);
|
||||||
if (NULL == a) {
|
if (a == NULL) {
|
||||||
fprintf(stderr, "bad action %s\n", k);
|
fprintf(stderr, "bad action %s\n", k);
|
||||||
goto bad_val;
|
goto bad_val;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,7 @@ static int bpf_print_opt(struct action_util *au, FILE *f, struct rtattr *arg)
|
||||||
{
|
{
|
||||||
struct rtattr *tb[TCA_ACT_BPF_MAX + 1];
|
struct rtattr *tb[TCA_ACT_BPF_MAX + 1];
|
||||||
struct tc_act_bpf *parm;
|
struct tc_act_bpf *parm;
|
||||||
|
|
||||||
SPRINT_BUF(action_buf);
|
SPRINT_BUF(action_buf);
|
||||||
|
|
||||||
if (arg == NULL)
|
if (arg == NULL)
|
||||||
|
|
@ -190,6 +191,7 @@ static int bpf_print_opt(struct action_util *au, FILE *f, struct rtattr *arg)
|
||||||
if (show_stats) {
|
if (show_stats) {
|
||||||
if (tb[TCA_ACT_BPF_TM]) {
|
if (tb[TCA_ACT_BPF_TM]) {
|
||||||
struct tcf_t *tm = RTA_DATA(tb[TCA_ACT_BPF_TM]);
|
struct tcf_t *tm = RTA_DATA(tb[TCA_ACT_BPF_TM]);
|
||||||
|
|
||||||
print_tm(f, tm);
|
print_tm(f, tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,7 @@ static int print_connmark(struct action_util *au, FILE *f, struct rtattr *arg)
|
||||||
if (show_stats) {
|
if (show_stats) {
|
||||||
if (tb[TCA_CONNMARK_TM]) {
|
if (tb[TCA_CONNMARK_TM]) {
|
||||||
struct tcf_t *tm = RTA_DATA(tb[TCA_CONNMARK_TM]);
|
struct tcf_t *tm = RTA_DATA(tb[TCA_CONNMARK_TM]);
|
||||||
|
|
||||||
print_tm(f, tm);
|
print_tm(f, tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,7 @@ explain(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: ... csum <UPDATE>\n"
|
fprintf(stderr, "Usage: ... csum <UPDATE>\n"
|
||||||
"Where: UPDATE := <TARGET> [<UPDATE>]\n"
|
"Where: UPDATE := <TARGET> [<UPDATE>]\n"
|
||||||
" TARGET := { ip4h | icmp | igmp |"
|
" TARGET := { ip4h | icmp | igmp | tcp | udp | udplite | <SWEETS> }\n"
|
||||||
" tcp | udp | udplite | <SWEETS> }\n"
|
|
||||||
" SWEETS := { and | or | \'+\' }\n");
|
" SWEETS := { and | or | \'+\' }\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,8 +107,7 @@ parse_csum(struct action_util *a, int *argc_p,
|
||||||
continue;
|
continue;
|
||||||
} else if (matches(*argv, "help") == 0) {
|
} else if (matches(*argv, "help") == 0) {
|
||||||
usage();
|
usage();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -186,6 +184,7 @@ print_csum(struct action_util *au, FILE * f, struct rtattr *arg)
|
||||||
char *uflag_4 = "";
|
char *uflag_4 = "";
|
||||||
char *uflag_5 = "";
|
char *uflag_5 = "";
|
||||||
char *uflag_6 = "";
|
char *uflag_6 = "";
|
||||||
|
|
||||||
SPRINT_BUF(action_buf);
|
SPRINT_BUF(action_buf);
|
||||||
|
|
||||||
int uflag_count = 0;
|
int uflag_count = 0;
|
||||||
|
|
@ -231,6 +230,7 @@ print_csum(struct action_util *au, FILE * f, struct rtattr *arg)
|
||||||
if (show_stats) {
|
if (show_stats) {
|
||||||
if (tb[TCA_CSUM_TM]) {
|
if (tb[TCA_CSUM_TM]) {
|
||||||
struct tcf_t *tm = RTA_DATA(tb[TCA_CSUM_TM]);
|
struct tcf_t *tm = RTA_DATA(tb[TCA_CSUM_TM]);
|
||||||
|
|
||||||
print_tm(f, tm);
|
print_tm(f, tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ static struct ematch_util *ematch_list;
|
||||||
/* export to bison parser */
|
/* export to bison parser */
|
||||||
int ematch_argc;
|
int ematch_argc;
|
||||||
char **ematch_argv;
|
char **ematch_argv;
|
||||||
char *ematch_err = NULL;
|
char *ematch_err;
|
||||||
struct ematch *ematch_root;
|
struct ematch *ematch_root;
|
||||||
|
|
||||||
static int begin_argc;
|
static int begin_argc;
|
||||||
|
|
@ -188,6 +188,7 @@ static int parse_tree(struct nlmsghdr *n, struct ematch *tree)
|
||||||
|
|
||||||
if (t->child) {
|
if (t->child) {
|
||||||
__u32 r = t->child_ref;
|
__u32 r = t->child_ref;
|
||||||
|
|
||||||
addraw_l(n, MAX_MSG, &hdr, sizeof(hdr));
|
addraw_l(n, MAX_MSG, &hdr, sizeof(hdr));
|
||||||
addraw_l(n, MAX_MSG, &r, sizeof(r));
|
addraw_l(n, MAX_MSG, &r, sizeof(r));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -558,6 +559,7 @@ void print_ematch_tree(const struct ematch *tree)
|
||||||
printf(")");
|
printf(")");
|
||||||
} else {
|
} else {
|
||||||
struct bstr *b;
|
struct bstr *b;
|
||||||
|
|
||||||
for (b = t->args; b; b = b->next)
|
for (b = t->args; b; b = b->next)
|
||||||
printf("%s%s", b->data, b->next ? " " : "");
|
printf("%s%s", b->data, b->next ? " " : "");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ int parse_estimator(int *p_argc, char ***p_argv, struct tc_estimator *est)
|
||||||
{
|
{
|
||||||
int argc = *p_argc;
|
int argc = *p_argc;
|
||||||
char **argv = *p_argv;
|
char **argv = *p_argv;
|
||||||
unsigned A, time_const;
|
unsigned int A, time_const;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (est->ewma_log)
|
if (est->ewma_log)
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,7 @@ print_gact(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
|
|
||||||
fprintf(f, "gact action %s", action_n2a(p->action, b1, sizeof(b1)));
|
fprintf(f, "gact action %s", action_n2a(p->action, b1, sizeof(b1)));
|
||||||
#ifdef CONFIG_GACT_PROB
|
#ifdef CONFIG_GACT_PROB
|
||||||
if (NULL != tb[TCA_GACT_PROB]) {
|
if (tb[TCA_GACT_PROB] != NULL) {
|
||||||
pp = RTA_DATA(tb[TCA_GACT_PROB]);
|
pp = RTA_DATA(tb[TCA_GACT_PROB]);
|
||||||
} else {
|
} else {
|
||||||
/* need to keep consistent output */
|
/* need to keep consistent output */
|
||||||
|
|
@ -241,6 +241,7 @@ print_gact(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
if (show_stats) {
|
if (show_stats) {
|
||||||
if (tb[TCA_GACT_TM]) {
|
if (tb[TCA_GACT_TM]) {
|
||||||
struct tcf_t *tm = RTA_DATA(tb[TCA_GACT_TM]);
|
struct tcf_t *tm = RTA_DATA(tb[TCA_GACT_TM]);
|
||||||
|
|
||||||
print_tm(f, tm);
|
print_tm(f, tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
30
tc/m_ipt.c
30
tc/m_ipt.c
|
|
@ -51,9 +51,9 @@ static struct option original_opts[] = {
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct iptables_target *t_list = NULL;
|
static struct iptables_target *t_list;
|
||||||
static struct option *opts = original_opts;
|
static struct option *opts = original_opts;
|
||||||
static unsigned int global_option_offset = 0;
|
static unsigned int global_option_offset;
|
||||||
#define OPTION_OFFSET 256
|
#define OPTION_OFFSET 256
|
||||||
|
|
||||||
char *lib_dir;
|
char *lib_dir;
|
||||||
|
|
@ -209,6 +209,7 @@ static struct iptables_target *
|
||||||
find_t(char *name)
|
find_t(char *name)
|
||||||
{
|
{
|
||||||
struct iptables_target *m;
|
struct iptables_target *m;
|
||||||
|
|
||||||
for (m = t_list; m; m = m->next) {
|
for (m = t_list; m; m = m->next) {
|
||||||
if (strcmp(m->name, name) == 0)
|
if (strcmp(m->name, name) == 0)
|
||||||
return m;
|
return m;
|
||||||
|
|
@ -247,6 +248,7 @@ get_target_name(const char *name)
|
||||||
|
|
||||||
if (isupper(lname[0])) {
|
if (isupper(lname[0])) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < strlen(name); i++) {
|
for (i = 0; i < strlen(name); i++) {
|
||||||
lname[i] = tolower(lname[i]);
|
lname[i] = tolower(lname[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -254,6 +256,7 @@ get_target_name(const char *name)
|
||||||
|
|
||||||
if (islower(new_name[0])) {
|
if (islower(new_name[0])) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < strlen(new_name); i++) {
|
for (i = 0; i < strlen(new_name); i++) {
|
||||||
new_name[i] = toupper(new_name[i]);
|
new_name[i] = toupper(new_name[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -291,9 +294,9 @@ get_target_name(const char *name)
|
||||||
m = (struct iptables_target *) dlsym(handle, lname);
|
m = (struct iptables_target *) dlsym(handle, lname);
|
||||||
if ((error = dlerror()) != NULL) {
|
if ((error = dlerror()) != NULL) {
|
||||||
m = find_t(new_name);
|
m = find_t(new_name);
|
||||||
if (NULL == m) {
|
if (m == NULL) {
|
||||||
m = find_t(lname);
|
m = find_t(lname);
|
||||||
if (NULL == m) {
|
if (m == NULL) {
|
||||||
fputs(error, stderr);
|
fputs(error, stderr);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
|
|
@ -368,7 +371,7 @@ build_st(struct iptables_target *target, struct ipt_entry_target *t)
|
||||||
size =
|
size =
|
||||||
IPT_ALIGN(sizeof(struct ipt_entry_target)) + target->size;
|
IPT_ALIGN(sizeof(struct ipt_entry_target)) + target->size;
|
||||||
|
|
||||||
if (NULL == t) {
|
if (t == NULL) {
|
||||||
target->t = fw_calloc(1, size);
|
target->t = fw_calloc(1, size);
|
||||||
target->t->u.target_size = size;
|
target->t->u.target_size = size;
|
||||||
|
|
||||||
|
|
@ -406,6 +409,7 @@ static int parse_ipt(struct action_util *a,int *argc_p,
|
||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < rargc; i++) {
|
for (i = 0; i < rargc; i++) {
|
||||||
if (NULL == argv[i] || 0 == strcmp(argv[i], "action")) {
|
if (NULL == argv[i] || 0 == strcmp(argv[i], "action")) {
|
||||||
break;
|
break;
|
||||||
|
|
@ -426,9 +430,9 @@ static int parse_ipt(struct action_util *a,int *argc_p,
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'j':
|
case 'j':
|
||||||
m = get_target_name(optarg);
|
m = get_target_name(optarg);
|
||||||
if (NULL != m) {
|
if (m != NULL) {
|
||||||
|
|
||||||
if (0 > build_st(m, NULL)) {
|
if (build_st(m, NULL) < 0) {
|
||||||
printf(" %s error\n", m->name);
|
printf(" %s error\n", m->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -482,6 +486,7 @@ static int parse_ipt(struct action_util *a,int *argc_p,
|
||||||
|
|
||||||
{
|
{
|
||||||
struct tcmsg *t = NLMSG_DATA(n);
|
struct tcmsg *t = NLMSG_DATA(n);
|
||||||
|
|
||||||
if (t->tcm_parent != TC_H_ROOT
|
if (t->tcm_parent != TC_H_ROOT
|
||||||
&& t->tcm_parent == TC_H_MAJ(TC_H_INGRESS)) {
|
&& t->tcm_parent == TC_H_MAJ(TC_H_INGRESS)) {
|
||||||
hook = NF_IP_PRE_ROUTING;
|
hook = NF_IP_PRE_ROUTING;
|
||||||
|
|
@ -560,6 +565,7 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
__u32 hook;
|
__u32 hook;
|
||||||
|
|
||||||
hook = rta_getattr_u32(tb[TCA_IPT_HOOK]);
|
hook = rta_getattr_u32(tb[TCA_IPT_HOOK]);
|
||||||
fprintf(f, " hook: %s\n", ipthooks[hook]);
|
fprintf(f, " hook: %s\n", ipthooks[hook]);
|
||||||
}
|
}
|
||||||
|
|
@ -569,10 +575,11 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
struct iptables_target *m = NULL;
|
struct iptables_target *m = NULL;
|
||||||
|
|
||||||
t = RTA_DATA(tb[TCA_IPT_TARG]);
|
t = RTA_DATA(tb[TCA_IPT_TARG]);
|
||||||
m = get_target_name(t->u.user.name);
|
m = get_target_name(t->u.user.name);
|
||||||
if (NULL != m) {
|
if (m != NULL) {
|
||||||
if (0 > build_st(m, t)) {
|
if (build_st(m, t) < 0) {
|
||||||
fprintf(stderr, " %s error\n", m->name);
|
fprintf(stderr, " %s error\n", m->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -591,17 +598,20 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
fprintf(f, " [NULL ipt target index ]\n");
|
fprintf(f, " [NULL ipt target index ]\n");
|
||||||
} else {
|
} else {
|
||||||
__u32 index;
|
__u32 index;
|
||||||
|
|
||||||
index = rta_getattr_u32(tb[TCA_IPT_INDEX]);
|
index = rta_getattr_u32(tb[TCA_IPT_INDEX]);
|
||||||
fprintf(f, "\n\tindex %d", index);
|
fprintf(f, "\n\tindex %d", index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tb[TCA_IPT_CNT]) {
|
if (tb[TCA_IPT_CNT]) {
|
||||||
struct tc_cnt *c = RTA_DATA(tb[TCA_IPT_CNT]);;
|
struct tc_cnt *c = RTA_DATA(tb[TCA_IPT_CNT]);
|
||||||
|
|
||||||
fprintf(f, " ref %d bind %d", c->refcnt, c->bindcnt);
|
fprintf(f, " ref %d bind %d", c->refcnt, c->bindcnt);
|
||||||
}
|
}
|
||||||
if (show_stats) {
|
if (show_stats) {
|
||||||
if (tb[TCA_IPT_TM]) {
|
if (tb[TCA_IPT_TM]) {
|
||||||
struct tcf_t *tm = RTA_DATA(tb[TCA_IPT_TM]);
|
struct tcf_t *tm = RTA_DATA(tb[TCA_IPT_TM]);
|
||||||
|
|
||||||
print_tm(f, tm);
|
print_tm(f, tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,7 @@ parse_egress(struct action_util *a, int *argc_p, char ***argv_p,
|
||||||
|
|
||||||
if (d[0]) {
|
if (d[0]) {
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
ll_init_map(&rth);
|
ll_init_map(&rth);
|
||||||
|
|
||||||
if ((idx = ll_name_to_index(d)) == 0) {
|
if ((idx = ll_name_to_index(d)) == 0) {
|
||||||
|
|
@ -229,6 +230,7 @@ parse_mirred(struct action_util *a, int *argc_p, char ***argv_p,
|
||||||
|
|
||||||
if (matches(*argv, "egress") == 0 || matches(*argv, "index") == 0) {
|
if (matches(*argv, "egress") == 0 || matches(*argv, "index") == 0) {
|
||||||
int ret = parse_egress(a, &argc, &argv, tca_id, n);
|
int ret = parse_egress(a, &argc, &argv, tca_id, n);
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
*argc_p = argc;
|
*argc_p = argc;
|
||||||
*argv_p = argv;
|
*argv_p = argv;
|
||||||
|
|
@ -253,6 +255,7 @@ print_mirred(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
struct tc_mirred *p;
|
struct tc_mirred *p;
|
||||||
struct rtattr *tb[TCA_MIRRED_MAX + 1];
|
struct rtattr *tb[TCA_MIRRED_MAX + 1];
|
||||||
const char *dev;
|
const char *dev;
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
|
|
||||||
if (arg == NULL)
|
if (arg == NULL)
|
||||||
|
|
@ -284,6 +287,7 @@ print_mirred(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
if (show_stats) {
|
if (show_stats) {
|
||||||
if (tb[TCA_MIRRED_TM]) {
|
if (tb[TCA_MIRRED_TM]) {
|
||||||
struct tcf_t *tm = RTA_DATA(tb[TCA_MIRRED_TM]);
|
struct tcf_t *tm = RTA_DATA(tb[TCA_MIRRED_TM]);
|
||||||
|
|
||||||
print_tm(f, tm);
|
print_tm(f, tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,7 @@ print_nat(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
struct rtattr *tb[TCA_NAT_MAX + 1];
|
struct rtattr *tb[TCA_NAT_MAX + 1];
|
||||||
char buf1[256];
|
char buf1[256];
|
||||||
char buf2[256];
|
char buf2[256];
|
||||||
|
|
||||||
SPRINT_BUF(buf3);
|
SPRINT_BUF(buf3);
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
|
@ -198,6 +199,7 @@ print_nat(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
if (show_stats) {
|
if (show_stats) {
|
||||||
if (tb[TCA_NAT_TM]) {
|
if (tb[TCA_NAT_TM]) {
|
||||||
struct tcf_t *tm = RTA_DATA(tb[TCA_NAT_TM]);
|
struct tcf_t *tm = RTA_DATA(tb[TCA_NAT_TM]);
|
||||||
|
|
||||||
print_tm(f, tm);
|
print_tm(f, tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
25
tc/m_pedit.c
25
tc/m_pedit.c
|
|
@ -38,14 +38,10 @@ explain(void)
|
||||||
fprintf(stderr, "Usage: ... pedit munge <MUNGE> [<BRANCH>]\n");
|
fprintf(stderr, "Usage: ... pedit munge <MUNGE> [<BRANCH>]\n");
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Where: MUNGE := <RAW>|<LAYERED>\n"
|
"Where: MUNGE := <RAW>|<LAYERED>\n"
|
||||||
"\t<RAW>:= <OFFSETC>[ATC]<CMD>\n "
|
"\t<RAW>:= <OFFSETC>[ATC]<CMD>\n \t\tOFFSETC:= offset <offval> <u8|u16|u32>\n "
|
||||||
"\t\tOFFSETC:= offset <offval> <u8|u16|u32>\n "
|
"\t\tATC:= at <atval> offmask <maskval> shift <shiftval>\n \t\tNOTE: offval is byte offset, must be multiple of 4\n "
|
||||||
"\t\tATC:= at <atval> offmask <maskval> shift <shiftval>\n "
|
"\t\tNOTE: maskval is a 32 bit hex number\n \t\tNOTE: shiftval is a is a shift value\n "
|
||||||
"\t\tNOTE: offval is byte offset, must be multiple of 4\n "
|
"\t\tCMD:= clear | invert | set <setval>| retain\n \t<LAYERED>:= ip <ipdata> | ip6 <ip6data> \n "
|
||||||
"\t\tNOTE: maskval is a 32 bit hex number\n "
|
|
||||||
"\t\tNOTE: shiftval is a is a shift value\n "
|
|
||||||
"\t\tCMD:= clear | invert | set <setval>| retain\n "
|
|
||||||
"\t<LAYERED>:= ip <ipdata> | ip6 <ip6data> \n "
|
|
||||||
" \t\t| udp <udpdata> | tcp <tcpdata> | icmp <icmpdata>\n"
|
" \t\t| udp <udpdata> | tcp <tcpdata> | icmp <icmpdata>\n"
|
||||||
"\t<BRANCH>:= reclassify | pipe | drop | continue | pass\n"
|
"\t<BRANCH>:= reclassify | pipe | drop | continue | pass\n"
|
||||||
"For Example usage look at the examples directory\n");
|
"For Example usage look at the examples directory\n");
|
||||||
|
|
@ -219,21 +215,22 @@ parse_val(int *argc_p, char ***argv_p, __u32 * val, int type)
|
||||||
if (argc <= 0)
|
if (argc <= 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (TINT == type)
|
if (type == TINT)
|
||||||
return get_integer((int *) val, *argv, 0);
|
return get_integer((int *) val, *argv, 0);
|
||||||
|
|
||||||
if (TU32 == type)
|
if (type == TU32)
|
||||||
return get_u32(val, *argv, 0);
|
return get_u32(val, *argv, 0);
|
||||||
|
|
||||||
if (TIPV4 == type) {
|
if (type == TIPV4) {
|
||||||
inet_prefix addr;
|
inet_prefix addr;
|
||||||
|
|
||||||
if (get_prefix_1(&addr, *argv, AF_INET)) {
|
if (get_prefix_1(&addr, *argv, AF_INET)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*val = addr.data[0];
|
*val = addr.data[0];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (TIPV6 == type) {
|
if (type == TIPV6) {
|
||||||
/* not implemented yet */
|
/* not implemented yet */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -411,7 +408,7 @@ parse_munge(int *argc_p, char ***argv_p,struct tc_pedit_sel *sel)
|
||||||
|
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
p = get_pedit_kind(k);
|
p = get_pedit_kind(k);
|
||||||
if (NULL == p)
|
if (p == NULL)
|
||||||
goto bad_val;
|
goto bad_val;
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
res = p->parse_peopt(&argc, &argv, sel, &tkey);
|
res = p->parse_peopt(&argc, &argv, sel, &tkey);
|
||||||
|
|
@ -529,6 +526,7 @@ print_pedit(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
{
|
{
|
||||||
struct tc_pedit_sel *sel;
|
struct tc_pedit_sel *sel;
|
||||||
struct rtattr *tb[TCA_PEDIT_MAX + 1];
|
struct rtattr *tb[TCA_PEDIT_MAX + 1];
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
|
|
||||||
if (arg == NULL)
|
if (arg == NULL)
|
||||||
|
|
@ -548,6 +546,7 @@ print_pedit(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
if (show_stats) {
|
if (show_stats) {
|
||||||
if (tb[TCA_PEDIT_TM]) {
|
if (tb[TCA_PEDIT_TM]) {
|
||||||
struct tcf_t *tm = RTA_DATA(tb[TCA_PEDIT_TM]);
|
struct tcf_t *tm = RTA_DATA(tb[TCA_PEDIT_TM]);
|
||||||
|
|
||||||
print_tm(f, tm);
|
print_tm(f, tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@ static int police_action_a2n(const char *arg, int *result)
|
||||||
res = TC_POLICE_PIPE;
|
res = TC_POLICE_PIPE;
|
||||||
else {
|
else {
|
||||||
char dummy;
|
char dummy;
|
||||||
|
|
||||||
if (sscanf(arg, "%d%c", &res, &dummy) != 1)
|
if (sscanf(arg, "%d%c", &res, &dummy) != 1)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -323,7 +324,7 @@ print_police(struct action_util *a, FILE *f, struct rtattr *arg)
|
||||||
SPRINT_BUF(b2);
|
SPRINT_BUF(b2);
|
||||||
struct tc_police *p;
|
struct tc_police *p;
|
||||||
struct rtattr *tb[TCA_POLICE_MAX+1];
|
struct rtattr *tb[TCA_POLICE_MAX+1];
|
||||||
unsigned buffer;
|
unsigned int buffer;
|
||||||
unsigned int linklayer;
|
unsigned int linklayer;
|
||||||
|
|
||||||
if (arg == NULL)
|
if (arg == NULL)
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,7 @@ static int print_simple(struct action_util *au, FILE * f, struct rtattr *arg)
|
||||||
if (show_stats) {
|
if (show_stats) {
|
||||||
if (tb[TCA_DEF_TM]) {
|
if (tb[TCA_DEF_TM]) {
|
||||||
struct tcf_t *tm = RTA_DATA(tb[TCA_DEF_TM]);
|
struct tcf_t *tm = RTA_DATA(tb[TCA_DEF_TM]);
|
||||||
|
|
||||||
print_tm(f, tm);
|
print_tm(f, tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,7 @@ parse_skbedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
|
||||||
static int print_skbedit(struct action_util *au, FILE *f, struct rtattr *arg)
|
static int print_skbedit(struct action_util *au, FILE *f, struct rtattr *arg)
|
||||||
{
|
{
|
||||||
struct rtattr *tb[TCA_SKBEDIT_MAX + 1];
|
struct rtattr *tb[TCA_SKBEDIT_MAX + 1];
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
__u32 *priority;
|
__u32 *priority;
|
||||||
__u32 *mark;
|
__u32 *mark;
|
||||||
|
|
@ -198,6 +199,7 @@ static int print_skbedit(struct action_util *au, FILE *f, struct rtattr *arg)
|
||||||
if (show_stats) {
|
if (show_stats) {
|
||||||
if (tb[TCA_SKBEDIT_TM]) {
|
if (tb[TCA_SKBEDIT_TM]) {
|
||||||
struct tcf_t *tm = RTA_DATA(tb[TCA_SKBEDIT_TM]);
|
struct tcf_t *tm = RTA_DATA(tb[TCA_SKBEDIT_TM]);
|
||||||
|
|
||||||
print_tm(f, tm);
|
print_tm(f, tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -211,6 +211,7 @@ static int print_vlan(struct action_util *au, FILE *f, struct rtattr *arg)
|
||||||
if (show_stats) {
|
if (show_stats) {
|
||||||
if (tb[TCA_VLAN_TM]) {
|
if (tb[TCA_VLAN_TM]) {
|
||||||
struct tcf_t *tm = RTA_DATA(tb[TCA_VLAN_TM]);
|
struct tcf_t *tm = RTA_DATA(tb[TCA_VLAN_TM]);
|
||||||
|
|
||||||
print_tm(f, tm);
|
print_tm(f, tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
19
tc/m_xt.c
19
tc/m_xt.c
|
|
@ -87,7 +87,7 @@ build_st(struct xtables_target *target, struct xt_entry_target *t)
|
||||||
size_t size =
|
size_t size =
|
||||||
XT_ALIGN(sizeof(struct xt_entry_target)) + target->size;
|
XT_ALIGN(sizeof(struct xt_entry_target)) + target->size;
|
||||||
|
|
||||||
if (NULL == t) {
|
if (t == NULL) {
|
||||||
target->t = xtables_calloc(1, size);
|
target->t = xtables_calloc(1, size);
|
||||||
target->t->u.target_size = size;
|
target->t->u.target_size = size;
|
||||||
strcpy(target->t->u.user.name, target->name);
|
strcpy(target->t->u.user.name, target->name);
|
||||||
|
|
@ -138,6 +138,7 @@ static int parse_ipt(struct action_util *a,int *argc_p,
|
||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < rargc; i++) {
|
for (i = 0; i < rargc; i++) {
|
||||||
if (NULL == argv[i] || 0 == strcmp(argv[i], "action")) {
|
if (NULL == argv[i] || 0 == strcmp(argv[i], "action")) {
|
||||||
break;
|
break;
|
||||||
|
|
@ -158,9 +159,9 @@ static int parse_ipt(struct action_util *a,int *argc_p,
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'j':
|
case 'j':
|
||||||
m = xtables_find_target(optarg, XTF_TRY_LOAD);
|
m = xtables_find_target(optarg, XTF_TRY_LOAD);
|
||||||
if (NULL != m) {
|
if (m != NULL) {
|
||||||
|
|
||||||
if (0 > build_st(m, NULL)) {
|
if (build_st(m, NULL) < 0) {
|
||||||
printf(" %s error\n", m->name);
|
printf(" %s error\n", m->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -235,6 +236,7 @@ static int parse_ipt(struct action_util *a,int *argc_p,
|
||||||
|
|
||||||
{
|
{
|
||||||
struct tcmsg *t = NLMSG_DATA(n);
|
struct tcmsg *t = NLMSG_DATA(n);
|
||||||
|
|
||||||
if (t->tcm_parent != TC_H_ROOT
|
if (t->tcm_parent != TC_H_ROOT
|
||||||
&& t->tcm_parent == TC_H_MAJ(TC_H_INGRESS)) {
|
&& t->tcm_parent == TC_H_MAJ(TC_H_INGRESS)) {
|
||||||
hook = NF_IP_PRE_ROUTING;
|
hook = NF_IP_PRE_ROUTING;
|
||||||
|
|
@ -318,6 +320,7 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
__u32 hook;
|
__u32 hook;
|
||||||
|
|
||||||
hook = rta_getattr_u32(tb[TCA_IPT_HOOK]);
|
hook = rta_getattr_u32(tb[TCA_IPT_HOOK]);
|
||||||
fprintf(f, " hook: %s\n", ipthooks[hook]);
|
fprintf(f, " hook: %s\n", ipthooks[hook]);
|
||||||
}
|
}
|
||||||
|
|
@ -327,10 +330,11 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
struct xtables_target *m = NULL;
|
struct xtables_target *m = NULL;
|
||||||
|
|
||||||
t = RTA_DATA(tb[TCA_IPT_TARG]);
|
t = RTA_DATA(tb[TCA_IPT_TARG]);
|
||||||
m = xtables_find_target(t->u.user.name, XTF_TRY_LOAD);
|
m = xtables_find_target(t->u.user.name, XTF_TRY_LOAD);
|
||||||
if (NULL != m) {
|
if (m != NULL) {
|
||||||
if (0 > build_st(m, t)) {
|
if (build_st(m, t) < 0) {
|
||||||
fprintf(stderr, " %s error\n", m->name);
|
fprintf(stderr, " %s error\n", m->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -361,17 +365,20 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
fprintf(f, " [NULL ipt target index ]\n");
|
fprintf(f, " [NULL ipt target index ]\n");
|
||||||
} else {
|
} else {
|
||||||
__u32 index;
|
__u32 index;
|
||||||
|
|
||||||
index = rta_getattr_u32(tb[TCA_IPT_INDEX]);
|
index = rta_getattr_u32(tb[TCA_IPT_INDEX]);
|
||||||
fprintf(f, "\n\tindex %d", index);
|
fprintf(f, "\n\tindex %d", index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tb[TCA_IPT_CNT]) {
|
if (tb[TCA_IPT_CNT]) {
|
||||||
struct tc_cnt *c = RTA_DATA(tb[TCA_IPT_CNT]);;
|
struct tc_cnt *c = RTA_DATA(tb[TCA_IPT_CNT]);
|
||||||
|
|
||||||
fprintf(f, " ref %d bind %d", c->refcnt, c->bindcnt);
|
fprintf(f, " ref %d bind %d", c->refcnt, c->bindcnt);
|
||||||
}
|
}
|
||||||
if (show_stats) {
|
if (show_stats) {
|
||||||
if (tb[TCA_IPT_TM]) {
|
if (tb[TCA_IPT_TM]) {
|
||||||
struct tcf_t *tm = RTA_DATA(tb[TCA_IPT_TM]);
|
struct tcf_t *tm = RTA_DATA(tb[TCA_IPT_TM]);
|
||||||
|
|
||||||
print_tm(f, tm);
|
print_tm(f, tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ static struct option original_opts[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct option *opts = original_opts;
|
static struct option *opts = original_opts;
|
||||||
static unsigned int global_option_offset = 0;
|
static unsigned int global_option_offset;
|
||||||
char *lib_dir;
|
char *lib_dir;
|
||||||
const char *program_version = XTABLES_VERSION;
|
const char *program_version = XTABLES_VERSION;
|
||||||
const char *program_name = "tc-ipt";
|
const char *program_name = "tc-ipt";
|
||||||
|
|
@ -175,7 +175,7 @@ build_st(struct xtables_target *target, struct xt_entry_target *t)
|
||||||
size_t size =
|
size_t size =
|
||||||
XT_ALIGN(sizeof(struct xt_entry_target)) + target->size;
|
XT_ALIGN(sizeof(struct xt_entry_target)) + target->size;
|
||||||
|
|
||||||
if (NULL == t) {
|
if (t == NULL) {
|
||||||
target->t = fw_calloc(1, size);
|
target->t = fw_calloc(1, size);
|
||||||
target->t->u.target_size = size;
|
target->t->u.target_size = size;
|
||||||
strcpy(target->t->u.user.name, target->name);
|
strcpy(target->t->u.user.name, target->name);
|
||||||
|
|
@ -223,6 +223,7 @@ static int parse_ipt(struct action_util *a,int *argc_p,
|
||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < rargc; i++) {
|
for (i = 0; i < rargc; i++) {
|
||||||
if (NULL == argv[i] || 0 == strcmp(argv[i], "action")) {
|
if (NULL == argv[i] || 0 == strcmp(argv[i], "action")) {
|
||||||
break;
|
break;
|
||||||
|
|
@ -243,9 +244,9 @@ static int parse_ipt(struct action_util *a,int *argc_p,
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'j':
|
case 'j':
|
||||||
m = find_target(optarg, TRY_LOAD);
|
m = find_target(optarg, TRY_LOAD);
|
||||||
if (NULL != m) {
|
if (m != NULL) {
|
||||||
|
|
||||||
if (0 > build_st(m, NULL)) {
|
if (build_st(m, NULL) < 0) {
|
||||||
printf(" %s error\n", m->name);
|
printf(" %s error\n", m->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -299,6 +300,7 @@ static int parse_ipt(struct action_util *a,int *argc_p,
|
||||||
|
|
||||||
{
|
{
|
||||||
struct tcmsg *t = NLMSG_DATA(n);
|
struct tcmsg *t = NLMSG_DATA(n);
|
||||||
|
|
||||||
if (t->tcm_parent != TC_H_ROOT
|
if (t->tcm_parent != TC_H_ROOT
|
||||||
&& t->tcm_parent == TC_H_MAJ(TC_H_INGRESS)) {
|
&& t->tcm_parent == TC_H_MAJ(TC_H_INGRESS)) {
|
||||||
hook = NF_IP_PRE_ROUTING;
|
hook = NF_IP_PRE_ROUTING;
|
||||||
|
|
@ -375,6 +377,7 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
__u32 hook;
|
__u32 hook;
|
||||||
|
|
||||||
hook = rta_getattr_u32(tb[TCA_IPT_HOOK]);
|
hook = rta_getattr_u32(tb[TCA_IPT_HOOK]);
|
||||||
fprintf(f, " hook: %s\n", ipthooks[hook]);
|
fprintf(f, " hook: %s\n", ipthooks[hook]);
|
||||||
}
|
}
|
||||||
|
|
@ -384,10 +387,11 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
struct xtables_target *m = NULL;
|
struct xtables_target *m = NULL;
|
||||||
|
|
||||||
t = RTA_DATA(tb[TCA_IPT_TARG]);
|
t = RTA_DATA(tb[TCA_IPT_TARG]);
|
||||||
m = find_target(t->u.user.name, TRY_LOAD);
|
m = find_target(t->u.user.name, TRY_LOAD);
|
||||||
if (NULL != m) {
|
if (m != NULL) {
|
||||||
if (0 > build_st(m, t)) {
|
if (build_st(m, t) < 0) {
|
||||||
fprintf(stderr, " %s error\n", m->name);
|
fprintf(stderr, " %s error\n", m->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -406,17 +410,20 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
|
||||||
fprintf(f, " [NULL ipt target index ]\n");
|
fprintf(f, " [NULL ipt target index ]\n");
|
||||||
} else {
|
} else {
|
||||||
__u32 index;
|
__u32 index;
|
||||||
|
|
||||||
index = rta_getattr_u32(tb[TCA_IPT_INDEX]);
|
index = rta_getattr_u32(tb[TCA_IPT_INDEX]);
|
||||||
fprintf(f, "\n\tindex %d", index);
|
fprintf(f, "\n\tindex %d", index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tb[TCA_IPT_CNT]) {
|
if (tb[TCA_IPT_CNT]) {
|
||||||
struct tc_cnt *c = RTA_DATA(tb[TCA_IPT_CNT]);;
|
struct tc_cnt *c = RTA_DATA(tb[TCA_IPT_CNT]);
|
||||||
|
|
||||||
fprintf(f, " ref %d bind %d", c->refcnt, c->bindcnt);
|
fprintf(f, " ref %d bind %d", c->refcnt, c->bindcnt);
|
||||||
}
|
}
|
||||||
if (show_stats) {
|
if (show_stats) {
|
||||||
if (tb[TCA_IPT_TM]) {
|
if (tb[TCA_IPT_TM]) {
|
||||||
struct tcf_t *tm = RTA_DATA(tb[TCA_IPT_TM]);
|
struct tcf_t *tm = RTA_DATA(tb[TCA_IPT_TM]);
|
||||||
|
|
||||||
print_tm(f, tm);
|
print_tm(f, tm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
30
tc/q_atm.c
30
tc/q_atm.c
|
|
@ -39,10 +39,8 @@ static int atm_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
|
||||||
|
|
||||||
static void explain(void)
|
static void explain(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: ... atm ( pvc ADDR | svc ADDR [ sap SAP ] ) "
|
fprintf(stderr, "Usage: ... atm ( pvc ADDR | svc ADDR [ sap SAP ] ) [ qos QOS ] [ sndbuf BYTES ]\n");
|
||||||
"[ qos QOS ] [ sndbuf BYTES ]\n");
|
fprintf(stderr, " [ hdr HEX... ] [ excess ( CLASSID | clp ) ] [ clip ]\n");
|
||||||
fprintf(stderr, " [ hdr HEX... ] [ excess ( CLASSID | clp ) ] "
|
|
||||||
"[ clip ]\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -71,23 +69,20 @@ static int atm_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
|
||||||
explain();
|
explain();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
} else if (!strcmp(*argv,"svc")) {
|
||||||
else if (!strcmp(*argv,"svc")) {
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (text2atm(*argv, (struct sockaddr *) &addr,
|
if (text2atm(*argv, (struct sockaddr *) &addr,
|
||||||
sizeof(addr), T2A_SVC | T2A_NAME) < 0) {
|
sizeof(addr), T2A_SVC | T2A_NAME) < 0) {
|
||||||
explain();
|
explain();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
} else if (!strcmp(*argv,"qos")) {
|
||||||
else if (!strcmp(*argv,"qos")) {
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (text2qos(*argv, &qos, 0) < 0) {
|
if (text2qos(*argv, &qos, 0) < 0) {
|
||||||
explain();
|
explain();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
} else if (!strcmp(*argv,"sndbuf")) {
|
||||||
else if (!strcmp(*argv,"sndbuf")) {
|
|
||||||
char *end;
|
char *end;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
|
|
@ -96,16 +91,14 @@ static int atm_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
|
||||||
explain();
|
explain();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
} else if (!strcmp(*argv,"sap")) {
|
||||||
else if (!strcmp(*argv,"sap")) {
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (addr.sas_family != AF_ATMSVC ||
|
if (addr.sas_family != AF_ATMSVC ||
|
||||||
text2sap(*argv, &sap, T2A_NAME) < 0) {
|
text2sap(*argv, &sap, T2A_NAME) < 0) {
|
||||||
explain();
|
explain();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
} else if (!strcmp(*argv,"hdr")) {
|
||||||
else if (!strcmp(*argv,"hdr")) {
|
|
||||||
unsigned char *ptr;
|
unsigned char *ptr;
|
||||||
char *walk;
|
char *walk;
|
||||||
|
|
||||||
|
|
@ -129,19 +122,16 @@ static int atm_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
|
||||||
walk++;
|
walk++;
|
||||||
}
|
}
|
||||||
hdr_len = ptr-hdr;
|
hdr_len = ptr-hdr;
|
||||||
}
|
} else if (!strcmp(*argv,"excess")) {
|
||||||
else if (!strcmp(*argv,"excess")) {
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (!strcmp(*argv, "clp")) excess = 0;
|
if (!strcmp(*argv, "clp")) excess = 0;
|
||||||
else if (get_tc_classid(&excess, *argv)) {
|
else if (get_tc_classid(&excess, *argv)) {
|
||||||
explain();
|
explain();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
} else if (!strcmp(*argv,"clip")) {
|
||||||
else if (!strcmp(*argv,"clip")) {
|
|
||||||
set_clip = 1;
|
set_clip = 1;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
explain();
|
explain();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
26
tc/q_cbq.c
26
tc/q_cbq.c
|
|
@ -81,8 +81,9 @@ static int cbq_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (matches(*argv, "cell") == 0) {
|
} else if (matches(*argv, "cell") == 0) {
|
||||||
unsigned cell;
|
unsigned int cell;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_size(&cell, *argv)) {
|
if (get_size(&cell, *argv)) {
|
||||||
explain1("cell");
|
explain1("cell");
|
||||||
|
|
@ -170,6 +171,7 @@ static int cbq_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
|
||||||
addattr_l(n, 3024, TCA_CBQ_RTAB, rtab, 1024);
|
addattr_l(n, 3024, TCA_CBQ_RTAB, rtab, 1024);
|
||||||
if (show_raw) {
|
if (show_raw) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
printf("%u ", rtab[i]);
|
printf("%u ", rtab[i]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
@ -190,7 +192,7 @@ static int cbq_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, str
|
||||||
unsigned mpu = 0;
|
unsigned mpu = 0;
|
||||||
int cell_log = -1;
|
int cell_log = -1;
|
||||||
int ewma_log = -1;
|
int ewma_log = -1;
|
||||||
unsigned bndw = 0;
|
unsigned int bndw = 0;
|
||||||
unsigned minburst = 0, maxburst = 0;
|
unsigned minburst = 0, maxburst = 0;
|
||||||
unsigned short overhead = 0;
|
unsigned short overhead = 0;
|
||||||
unsigned int linklayer = LINKLAYER_ETHERNET; /* Assume ethernet */
|
unsigned int linklayer = LINKLAYER_ETHERNET; /* Assume ethernet */
|
||||||
|
|
@ -260,8 +262,9 @@ static int cbq_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, str
|
||||||
}
|
}
|
||||||
lss.change |= TCF_CBQ_LSS_EWMA;
|
lss.change |= TCF_CBQ_LSS_EWMA;
|
||||||
} else if (matches(*argv, "cell") == 0) {
|
} else if (matches(*argv, "cell") == 0) {
|
||||||
unsigned cell;
|
unsigned int cell;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_size(&cell, *argv)) {
|
if (get_size(&cell, *argv)) {
|
||||||
explain1("cell");
|
explain1("cell");
|
||||||
|
|
@ -276,7 +279,8 @@ static int cbq_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, str
|
||||||
}
|
}
|
||||||
cell_log = i;
|
cell_log = i;
|
||||||
} else if (matches(*argv, "prio") == 0) {
|
} else if (matches(*argv, "prio") == 0) {
|
||||||
unsigned prio;
|
unsigned int prio;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (get_u32(&prio, *argv, 0)) {
|
if (get_u32(&prio, *argv, 0)) {
|
||||||
explain1("prio");
|
explain1("prio");
|
||||||
|
|
@ -323,6 +327,7 @@ static int cbq_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, str
|
||||||
fopt_ok++;
|
fopt_ok++;
|
||||||
} else if (matches(*argv, "defmap") == 0) {
|
} else if (matches(*argv, "defmap") == 0) {
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
err = sscanf(*argv, "%08x/%08x", &fopt.defmap, &fopt.defchange);
|
err = sscanf(*argv, "%08x/%08x", &fopt.defmap, &fopt.defchange);
|
||||||
if (err < 1) {
|
if (err < 1) {
|
||||||
|
|
@ -357,7 +362,8 @@ static int cbq_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, str
|
||||||
|
|
||||||
/* 1. Prepare link sharing scheduler parameters */
|
/* 1. Prepare link sharing scheduler parameters */
|
||||||
if (r.rate) {
|
if (r.rate) {
|
||||||
unsigned pktsize = wrr.allot;
|
unsigned int pktsize = wrr.allot;
|
||||||
|
|
||||||
if (wrr.allot < (lss.avpkt*3)/2)
|
if (wrr.allot < (lss.avpkt*3)/2)
|
||||||
wrr.allot = (lss.avpkt*3)/2;
|
wrr.allot = (lss.avpkt*3)/2;
|
||||||
r.mpu = mpu;
|
r.mpu = mpu;
|
||||||
|
|
@ -424,6 +430,7 @@ static int cbq_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, str
|
||||||
addattr_l(n, 3024, TCA_CBQ_RTAB, rtab, 1024);
|
addattr_l(n, 3024, TCA_CBQ_RTAB, rtab, 1024);
|
||||||
if (show_raw) {
|
if (show_raw) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
printf("%u ", rtab[i]);
|
printf("%u ", rtab[i]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
@ -443,6 +450,7 @@ static int cbq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
struct tc_cbq_fopt *fopt = NULL;
|
struct tc_cbq_fopt *fopt = NULL;
|
||||||
struct tc_cbq_ovl *ovl = NULL;
|
struct tc_cbq_ovl *ovl = NULL;
|
||||||
unsigned int linklayer;
|
unsigned int linklayer;
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
SPRINT_BUF(b2);
|
SPRINT_BUF(b2);
|
||||||
|
|
||||||
|
|
@ -478,14 +486,15 @@ static int cbq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
if (tb[TCA_CBQ_OVL_STRATEGY]) {
|
if (tb[TCA_CBQ_OVL_STRATEGY]) {
|
||||||
if (RTA_PAYLOAD(tb[TCA_CBQ_OVL_STRATEGY]) < sizeof(*ovl))
|
if (RTA_PAYLOAD(tb[TCA_CBQ_OVL_STRATEGY]) < sizeof(*ovl))
|
||||||
fprintf(stderr, "CBQ: too short overlimit strategy %u/%u\n",
|
fprintf(stderr, "CBQ: too short overlimit strategy %u/%u\n",
|
||||||
(unsigned) RTA_PAYLOAD(tb[TCA_CBQ_OVL_STRATEGY]),
|
(unsigned int) RTA_PAYLOAD(tb[TCA_CBQ_OVL_STRATEGY]),
|
||||||
(unsigned) sizeof(*ovl));
|
(unsigned int) sizeof(*ovl));
|
||||||
else
|
else
|
||||||
ovl = RTA_DATA(tb[TCA_CBQ_OVL_STRATEGY]);
|
ovl = RTA_DATA(tb[TCA_CBQ_OVL_STRATEGY]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r) {
|
if (r) {
|
||||||
char buf[64];
|
char buf[64];
|
||||||
|
|
||||||
print_rate(buf, sizeof(buf), r->rate);
|
print_rate(buf, sizeof(buf), r->rate);
|
||||||
fprintf(f, "rate %s ", buf);
|
fprintf(f, "rate %s ", buf);
|
||||||
linklayer = (r->linklayer & TC_LINKLAYER_MASK);
|
linklayer = (r->linklayer & TC_LINKLAYER_MASK);
|
||||||
|
|
@ -501,6 +510,7 @@ static int cbq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
}
|
}
|
||||||
if (lss && lss->flags) {
|
if (lss && lss->flags) {
|
||||||
int comma = 0;
|
int comma = 0;
|
||||||
|
|
||||||
fprintf(f, "(");
|
fprintf(f, "(");
|
||||||
if (lss->flags&TCF_CBQ_LSS_BOUNDED) {
|
if (lss->flags&TCF_CBQ_LSS_BOUNDED) {
|
||||||
fprintf(f, "bounded");
|
fprintf(f, "bounded");
|
||||||
|
|
@ -520,6 +530,7 @@ static int cbq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
fprintf(f, "prio no-transmit");
|
fprintf(f, "prio no-transmit");
|
||||||
if (show_details) {
|
if (show_details) {
|
||||||
char buf[64];
|
char buf[64];
|
||||||
|
|
||||||
fprintf(f, "/%u ", wrr->cpriority);
|
fprintf(f, "/%u ", wrr->cpriority);
|
||||||
if (wrr->weight != 1) {
|
if (wrr->weight != 1) {
|
||||||
print_rate(buf, sizeof(buf), wrr->weight);
|
print_rate(buf, sizeof(buf), wrr->weight);
|
||||||
|
|
@ -549,6 +560,7 @@ static int cbq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
}
|
}
|
||||||
if (fopt && show_details) {
|
if (fopt && show_details) {
|
||||||
char buf[64];
|
char buf[64];
|
||||||
|
|
||||||
print_tc_classid(buf, sizeof(buf), fopt->split);
|
print_tc_classid(buf, sizeof(buf), fopt->split);
|
||||||
fprintf(f, "\nsplit %s ", buf);
|
fprintf(f, "\nsplit %s ", buf);
|
||||||
if (fopt->defmap) {
|
if (fopt->defmap) {
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,10 @@ static int choke_parse_opt(struct qdisc_util *qu, int argc, char **argv,
|
||||||
struct nlmsghdr *n)
|
struct nlmsghdr *n)
|
||||||
{
|
{
|
||||||
struct tc_red_qopt opt;
|
struct tc_red_qopt opt;
|
||||||
unsigned burst = 0;
|
unsigned int burst = 0;
|
||||||
unsigned avpkt = 1000;
|
unsigned int avpkt = 1000;
|
||||||
double probability = 0.02;
|
double probability = 0.02;
|
||||||
unsigned rate = 0;
|
unsigned int rate = 0;
|
||||||
int ecn_ok = 0;
|
int ecn_ok = 0;
|
||||||
int wlog;
|
int wlog;
|
||||||
__u8 sbuf[256];
|
__u8 sbuf[256];
|
||||||
|
|
|
||||||
20
tc/q_codel.c
20
tc/q_codel.c
|
|
@ -61,10 +61,10 @@ static void explain(void)
|
||||||
static int codel_parse_opt(struct qdisc_util *qu, int argc, char **argv,
|
static int codel_parse_opt(struct qdisc_util *qu, int argc, char **argv,
|
||||||
struct nlmsghdr *n)
|
struct nlmsghdr *n)
|
||||||
{
|
{
|
||||||
unsigned limit = 0;
|
unsigned int limit = 0;
|
||||||
unsigned target = 0;
|
unsigned int target = 0;
|
||||||
unsigned interval = 0;
|
unsigned int interval = 0;
|
||||||
unsigned ce_threshold = ~0U;
|
unsigned int ce_threshold = ~0U;
|
||||||
int ecn = -1;
|
int ecn = -1;
|
||||||
struct rtattr *tail;
|
struct rtattr *tail;
|
||||||
|
|
||||||
|
|
@ -129,11 +129,12 @@ static int codel_parse_opt(struct qdisc_util *qu, int argc, char **argv,
|
||||||
static int codel_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
static int codel_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
{
|
{
|
||||||
struct rtattr *tb[TCA_CODEL_MAX + 1];
|
struct rtattr *tb[TCA_CODEL_MAX + 1];
|
||||||
unsigned limit;
|
unsigned int limit;
|
||||||
unsigned interval;
|
unsigned int interval;
|
||||||
unsigned target;
|
unsigned int target;
|
||||||
unsigned ecn;
|
unsigned int ecn;
|
||||||
unsigned ce_threshold;
|
unsigned int ce_threshold;
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
|
|
||||||
if (opt == NULL)
|
if (opt == NULL)
|
||||||
|
|
@ -175,6 +176,7 @@ static int codel_print_xstats(struct qdisc_util *qu, FILE *f,
|
||||||
struct rtattr *xstats)
|
struct rtattr *xstats)
|
||||||
{
|
{
|
||||||
struct tc_codel_xstats _st, *st;
|
struct tc_codel_xstats _st, *st;
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
|
|
||||||
if (xstats == NULL)
|
if (xstats == NULL)
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ static int drr_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
|
||||||
static int drr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
static int drr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
{
|
{
|
||||||
struct rtattr *tb[TCA_DRR_MAX + 1];
|
struct rtattr *tb[TCA_DRR_MAX + 1];
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
|
|
||||||
if (opt == NULL)
|
if (opt == NULL)
|
||||||
|
|
@ -100,6 +101,7 @@ static int drr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
static int drr_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
|
static int drr_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
|
||||||
{
|
{
|
||||||
struct tc_drr_stats *x;
|
struct tc_drr_stats *x;
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
|
|
||||||
if (xstats == NULL)
|
if (xstats == NULL)
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,7 @@
|
||||||
|
|
||||||
static void explain(void)
|
static void explain(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Usage: dsmark indices INDICES [ default_index "
|
fprintf(stderr,"Usage: dsmark indices INDICES [ default_index DEFAULT_INDEX ] [ set_tc_index ]\n");
|
||||||
"DEFAULT_INDEX ] [ set_tc_index ]\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -44,8 +43,7 @@ static int dsmark_parse_opt(struct qdisc_util *qu, int argc, char **argv,
|
||||||
explain();
|
explain();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
} else if (!strcmp(*argv,"default_index") || !strcmp(*argv,
|
||||||
else if (!strcmp(*argv,"default_index") || !strcmp(*argv,
|
|
||||||
"default")) {
|
"default")) {
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
dflt = strtoul(*argv, &end, 0);
|
dflt = strtoul(*argv, &end, 0);
|
||||||
|
|
@ -53,11 +51,9 @@ static int dsmark_parse_opt(struct qdisc_util *qu, int argc, char **argv,
|
||||||
explain();
|
explain();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
} else if (!strcmp(*argv,"set_tc_index")) {
|
||||||
else if (!strcmp(*argv,"set_tc_index")) {
|
|
||||||
set_tc_index = 1;
|
set_tc_index = 1;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
explain();
|
explain();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -106,8 +102,7 @@ static int dsmark_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
addattr_l(n, 1024, TCA_DSMARK_MASK, &tmp, 1);
|
addattr_l(n, 1024, TCA_DSMARK_MASK, &tmp, 1);
|
||||||
}
|
} else if (!strcmp(*argv,"value")) {
|
||||||
else if (!strcmp(*argv,"value")) {
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
tmp = strtoul(*argv, &end, 0);
|
tmp = strtoul(*argv, &end, 0);
|
||||||
if (*end) {
|
if (*end) {
|
||||||
|
|
@ -115,8 +110,7 @@ static int dsmark_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
addattr_l(n, 1024, TCA_DSMARK_VALUE, &tmp, 1);
|
addattr_l(n, 1024, TCA_DSMARK_VALUE, &tmp, 1);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
explain_class();
|
explain_class();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ static int fifo_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct n
|
||||||
{
|
{
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
struct tc_fifo_qopt opt;
|
struct tc_fifo_qopt opt;
|
||||||
|
|
||||||
memset(&opt, 0, sizeof(opt));
|
memset(&opt, 0, sizeof(opt));
|
||||||
|
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,7 @@ static int fq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
unsigned int rate, quantum;
|
unsigned int rate, quantum;
|
||||||
unsigned int refill_delay;
|
unsigned int refill_delay;
|
||||||
unsigned int orphan_mask;
|
unsigned int orphan_mask;
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
|
|
||||||
if (opt == NULL)
|
if (opt == NULL)
|
||||||
|
|
|
||||||
|
|
@ -59,12 +59,12 @@ static void explain(void)
|
||||||
static int fq_codel_parse_opt(struct qdisc_util *qu, int argc, char **argv,
|
static int fq_codel_parse_opt(struct qdisc_util *qu, int argc, char **argv,
|
||||||
struct nlmsghdr *n)
|
struct nlmsghdr *n)
|
||||||
{
|
{
|
||||||
unsigned limit = 0;
|
unsigned int limit = 0;
|
||||||
unsigned flows = 0;
|
unsigned int flows = 0;
|
||||||
unsigned target = 0;
|
unsigned int target = 0;
|
||||||
unsigned interval = 0;
|
unsigned int interval = 0;
|
||||||
unsigned quantum = 0;
|
unsigned int quantum = 0;
|
||||||
unsigned ce_threshold = ~0U;
|
unsigned int ce_threshold = ~0U;
|
||||||
int ecn = -1;
|
int ecn = -1;
|
||||||
struct rtattr *tail;
|
struct rtattr *tail;
|
||||||
|
|
||||||
|
|
@ -144,13 +144,14 @@ static int fq_codel_parse_opt(struct qdisc_util *qu, int argc, char **argv,
|
||||||
static int fq_codel_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
static int fq_codel_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
{
|
{
|
||||||
struct rtattr *tb[TCA_FQ_CODEL_MAX + 1];
|
struct rtattr *tb[TCA_FQ_CODEL_MAX + 1];
|
||||||
unsigned limit;
|
unsigned int limit;
|
||||||
unsigned flows;
|
unsigned int flows;
|
||||||
unsigned interval;
|
unsigned int interval;
|
||||||
unsigned target;
|
unsigned int target;
|
||||||
unsigned ecn;
|
unsigned int ecn;
|
||||||
unsigned quantum;
|
unsigned int quantum;
|
||||||
unsigned ce_threshold;
|
unsigned int ce_threshold;
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
|
|
||||||
if (opt == NULL)
|
if (opt == NULL)
|
||||||
|
|
@ -202,6 +203,7 @@ static int fq_codel_print_xstats(struct qdisc_util *qu, FILE *f,
|
||||||
struct rtattr *xstats)
|
struct rtattr *xstats)
|
||||||
{
|
{
|
||||||
struct tc_fq_codel_xstats _st, *st;
|
struct tc_fq_codel_xstats _st, *st;
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
|
|
||||||
if (xstats == NULL)
|
if (xstats == NULL)
|
||||||
|
|
|
||||||
33
tc/q_gred.c
33
tc/q_gred.c
|
|
@ -63,14 +63,13 @@ static int init_gred(struct qdisc_util *qu, int argc, char **argv,
|
||||||
fprintf(stderr, "Illegal \"vqs\"\n");
|
fprintf(stderr, "Illegal \"vqs\"\n");
|
||||||
return -1;
|
return -1;
|
||||||
} else if (opt.DPs > MAX_DPs) {
|
} else if (opt.DPs > MAX_DPs) {
|
||||||
fprintf(stderr, "GRED: only %u VQs are "
|
fprintf(stderr, "GRED: only %u VQs are currently supported\n",
|
||||||
"currently supported\n", MAX_DPs);
|
MAX_DPs);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (strcmp(*argv, "default") == 0) {
|
} else if (strcmp(*argv, "default") == 0) {
|
||||||
if (opt.DPs == 0) {
|
if (opt.DPs == 0) {
|
||||||
fprintf(stderr, "\"default\" must be defined "
|
fprintf(stderr, "\"default\" must be defined after \"vqs\"\n");
|
||||||
"after \"vqs\"\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
|
|
@ -78,8 +77,7 @@ static int init_gred(struct qdisc_util *qu, int argc, char **argv,
|
||||||
fprintf(stderr, "Illegal \"default\"\n");
|
fprintf(stderr, "Illegal \"default\"\n");
|
||||||
return -1;
|
return -1;
|
||||||
} else if (opt.def_DP >= opt.DPs) {
|
} else if (opt.def_DP >= opt.DPs) {
|
||||||
fprintf(stderr, "\"default\" must be less than "
|
fprintf(stderr, "\"default\" must be less than \"vqs\"\n");
|
||||||
"\"vqs\"\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (strcmp(*argv, "grio") == 0) {
|
} else if (strcmp(*argv, "grio") == 0) {
|
||||||
|
|
@ -123,10 +121,10 @@ static int gred_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct n
|
||||||
{
|
{
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
struct tc_gred_qopt opt = { 0 };
|
struct tc_gred_qopt opt = { 0 };
|
||||||
unsigned burst = 0;
|
unsigned int burst = 0;
|
||||||
unsigned avpkt = 0;
|
unsigned int avpkt = 0;
|
||||||
double probability = 0.02;
|
double probability = 0.02;
|
||||||
unsigned rate = 0;
|
unsigned int rate = 0;
|
||||||
int parm;
|
int parm;
|
||||||
__u8 sbuf[256];
|
__u8 sbuf[256];
|
||||||
struct rtattr *tail;
|
struct rtattr *tail;
|
||||||
|
|
@ -169,8 +167,8 @@ static int gred_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct n
|
||||||
fprintf(stderr, "Illegal \"vq\"\n");
|
fprintf(stderr, "Illegal \"vq\"\n");
|
||||||
return -1;
|
return -1;
|
||||||
} else if (opt.DP >= MAX_DPs) {
|
} else if (opt.DP >= MAX_DPs) {
|
||||||
fprintf(stderr, "GRED: only %u VQs are "
|
fprintf(stderr, "GRED: only %u VQs are currently supported\n",
|
||||||
"currently supported\n", MAX_DPs);
|
MAX_DPs);
|
||||||
return -1;
|
return -1;
|
||||||
} /* need a better error check */
|
} /* need a better error check */
|
||||||
ok++;
|
ok++;
|
||||||
|
|
@ -224,8 +222,7 @@ static int gred_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct n
|
||||||
}
|
}
|
||||||
if (opt.DP == MAX_DPs || !opt.limit || !opt.qth_min || !opt.qth_max ||
|
if (opt.DP == MAX_DPs || !opt.limit || !opt.qth_min || !opt.qth_max ||
|
||||||
!avpkt) {
|
!avpkt) {
|
||||||
fprintf(stderr, "Required parameter (vq, limit, min, max, "
|
fprintf(stderr, "Required parameter (vq, limit, min, max, avpkt) is missing\n");
|
||||||
"avpkt) is missing\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!burst) {
|
if (!burst) {
|
||||||
|
|
@ -241,8 +238,8 @@ static int gred_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct n
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (parm >= 10)
|
if (parm >= 10)
|
||||||
fprintf(stderr, "GRED: WARNING. Burst %u seems to be too "
|
fprintf(stderr, "GRED: WARNING. Burst %u seems to be too large.\n",
|
||||||
"large.\n", burst);
|
burst);
|
||||||
opt.Wlog = parm;
|
opt.Wlog = parm;
|
||||||
if ((parm = tc_red_eval_P(opt.qth_min, opt.qth_max, probability)) < 0) {
|
if ((parm = tc_red_eval_P(opt.qth_min, opt.qth_max, probability)) < 0) {
|
||||||
fprintf(stderr, "GRED: failed to calculate probability.\n");
|
fprintf(stderr, "GRED: failed to calculate probability.\n");
|
||||||
|
|
@ -251,8 +248,7 @@ static int gred_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct n
|
||||||
opt.Plog = parm;
|
opt.Plog = parm;
|
||||||
if ((parm = tc_red_eval_idle_damping(opt.Wlog, avpkt, rate, sbuf)) < 0)
|
if ((parm = tc_red_eval_idle_damping(opt.Wlog, avpkt, rate, sbuf)) < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "GRED: failed to calculate idle damping "
|
fprintf(stderr, "GRED: failed to calculate idle damping table.\n");
|
||||||
"table.\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
opt.Scell_log = parm;
|
opt.Scell_log = parm;
|
||||||
|
|
@ -274,7 +270,8 @@ static int gred_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
struct tc_gred_qopt *qopt;
|
struct tc_gred_qopt *qopt;
|
||||||
__u32 *max_p = NULL;
|
__u32 *max_p = NULL;
|
||||||
__u32 *limit = NULL;
|
__u32 *limit = NULL;
|
||||||
unsigned i;
|
unsigned int i;
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
SPRINT_BUF(b2);
|
SPRINT_BUF(b2);
|
||||||
SPRINT_BUF(b3);
|
SPRINT_BUF(b3);
|
||||||
|
|
|
||||||
|
|
@ -203,8 +203,7 @@ hfsc_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (usc_ok && !fsc_ok) {
|
if (usc_ok && !fsc_ok) {
|
||||||
fprintf(stderr, "HFSC: Upper-limit Service Curve without "
|
fprintf(stderr, "HFSC: Upper-limit Service Curve without Link-Share Service Curve\n");
|
||||||
"Link-Share Service Curve\n");
|
|
||||||
explain_class();
|
explain_class();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
29
tc/q_hhf.c
29
tc/q_hhf.c
|
|
@ -28,13 +28,13 @@ static void explain(void)
|
||||||
static int hhf_parse_opt(struct qdisc_util *qu, int argc, char **argv,
|
static int hhf_parse_opt(struct qdisc_util *qu, int argc, char **argv,
|
||||||
struct nlmsghdr *n)
|
struct nlmsghdr *n)
|
||||||
{
|
{
|
||||||
unsigned limit = 0;
|
unsigned int limit = 0;
|
||||||
unsigned quantum = 0;
|
unsigned int quantum = 0;
|
||||||
unsigned hh_limit = 0;
|
unsigned int hh_limit = 0;
|
||||||
unsigned reset_timeout = 0;
|
unsigned int reset_timeout = 0;
|
||||||
unsigned admit_bytes = 0;
|
unsigned int admit_bytes = 0;
|
||||||
unsigned evict_timeout = 0;
|
unsigned int evict_timeout = 0;
|
||||||
unsigned non_hh_weight = 0;
|
unsigned int non_hh_weight = 0;
|
||||||
struct rtattr *tail;
|
struct rtattr *tail;
|
||||||
|
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
|
|
@ -120,13 +120,14 @@ static int hhf_parse_opt(struct qdisc_util *qu, int argc, char **argv,
|
||||||
static int hhf_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
static int hhf_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
{
|
{
|
||||||
struct rtattr *tb[TCA_HHF_MAX + 1];
|
struct rtattr *tb[TCA_HHF_MAX + 1];
|
||||||
unsigned limit;
|
unsigned int limit;
|
||||||
unsigned quantum;
|
unsigned int quantum;
|
||||||
unsigned hh_limit;
|
unsigned int hh_limit;
|
||||||
unsigned reset_timeout;
|
unsigned int reset_timeout;
|
||||||
unsigned admit_bytes;
|
unsigned int admit_bytes;
|
||||||
unsigned evict_timeout;
|
unsigned int evict_timeout;
|
||||||
unsigned non_hh_weight;
|
unsigned int non_hh_weight;
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
|
|
||||||
if (opt == NULL)
|
if (opt == NULL)
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,8 @@ static int htb_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
|
||||||
unsigned int direct_qlen = ~0U;
|
unsigned int direct_qlen = ~0U;
|
||||||
struct tc_htb_glob opt;
|
struct tc_htb_glob opt;
|
||||||
struct rtattr *tail;
|
struct rtattr *tail;
|
||||||
unsigned i; char *p;
|
unsigned int i; char *p;
|
||||||
|
|
||||||
memset(&opt, 0, sizeof(opt));
|
memset(&opt, 0, sizeof(opt));
|
||||||
opt.rate2quantum = 10;
|
opt.rate2quantum = 10;
|
||||||
opt.version = 3;
|
opt.version = 3;
|
||||||
|
|
@ -116,7 +117,7 @@ static int htb_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, str
|
||||||
__u32 rtab[256], ctab[256];
|
__u32 rtab[256], ctab[256];
|
||||||
unsigned buffer = 0, cbuffer = 0;
|
unsigned buffer = 0, cbuffer = 0;
|
||||||
int cell_log = -1, ccell_log = -1;
|
int cell_log = -1, ccell_log = -1;
|
||||||
unsigned mtu;
|
unsigned int mtu;
|
||||||
unsigned short mpu = 0;
|
unsigned short mpu = 0;
|
||||||
unsigned short overhead = 0;
|
unsigned short overhead = 0;
|
||||||
unsigned int linklayer = LINKLAYER_ETHERNET; /* Assume ethernet */
|
unsigned int linklayer = LINKLAYER_ETHERNET; /* Assume ethernet */
|
||||||
|
|
@ -271,6 +272,7 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
double buffer, cbuffer;
|
double buffer, cbuffer;
|
||||||
unsigned int linklayer;
|
unsigned int linklayer;
|
||||||
__u64 rate64, ceil64;
|
__u64 rate64, ceil64;
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
SPRINT_BUF(b2);
|
SPRINT_BUF(b2);
|
||||||
SPRINT_BUF(b3);
|
SPRINT_BUF(b3);
|
||||||
|
|
@ -350,6 +352,7 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
static int htb_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
|
static int htb_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
|
||||||
{
|
{
|
||||||
struct tc_htb_xstats *st;
|
struct tc_htb_xstats *st;
|
||||||
|
|
||||||
if (xstats == NULL)
|
if (xstats == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ static const double max_percent_value = 0xffffffff;
|
||||||
/* scaled value used to percent of maximum. */
|
/* scaled value used to percent of maximum. */
|
||||||
static void set_percent(__u32 *percent, double per)
|
static void set_percent(__u32 *percent, double per)
|
||||||
{
|
{
|
||||||
*percent = (unsigned) rint(per * max_percent_value);
|
*percent = (unsigned int) rint(per * max_percent_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -123,6 +123,7 @@ static int get_distribution(const char *type, __s16 *data, int maxdata)
|
||||||
n = 0;
|
n = 0;
|
||||||
while (getline(&line, &len, f) != -1) {
|
while (getline(&line, &len, f) != -1) {
|
||||||
char *p, *endp;
|
char *p, *endp;
|
||||||
|
|
||||||
if (*line == '\n' || *line == '#')
|
if (*line == '\n' || *line == '#')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -154,7 +155,7 @@ static int get_distribution(const char *type, __s16 *data, int maxdata)
|
||||||
(based on kernel PSCHED_CLOCK configuration */
|
(based on kernel PSCHED_CLOCK configuration */
|
||||||
static int get_ticks(__u32 *ticks, const char *str)
|
static int get_ticks(__u32 *ticks, const char *str)
|
||||||
{
|
{
|
||||||
unsigned t;
|
unsigned int t;
|
||||||
|
|
||||||
if (get_time(&t, str))
|
if (get_time(&t, str))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -545,6 +546,7 @@ static int netem_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
const struct tc_netem_rate *rate = NULL;
|
const struct tc_netem_rate *rate = NULL;
|
||||||
int len = RTA_PAYLOAD(opt) - sizeof(qopt);
|
int len = RTA_PAYLOAD(opt) - sizeof(qopt);
|
||||||
__u64 rate64 = 0;
|
__u64 rate64 = 0;
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
|
|
||||||
if (opt == NULL)
|
if (opt == NULL)
|
||||||
|
|
@ -558,6 +560,7 @@ static int netem_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
|
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
struct rtattr *tb[TCA_NETEM_MAX+1];
|
struct rtattr *tb[TCA_NETEM_MAX+1];
|
||||||
|
|
||||||
parse_rtattr(tb, TCA_NETEM_MAX, RTA_DATA(opt) + sizeof(qopt),
|
parse_rtattr(tb, TCA_NETEM_MAX, RTA_DATA(opt) + sizeof(qopt),
|
||||||
len);
|
len);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -136,8 +136,9 @@ static int pie_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
unsigned int target;
|
unsigned int target;
|
||||||
unsigned int alpha;
|
unsigned int alpha;
|
||||||
unsigned int beta;
|
unsigned int beta;
|
||||||
unsigned ecn;
|
unsigned int ecn;
|
||||||
unsigned bytemode;
|
unsigned int bytemode;
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
|
|
||||||
if (opt == NULL)
|
if (opt == NULL)
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,8 @@ static int prio_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct n
|
||||||
explain();
|
explain();
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
unsigned band;
|
unsigned int band;
|
||||||
|
|
||||||
if (!pmap_mode) {
|
if (!pmap_mode) {
|
||||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||||
explain();
|
explain();
|
||||||
|
|
|
||||||
|
|
@ -36,10 +36,10 @@ static void explain(void)
|
||||||
static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
|
static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
|
||||||
{
|
{
|
||||||
struct tc_red_qopt opt;
|
struct tc_red_qopt opt;
|
||||||
unsigned burst = 0;
|
unsigned int burst = 0;
|
||||||
unsigned avpkt = 0;
|
unsigned int avpkt = 0;
|
||||||
double probability = 0.02;
|
double probability = 0.02;
|
||||||
unsigned rate = 0;
|
unsigned int rate = 0;
|
||||||
int parm;
|
int parm;
|
||||||
__u8 sbuf[256];
|
__u8 sbuf[256];
|
||||||
__u32 max_P;
|
__u32 max_P;
|
||||||
|
|
@ -160,6 +160,7 @@ static int red_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
struct rtattr *tb[TCA_RED_MAX + 1];
|
struct rtattr *tb[TCA_RED_MAX + 1];
|
||||||
struct tc_red_qopt *qopt;
|
struct tc_red_qopt *qopt;
|
||||||
__u32 max_P = 0;
|
__u32 max_P = 0;
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
SPRINT_BUF(b2);
|
SPRINT_BUF(b2);
|
||||||
SPRINT_BUF(b3);
|
SPRINT_BUF(b3);
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,8 @@ static int rr_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlm
|
||||||
} else if (strcmp(*argv, "multiqueue") == 0) {
|
} else if (strcmp(*argv, "multiqueue") == 0) {
|
||||||
mq = 1;
|
mq = 1;
|
||||||
} else {
|
} else {
|
||||||
unsigned band;
|
unsigned int band;
|
||||||
|
|
||||||
if (!pmap_mode) {
|
if (!pmap_mode) {
|
||||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||||
explain();
|
explain();
|
||||||
|
|
|
||||||
|
|
@ -158,8 +158,7 @@ static int sfb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
|
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"limit %d max %d target %d\n"
|
"limit %d max %d target %d\n"
|
||||||
" increment %.5f decrement %.5f penalty rate %d burst %d "
|
" increment %.5f decrement %.5f penalty rate %d burst %d (%ums %ums)",
|
||||||
"(%ums %ums)",
|
|
||||||
qopt->limit, qopt->max, qopt->bin_size,
|
qopt->limit, qopt->max, qopt->bin_size,
|
||||||
(double)qopt->increment / SFB_MAX_PROB,
|
(double)qopt->increment / SFB_MAX_PROB,
|
||||||
(double)qopt->decrement / SFB_MAX_PROB,
|
(double)qopt->decrement / SFB_MAX_PROB,
|
||||||
|
|
|
||||||
|
|
@ -207,6 +207,7 @@ static int sfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
{
|
{
|
||||||
struct tc_sfq_qopt *qopt;
|
struct tc_sfq_qopt *qopt;
|
||||||
struct tc_sfq_qopt_v1 *qopt_ext = NULL;
|
struct tc_sfq_qopt_v1 *qopt_ext = NULL;
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
SPRINT_BUF(b2);
|
SPRINT_BUF(b2);
|
||||||
SPRINT_BUF(b3);
|
SPRINT_BUF(b3);
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ static int tbf_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
|
||||||
strcmp(*argv, "buffer") == 0 ||
|
strcmp(*argv, "buffer") == 0 ||
|
||||||
strcmp(*argv, "maxburst") == 0) {
|
strcmp(*argv, "maxburst") == 0) {
|
||||||
const char *parm_name = *argv;
|
const char *parm_name = *argv;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
fprintf(stderr, "tbf: duplicate \"buffer/burst/maxburst\" specification\n");
|
fprintf(stderr, "tbf: duplicate \"buffer/burst/maxburst\" specification\n");
|
||||||
|
|
@ -99,6 +100,7 @@ static int tbf_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
|
||||||
} else if (strcmp(*argv, "mtu") == 0 ||
|
} else if (strcmp(*argv, "mtu") == 0 ||
|
||||||
strcmp(*argv, "minburst") == 0) {
|
strcmp(*argv, "minburst") == 0) {
|
||||||
const char *parm_name = *argv;
|
const char *parm_name = *argv;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (mtu) {
|
if (mtu) {
|
||||||
fprintf(stderr, "tbf: duplicate \"mtu/minburst\" specification\n");
|
fprintf(stderr, "tbf: duplicate \"mtu/minburst\" specification\n");
|
||||||
|
|
@ -203,8 +205,10 @@ static int tbf_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
|
||||||
|
|
||||||
if (opt.limit == 0) {
|
if (opt.limit == 0) {
|
||||||
double lim = rate64*(double)latency/TIME_UNITS_PER_SEC + buffer;
|
double lim = rate64*(double)latency/TIME_UNITS_PER_SEC + buffer;
|
||||||
|
|
||||||
if (prate64) {
|
if (prate64) {
|
||||||
double lim2 = prate64*(double)latency/TIME_UNITS_PER_SEC + mtu;
|
double lim2 = prate64*(double)latency/TIME_UNITS_PER_SEC + mtu;
|
||||||
|
|
||||||
if (lim2 < lim)
|
if (lim2 < lim)
|
||||||
lim = lim2;
|
lim = lim2;
|
||||||
}
|
}
|
||||||
|
|
@ -254,6 +258,7 @@ static int tbf_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
double buffer, mtu;
|
double buffer, mtu;
|
||||||
double latency;
|
double latency;
|
||||||
__u64 rate64 = 0, prate64 = 0;
|
__u64 rate64 = 0, prate64 = 0;
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
SPRINT_BUF(b2);
|
SPRINT_BUF(b2);
|
||||||
SPRINT_BUF(b3);
|
SPRINT_BUF(b3);
|
||||||
|
|
@ -305,6 +310,7 @@ static int tbf_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
|
||||||
latency = TIME_UNITS_PER_SEC*(qopt->limit/(double)rate64) - tc_core_tick2time(qopt->buffer);
|
latency = TIME_UNITS_PER_SEC*(qopt->limit/(double)rate64) - tc_core_tick2time(qopt->buffer);
|
||||||
if (prate64) {
|
if (prate64) {
|
||||||
double lat2 = TIME_UNITS_PER_SEC*(qopt->limit/(double)prate64) - tc_core_tick2time(qopt->mtu);
|
double lat2 = TIME_UNITS_PER_SEC*(qopt->limit/(double)prate64) - tc_core_tick2time(qopt->mtu);
|
||||||
|
|
||||||
if (lat2 > latency)
|
if (lat2 > latency)
|
||||||
latency = lat2;
|
latency = lat2;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
30
tc/tc.c
30
tc/tc.c
|
|
@ -31,24 +31,24 @@
|
||||||
#include "tc_common.h"
|
#include "tc_common.h"
|
||||||
#include "namespace.h"
|
#include "namespace.h"
|
||||||
|
|
||||||
int show_stats = 0;
|
int show_stats;
|
||||||
int show_details = 0;
|
int show_details;
|
||||||
int show_raw = 0;
|
int show_raw;
|
||||||
int show_pretty = 0;
|
int show_pretty;
|
||||||
int show_graph = 0;
|
int show_graph;
|
||||||
int timestamp;
|
int timestamp;
|
||||||
|
|
||||||
int batch_mode = 0;
|
int batch_mode;
|
||||||
int resolve_hosts = 0;
|
int resolve_hosts;
|
||||||
int use_iec = 0;
|
int use_iec;
|
||||||
int force = 0;
|
int force;
|
||||||
bool use_names = false;
|
bool use_names;
|
||||||
|
|
||||||
static char *conf_file;
|
static char *conf_file;
|
||||||
|
|
||||||
struct rtnl_handle rth;
|
struct rtnl_handle rth;
|
||||||
|
|
||||||
static void *BODY = NULL; /* cached handle dlopen(NULL) */
|
static void *BODY; /* cached handle dlopen(NULL) */
|
||||||
static struct qdisc_util *qdisc_list;
|
static struct qdisc_util *qdisc_list;
|
||||||
static struct filter_util *filter_list;
|
static struct filter_util *filter_list;
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ static int print_noqopt(struct qdisc_util *qu, FILE *f,
|
||||||
{
|
{
|
||||||
if (opt && RTA_PAYLOAD(opt))
|
if (opt && RTA_PAYLOAD(opt))
|
||||||
fprintf(f, "[Unknown qdisc, optlen=%u] ",
|
fprintf(f, "[Unknown qdisc, optlen=%u] ",
|
||||||
(unsigned) RTA_PAYLOAD(opt));
|
(unsigned int) RTA_PAYLOAD(opt));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ static int print_nofopt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u
|
||||||
{
|
{
|
||||||
if (opt && RTA_PAYLOAD(opt))
|
if (opt && RTA_PAYLOAD(opt))
|
||||||
fprintf(f, "fh %08x [Unknown filter, optlen=%u] ",
|
fprintf(f, "fh %08x [Unknown filter, optlen=%u] ",
|
||||||
fhandle, (unsigned) RTA_PAYLOAD(opt));
|
fhandle, (unsigned int) RTA_PAYLOAD(opt));
|
||||||
else if (fhandle)
|
else if (fhandle)
|
||||||
fprintf(f, "fh %08x ", fhandle);
|
fprintf(f, "fh %08x ", fhandle);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -90,6 +90,7 @@ static int parse_nofopt(struct filter_util *qu, char *fhandle, int argc, char **
|
||||||
}
|
}
|
||||||
if (fhandle) {
|
if (fhandle) {
|
||||||
struct tcmsg *t = NLMSG_DATA(n);
|
struct tcmsg *t = NLMSG_DATA(n);
|
||||||
|
|
||||||
if (get_u32(&handle, fhandle, 16)) {
|
if (get_u32(&handle, fhandle, 16)) {
|
||||||
fprintf(stderr, "Unparsable filter ID \"%s\"\n", fhandle);
|
fprintf(stderr, "Unparsable filter ID \"%s\"\n", fhandle);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -192,8 +193,7 @@ static void usage(void)
|
||||||
fprintf(stderr, "Usage: tc [ OPTIONS ] OBJECT { COMMAND | help }\n"
|
fprintf(stderr, "Usage: tc [ OPTIONS ] OBJECT { COMMAND | help }\n"
|
||||||
" tc [-force] -batch filename\n"
|
" tc [-force] -batch filename\n"
|
||||||
"where OBJECT := { qdisc | class | filter | action | monitor | exec }\n"
|
"where OBJECT := { qdisc | class | filter | action | monitor | exec }\n"
|
||||||
" OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -b[atch] [filename] | "
|
" OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -b[atch] [filename] | -n[etns] name |\n"
|
||||||
"-n[etns] name |\n"
|
|
||||||
" -nm | -nam[es] | { -cf | -conf } path }\n");
|
" -nm | -nam[es] | { -cf | -conf } path }\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
39
tc/tc_bpf.c
39
tc/tc_bpf.c
|
|
@ -167,8 +167,7 @@ static int bpf_ops_parse(int argc, char **argv, struct sock_filter *bpf_ops,
|
||||||
token = bpf_string;
|
token = bpf_string;
|
||||||
while ((token = strchr(token, separator)) && (++token)[0]) {
|
while ((token = strchr(token, separator)) && (++token)[0]) {
|
||||||
if (i >= bpf_len) {
|
if (i >= bpf_len) {
|
||||||
fprintf(stderr, "Real program length exceeds encoded "
|
fprintf(stderr, "Real program length exceeds encoded length parameter!\n");
|
||||||
"length parameter!\n");
|
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
@ -185,8 +184,7 @@ static int bpf_ops_parse(int argc, char **argv, struct sock_filter *bpf_ops,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != bpf_len) {
|
if (i != bpf_len) {
|
||||||
fprintf(stderr, "Parsed program length is less than encoded"
|
fprintf(stderr, "Parsed program length is less than encodedlength parameter!\n");
|
||||||
"length parameter!\n");
|
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
@ -385,7 +383,7 @@ int bpf_trace_pipe(void)
|
||||||
|
|
||||||
static const char *bpf_get_tc_dir(void)
|
static const char *bpf_get_tc_dir(void)
|
||||||
{
|
{
|
||||||
static bool bpf_mnt_cached = false;
|
static bool bpf_mnt_cached;
|
||||||
static char bpf_tc_dir[PATH_MAX];
|
static char bpf_tc_dir[PATH_MAX];
|
||||||
static const char *mnt;
|
static const char *mnt;
|
||||||
static const char * const bpf_known_mnts[] = {
|
static const char * const bpf_known_mnts[] = {
|
||||||
|
|
@ -648,8 +646,7 @@ int bpf_graft_map(const char *map_path, uint32_t *key, int argc, char **argv)
|
||||||
} else {
|
} else {
|
||||||
ret = sscanf(section, "%*i/%i", &map_key);
|
ret = sscanf(section, "%*i/%i", &map_key);
|
||||||
if (ret != 1) {
|
if (ret != 1) {
|
||||||
fprintf(stderr, "Couldn\'t infer map key from section "
|
fprintf(stderr, "Couldn\'t infer map key from section name! Please provide \'key\' argument!\n");
|
||||||
"name! Please provide \'key\' argument!\n");
|
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out_prog;
|
goto out_prog;
|
||||||
}
|
}
|
||||||
|
|
@ -889,7 +886,7 @@ out_cfd:
|
||||||
|
|
||||||
static const char *bpf_get_obj_uid(const char *pathname)
|
static const char *bpf_get_obj_uid(const char *pathname)
|
||||||
{
|
{
|
||||||
static bool bpf_uid_cached = false;
|
static bool bpf_uid_cached;
|
||||||
static char bpf_uid[64];
|
static char bpf_uid[64];
|
||||||
uint8_t tmp[20];
|
uint8_t tmp[20];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
@ -920,8 +917,7 @@ static int bpf_init_env(const char *pathname)
|
||||||
setrlimit(RLIMIT_MEMLOCK, &limit);
|
setrlimit(RLIMIT_MEMLOCK, &limit);
|
||||||
|
|
||||||
if (!bpf_get_tc_dir()) {
|
if (!bpf_get_tc_dir()) {
|
||||||
fprintf(stderr, "Continuing without mounted eBPF fs. "
|
fprintf(stderr, "Continuing without mounted eBPF fs. Too old kernel?\n");
|
||||||
"Too old kernel?\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1091,8 +1087,7 @@ retry:
|
||||||
if (tries++ < 6 && !bpf_log_realloc(ctx))
|
if (tries++ < 6 && !bpf_log_realloc(ctx))
|
||||||
goto retry;
|
goto retry;
|
||||||
|
|
||||||
fprintf(stderr, "Log buffer too small to dump "
|
fprintf(stderr, "Log buffer too small to dump verifier log %zu bytes (%d tries)!\n",
|
||||||
"verifier log %zu bytes (%d tries)!\n",
|
|
||||||
ctx->log_size, tries);
|
ctx->log_size, tries);
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
@ -1311,8 +1306,8 @@ static int bpf_fetch_ancillary(struct bpf_elf_ctx *ctx)
|
||||||
!strcmp(data.sec_name, ".strtab"))
|
!strcmp(data.sec_name, ".strtab"))
|
||||||
ret = bpf_fetch_strtab(ctx, i, &data);
|
ret = bpf_fetch_strtab(ctx, i, &data);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "Error parsing section %d! Perhaps"
|
fprintf(stderr, "Error parsing section %d! Perhapscheck with readelf -a?\n",
|
||||||
"check with readelf -a?\n", i);
|
i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1383,21 +1378,18 @@ static int bpf_apply_relo_data(struct bpf_elf_ctx *ctx,
|
||||||
ioff = relo.r_offset / sizeof(struct bpf_insn);
|
ioff = relo.r_offset / sizeof(struct bpf_insn);
|
||||||
if (ioff >= num_insns ||
|
if (ioff >= num_insns ||
|
||||||
insns[ioff].code != (BPF_LD | BPF_IMM | BPF_DW)) {
|
insns[ioff].code != (BPF_LD | BPF_IMM | BPF_DW)) {
|
||||||
fprintf(stderr, "ELF contains relo data for non ld64 "
|
fprintf(stderr, "ELF contains relo data for non ld64 instruction at offset %u! Compiler bug?!\n",
|
||||||
"instruction at offset %u! Compiler bug?!\n",
|
|
||||||
ioff);
|
ioff);
|
||||||
if (ioff < num_insns &&
|
if (ioff < num_insns &&
|
||||||
insns[ioff].code == (BPF_JMP | BPF_CALL))
|
insns[ioff].code == (BPF_JMP | BPF_CALL))
|
||||||
fprintf(stderr, " - Try to annotate functions "
|
fprintf(stderr, " - Try to annotate functions with always_inline attribute!\n");
|
||||||
"with always_inline attribute!\n");
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gelf_getsym(ctx->sym_tab, GELF_R_SYM(relo.r_info), &sym) != &sym)
|
if (gelf_getsym(ctx->sym_tab, GELF_R_SYM(relo.r_info), &sym) != &sym)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
if (sym.st_shndx != ctx->sec_maps) {
|
if (sym.st_shndx != ctx->sec_maps) {
|
||||||
fprintf(stderr, "ELF contains non-map related relo data in "
|
fprintf(stderr, "ELF contains non-map related relo data in entry %u pointing to section %u! Compiler bug?!\n",
|
||||||
"entry %u pointing to section %u! Compiler bug?!\n",
|
|
||||||
relo_ent, sym.st_shndx);
|
relo_ent, sym.st_shndx);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
@ -1409,8 +1401,7 @@ static int bpf_apply_relo_data(struct bpf_elf_ctx *ctx,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (ctx->verbose)
|
if (ctx->verbose)
|
||||||
fprintf(stderr, "Map \'%s\' (%d) injected into prog "
|
fprintf(stderr, "Map \'%s\' (%d) injected into prog section \'%s\' at offset %u!\n",
|
||||||
"section \'%s\' at offset %u!\n",
|
|
||||||
bpf_str_tab_name(ctx, &sym), ctx->map_fds[rmap],
|
bpf_str_tab_name(ctx, &sym), ctx->map_fds[rmap],
|
||||||
data_insn->sec_name, ioff);
|
data_insn->sec_name, ioff);
|
||||||
|
|
||||||
|
|
@ -1599,8 +1590,8 @@ static void bpf_hash_init(struct bpf_elf_ctx *ctx, const char *db_file)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bpf_pinning_reserved(pinning)) {
|
if (bpf_pinning_reserved(pinning)) {
|
||||||
fprintf(stderr, "Database %s, id %u is reserved - "
|
fprintf(stderr, "Database %s, id %u is reserved - ignoring!\n",
|
||||||
"ignoring!\n", db_file, pinning);
|
db_file, pinning);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@
|
||||||
#include "tc_core.h"
|
#include "tc_core.h"
|
||||||
#include "tc_cbq.h"
|
#include "tc_cbq.h"
|
||||||
|
|
||||||
unsigned tc_cbq_calc_maxidle(unsigned bndw, unsigned rate, unsigned avpkt,
|
unsigned int tc_cbq_calc_maxidle(unsigned int bndw, unsigned int rate, unsigned int avpkt,
|
||||||
int ewma_log, unsigned maxburst)
|
int ewma_log, unsigned int maxburst)
|
||||||
{
|
{
|
||||||
double maxidle;
|
double maxidle;
|
||||||
double g = 1.0 - 1.0/(1<<ewma_log);
|
double g = 1.0 - 1.0/(1<<ewma_log);
|
||||||
|
|
@ -34,6 +34,7 @@ unsigned tc_cbq_calc_maxidle(unsigned bndw, unsigned rate, unsigned avpkt,
|
||||||
maxidle = xmt*(1-g);
|
maxidle = xmt*(1-g);
|
||||||
if (bndw != rate && maxburst) {
|
if (bndw != rate && maxburst) {
|
||||||
double vxmt = (double)avpkt/rate - xmt;
|
double vxmt = (double)avpkt/rate - xmt;
|
||||||
|
|
||||||
vxmt *= (pow(g, -(double)maxburst) - 1);
|
vxmt *= (pow(g, -(double)maxburst) - 1);
|
||||||
if (vxmt > maxidle)
|
if (vxmt > maxidle)
|
||||||
maxidle = vxmt;
|
maxidle = vxmt;
|
||||||
|
|
@ -41,8 +42,8 @@ unsigned tc_cbq_calc_maxidle(unsigned bndw, unsigned rate, unsigned avpkt,
|
||||||
return tc_core_time2tick(maxidle*(1<<ewma_log)*TIME_UNITS_PER_SEC);
|
return tc_core_time2tick(maxidle*(1<<ewma_log)*TIME_UNITS_PER_SEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned tc_cbq_calc_offtime(unsigned bndw, unsigned rate, unsigned avpkt,
|
unsigned int tc_cbq_calc_offtime(unsigned int bndw, unsigned int rate, unsigned int avpkt,
|
||||||
int ewma_log, unsigned minburst)
|
int ewma_log, unsigned int minburst)
|
||||||
{
|
{
|
||||||
double g = 1.0 - 1.0/(1<<ewma_log);
|
double g = 1.0 - 1.0/(1<<ewma_log);
|
||||||
double offtime = (double)avpkt/rate - (double)avpkt/bndw;
|
double offtime = (double)avpkt/rate - (double)avpkt/bndw;
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ static void usage(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tc_class_modify(int cmd, unsigned flags, int argc, char **argv)
|
static int tc_class_modify(int cmd, unsigned int flags, int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
struct nlmsghdr n;
|
struct nlmsghdr n;
|
||||||
|
|
@ -85,6 +85,7 @@ static int tc_class_modify(int cmd, unsigned flags, int argc, char **argv)
|
||||||
strncpy(d, *argv, sizeof(d)-1);
|
strncpy(d, *argv, sizeof(d)-1);
|
||||||
} else if (strcmp(*argv, "classid") == 0) {
|
} else if (strcmp(*argv, "classid") == 0) {
|
||||||
__u32 handle;
|
__u32 handle;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (req.t.tcm_handle)
|
if (req.t.tcm_handle)
|
||||||
duparg("classid", *argv);
|
duparg("classid", *argv);
|
||||||
|
|
@ -102,6 +103,7 @@ static int tc_class_modify(int cmd, unsigned flags, int argc, char **argv)
|
||||||
req.t.tcm_parent = TC_H_ROOT;
|
req.t.tcm_parent = TC_H_ROOT;
|
||||||
} else if (strcmp(*argv, "parent") == 0) {
|
} else if (strcmp(*argv, "parent") == 0) {
|
||||||
__u32 handle;
|
__u32 handle;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (req.t.tcm_parent)
|
if (req.t.tcm_parent)
|
||||||
duparg("parent", *argv);
|
duparg("parent", *argv);
|
||||||
|
|
@ -430,6 +432,7 @@ static int tc_class_list(int argc, char **argv)
|
||||||
t.tcm_parent = TC_H_ROOT;
|
t.tcm_parent = TC_H_ROOT;
|
||||||
} else if (strcmp(*argv, "parent") == 0) {
|
} else if (strcmp(*argv, "parent") == 0) {
|
||||||
__u32 handle;
|
__u32 handle;
|
||||||
|
|
||||||
if (t.tcm_parent)
|
if (t.tcm_parent)
|
||||||
duparg("parent", *argv);
|
duparg("parent", *argv);
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
|
|
|
||||||
33
tc/tc_core.c
33
tc/tc_core.c
|
|
@ -27,7 +27,7 @@
|
||||||
static double tick_in_usec = 1;
|
static double tick_in_usec = 1;
|
||||||
static double clock_factor = 1;
|
static double clock_factor = 1;
|
||||||
|
|
||||||
int tc_core_time2big(unsigned time)
|
int tc_core_time2big(unsigned int time)
|
||||||
{
|
{
|
||||||
__u64 t = time;
|
__u64 t = time;
|
||||||
|
|
||||||
|
|
@ -36,32 +36,32 @@ int tc_core_time2big(unsigned time)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned tc_core_time2tick(unsigned time)
|
unsigned int tc_core_time2tick(unsigned int time)
|
||||||
{
|
{
|
||||||
return time*tick_in_usec;
|
return time*tick_in_usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned tc_core_tick2time(unsigned tick)
|
unsigned int tc_core_tick2time(unsigned int tick)
|
||||||
{
|
{
|
||||||
return tick/tick_in_usec;
|
return tick/tick_in_usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned tc_core_time2ktime(unsigned time)
|
unsigned int tc_core_time2ktime(unsigned int time)
|
||||||
{
|
{
|
||||||
return time * clock_factor;
|
return time * clock_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned tc_core_ktime2time(unsigned ktime)
|
unsigned int tc_core_ktime2time(unsigned int ktime)
|
||||||
{
|
{
|
||||||
return ktime / clock_factor;
|
return ktime / clock_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned tc_calc_xmittime(__u64 rate, unsigned size)
|
unsigned int tc_calc_xmittime(__u64 rate, unsigned int size)
|
||||||
{
|
{
|
||||||
return tc_core_time2tick(TIME_UNITS_PER_SEC*((double)size/(double)rate));
|
return tc_core_time2tick(TIME_UNITS_PER_SEC*((double)size/(double)rate));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned tc_calc_xmitsize(__u64 rate, unsigned ticks)
|
unsigned int tc_calc_xmitsize(__u64 rate, unsigned int ticks)
|
||||||
{
|
{
|
||||||
return ((double)rate*tc_core_tick2time(ticks))/TIME_UNITS_PER_SEC;
|
return ((double)rate*tc_core_tick2time(ticks))/TIME_UNITS_PER_SEC;
|
||||||
}
|
}
|
||||||
|
|
@ -76,9 +76,10 @@ unsigned tc_calc_xmitsize(__u64 rate, unsigned ticks)
|
||||||
* (as the table will always be aligned for 48 bytes).
|
* (as the table will always be aligned for 48 bytes).
|
||||||
* --Hawk, d.7/11-2004. <hawk@diku.dk>
|
* --Hawk, d.7/11-2004. <hawk@diku.dk>
|
||||||
*/
|
*/
|
||||||
static unsigned tc_align_to_atm(unsigned size)
|
static unsigned int tc_align_to_atm(unsigned int size)
|
||||||
{
|
{
|
||||||
int linksize, cells;
|
int linksize, cells;
|
||||||
|
|
||||||
cells = size / ATM_CELL_PAYLOAD;
|
cells = size / ATM_CELL_PAYLOAD;
|
||||||
if ((size % ATM_CELL_PAYLOAD) > 0)
|
if ((size % ATM_CELL_PAYLOAD) > 0)
|
||||||
cells++;
|
cells++;
|
||||||
|
|
@ -87,7 +88,7 @@ static unsigned tc_align_to_atm(unsigned size)
|
||||||
return linksize;
|
return linksize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned tc_adjust_size(unsigned sz, unsigned mpu, enum link_layer linklayer)
|
static unsigned int tc_adjust_size(unsigned int sz, unsigned int mpu, enum link_layer linklayer)
|
||||||
{
|
{
|
||||||
if (sz < mpu)
|
if (sz < mpu)
|
||||||
sz = mpu;
|
sz = mpu;
|
||||||
|
|
@ -97,7 +98,7 @@ static unsigned tc_adjust_size(unsigned sz, unsigned mpu, enum link_layer linkla
|
||||||
return tc_align_to_atm(sz);
|
return tc_align_to_atm(sz);
|
||||||
case LINKLAYER_ETHERNET:
|
case LINKLAYER_ETHERNET:
|
||||||
default:
|
default:
|
||||||
// No size adjustments on Ethernet
|
/* No size adjustments on Ethernet */
|
||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -122,13 +123,13 @@ static unsigned tc_adjust_size(unsigned sz, unsigned mpu, enum link_layer linkla
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int tc_calc_rtable(struct tc_ratespec *r, __u32 *rtab,
|
int tc_calc_rtable(struct tc_ratespec *r, __u32 *rtab,
|
||||||
int cell_log, unsigned mtu,
|
int cell_log, unsigned int mtu,
|
||||||
enum link_layer linklayer)
|
enum link_layer linklayer)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned sz;
|
unsigned int sz;
|
||||||
unsigned bps = r->rate;
|
unsigned int bps = r->rate;
|
||||||
unsigned mpu = r->mpu;
|
unsigned int mpu = r->mpu;
|
||||||
|
|
||||||
if (mtu == 0)
|
if (mtu == 0)
|
||||||
mtu = 2047;
|
mtu = 2047;
|
||||||
|
|
@ -144,7 +145,7 @@ int tc_calc_rtable(struct tc_ratespec *r, __u32 *rtab,
|
||||||
rtab[i] = tc_calc_xmittime(bps, sz);
|
rtab[i] = tc_calc_xmittime(bps, sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
r->cell_align=-1; // Due to the sz calc
|
r->cell_align = -1;
|
||||||
r->cell_log = cell_log;
|
r->cell_log = cell_log;
|
||||||
r->linklayer = (linklayer & TC_LINKLAYER_MASK);
|
r->linklayer = (linklayer & TC_LINKLAYER_MASK);
|
||||||
return cell_log;
|
return cell_log;
|
||||||
|
|
@ -193,7 +194,7 @@ again:
|
||||||
(*stab)[i] = sz >> s->size_log;
|
(*stab)[i] = sz >> s->size_log;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->cell_align = -1; // Due to the sz calc
|
s->cell_align = -1; /* Due to the sz calc */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
#include "tc_core.h"
|
#include "tc_core.h"
|
||||||
|
|
||||||
int tc_setup_estimator(unsigned A, unsigned time_const, struct tc_estimator *est)
|
int tc_setup_estimator(unsigned int A, unsigned int time_const, struct tc_estimator *est)
|
||||||
{
|
{
|
||||||
for (est->interval = 0; est->interval <= 5; est->interval++) {
|
for (est->interval = 0; est->interval <= 5; est->interval++) {
|
||||||
if (A <= (1<<est->interval)*(TIME_UNITS_PER_SEC/4))
|
if (A <= (1<<est->interval)*(TIME_UNITS_PER_SEC/4))
|
||||||
|
|
@ -34,6 +34,7 @@ int tc_setup_estimator(unsigned A, unsigned time_const, struct tc_estimator *est
|
||||||
est->interval -= 2;
|
est->interval -= 2;
|
||||||
for (est->ewma_log = 1; est->ewma_log < 32; est->ewma_log++) {
|
for (est->ewma_log = 1; est->ewma_log < 32; est->ewma_log++) {
|
||||||
double w = 1.0 - 1.0/(1<<est->ewma_log);
|
double w = 1.0 - 1.0/(1<<est->ewma_log);
|
||||||
|
|
||||||
if (A/(-log(w)) > time_const)
|
if (A/(-log(w)) > time_const)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
#include "tc_common.h"
|
#include "tc_common.h"
|
||||||
|
|
||||||
static struct exec_util *exec_list;
|
static struct exec_util *exec_list;
|
||||||
static void *BODY = NULL;
|
static void *BODY;
|
||||||
|
|
||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
|
|
@ -32,8 +32,8 @@ static void usage(void)
|
||||||
static int parse_noeopt(struct exec_util *eu, int argc, char **argv)
|
static int parse_noeopt(struct exec_util *eu, int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc) {
|
if (argc) {
|
||||||
fprintf(stderr, "Unknown exec \"%s\", hence option \"%s\" "
|
fprintf(stderr, "Unknown exec \"%s\", hence option \"%s\" is unparsable\n",
|
||||||
"is unparsable\n", eu->id, *argv);
|
eu->id, *argv);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ static void usage(void)
|
||||||
fprintf(stderr, "OPTIONS := ... try tc filter add <desired FILTER_KIND> help\n");
|
fprintf(stderr, "OPTIONS := ... try tc filter add <desired FILTER_KIND> help\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tc_filter_modify(int cmd, unsigned flags, int argc, char **argv)
|
static int tc_filter_modify(int cmd, unsigned int flags, int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
struct nlmsghdr n;
|
struct nlmsghdr n;
|
||||||
|
|
@ -99,6 +99,7 @@ static int tc_filter_modify(int cmd, unsigned flags, int argc, char **argv)
|
||||||
TC_H_MIN_EGRESS);
|
TC_H_MIN_EGRESS);
|
||||||
} else if (strcmp(*argv, "parent") == 0) {
|
} else if (strcmp(*argv, "parent") == 0) {
|
||||||
__u32 handle;
|
__u32 handle;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (req.t.tcm_parent)
|
if (req.t.tcm_parent)
|
||||||
duparg("parent", *argv);
|
duparg("parent", *argv);
|
||||||
|
|
@ -119,6 +120,7 @@ static int tc_filter_modify(int cmd, unsigned flags, int argc, char **argv)
|
||||||
invarg("invalid priority value", *argv);
|
invarg("invalid priority value", *argv);
|
||||||
} else if (matches(*argv, "protocol") == 0) {
|
} else if (matches(*argv, "protocol") == 0) {
|
||||||
__u16 id;
|
__u16 id;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (protocol_set)
|
if (protocol_set)
|
||||||
duparg("protocol", *argv);
|
duparg("protocol", *argv);
|
||||||
|
|
@ -153,8 +155,7 @@ static int tc_filter_modify(int cmd, unsigned flags, int argc, char **argv)
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
if (fhandle) {
|
if (fhandle) {
|
||||||
fprintf(stderr, "Must specify filter type when using "
|
fprintf(stderr, "Must specify filter type when using \"handle\"\n");
|
||||||
"\"handle\"\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (argc) {
|
if (argc) {
|
||||||
|
|
@ -189,7 +190,7 @@ static __u32 filter_parent;
|
||||||
static int filter_ifindex;
|
static int filter_ifindex;
|
||||||
static __u32 filter_prio;
|
static __u32 filter_prio;
|
||||||
static __u32 filter_protocol;
|
static __u32 filter_protocol;
|
||||||
__u16 f_proto = 0;
|
__u16 f_proto;
|
||||||
|
|
||||||
int print_filter(const struct sockaddr_nl *who,
|
int print_filter(const struct sockaddr_nl *who,
|
||||||
struct nlmsghdr *n,
|
struct nlmsghdr *n,
|
||||||
|
|
@ -243,6 +244,7 @@ int print_filter(const struct sockaddr_nl *who,
|
||||||
if (t->tcm_info) {
|
if (t->tcm_info) {
|
||||||
f_proto = TC_H_MIN(t->tcm_info);
|
f_proto = TC_H_MIN(t->tcm_info);
|
||||||
__u32 prio = TC_H_MAJ(t->tcm_info)>>16;
|
__u32 prio = TC_H_MAJ(t->tcm_info)>>16;
|
||||||
|
|
||||||
if (!filter_protocol || filter_protocol != f_proto) {
|
if (!filter_protocol || filter_protocol != f_proto) {
|
||||||
if (f_proto) {
|
if (f_proto) {
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
|
|
@ -316,6 +318,7 @@ static int tc_filter_list(int argc, char **argv)
|
||||||
t.tcm_parent = filter_parent;
|
t.tcm_parent = filter_parent;
|
||||||
} else if (strcmp(*argv, "parent") == 0) {
|
} else if (strcmp(*argv, "parent") == 0) {
|
||||||
__u32 handle;
|
__u32 handle;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (t.tcm_parent)
|
if (t.tcm_parent)
|
||||||
duparg("parent", *argv);
|
duparg("parent", *argv);
|
||||||
|
|
@ -337,6 +340,7 @@ static int tc_filter_list(int argc, char **argv)
|
||||||
filter_prio = prio;
|
filter_prio = prio;
|
||||||
} else if (matches(*argv, "protocol") == 0) {
|
} else if (matches(*argv, "protocol") == 0) {
|
||||||
__u16 res;
|
__u16 res;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (protocol)
|
if (protocol)
|
||||||
duparg("protocol", *argv);
|
duparg("protocol", *argv);
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ int do_tcmonitor(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct rtnl_handle rth;
|
struct rtnl_handle rth;
|
||||||
char *file = NULL;
|
char *file = NULL;
|
||||||
unsigned groups = nl_mgrp(RTNLGRP_TC);
|
unsigned int groups = nl_mgrp(RTNLGRP_TC);
|
||||||
|
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
if (matches(*argv, "file") == 0) {
|
if (matches(*argv, "file") == 0) {
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ static int usage(void)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv)
|
static int tc_qdisc_modify(int cmd, unsigned int flags, int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct qdisc_util *q = NULL;
|
struct qdisc_util *q = NULL;
|
||||||
struct tc_estimator est;
|
struct tc_estimator est;
|
||||||
|
|
@ -77,6 +77,7 @@ static int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv)
|
||||||
strncpy(d, *argv, sizeof(d)-1);
|
strncpy(d, *argv, sizeof(d)-1);
|
||||||
} else if (strcmp(*argv, "handle") == 0) {
|
} else if (strcmp(*argv, "handle") == 0) {
|
||||||
__u32 handle;
|
__u32 handle;
|
||||||
|
|
||||||
if (req.t.tcm_handle)
|
if (req.t.tcm_handle)
|
||||||
duparg("handle", *argv);
|
duparg("handle", *argv);
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
|
|
@ -113,6 +114,7 @@ static int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
} else if (strcmp(*argv, "parent") == 0) {
|
} else if (strcmp(*argv, "parent") == 0) {
|
||||||
__u32 handle;
|
__u32 handle;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (req.t.tcm_parent)
|
if (req.t.tcm_parent)
|
||||||
duparg("parent", *argv);
|
duparg("parent", *argv);
|
||||||
|
|
|
||||||
10
tc/tc_red.c
10
tc/tc_red.c
|
|
@ -27,7 +27,7 @@
|
||||||
/*
|
/*
|
||||||
Plog = log(prob/(qmax - qmin))
|
Plog = log(prob/(qmax - qmin))
|
||||||
*/
|
*/
|
||||||
int tc_red_eval_P(unsigned qmin, unsigned qmax, double prob)
|
int tc_red_eval_P(unsigned int qmin, unsigned int qmax, double prob)
|
||||||
{
|
{
|
||||||
int i = qmax - qmin;
|
int i = qmax - qmin;
|
||||||
|
|
||||||
|
|
@ -50,15 +50,15 @@ int tc_red_eval_P(unsigned qmin, unsigned qmax, double prob)
|
||||||
burst + 1 - qmin/avpkt < (1-(1-W)^burst)/W
|
burst + 1 - qmin/avpkt < (1-(1-W)^burst)/W
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int tc_red_eval_ewma(unsigned qmin, unsigned burst, unsigned avpkt)
|
int tc_red_eval_ewma(unsigned int qmin, unsigned int burst, unsigned int avpkt)
|
||||||
{
|
{
|
||||||
int wlog = 1;
|
int wlog = 1;
|
||||||
double W = 0.5;
|
double W = 0.5;
|
||||||
double a = (double)burst + 1 - (double)qmin/avpkt;
|
double a = (double)burst + 1 - (double)qmin/avpkt;
|
||||||
|
|
||||||
if (a < 1.0) {
|
if (a < 1.0) {
|
||||||
fprintf(stderr, "tc_red_eval_ewma() burst %u is too small ?"
|
fprintf(stderr, "tc_red_eval_ewma() burst %u is too small ? Try burst %u\n",
|
||||||
" Try burst %u\n", burst, 1 + qmin/avpkt);
|
burst, 1 + qmin/avpkt);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (wlog = 1; wlog < 32; wlog++, W /= 2) {
|
for (wlog = 1; wlog < 32; wlog++, W /= 2) {
|
||||||
|
|
@ -72,7 +72,7 @@ int tc_red_eval_ewma(unsigned qmin, unsigned burst, unsigned avpkt)
|
||||||
Stab[t>>Scell_log] = -log(1-W) * t/xmit_time
|
Stab[t>>Scell_log] = -log(1-W) * t/xmit_time
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int tc_red_eval_idle_damping(int Wlog, unsigned avpkt, unsigned bps, __u8 *sbuf)
|
int tc_red_eval_idle_damping(int Wlog, unsigned int avpkt, unsigned int bps, __u8 *sbuf)
|
||||||
{
|
{
|
||||||
double xmit_time = tc_calc_xmittime(bps, avpkt);
|
double xmit_time = tc_calc_xmittime(bps, avpkt);
|
||||||
double lW = -log(1.0 - 1.0/(1<<Wlog))/xmit_time;
|
double lW = -log(1.0 - 1.0/(1<<Wlog))/xmit_time;
|
||||||
|
|
|
||||||
|
|
@ -110,12 +110,14 @@ int parse_size_table(int *argcp, char ***argvp, struct tc_sizespec *sp)
|
||||||
void print_size_table(FILE *fp, const char *prefix, struct rtattr *rta)
|
void print_size_table(FILE *fp, const char *prefix, struct rtattr *rta)
|
||||||
{
|
{
|
||||||
struct rtattr *tb[TCA_STAB_MAX + 1];
|
struct rtattr *tb[TCA_STAB_MAX + 1];
|
||||||
|
|
||||||
SPRINT_BUF(b1);
|
SPRINT_BUF(b1);
|
||||||
|
|
||||||
parse_rtattr_nested(tb, TCA_STAB_MAX, rta);
|
parse_rtattr_nested(tb, TCA_STAB_MAX, rta);
|
||||||
|
|
||||||
if (tb[TCA_STAB_BASE]) {
|
if (tb[TCA_STAB_BASE]) {
|
||||||
struct tc_sizespec s = {0};
|
struct tc_sizespec s = {0};
|
||||||
|
|
||||||
memcpy(&s, RTA_DATA(tb[TCA_STAB_BASE]),
|
memcpy(&s, RTA_DATA(tb[TCA_STAB_BASE]),
|
||||||
MIN(RTA_PAYLOAD(tb[TCA_STAB_BASE]), sizeof(s)));
|
MIN(RTA_PAYLOAD(tb[TCA_STAB_BASE]), sizeof(s)));
|
||||||
|
|
||||||
|
|
@ -135,8 +137,9 @@ void print_size_table(FILE *fp, const char *prefix, struct rtattr *rta)
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (tb[TCA_STAB_DATA]) {
|
if (tb[TCA_STAB_DATA]) {
|
||||||
unsigned i, j, dlen;
|
unsigned int i, j, dlen;
|
||||||
__u16 *data = RTA_DATA(tb[TCA_STAB_DATA]);
|
__u16 *data = RTA_DATA(tb[TCA_STAB_DATA]);
|
||||||
|
|
||||||
dlen = RTA_PAYLOAD(tb[TCA_STAB_DATA]) / sizeof(__u16);
|
dlen = RTA_PAYLOAD(tb[TCA_STAB_DATA]) / sizeof(__u16);
|
||||||
|
|
||||||
fprintf(fp, "\n%sstab data:", prefix);
|
fprintf(fp, "\n%sstab data:", prefix);
|
||||||
|
|
|
||||||
27
tc/tc_util.c
27
tc/tc_util.c
|
|
@ -32,7 +32,7 @@
|
||||||
#define LIBDIR "/usr/lib"
|
#define LIBDIR "/usr/lib"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct db_names *cls_names = NULL;
|
static struct db_names *cls_names;
|
||||||
|
|
||||||
#define NAMES_DB "/etc/iproute2/tc_cls"
|
#define NAMES_DB "/etc/iproute2/tc_cls"
|
||||||
|
|
||||||
|
|
@ -192,7 +192,7 @@ static const struct rate_suffix {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int get_rate(unsigned *rate, const char *str)
|
int get_rate(unsigned int *rate, const char *str)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
double bps = strtod(str, &p);
|
double bps = strtod(str, &p);
|
||||||
|
|
@ -272,7 +272,7 @@ char * sprint_rate(__u64 rate, char *buf)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_time(unsigned *time, const char *str)
|
int get_time(unsigned int *time, const char *str)
|
||||||
{
|
{
|
||||||
double t;
|
double t;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
@ -323,7 +323,7 @@ char * sprint_ticks(__u32 ticks, char *buf)
|
||||||
return sprint_time(tc_core_tick2time(ticks), buf);
|
return sprint_time(tc_core_tick2time(ticks), buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_size(unsigned *size, const char *str)
|
int get_size(unsigned int *size, const char *str)
|
||||||
{
|
{
|
||||||
double sz;
|
double sz;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
@ -353,7 +353,7 @@ int get_size(unsigned *size, const char *str)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_size_and_cell(unsigned *size, int *cell_log, char *str)
|
int get_size_and_cell(unsigned int *size, int *cell_log, char *str)
|
||||||
{
|
{
|
||||||
char *slash = strchr(str, '/');
|
char *slash = strchr(str, '/');
|
||||||
|
|
||||||
|
|
@ -453,6 +453,7 @@ int action_a2n(char *arg, int *result)
|
||||||
res = TC_ACT_RECLASSIFY;
|
res = TC_ACT_RECLASSIFY;
|
||||||
else {
|
else {
|
||||||
char dummy;
|
char dummy;
|
||||||
|
|
||||||
if (sscanf(arg, "%d%c", &res, &dummy) != 1)
|
if (sscanf(arg, "%d%c", &res, &dummy) != 1)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -460,7 +461,7 @@ int action_a2n(char *arg, int *result)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_linklayer(unsigned *val, const char *arg)
|
int get_linklayer(unsigned int *val, const char *arg)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
|
@ -477,7 +478,7 @@ int get_linklayer(unsigned *val, const char *arg)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_linklayer(char *buf, int len, unsigned linklayer)
|
void print_linklayer(char *buf, int len, unsigned int linklayer)
|
||||||
{
|
{
|
||||||
switch (linklayer) {
|
switch (linklayer) {
|
||||||
case LINKLAYER_UNSPEC:
|
case LINKLAYER_UNSPEC:
|
||||||
|
|
@ -495,7 +496,7 @@ void print_linklayer(char *buf, int len, unsigned linklayer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *sprint_linklayer(unsigned linklayer, char *buf)
|
char *sprint_linklayer(unsigned int linklayer, char *buf)
|
||||||
{
|
{
|
||||||
print_linklayer(buf, SPRINT_BSIZE-1, linklayer);
|
print_linklayer(buf, SPRINT_BSIZE-1, linklayer);
|
||||||
return buf;
|
return buf;
|
||||||
|
|
@ -504,12 +505,13 @@ char *sprint_linklayer(unsigned linklayer, char *buf)
|
||||||
void print_tm(FILE *f, const struct tcf_t *tm)
|
void print_tm(FILE *f, const struct tcf_t *tm)
|
||||||
{
|
{
|
||||||
int hz = get_user_hz();
|
int hz = get_user_hz();
|
||||||
|
|
||||||
if (tm->install != 0)
|
if (tm->install != 0)
|
||||||
fprintf(f, " installed %u sec", (unsigned)(tm->install/hz));
|
fprintf(f, " installed %u sec", (unsigned int)(tm->install/hz));
|
||||||
if (tm->lastuse != 0)
|
if (tm->lastuse != 0)
|
||||||
fprintf(f, " used %u sec", (unsigned)(tm->lastuse/hz));
|
fprintf(f, " used %u sec", (unsigned int)(tm->lastuse/hz));
|
||||||
if (tm->expires != 0)
|
if (tm->expires != 0)
|
||||||
fprintf(f, " expires %u sec", (unsigned)(tm->expires/hz));
|
fprintf(f, " expires %u sec", (unsigned int)(tm->expires/hz));
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtattr **xstats)
|
void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtattr **xstats)
|
||||||
|
|
@ -521,6 +523,7 @@ void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtat
|
||||||
|
|
||||||
if (tbs[TCA_STATS_BASIC]) {
|
if (tbs[TCA_STATS_BASIC]) {
|
||||||
struct gnet_stats_basic bs = {0};
|
struct gnet_stats_basic bs = {0};
|
||||||
|
|
||||||
memcpy(&bs, RTA_DATA(tbs[TCA_STATS_BASIC]), MIN(RTA_PAYLOAD(tbs[TCA_STATS_BASIC]), sizeof(bs)));
|
memcpy(&bs, RTA_DATA(tbs[TCA_STATS_BASIC]), MIN(RTA_PAYLOAD(tbs[TCA_STATS_BASIC]), sizeof(bs)));
|
||||||
fprintf(fp, "%sSent %llu bytes %u pkt",
|
fprintf(fp, "%sSent %llu bytes %u pkt",
|
||||||
prefix, (unsigned long long) bs.bytes, bs.packets);
|
prefix, (unsigned long long) bs.bytes, bs.packets);
|
||||||
|
|
@ -528,6 +531,7 @@ void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtat
|
||||||
|
|
||||||
if (tbs[TCA_STATS_QUEUE]) {
|
if (tbs[TCA_STATS_QUEUE]) {
|
||||||
struct gnet_stats_queue q = {0};
|
struct gnet_stats_queue q = {0};
|
||||||
|
|
||||||
memcpy(&q, RTA_DATA(tbs[TCA_STATS_QUEUE]), MIN(RTA_PAYLOAD(tbs[TCA_STATS_QUEUE]), sizeof(q)));
|
memcpy(&q, RTA_DATA(tbs[TCA_STATS_QUEUE]), MIN(RTA_PAYLOAD(tbs[TCA_STATS_QUEUE]), sizeof(q)));
|
||||||
fprintf(fp, " (dropped %u, overlimits %u requeues %u) ",
|
fprintf(fp, " (dropped %u, overlimits %u requeues %u) ",
|
||||||
q.drops, q.overlimits, q.requeues);
|
q.drops, q.overlimits, q.requeues);
|
||||||
|
|
@ -552,6 +556,7 @@ void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtat
|
||||||
|
|
||||||
if (tbs[TCA_STATS_QUEUE]) {
|
if (tbs[TCA_STATS_QUEUE]) {
|
||||||
struct gnet_stats_queue q = {0};
|
struct gnet_stats_queue q = {0};
|
||||||
|
|
||||||
memcpy(&q, RTA_DATA(tbs[TCA_STATS_QUEUE]), MIN(RTA_PAYLOAD(tbs[TCA_STATS_QUEUE]), sizeof(q)));
|
memcpy(&q, RTA_DATA(tbs[TCA_STATS_QUEUE]), MIN(RTA_PAYLOAD(tbs[TCA_STATS_QUEUE]), sizeof(q)));
|
||||||
if (!tbs[TCA_STATS_RATE_EST])
|
if (!tbs[TCA_STATS_RATE_EST])
|
||||||
fprintf(fp, "\n%s", prefix);
|
fprintf(fp, "\n%s", prefix);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue