tc: code cleanup

Use checkpatch to fix whitespace and other style issues.
This commit is contained in:
Stephen Hemminger 2016-03-21 11:48:36 -07:00
parent 4733b18a5e
commit 32a121cba2
70 changed files with 964 additions and 862 deletions

View File

@ -52,8 +52,8 @@ union ip_set_name_index {
#define IP_SET_OP_GET_BYNAME 0x00000006 /* Get set index by name */
struct ip_set_req_get_set {
unsigned op;
unsigned version;
unsigned int op;
unsigned int version;
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 */
struct ip_set_req_version {
unsigned op;
unsigned version;
unsigned int op;
unsigned int version;
};
#endif /* IPSET_INVALID_ID */
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);
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;
socklen_t size = sizeof(struct ip_set_req_get_set);
sockfd = get_version(&req->version);
if (sockfd < 0)
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)) {
fprintf(stderr,
"Incorrect return size from kernel during ipset lookup, "
"(want %zu, got %zu)\n",
"Incorrect return size from kernel during ipset lookup, (want %zu, got %zu)\n",
sizeof(struct ip_set_req_get_set), (size_t)size);
return -1;
}

View File

@ -126,7 +126,7 @@ static struct meta_entry * lookup_meta_entry(struct bstr *kind)
{
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) &&
meta_table[i].id != 0)
return &meta_table[i];
@ -138,7 +138,7 @@ static struct meta_entry * lookup_meta_entry_byid(int id)
{
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)
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:
if (TCF_META_ID(hdr->kind) == TCF_META_ID_VALUE) {
struct bstr *a = (struct bstr *) val;
addattr_l(n, MAX_MSG, tlv, a->data, a->len);
}
break;
@ -192,7 +193,7 @@ static void list_meta_ids(FILE *fd)
" 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) {
fprintf(fd, "\n%s:\n", meta_table[i].kind);
} else {

View File

@ -85,6 +85,7 @@ static int u32_parse_eopt(struct nlmsghdr *n, struct tcf_ematch_hdr *hdr,
nh_len = strlen("nexthdr+");
if (a->len > nh_len && !memcmp(a->data, "nexthdr+", nh_len)) {
char buf[a->len - nh_len + 1];
offmask = -1;
memcpy(buf, a->data + nh_len, a->len - nh_len);
offset = strtoul(buf, NULL, 0);

View File

@ -69,7 +69,8 @@ static int basic_parse_opt(struct filter_util *qu, char *handle,
continue;
} else if (matches(*argv, "classid") == 0 ||
strcmp(*argv, "flowid") == 0) {
unsigned handle;
unsigned int handle;
NEXT_ARG();
if (get_tc_classid(&handle, *argv)) {
fprintf(stderr, "Illegal \"classid\"\n");

View File

@ -270,6 +270,7 @@ static int flow_print_opt(struct filter_util *fu, FILE *f, struct rtattr *opt,
__u32 handle)
{
struct rtattr *tb[TCA_FLOW_MAX+1];
SPRINT_BUF(b1);
unsigned int i;
__u32 mask = ~0, val = 0;

View File

@ -187,7 +187,7 @@ static int flower_parse_opt(struct filter_util *qu, char *handle,
while (argc > 0) {
if (matches(*argv, "classid") == 0 ||
matches(*argv, "flowid") == 0) {
unsigned handle;
unsigned int handle;
NEXT_ARG();
ret = get_tc_classid(&handle, *argv);

View File

@ -43,6 +43,7 @@ static int fw_parse_opt(struct filter_util *qu, char *handle, int argc, char **a
if (handle) {
char *slash;
if ((slash = strchr(handle, '/')) != NULL)
*slash = '\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) {
if (matches(*argv, "classid") == 0 ||
matches(*argv, "flowid") == 0) {
unsigned handle;
unsigned int handle;
NEXT_ARG();
if (get_tc_classid(&handle, *argv)) {
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;
} else if (strcmp(*argv, "indev") == 0) {
char d[IFNAMSIZ+1];
memset(d, 0, sizeof(d));
argc--;
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]) {
__u32 mark = 0, mask = 0;
if (handle)
mark = handle;
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]);
if (tb[TCA_FW_INDEV]) {
struct rtattr *idev = tb[TCA_FW_INDEV];
fprintf(f, "input dev %s ", rta_getattr_str(idev));
}

View File

@ -60,6 +60,7 @@ static int route_parse_opt(struct filter_util *qu, char *handle, int argc, char
while (argc > 0) {
if (matches(*argv, "to") == 0) {
__u32 id;
NEXT_ARG();
if (rtnl_rtrealm_a2n(&id, *argv)) {
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;
} else if (matches(*argv, "from") == 0) {
__u32 id;
NEXT_ARG();
if (rtnl_rtrealm_a2n(&id, *argv)) {
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;
} else if (matches(*argv, "fromif") == 0) {
__u32 id;
NEXT_ARG();
ll_init_map(&rth);
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;
} else if (matches(*argv, "classid") == 0 ||
strcmp(*argv, "flowid") == 0) {
unsigned handle;
unsigned int handle;
NEXT_ARG();
if (get_tc_classid(&handle, *argv)) {
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)
{
struct rtattr *tb[TCA_ROUTE4_MAX+1];
SPRINT_BUF(b1);
if (opt == NULL)

View File

@ -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 ||
strcmp(*argv, "gpi/ah") == 0) {
__u32 gpi;
NEXT_ARG();
if (get_u32(&gpi, *argv, 0))
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 ||
strcmp(*argv, "gpi/esp") == 0) {
__u32 gpi;
NEXT_ARG();
if (get_u32(&gpi, *argv, 0))
return -1;
@ -99,6 +101,7 @@ static int get_addr_and_pi(int *argc_p, char ***argv_p, inet_prefix * addr,
argc--; argv++;
} else if (strcmp(*argv, "flowlabel") == 0) {
__u32 flabel;
NEXT_ARG();
if (get_u32(&flabel, *argv, 0))
return -1;
@ -114,6 +117,7 @@ static int get_addr_and_pi(int *argc_p, char ***argv_p, inet_prefix * addr,
int sz = 1;
__u32 tmp;
__u32 mask = 0xff;
if (strcmp(*argv, "u32") == 0) {
sz = 4;
mask = 0xffff;
@ -194,6 +198,7 @@ static int rsvp_parse_opt(struct filter_util *qu, char *handle, int argc, char *
while (argc > 0) {
if (matches(*argv, "session") == 0) {
inet_prefix addr;
NEXT_ARG();
if (get_addr_and_pi(&argc, &argv, &addr, &pinfo, 1, family)) {
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 ||
matches(*argv, "flowspec") == 0) {
inet_prefix addr;
NEXT_ARG();
if (get_addr_and_pi(&argc, &argv, &addr, &pinfo, 0, family)) {
fprintf(stderr, "Illegal \"sender\"\n");
@ -217,6 +223,7 @@ static int rsvp_parse_opt(struct filter_util *qu, char *handle, int argc, char *
continue;
} else if (matches("ipproto", *argv) == 0) {
int num;
NEXT_ARG();
num = inet_proto_a2n(*argv);
if (num < 0) {
@ -227,7 +234,8 @@ static int rsvp_parse_opt(struct filter_util *qu, char *handle, int argc, char *
pinfo_ok++;
} else if (matches(*argv, "classid") == 0 ||
strcmp(*argv, "flowid") == 0) {
unsigned handle;
unsigned int handle;
NEXT_ARG();
if (get_tc_classid(&handle, *argv)) {
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);
} else if (strcmp(*argv, "tunnelid") == 0) {
unsigned tid;
unsigned int tid;
NEXT_ARG();
if (get_unsigned(&tid, *argv, 0)) {
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_ok++;
} else if (strcmp(*argv, "tunnel") == 0) {
unsigned tid;
unsigned int tid;
NEXT_ARG();
if (get_unsigned(&tid, *argv, 0)) {
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]) {
char buf[128];
fprintf(f, "session ");
if (inet_ntop(family, RTA_DATA(tb[TCA_RSVP_DST]), buf, sizeof(buf)) == 0)
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);
if (tb[TCA_RSVP_SRC]) {
char buf[128];
fprintf(f, "sender ");
if (inet_ntop(family, RTA_DATA(tb[TCA_RSVP_SRC]), buf, sizeof(buf)) == 0) {
fprintf(f, "[BAD]");

View File

@ -17,11 +17,9 @@
static void explain(void)
{
fprintf(stderr," Usage: ... tcindex [ hash SIZE ] [ mask MASK ]"
" [ shift SHIFT ]\n");
fprintf(stderr," Usage: ... tcindex [ hash SIZE ] [ mask MASK ] [ shift SHIFT ]\n");
fprintf(stderr, " [ pass_on | fall_through ]\n");
fprintf(stderr," [ classid CLASSID ] "
"[ action ACTION_SPEC ]\n");
fprintf(stderr," [ classid CLASSID ] [ action ACTION_SPEC ]\n");
}
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;
}
addattr_l(n, 4096, TCA_TCINDEX_HASH, &hash, sizeof(hash));
}
else if (!strcmp(*argv,"mask")) {
} else if (!strcmp(*argv,"mask")) {
__u16 mask;
NEXT_ARG();
@ -63,8 +60,7 @@ static int tcindex_parse_opt(struct filter_util *qu, char *handle, int argc,
return -1;
}
addattr_l(n, 4096, TCA_TCINDEX_MASK, &mask, sizeof(mask));
}
else if (!strcmp(*argv,"shift")) {
} else if (!strcmp(*argv,"shift")) {
int shift;
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,
sizeof(shift));
}
else if (!strcmp(*argv,"fall_through")) {
} else if (!strcmp(*argv,"fall_through")) {
int value = 1;
addattr_l(n, 4096, TCA_TCINDEX_FALL_THROUGH, &value,
sizeof(value));
}
else if (!strcmp(*argv,"pass_on")) {
} else if (!strcmp(*argv,"pass_on")) {
int value = 0;
addattr_l(n, 4096, TCA_TCINDEX_FALL_THROUGH, &value,
sizeof(value));
}
else if (!strcmp(*argv,"classid")) {
} else if (!strcmp(*argv,"classid")) {
__u32 handle;
NEXT_ARG();
@ -97,24 +90,21 @@ static int tcindex_parse_opt(struct filter_util *qu, char *handle, int argc,
return -1;
}
addattr_l(n, 4096, TCA_TCINDEX_CLASSID, &handle, 4);
}
else if (!strcmp(*argv,"police")) {
} else if (!strcmp(*argv,"police")) {
NEXT_ARG();
if (parse_police(&argc, &argv, TCA_TCINDEX_POLICE, n)) {
fprintf(stderr, "Illegal \"police\"\n");
return -1;
}
continue;
}
else if (!strcmp(*argv,"action")) {
} else if (!strcmp(*argv,"action")) {
NEXT_ARG();
if (parse_police(&argc, &argv, TCA_TCINDEX_ACT, n)) {
fprintf(stderr, "Illegal \"action\"\n");
return -1;
}
continue;
}
else {
} else {
explain();
return -1;
}

View File

@ -30,17 +30,14 @@ extern int show_pretty;
static void explain(void)
{
fprintf(stderr, "Usage: ... u32 [ match SELECTOR ... ] [ link HTID ]"
" [ classid CLASSID ]\n");
fprintf(stderr, " [ action ACTION_SPEC ]"
" [ offset OFFSET_SPEC ]\n");
fprintf(stderr, "Usage: ... u32 [ match SELECTOR ... ] [ link HTID ] [ classid CLASSID ]\n");
fprintf(stderr, " [ action ACTION_SPEC ] [ offset OFFSET_SPEC ]\n");
fprintf(stderr, " [ ht HTID ] [ hashkey HASHKEY_SPEC ]\n");
fprintf(stderr, " [ sample SAMPLE ]\n");
fprintf(stderr, "or u32 divisor DIVISOR\n");
fprintf(stderr, "\n");
fprintf(stderr, "Where: SELECTOR := SAMPLE SAMPLE ...\n");
fprintf(stderr, " SAMPLE := { ip | ip6 | udp | tcp | icmp |"
" u{32|16|8} | mark } SAMPLE_ARGS [divisor DIVISOR]\n");
fprintf(stderr, " SAMPLE := { ip | ip6 | udp | tcp | icmp | u{32|16|8} | mark } SAMPLE_ARGS [divisor DIVISOR]\n");
fprintf(stderr, " FILTERID := X:Y:Z\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) {
int l = snprintf(b, bsize, "%x:", htid>>20);
bsize -= l;
b += l;
}
if (nodeid|hash) {
if (hash) {
int l = snprintf(b, bsize, "%x", hash);
bsize -= l;
b += l;
}
if (nodeid) {
int l = snprintf(b, bsize, ":%x", nodeid);
bsize -= l;
b += l;
}
@ -390,6 +390,7 @@ static int parse_ip6_addr(int *argc_p, char ***argv_p,
return -1;
} else if (i < plen) {
__u32 mask = htonl(0xFFFFFFFF << (32 - (plen - i)));
res = pack_key(sel, addr.data[i / 32],
mask, off + 4 * (i / 32), offmask);
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) {
if (matches(*argv, "plus") == 0) {
int off;
NEXT_ARG();
if (get_integer(&off, *argv, 0))
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;
} else if (matches(*argv, "at") == 0) {
int off;
NEXT_ARG();
if (get_integer(&off, *argv, 0))
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;
} else if (matches(*argv, "mask") == 0) {
__u16 mask;
NEXT_ARG();
if (get_u16(&mask, *argv, 16))
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;
} else if (matches(*argv, "shift") == 0) {
int shift;
NEXT_ARG();
if (get_integer(&shift, *argv, 0))
return -1;
@ -797,12 +802,14 @@ static int parse_hashkey(int *argc_p, char ***argv_p, struct tc_u32_sel *sel)
while (argc > 0) {
if (matches(*argv, "mask") == 0) {
__u32 mask;
NEXT_ARG();
if (get_u32(&mask, *argv, 16))
return -1;
sel->hmask = htonl(mask);
} else if (matches(*argv, "at") == 0) {
int num;
NEXT_ARG();
if (get_integer(&num, *argv, 0))
return -1;
@ -844,6 +851,7 @@ static void print_ipv4(FILE *f, const struct tc_u32_key *key)
case 12:
case 16: {
int bits = mask2bits(key->mask);
if (bits >= 0) {
fprintf(f, "\n %s %s/%d",
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 16: {
int bits = mask2bits(key->mask);
if (bits >= 0) {
fprintf(f, "\n %s %s/%d",
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)
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)) {
show_k:
u32_pprinters[i].pprinter(f, key);
@ -1022,7 +1031,8 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
continue;
} else if (matches(*argv, "classid") == 0 ||
strcmp(*argv, "flowid") == 0) {
unsigned handle;
unsigned int handle;
NEXT_ARG();
if (get_tc_classid(&handle, *argv)) {
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);
sel.sel.flags |= TC_U32_TERMINAL;
} else if (matches(*argv, "divisor") == 0) {
unsigned divisor;
unsigned int divisor;
NEXT_ARG();
if (get_unsigned(&divisor, *argv, 0) ||
divisor == 0 ||
@ -1047,7 +1058,8 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
return -1;
}
} else if (strcmp(*argv, "link") == 0) {
unsigned handle;
unsigned int handle;
NEXT_ARG();
if (get_u32_handle(&handle, *argv)) {
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);
} else if (strcmp(*argv, "ht") == 0) {
unsigned handle;
unsigned int handle;
NEXT_ARG();
if (get_u32_handle(&handle, *argv)) {
fprintf(stderr, "Illegal \"ht\"\n");
@ -1075,7 +1088,7 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
htid = (handle & 0xFFFFF000);
} else if (strcmp(*argv, "sample") == 0) {
__u32 hash;
unsigned divisor = 0x100;
unsigned int divisor = 0x100;
struct {
struct tc_u32_sel sel;
@ -1088,8 +1101,7 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
return -1;
}
if (sel2.sel.nkeys != 1) {
fprintf(stderr, "\"sample\" must contain"
" exactly ONE key.\n");
fprintf(stderr, "\"sample\" must contain exactly ONE key.\n");
return -1;
}
if (*argv != 0 && strcmp(*argv, "divisor") == 0) {
@ -1109,6 +1121,7 @@ static int u32_parse_opt(struct filter_util *qu, char *handle,
continue;
} else if (strcmp(*argv, "indev") == 0) {
char ind[IFNAMSIZ + 1];
memset(ind, 0, sizeof(ind));
argc--;
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]));
} else if (tb[TCA_U32_HASH]) {
__u32 htid = rta_getattr_u32(tb[TCA_U32_HASH]);
fprintf(f, "key ht %x bkt %x ", TC_U32_USERHTID(htid),
TC_U32_HASH(htid));
} else {
@ -1233,6 +1247,7 @@ static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
if (tb[TCA_U32_MARK]) {
struct tc_u32_mark *mark = RTA_DATA(tb[TCA_U32_MARK]);
if (RTA_PAYLOAD(tb[TCA_U32_MARK]) < sizeof(*mark)) {
fprintf(f, "\n Invalid mark (kernel&iproute2 mismatch)\n");
} else {
@ -1244,6 +1259,7 @@ static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt,
if (sel) {
if (sel->nkeys) {
int i;
for (i = 0; i < sel->nkeys; i++) {
show_keys(f, sel->keys + i);
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]) {
struct rtattr *idev = tb[TCA_U32_INDEV];
fprintf(f, "\n input dev %s\n", rta_getattr_str(idev));
}
if (tb[TCA_U32_ACT]) {

View File

@ -30,9 +30,9 @@
static struct action_util *action_list;
#ifdef CONFIG_GACT
int gact_ld = 0 ; //fuckin backward compatibility
int gact_ld; /* f*ckin backward compatibility */
#endif
int tab_flush = 0;
int tab_flush;
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))
fprintf(f, "[Unknown action, optlen=%u] ",
(unsigned) RTA_PAYLOAD(opt));
(unsigned int) RTA_PAYLOAD(opt));
return 0;
}
@ -195,6 +195,7 @@ parse_action(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n)
goto done0;
} else {
struct action_util *a = NULL;
strncpy(k, *argv, sizeof(k) - 1);
eap = 0;
if (argc > 0) {
@ -207,7 +208,7 @@ done0:
goto done;
}
if (NULL == a) {
if (a == NULL) {
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]));
if (NULL == a)
if (a == NULL)
return err;
err = a->print_aopt(a, f, tb[TCA_ACT_OPTIONS]);
if (0 > err)
if (err < 0)
return err;
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]));
if (NULL == a)
if (a == NULL)
return err;
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++) {
if (tb[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");
}
}
@ -354,7 +355,7 @@ int print_action(const struct sockaddr_nl *who,
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)
fprintf(stderr, "print_action: NULL kind\n");
return -1;
@ -376,7 +377,7 @@ int print_action(const struct sockaddr_nl *who,
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];
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);
a = get_action_kind(k);
if (NULL == a) {
if (a == NULL) {
fprintf(stderr, "Error: non existent action: %s\n", k);
ret = -1;
goto bad_val;
@ -488,7 +489,7 @@ bad_val:
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;
char **argv = *argv_p;
@ -557,7 +558,7 @@ static int tc_act_list_or_flush(int argc, char **argv, int event)
}
#endif
a = get_action_kind(k);
if (NULL == a) {
if (a == NULL) {
fprintf(stderr, "bad action %s\n", k);
goto bad_val;
}

View File

@ -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 tc_act_bpf *parm;
SPRINT_BUF(action_buf);
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 (tb[TCA_ACT_BPF_TM]) {
struct tcf_t *tm = RTA_DATA(tb[TCA_ACT_BPF_TM]);
print_tm(f, tm);
}
}

View File

@ -151,6 +151,7 @@ static int print_connmark(struct action_util *au, FILE *f, struct rtattr *arg)
if (show_stats) {
if (tb[TCA_CONNMARK_TM]) {
struct tcf_t *tm = RTA_DATA(tb[TCA_CONNMARK_TM]);
print_tm(f, tm);
}
}

View File

@ -24,8 +24,7 @@ explain(void)
{
fprintf(stderr, "Usage: ... csum <UPDATE>\n"
"Where: UPDATE := <TARGET> [<UPDATE>]\n"
" TARGET := { ip4h | icmp | igmp |"
" tcp | udp | udplite | <SWEETS> }\n"
" TARGET := { ip4h | icmp | igmp | tcp | udp | udplite | <SWEETS> }\n"
" SWEETS := { and | or | \'+\' }\n");
}
@ -108,8 +107,7 @@ parse_csum(struct action_util *a, int *argc_p,
continue;
} else if (matches(*argv, "help") == 0) {
usage();
}
else {
} else {
break;
}
}
@ -186,6 +184,7 @@ print_csum(struct action_util *au, FILE * f, struct rtattr *arg)
char *uflag_4 = "";
char *uflag_5 = "";
char *uflag_6 = "";
SPRINT_BUF(action_buf);
int uflag_count = 0;
@ -231,6 +230,7 @@ print_csum(struct action_util *au, FILE * f, struct rtattr *arg)
if (show_stats) {
if (tb[TCA_CSUM_TM]) {
struct tcf_t *tm = RTA_DATA(tb[TCA_CSUM_TM]);
print_tm(f, tm);
}
}

View File

@ -33,7 +33,7 @@ static struct ematch_util *ematch_list;
/* export to bison parser */
int ematch_argc;
char **ematch_argv;
char *ematch_err = NULL;
char *ematch_err;
struct ematch *ematch_root;
static int begin_argc;
@ -188,6 +188,7 @@ static int parse_tree(struct nlmsghdr *n, struct ematch *tree)
if (t->child) {
__u32 r = t->child_ref;
addraw_l(n, MAX_MSG, &hdr, sizeof(hdr));
addraw_l(n, MAX_MSG, &r, sizeof(r));
} else {
@ -558,6 +559,7 @@ void print_ematch_tree(const struct ematch *tree)
printf(")");
} else {
struct bstr *b;
for (b = t->args; b; b = b->next)
printf("%s%s", b->data, b->next ? " " : "");
}

View File

@ -38,7 +38,7 @@ int parse_estimator(int *p_argc, char ***p_argv, struct tc_estimator *est)
{
int argc = *p_argc;
char **argv = *p_argv;
unsigned A, time_const;
unsigned int A, time_const;
NEXT_ARG();
if (est->ewma_log)

View File

@ -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)));
#ifdef CONFIG_GACT_PROB
if (NULL != tb[TCA_GACT_PROB]) {
if (tb[TCA_GACT_PROB] != NULL) {
pp = RTA_DATA(tb[TCA_GACT_PROB]);
} else {
/* need to keep consistent output */
@ -241,6 +241,7 @@ print_gact(struct action_util *au,FILE * f, struct rtattr *arg)
if (show_stats) {
if (tb[TCA_GACT_TM]) {
struct tcf_t *tm = RTA_DATA(tb[TCA_GACT_TM]);
print_tm(f, tm);
}
}

View File

@ -51,9 +51,9 @@ static struct option original_opts[] = {
{0, 0, 0, 0}
};
static struct iptables_target *t_list = NULL;
static struct iptables_target *t_list;
static struct option *opts = original_opts;
static unsigned int global_option_offset = 0;
static unsigned int global_option_offset;
#define OPTION_OFFSET 256
char *lib_dir;
@ -209,6 +209,7 @@ static struct iptables_target *
find_t(char *name)
{
struct iptables_target *m;
for (m = t_list; m; m = m->next) {
if (strcmp(m->name, name) == 0)
return m;
@ -247,6 +248,7 @@ get_target_name(const char *name)
if (isupper(lname[0])) {
int i;
for (i = 0; i < strlen(name); i++) {
lname[i] = tolower(lname[i]);
}
@ -254,6 +256,7 @@ get_target_name(const char *name)
if (islower(new_name[0])) {
int i;
for (i = 0; i < strlen(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);
if ((error = dlerror()) != NULL) {
m = find_t(new_name);
if (NULL == m) {
if (m == NULL) {
m = find_t(lname);
if (NULL == m) {
if (m == NULL) {
fputs(error, stderr);
fprintf(stderr, "\n");
dlclose(handle);
@ -368,7 +371,7 @@ build_st(struct iptables_target *target, struct ipt_entry_target *t)
size =
IPT_ALIGN(sizeof(struct ipt_entry_target)) + target->size;
if (NULL == t) {
if (t == NULL) {
target->t = fw_calloc(1, size);
target->t->u.target_size = size;
@ -406,6 +409,7 @@ static int parse_ipt(struct action_util *a,int *argc_p,
{
int i;
for (i = 0; i < rargc; i++) {
if (NULL == argv[i] || 0 == strcmp(argv[i], "action")) {
break;
@ -426,9 +430,9 @@ static int parse_ipt(struct action_util *a,int *argc_p,
switch (c) {
case 'j':
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);
return -1;
}
@ -482,6 +486,7 @@ static int parse_ipt(struct action_util *a,int *argc_p,
{
struct tcmsg *t = NLMSG_DATA(n);
if (t->tcm_parent != TC_H_ROOT
&& t->tcm_parent == TC_H_MAJ(TC_H_INGRESS)) {
hook = NF_IP_PRE_ROUTING;
@ -560,6 +565,7 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
return -1;
} else {
__u32 hook;
hook = rta_getattr_u32(tb[TCA_IPT_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;
} else {
struct iptables_target *m = NULL;
t = RTA_DATA(tb[TCA_IPT_TARG]);
m = get_target_name(t->u.user.name);
if (NULL != m) {
if (0 > build_st(m, t)) {
if (m != NULL) {
if (build_st(m, t) < 0) {
fprintf(stderr, " %s error\n", m->name);
return -1;
}
@ -591,17 +598,20 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
fprintf(f, " [NULL ipt target index ]\n");
} else {
__u32 index;
index = rta_getattr_u32(tb[TCA_IPT_INDEX]);
fprintf(f, "\n\tindex %d", index);
}
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);
}
if (show_stats) {
if (tb[TCA_IPT_TM]) {
struct tcf_t *tm = RTA_DATA(tb[TCA_IPT_TM]);
print_tm(f, tm);
}
}

View File

@ -145,6 +145,7 @@ parse_egress(struct action_util *a, int *argc_p, char ***argv_p,
if (d[0]) {
int idx;
ll_init_map(&rth);
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) {
int ret = parse_egress(a, &argc, &argv, tca_id, n);
if (ret == 0) {
*argc_p = argc;
*argv_p = argv;
@ -253,6 +255,7 @@ print_mirred(struct action_util *au,FILE * f, struct rtattr *arg)
struct tc_mirred *p;
struct rtattr *tb[TCA_MIRRED_MAX + 1];
const char *dev;
SPRINT_BUF(b1);
if (arg == NULL)
@ -284,6 +287,7 @@ print_mirred(struct action_util *au,FILE * f, struct rtattr *arg)
if (show_stats) {
if (tb[TCA_MIRRED_TM]) {
struct tcf_t *tm = RTA_DATA(tb[TCA_MIRRED_TM]);
print_tm(f, tm);
}
}

View File

@ -171,6 +171,7 @@ print_nat(struct action_util *au,FILE * f, struct rtattr *arg)
struct rtattr *tb[TCA_NAT_MAX + 1];
char buf1[256];
char buf2[256];
SPRINT_BUF(buf3);
int len;
@ -198,6 +199,7 @@ print_nat(struct action_util *au,FILE * f, struct rtattr *arg)
if (show_stats) {
if (tb[TCA_NAT_TM]) {
struct tcf_t *tm = RTA_DATA(tb[TCA_NAT_TM]);
print_tm(f, tm);
}
}

View File

@ -38,14 +38,10 @@ explain(void)
fprintf(stderr, "Usage: ... pedit munge <MUNGE> [<BRANCH>]\n");
fprintf(stderr,
"Where: MUNGE := <RAW>|<LAYERED>\n"
"\t<RAW>:= <OFFSETC>[ATC]<CMD>\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\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<RAW>:= <OFFSETC>[ATC]<CMD>\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\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<BRANCH>:= reclassify | pipe | drop | continue | pass\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)
return -1;
if (TINT == type)
if (type == TINT)
return get_integer((int *) val, *argv, 0);
if (TU32 == type)
if (type == TU32)
return get_u32(val, *argv, 0);
if (TIPV4 == type) {
if (type == TIPV4) {
inet_prefix addr;
if (get_prefix_1(&addr, *argv, AF_INET)) {
return -1;
}
*val = addr.data[0];
return 0;
}
if (TIPV6 == type) {
if (type == TIPV6) {
/* not implemented yet */
return -1;
}
@ -411,7 +408,7 @@ parse_munge(int *argc_p, char ***argv_p,struct tc_pedit_sel *sel)
if (argc > 0) {
p = get_pedit_kind(k);
if (NULL == p)
if (p == NULL)
goto bad_val;
NEXT_ARG();
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 rtattr *tb[TCA_PEDIT_MAX + 1];
SPRINT_BUF(b1);
if (arg == NULL)
@ -548,6 +546,7 @@ print_pedit(struct action_util *au,FILE * f, struct rtattr *arg)
if (show_stats) {
if (tb[TCA_PEDIT_TM]) {
struct tcf_t *tm = RTA_DATA(tb[TCA_PEDIT_TM]);
print_tm(f, tm);
}
}

View File

@ -91,6 +91,7 @@ static int police_action_a2n(const char *arg, int *result)
res = TC_POLICE_PIPE;
else {
char dummy;
if (sscanf(arg, "%d%c", &res, &dummy) != 1)
return -1;
}
@ -323,7 +324,7 @@ print_police(struct action_util *a, FILE *f, struct rtattr *arg)
SPRINT_BUF(b2);
struct tc_police *p;
struct rtattr *tb[TCA_POLICE_MAX+1];
unsigned buffer;
unsigned int buffer;
unsigned int linklayer;
if (arg == NULL)

View File

@ -187,6 +187,7 @@ static int print_simple(struct action_util *au, FILE * f, struct rtattr *arg)
if (show_stats) {
if (tb[TCA_DEF_TM]) {
struct tcf_t *tm = RTA_DATA(tb[TCA_DEF_TM]);
print_tm(f, tm);
}
}

View File

@ -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)
{
struct rtattr *tb[TCA_SKBEDIT_MAX + 1];
SPRINT_BUF(b1);
__u32 *priority;
__u32 *mark;
@ -198,6 +199,7 @@ static int print_skbedit(struct action_util *au, FILE *f, struct rtattr *arg)
if (show_stats) {
if (tb[TCA_SKBEDIT_TM]) {
struct tcf_t *tm = RTA_DATA(tb[TCA_SKBEDIT_TM]);
print_tm(f, tm);
}
}

View File

@ -211,6 +211,7 @@ static int print_vlan(struct action_util *au, FILE *f, struct rtattr *arg)
if (show_stats) {
if (tb[TCA_VLAN_TM]) {
struct tcf_t *tm = RTA_DATA(tb[TCA_VLAN_TM]);
print_tm(f, tm);
}
}

View File

@ -87,7 +87,7 @@ build_st(struct xtables_target *target, struct xt_entry_target *t)
size_t size =
XT_ALIGN(sizeof(struct xt_entry_target)) + target->size;
if (NULL == t) {
if (t == NULL) {
target->t = xtables_calloc(1, size);
target->t->u.target_size = size;
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;
for (i = 0; i < rargc; i++) {
if (NULL == argv[i] || 0 == strcmp(argv[i], "action")) {
break;
@ -158,9 +159,9 @@ static int parse_ipt(struct action_util *a,int *argc_p,
switch (c) {
case 'j':
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);
return -1;
}
@ -235,6 +236,7 @@ static int parse_ipt(struct action_util *a,int *argc_p,
{
struct tcmsg *t = NLMSG_DATA(n);
if (t->tcm_parent != TC_H_ROOT
&& t->tcm_parent == TC_H_MAJ(TC_H_INGRESS)) {
hook = NF_IP_PRE_ROUTING;
@ -318,6 +320,7 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
return -1;
} else {
__u32 hook;
hook = rta_getattr_u32(tb[TCA_IPT_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;
} else {
struct xtables_target *m = NULL;
t = RTA_DATA(tb[TCA_IPT_TARG]);
m = xtables_find_target(t->u.user.name, XTF_TRY_LOAD);
if (NULL != m) {
if (0 > build_st(m, t)) {
if (m != NULL) {
if (build_st(m, t) < 0) {
fprintf(stderr, " %s error\n", m->name);
return -1;
}
@ -361,17 +365,20 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
fprintf(f, " [NULL ipt target index ]\n");
} else {
__u32 index;
index = rta_getattr_u32(tb[TCA_IPT_INDEX]);
fprintf(f, "\n\tindex %d", index);
}
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);
}
if (show_stats) {
if (tb[TCA_IPT_TM]) {
struct tcf_t *tm = RTA_DATA(tb[TCA_IPT_TM]);
print_tm(f, tm);
}
}

View File

@ -63,7 +63,7 @@ static struct option original_opts[] = {
};
static struct option *opts = original_opts;
static unsigned int global_option_offset = 0;
static unsigned int global_option_offset;
char *lib_dir;
const char *program_version = XTABLES_VERSION;
const char *program_name = "tc-ipt";
@ -175,7 +175,7 @@ build_st(struct xtables_target *target, struct xt_entry_target *t)
size_t size =
XT_ALIGN(sizeof(struct xt_entry_target)) + target->size;
if (NULL == t) {
if (t == NULL) {
target->t = fw_calloc(1, size);
target->t->u.target_size = size;
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;
for (i = 0; i < rargc; i++) {
if (NULL == argv[i] || 0 == strcmp(argv[i], "action")) {
break;
@ -243,9 +244,9 @@ static int parse_ipt(struct action_util *a,int *argc_p,
switch (c) {
case 'j':
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);
return -1;
}
@ -299,6 +300,7 @@ static int parse_ipt(struct action_util *a,int *argc_p,
{
struct tcmsg *t = NLMSG_DATA(n);
if (t->tcm_parent != TC_H_ROOT
&& t->tcm_parent == TC_H_MAJ(TC_H_INGRESS)) {
hook = NF_IP_PRE_ROUTING;
@ -375,6 +377,7 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
return -1;
} else {
__u32 hook;
hook = rta_getattr_u32(tb[TCA_IPT_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;
} else {
struct xtables_target *m = NULL;
t = RTA_DATA(tb[TCA_IPT_TARG]);
m = find_target(t->u.user.name, TRY_LOAD);
if (NULL != m) {
if (0 > build_st(m, t)) {
if (m != NULL) {
if (build_st(m, t) < 0) {
fprintf(stderr, " %s error\n", m->name);
return -1;
}
@ -406,17 +410,20 @@ print_ipt(struct action_util *au,FILE * f, struct rtattr *arg)
fprintf(f, " [NULL ipt target index ]\n");
} else {
__u32 index;
index = rta_getattr_u32(tb[TCA_IPT_INDEX]);
fprintf(f, "\n\tindex %d", index);
}
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);
}
if (show_stats) {
if (tb[TCA_IPT_TM]) {
struct tcf_t *tm = RTA_DATA(tb[TCA_IPT_TM]);
print_tm(f, tm);
}
}

View File

@ -39,10 +39,8 @@ static int atm_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
static void explain(void)
{
fprintf(stderr, "Usage: ... atm ( pvc ADDR | svc ADDR [ sap SAP ] ) "
"[ qos QOS ] [ sndbuf BYTES ]\n");
fprintf(stderr, " [ hdr HEX... ] [ excess ( CLASSID | clp ) ] "
"[ clip ]\n");
fprintf(stderr, "Usage: ... atm ( pvc ADDR | svc ADDR [ sap SAP ] ) [ qos QOS ] [ sndbuf BYTES ]\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();
return -1;
}
}
else if (!strcmp(*argv,"svc")) {
} else if (!strcmp(*argv,"svc")) {
NEXT_ARG();
if (text2atm(*argv, (struct sockaddr *) &addr,
sizeof(addr), T2A_SVC | T2A_NAME) < 0) {
explain();
return -1;
}
}
else if (!strcmp(*argv,"qos")) {
} else if (!strcmp(*argv,"qos")) {
NEXT_ARG();
if (text2qos(*argv, &qos, 0) < 0) {
explain();
return -1;
}
}
else if (!strcmp(*argv,"sndbuf")) {
} else if (!strcmp(*argv,"sndbuf")) {
char *end;
NEXT_ARG();
@ -96,16 +91,14 @@ static int atm_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
explain();
return -1;
}
}
else if (!strcmp(*argv,"sap")) {
} else if (!strcmp(*argv,"sap")) {
NEXT_ARG();
if (addr.sas_family != AF_ATMSVC ||
text2sap(*argv, &sap, T2A_NAME) < 0) {
explain();
return -1;
}
}
else if (!strcmp(*argv,"hdr")) {
} else if (!strcmp(*argv,"hdr")) {
unsigned char *ptr;
char *walk;
@ -129,19 +122,16 @@ static int atm_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
walk++;
}
hdr_len = ptr-hdr;
}
else if (!strcmp(*argv,"excess")) {
} else if (!strcmp(*argv,"excess")) {
NEXT_ARG();
if (!strcmp(*argv, "clp")) excess = 0;
else if (get_tc_classid(&excess, *argv)) {
explain();
return -1;
}
}
else if (!strcmp(*argv,"clip")) {
} else if (!strcmp(*argv,"clip")) {
set_clip = 1;
}
else {
} else {
explain();
return 1;
}

View File

@ -81,8 +81,9 @@ static int cbq_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
return -1;
}
} else if (matches(*argv, "cell") == 0) {
unsigned cell;
unsigned int cell;
int i;
NEXT_ARG();
if (get_size(&cell, *argv)) {
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);
if (show_raw) {
int i;
for (i = 0; i < 256; i++)
printf("%u ", rtab[i]);
printf("\n");
@ -190,7 +192,7 @@ static int cbq_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, str
unsigned mpu = 0;
int cell_log = -1;
int ewma_log = -1;
unsigned bndw = 0;
unsigned int bndw = 0;
unsigned minburst = 0, maxburst = 0;
unsigned short overhead = 0;
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;
} else if (matches(*argv, "cell") == 0) {
unsigned cell;
unsigned int cell;
int i;
NEXT_ARG();
if (get_size(&cell, *argv)) {
explain1("cell");
@ -276,7 +279,8 @@ static int cbq_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, str
}
cell_log = i;
} else if (matches(*argv, "prio") == 0) {
unsigned prio;
unsigned int prio;
NEXT_ARG();
if (get_u32(&prio, *argv, 0)) {
explain1("prio");
@ -323,6 +327,7 @@ static int cbq_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, str
fopt_ok++;
} else if (matches(*argv, "defmap") == 0) {
int err;
NEXT_ARG();
err = sscanf(*argv, "%08x/%08x", &fopt.defmap, &fopt.defchange);
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 */
if (r.rate) {
unsigned pktsize = wrr.allot;
unsigned int pktsize = wrr.allot;
if (wrr.allot < (lss.avpkt*3)/2)
wrr.allot = (lss.avpkt*3)/2;
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);
if (show_raw) {
int i;
for (i = 0; i < 256; i++)
printf("%u ", rtab[i]);
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_ovl *ovl = NULL;
unsigned int linklayer;
SPRINT_BUF(b1);
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 (RTA_PAYLOAD(tb[TCA_CBQ_OVL_STRATEGY]) < sizeof(*ovl))
fprintf(stderr, "CBQ: too short overlimit strategy %u/%u\n",
(unsigned) RTA_PAYLOAD(tb[TCA_CBQ_OVL_STRATEGY]),
(unsigned) sizeof(*ovl));
(unsigned int) RTA_PAYLOAD(tb[TCA_CBQ_OVL_STRATEGY]),
(unsigned int) sizeof(*ovl));
else
ovl = RTA_DATA(tb[TCA_CBQ_OVL_STRATEGY]);
}
if (r) {
char buf[64];
print_rate(buf, sizeof(buf), r->rate);
fprintf(f, "rate %s ", buf);
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) {
int comma = 0;
fprintf(f, "(");
if (lss->flags&TCF_CBQ_LSS_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");
if (show_details) {
char buf[64];
fprintf(f, "/%u ", wrr->cpriority);
if (wrr->weight != 1) {
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) {
char buf[64];
print_tc_classid(buf, sizeof(buf), fopt->split);
fprintf(f, "\nsplit %s ", buf);
if (fopt->defmap) {

View File

@ -35,10 +35,10 @@ static int choke_parse_opt(struct qdisc_util *qu, int argc, char **argv,
struct nlmsghdr *n)
{
struct tc_red_qopt opt;
unsigned burst = 0;
unsigned avpkt = 1000;
unsigned int burst = 0;
unsigned int avpkt = 1000;
double probability = 0.02;
unsigned rate = 0;
unsigned int rate = 0;
int ecn_ok = 0;
int wlog;
__u8 sbuf[256];

View File

@ -61,10 +61,10 @@ static void explain(void)
static int codel_parse_opt(struct qdisc_util *qu, int argc, char **argv,
struct nlmsghdr *n)
{
unsigned limit = 0;
unsigned target = 0;
unsigned interval = 0;
unsigned ce_threshold = ~0U;
unsigned int limit = 0;
unsigned int target = 0;
unsigned int interval = 0;
unsigned int ce_threshold = ~0U;
int ecn = -1;
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)
{
struct rtattr *tb[TCA_CODEL_MAX + 1];
unsigned limit;
unsigned interval;
unsigned target;
unsigned ecn;
unsigned ce_threshold;
unsigned int limit;
unsigned int interval;
unsigned int target;
unsigned int ecn;
unsigned int ce_threshold;
SPRINT_BUF(b1);
if (opt == NULL)
@ -175,6 +176,7 @@ static int codel_print_xstats(struct qdisc_util *qu, FILE *f,
struct rtattr *xstats)
{
struct tc_codel_xstats _st, *st;
SPRINT_BUF(b1);
if (xstats == NULL)

View File

@ -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)
{
struct rtattr *tb[TCA_DRR_MAX + 1];
SPRINT_BUF(b1);
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)
{
struct tc_drr_stats *x;
SPRINT_BUF(b1);
if (xstats == NULL)

View File

@ -21,8 +21,7 @@
static void explain(void)
{
fprintf(stderr,"Usage: dsmark indices INDICES [ default_index "
"DEFAULT_INDEX ] [ set_tc_index ]\n");
fprintf(stderr,"Usage: dsmark indices INDICES [ default_index DEFAULT_INDEX ] [ set_tc_index ]\n");
}
@ -44,8 +43,7 @@ static int dsmark_parse_opt(struct qdisc_util *qu, int argc, char **argv,
explain();
return -1;
}
}
else if (!strcmp(*argv,"default_index") || !strcmp(*argv,
} else if (!strcmp(*argv,"default_index") || !strcmp(*argv,
"default")) {
NEXT_ARG();
dflt = strtoul(*argv, &end, 0);
@ -53,11 +51,9 @@ static int dsmark_parse_opt(struct qdisc_util *qu, int argc, char **argv,
explain();
return -1;
}
}
else if (!strcmp(*argv,"set_tc_index")) {
} else if (!strcmp(*argv,"set_tc_index")) {
set_tc_index = 1;
}
else {
} else {
explain();
return -1;
}
@ -106,8 +102,7 @@ static int dsmark_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
return -1;
}
addattr_l(n, 1024, TCA_DSMARK_MASK, &tmp, 1);
}
else if (!strcmp(*argv,"value")) {
} else if (!strcmp(*argv,"value")) {
NEXT_ARG();
tmp = strtoul(*argv, &end, 0);
if (*end) {
@ -115,8 +110,7 @@ static int dsmark_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
return -1;
}
addattr_l(n, 1024, TCA_DSMARK_VALUE, &tmp, 1);
}
else {
} else {
explain_class();
return -1;
}

View File

@ -32,6 +32,7 @@ static int fifo_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct n
{
int ok = 0;
struct tc_fifo_qopt opt;
memset(&opt, 0, sizeof(opt));
while (argc > 0) {

View File

@ -218,6 +218,7 @@ static int fq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
unsigned int rate, quantum;
unsigned int refill_delay;
unsigned int orphan_mask;
SPRINT_BUF(b1);
if (opt == NULL)

View File

@ -59,12 +59,12 @@ static void explain(void)
static int fq_codel_parse_opt(struct qdisc_util *qu, int argc, char **argv,
struct nlmsghdr *n)
{
unsigned limit = 0;
unsigned flows = 0;
unsigned target = 0;
unsigned interval = 0;
unsigned quantum = 0;
unsigned ce_threshold = ~0U;
unsigned int limit = 0;
unsigned int flows = 0;
unsigned int target = 0;
unsigned int interval = 0;
unsigned int quantum = 0;
unsigned int ce_threshold = ~0U;
int ecn = -1;
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)
{
struct rtattr *tb[TCA_FQ_CODEL_MAX + 1];
unsigned limit;
unsigned flows;
unsigned interval;
unsigned target;
unsigned ecn;
unsigned quantum;
unsigned ce_threshold;
unsigned int limit;
unsigned int flows;
unsigned int interval;
unsigned int target;
unsigned int ecn;
unsigned int quantum;
unsigned int ce_threshold;
SPRINT_BUF(b1);
if (opt == NULL)
@ -202,6 +203,7 @@ static int fq_codel_print_xstats(struct qdisc_util *qu, FILE *f,
struct rtattr *xstats)
{
struct tc_fq_codel_xstats _st, *st;
SPRINT_BUF(b1);
if (xstats == NULL)

View File

@ -63,14 +63,13 @@ static int init_gred(struct qdisc_util *qu, int argc, char **argv,
fprintf(stderr, "Illegal \"vqs\"\n");
return -1;
} else if (opt.DPs > MAX_DPs) {
fprintf(stderr, "GRED: only %u VQs are "
"currently supported\n", MAX_DPs);
fprintf(stderr, "GRED: only %u VQs are currently supported\n",
MAX_DPs);
return -1;
}
} else if (strcmp(*argv, "default") == 0) {
if (opt.DPs == 0) {
fprintf(stderr, "\"default\" must be defined "
"after \"vqs\"\n");
fprintf(stderr, "\"default\" must be defined after \"vqs\"\n");
return -1;
}
NEXT_ARG();
@ -78,8 +77,7 @@ static int init_gred(struct qdisc_util *qu, int argc, char **argv,
fprintf(stderr, "Illegal \"default\"\n");
return -1;
} else if (opt.def_DP >= opt.DPs) {
fprintf(stderr, "\"default\" must be less than "
"\"vqs\"\n");
fprintf(stderr, "\"default\" must be less than \"vqs\"\n");
return -1;
}
} 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;
struct tc_gred_qopt opt = { 0 };
unsigned burst = 0;
unsigned avpkt = 0;
unsigned int burst = 0;
unsigned int avpkt = 0;
double probability = 0.02;
unsigned rate = 0;
unsigned int rate = 0;
int parm;
__u8 sbuf[256];
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");
return -1;
} else if (opt.DP >= MAX_DPs) {
fprintf(stderr, "GRED: only %u VQs are "
"currently supported\n", MAX_DPs);
fprintf(stderr, "GRED: only %u VQs are currently supported\n",
MAX_DPs);
return -1;
} /* need a better error check */
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 ||
!avpkt) {
fprintf(stderr, "Required parameter (vq, limit, min, max, "
"avpkt) is missing\n");
fprintf(stderr, "Required parameter (vq, limit, min, max, avpkt) is missing\n");
return -1;
}
if (!burst) {
@ -241,8 +238,8 @@ static int gred_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct n
return -1;
}
if (parm >= 10)
fprintf(stderr, "GRED: WARNING. Burst %u seems to be too "
"large.\n", burst);
fprintf(stderr, "GRED: WARNING. Burst %u seems to be too large.\n",
burst);
opt.Wlog = parm;
if ((parm = tc_red_eval_P(opt.qth_min, opt.qth_max, probability)) < 0) {
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;
if ((parm = tc_red_eval_idle_damping(opt.Wlog, avpkt, rate, sbuf)) < 0)
{
fprintf(stderr, "GRED: failed to calculate idle damping "
"table.\n");
fprintf(stderr, "GRED: failed to calculate idle damping table.\n");
return -1;
}
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;
__u32 *max_p = NULL;
__u32 *limit = NULL;
unsigned i;
unsigned int i;
SPRINT_BUF(b1);
SPRINT_BUF(b2);
SPRINT_BUF(b3);

View File

@ -203,8 +203,7 @@ hfsc_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
return -1;
}
if (usc_ok && !fsc_ok) {
fprintf(stderr, "HFSC: Upper-limit Service Curve without "
"Link-Share Service Curve\n");
fprintf(stderr, "HFSC: Upper-limit Service Curve without Link-Share Service Curve\n");
explain_class();
return -1;
}

View File

@ -28,13 +28,13 @@ static void explain(void)
static int hhf_parse_opt(struct qdisc_util *qu, int argc, char **argv,
struct nlmsghdr *n)
{
unsigned limit = 0;
unsigned quantum = 0;
unsigned hh_limit = 0;
unsigned reset_timeout = 0;
unsigned admit_bytes = 0;
unsigned evict_timeout = 0;
unsigned non_hh_weight = 0;
unsigned int limit = 0;
unsigned int quantum = 0;
unsigned int hh_limit = 0;
unsigned int reset_timeout = 0;
unsigned int admit_bytes = 0;
unsigned int evict_timeout = 0;
unsigned int non_hh_weight = 0;
struct rtattr *tail;
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)
{
struct rtattr *tb[TCA_HHF_MAX + 1];
unsigned limit;
unsigned quantum;
unsigned hh_limit;
unsigned reset_timeout;
unsigned admit_bytes;
unsigned evict_timeout;
unsigned non_hh_weight;
unsigned int limit;
unsigned int quantum;
unsigned int hh_limit;
unsigned int reset_timeout;
unsigned int admit_bytes;
unsigned int evict_timeout;
unsigned int non_hh_weight;
SPRINT_BUF(b1);
if (opt == NULL)

View File

@ -65,7 +65,8 @@ static int htb_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
unsigned int direct_qlen = ~0U;
struct tc_htb_glob opt;
struct rtattr *tail;
unsigned i; char *p;
unsigned int i; char *p;
memset(&opt, 0, sizeof(opt));
opt.rate2quantum = 10;
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];
unsigned buffer = 0, cbuffer = 0;
int cell_log = -1, ccell_log = -1;
unsigned mtu;
unsigned int mtu;
unsigned short mpu = 0;
unsigned short overhead = 0;
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;
unsigned int linklayer;
__u64 rate64, ceil64;
SPRINT_BUF(b1);
SPRINT_BUF(b2);
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)
{
struct tc_htb_xstats *st;
if (xstats == NULL)
return 0;

View File

@ -58,7 +58,7 @@ static const double max_percent_value = 0xffffffff;
/* scaled value used to percent of maximum. */
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;
while (getline(&line, &len, f) != -1) {
char *p, *endp;
if (*line == '\n' || *line == '#')
continue;
@ -154,7 +155,7 @@ static int get_distribution(const char *type, __s16 *data, int maxdata)
(based on kernel PSCHED_CLOCK configuration */
static int get_ticks(__u32 *ticks, const char *str)
{
unsigned t;
unsigned int t;
if (get_time(&t, str))
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;
int len = RTA_PAYLOAD(opt) - sizeof(qopt);
__u64 rate64 = 0;
SPRINT_BUF(b1);
if (opt == NULL)
@ -558,6 +560,7 @@ static int netem_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
if (len > 0) {
struct rtattr *tb[TCA_NETEM_MAX+1];
parse_rtattr(tb, TCA_NETEM_MAX, RTA_DATA(opt) + sizeof(qopt),
len);

View File

@ -136,8 +136,9 @@ static int pie_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
unsigned int target;
unsigned int alpha;
unsigned int beta;
unsigned ecn;
unsigned bytemode;
unsigned int ecn;
unsigned int bytemode;
SPRINT_BUF(b1);
if (opt == NULL)

View File

@ -57,7 +57,8 @@ static int prio_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct n
explain();
return -1;
} else {
unsigned band;
unsigned int band;
if (!pmap_mode) {
fprintf(stderr, "What is \"%s\"?\n", *argv);
explain();

View File

@ -36,10 +36,10 @@ static void explain(void)
static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
{
struct tc_red_qopt opt;
unsigned burst = 0;
unsigned avpkt = 0;
unsigned int burst = 0;
unsigned int avpkt = 0;
double probability = 0.02;
unsigned rate = 0;
unsigned int rate = 0;
int parm;
__u8 sbuf[256];
__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 tc_red_qopt *qopt;
__u32 max_P = 0;
SPRINT_BUF(b1);
SPRINT_BUF(b2);
SPRINT_BUF(b3);

View File

@ -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) {
mq = 1;
} else {
unsigned band;
unsigned int band;
if (!pmap_mode) {
fprintf(stderr, "What is \"%s\"?\n", *argv);
explain();

View File

@ -158,8 +158,7 @@ static int sfb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
fprintf(f,
"limit %d max %d target %d\n"
" increment %.5f decrement %.5f penalty rate %d burst %d "
"(%ums %ums)",
" increment %.5f decrement %.5f penalty rate %d burst %d (%ums %ums)",
qopt->limit, qopt->max, qopt->bin_size,
(double)qopt->increment / SFB_MAX_PROB,
(double)qopt->decrement / SFB_MAX_PROB,

View File

@ -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_v1 *qopt_ext = NULL;
SPRINT_BUF(b1);
SPRINT_BUF(b2);
SPRINT_BUF(b3);

View File

@ -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, "maxburst") == 0) {
const char *parm_name = *argv;
NEXT_ARG();
if (buffer) {
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 ||
strcmp(*argv, "minburst") == 0) {
const char *parm_name = *argv;
NEXT_ARG();
if (mtu) {
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) {
double lim = rate64*(double)latency/TIME_UNITS_PER_SEC + buffer;
if (prate64) {
double lim2 = prate64*(double)latency/TIME_UNITS_PER_SEC + mtu;
if (lim2 < lim)
lim = lim2;
}
@ -254,6 +258,7 @@ static int tbf_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
double buffer, mtu;
double latency;
__u64 rate64 = 0, prate64 = 0;
SPRINT_BUF(b1);
SPRINT_BUF(b2);
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);
if (prate64) {
double lat2 = TIME_UNITS_PER_SEC*(qopt->limit/(double)prate64) - tc_core_tick2time(qopt->mtu);
if (lat2 > latency)
latency = lat2;
}

30
tc/tc.c
View File

@ -31,24 +31,24 @@
#include "tc_common.h"
#include "namespace.h"
int show_stats = 0;
int show_details = 0;
int show_raw = 0;
int show_pretty = 0;
int show_graph = 0;
int show_stats;
int show_details;
int show_raw;
int show_pretty;
int show_graph;
int timestamp;
int batch_mode = 0;
int resolve_hosts = 0;
int use_iec = 0;
int force = 0;
bool use_names = false;
int batch_mode;
int resolve_hosts;
int use_iec;
int force;
bool use_names;
static char *conf_file;
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 filter_util *filter_list;
@ -57,7 +57,7 @@ static int print_noqopt(struct qdisc_util *qu, FILE *f,
{
if (opt && RTA_PAYLOAD(opt))
fprintf(f, "[Unknown qdisc, optlen=%u] ",
(unsigned) RTA_PAYLOAD(opt));
(unsigned int) RTA_PAYLOAD(opt));
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))
fprintf(f, "fh %08x [Unknown filter, optlen=%u] ",
fhandle, (unsigned) RTA_PAYLOAD(opt));
fhandle, (unsigned int) RTA_PAYLOAD(opt));
else if (fhandle)
fprintf(f, "fh %08x ", fhandle);
return 0;
@ -90,6 +90,7 @@ static int parse_nofopt(struct filter_util *qu, char *fhandle, int argc, char **
}
if (fhandle) {
struct tcmsg *t = NLMSG_DATA(n);
if (get_u32(&handle, fhandle, 16)) {
fprintf(stderr, "Unparsable filter ID \"%s\"\n", fhandle);
return -1;
@ -192,8 +193,7 @@ static void usage(void)
fprintf(stderr, "Usage: tc [ OPTIONS ] OBJECT { COMMAND | help }\n"
" tc [-force] -batch filename\n"
"where OBJECT := { qdisc | class | filter | action | monitor | exec }\n"
" OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -b[atch] [filename] | "
"-n[etns] name |\n"
" OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -b[atch] [filename] | -n[etns] name |\n"
" -nm | -nam[es] | { -cf | -conf } path }\n");
}

View File

@ -167,8 +167,7 @@ static int bpf_ops_parse(int argc, char **argv, struct sock_filter *bpf_ops,
token = bpf_string;
while ((token = strchr(token, separator)) && (++token)[0]) {
if (i >= bpf_len) {
fprintf(stderr, "Real program length exceeds encoded "
"length parameter!\n");
fprintf(stderr, "Real program length exceeds encoded length parameter!\n");
ret = -EINVAL;
goto out;
}
@ -185,8 +184,7 @@ static int bpf_ops_parse(int argc, char **argv, struct sock_filter *bpf_ops,
}
if (i != bpf_len) {
fprintf(stderr, "Parsed program length is less than encoded"
"length parameter!\n");
fprintf(stderr, "Parsed program length is less than encodedlength parameter!\n");
ret = -EINVAL;
goto out;
}
@ -385,7 +383,7 @@ int bpf_trace_pipe(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 const char *mnt;
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 {
ret = sscanf(section, "%*i/%i", &map_key);
if (ret != 1) {
fprintf(stderr, "Couldn\'t infer map key from section "
"name! Please provide \'key\' argument!\n");
fprintf(stderr, "Couldn\'t infer map key from section name! Please provide \'key\' argument!\n");
ret = -EINVAL;
goto out_prog;
}
@ -889,7 +886,7 @@ out_cfd:
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];
uint8_t tmp[20];
int ret;
@ -920,8 +917,7 @@ static int bpf_init_env(const char *pathname)
setrlimit(RLIMIT_MEMLOCK, &limit);
if (!bpf_get_tc_dir()) {
fprintf(stderr, "Continuing without mounted eBPF fs. "
"Too old kernel?\n");
fprintf(stderr, "Continuing without mounted eBPF fs. Too old kernel?\n");
return 0;
}
@ -1091,8 +1087,7 @@ retry:
if (tries++ < 6 && !bpf_log_realloc(ctx))
goto retry;
fprintf(stderr, "Log buffer too small to dump "
"verifier log %zu bytes (%d tries)!\n",
fprintf(stderr, "Log buffer too small to dump verifier log %zu bytes (%d tries)!\n",
ctx->log_size, tries);
return fd;
}
@ -1311,8 +1306,8 @@ static int bpf_fetch_ancillary(struct bpf_elf_ctx *ctx)
!strcmp(data.sec_name, ".strtab"))
ret = bpf_fetch_strtab(ctx, i, &data);
if (ret < 0) {
fprintf(stderr, "Error parsing section %d! Perhaps"
"check with readelf -a?\n", i);
fprintf(stderr, "Error parsing section %d! Perhapscheck with readelf -a?\n",
i);
break;
}
}
@ -1383,21 +1378,18 @@ static int bpf_apply_relo_data(struct bpf_elf_ctx *ctx,
ioff = relo.r_offset / sizeof(struct bpf_insn);
if (ioff >= num_insns ||
insns[ioff].code != (BPF_LD | BPF_IMM | BPF_DW)) {
fprintf(stderr, "ELF contains relo data for non ld64 "
"instruction at offset %u! Compiler bug?!\n",
fprintf(stderr, "ELF contains relo data for non ld64 instruction at offset %u! Compiler bug?!\n",
ioff);
if (ioff < num_insns &&
insns[ioff].code == (BPF_JMP | BPF_CALL))
fprintf(stderr, " - Try to annotate functions "
"with always_inline attribute!\n");
fprintf(stderr, " - Try to annotate functions with always_inline attribute!\n");
return -EINVAL;
}
if (gelf_getsym(ctx->sym_tab, GELF_R_SYM(relo.r_info), &sym) != &sym)
return -EIO;
if (sym.st_shndx != ctx->sec_maps) {
fprintf(stderr, "ELF contains non-map related relo data in "
"entry %u pointing to section %u! Compiler bug?!\n",
fprintf(stderr, "ELF contains non-map related relo data in entry %u pointing to section %u! Compiler bug?!\n",
relo_ent, sym.st_shndx);
return -EIO;
}
@ -1409,8 +1401,7 @@ static int bpf_apply_relo_data(struct bpf_elf_ctx *ctx,
return -EINVAL;
if (ctx->verbose)
fprintf(stderr, "Map \'%s\' (%d) injected into prog "
"section \'%s\' at offset %u!\n",
fprintf(stderr, "Map \'%s\' (%d) injected into prog section \'%s\' at offset %u!\n",
bpf_str_tab_name(ctx, &sym), ctx->map_fds[rmap],
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)) {
fprintf(stderr, "Database %s, id %u is reserved - "
"ignoring!\n", db_file, pinning);
fprintf(stderr, "Database %s, id %u is reserved - ignoring!\n",
db_file, pinning);
continue;
}

View File

@ -24,8 +24,8 @@
#include "tc_core.h"
#include "tc_cbq.h"
unsigned tc_cbq_calc_maxidle(unsigned bndw, unsigned rate, unsigned avpkt,
int ewma_log, unsigned maxburst)
unsigned int tc_cbq_calc_maxidle(unsigned int bndw, unsigned int rate, unsigned int avpkt,
int ewma_log, unsigned int maxburst)
{
double maxidle;
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);
if (bndw != rate && maxburst) {
double vxmt = (double)avpkt/rate - xmt;
vxmt *= (pow(g, -(double)maxburst) - 1);
if (vxmt > maxidle)
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);
}
unsigned tc_cbq_calc_offtime(unsigned bndw, unsigned rate, unsigned avpkt,
int ewma_log, unsigned minburst)
unsigned int tc_cbq_calc_offtime(unsigned int bndw, unsigned int rate, unsigned int avpkt,
int ewma_log, unsigned int minburst)
{
double g = 1.0 - 1.0/(1<<ewma_log);
double offtime = (double)avpkt/rate - (double)avpkt/bndw;

View File

@ -55,7 +55,7 @@ static void usage(void)
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 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);
} else if (strcmp(*argv, "classid") == 0) {
__u32 handle;
NEXT_ARG();
if (req.t.tcm_handle)
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;
} else if (strcmp(*argv, "parent") == 0) {
__u32 handle;
NEXT_ARG();
if (req.t.tcm_parent)
duparg("parent", *argv);
@ -430,6 +432,7 @@ static int tc_class_list(int argc, char **argv)
t.tcm_parent = TC_H_ROOT;
} else if (strcmp(*argv, "parent") == 0) {
__u32 handle;
if (t.tcm_parent)
duparg("parent", *argv);
NEXT_ARG();

View File

@ -27,7 +27,7 @@
static double tick_in_usec = 1;
static double clock_factor = 1;
int tc_core_time2big(unsigned time)
int tc_core_time2big(unsigned int 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;
}
unsigned tc_core_tick2time(unsigned tick)
unsigned int tc_core_tick2time(unsigned int tick)
{
return tick/tick_in_usec;
}
unsigned tc_core_time2ktime(unsigned time)
unsigned int tc_core_time2ktime(unsigned int time)
{
return time * clock_factor;
}
unsigned tc_core_ktime2time(unsigned ktime)
unsigned int tc_core_ktime2time(unsigned int ktime)
{
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));
}
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;
}
@ -76,9 +76,10 @@ unsigned tc_calc_xmitsize(__u64 rate, unsigned ticks)
* (as the table will always be aligned for 48 bytes).
* --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;
cells = size / ATM_CELL_PAYLOAD;
if ((size % ATM_CELL_PAYLOAD) > 0)
cells++;
@ -87,7 +88,7 @@ static unsigned tc_align_to_atm(unsigned size)
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)
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);
case LINKLAYER_ETHERNET:
default:
// No size adjustments on Ethernet
/* No size adjustments on Ethernet */
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 cell_log, unsigned mtu,
int cell_log, unsigned int mtu,
enum link_layer linklayer)
{
int i;
unsigned sz;
unsigned bps = r->rate;
unsigned mpu = r->mpu;
unsigned int sz;
unsigned int bps = r->rate;
unsigned int mpu = r->mpu;
if (mtu == 0)
mtu = 2047;
@ -144,7 +145,7 @@ int tc_calc_rtable(struct tc_ratespec *r, __u32 *rtab,
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->linklayer = (linklayer & TC_LINKLAYER_MASK);
return cell_log;
@ -193,7 +194,7 @@ again:
(*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;
}

View File

@ -23,7 +23,7 @@
#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++) {
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;
for (est->ewma_log = 1; est->ewma_log < 32; est->ewma_log++) {
double w = 1.0 - 1.0/(1<<est->ewma_log);
if (A/(-log(w)) > time_const)
break;
}

View File

@ -19,7 +19,7 @@
#include "tc_common.h"
static struct exec_util *exec_list;
static void *BODY = NULL;
static void *BODY;
static void usage(void)
{
@ -32,8 +32,8 @@ static void usage(void)
static int parse_noeopt(struct exec_util *eu, int argc, char **argv)
{
if (argc) {
fprintf(stderr, "Unknown exec \"%s\", hence option \"%s\" "
"is unparsable\n", eu->id, *argv);
fprintf(stderr, "Unknown exec \"%s\", hence option \"%s\" is unparsable\n",
eu->id, *argv);
return -1;
}

View File

@ -41,7 +41,7 @@ static void usage(void)
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 nlmsghdr n;
@ -99,6 +99,7 @@ static int tc_filter_modify(int cmd, unsigned flags, int argc, char **argv)
TC_H_MIN_EGRESS);
} else if (strcmp(*argv, "parent") == 0) {
__u32 handle;
NEXT_ARG();
if (req.t.tcm_parent)
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);
} else if (matches(*argv, "protocol") == 0) {
__u16 id;
NEXT_ARG();
if (protocol_set)
duparg("protocol", *argv);
@ -153,8 +155,7 @@ static int tc_filter_modify(int cmd, unsigned flags, int argc, char **argv)
return 1;
} else {
if (fhandle) {
fprintf(stderr, "Must specify filter type when using "
"\"handle\"\n");
fprintf(stderr, "Must specify filter type when using \"handle\"\n");
return -1;
}
if (argc) {
@ -189,7 +190,7 @@ static __u32 filter_parent;
static int filter_ifindex;
static __u32 filter_prio;
static __u32 filter_protocol;
__u16 f_proto = 0;
__u16 f_proto;
int print_filter(const struct sockaddr_nl *who,
struct nlmsghdr *n,
@ -243,6 +244,7 @@ int print_filter(const struct sockaddr_nl *who,
if (t->tcm_info) {
f_proto = TC_H_MIN(t->tcm_info);
__u32 prio = TC_H_MAJ(t->tcm_info)>>16;
if (!filter_protocol || filter_protocol != f_proto) {
if (f_proto) {
SPRINT_BUF(b1);
@ -316,6 +318,7 @@ static int tc_filter_list(int argc, char **argv)
t.tcm_parent = filter_parent;
} else if (strcmp(*argv, "parent") == 0) {
__u32 handle;
NEXT_ARG();
if (t.tcm_parent)
duparg("parent", *argv);
@ -337,6 +340,7 @@ static int tc_filter_list(int argc, char **argv)
filter_prio = prio;
} else if (matches(*argv, "protocol") == 0) {
__u16 res;
NEXT_ARG();
if (protocol)
duparg("protocol", *argv);

View File

@ -73,7 +73,7 @@ int do_tcmonitor(int argc, char **argv)
{
struct rtnl_handle rth;
char *file = NULL;
unsigned groups = nl_mgrp(RTNLGRP_TC);
unsigned int groups = nl_mgrp(RTNLGRP_TC);
while (argc > 0) {
if (matches(*argv, "file") == 0) {

View File

@ -42,7 +42,7 @@ static int usage(void)
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 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);
} else if (strcmp(*argv, "handle") == 0) {
__u32 handle;
if (req.t.tcm_handle)
duparg("handle", *argv);
NEXT_ARG();
@ -113,6 +114,7 @@ static int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv)
break;
} else if (strcmp(*argv, "parent") == 0) {
__u32 handle;
NEXT_ARG();
if (req.t.tcm_parent)
duparg("parent", *argv);

View File

@ -27,7 +27,7 @@
/*
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;
@ -50,15 +50,15 @@ int tc_red_eval_P(unsigned qmin, unsigned qmax, double prob)
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;
double W = 0.5;
double a = (double)burst + 1 - (double)qmin/avpkt;
if (a < 1.0) {
fprintf(stderr, "tc_red_eval_ewma() burst %u is too small ?"
" Try burst %u\n", burst, 1 + qmin/avpkt);
fprintf(stderr, "tc_red_eval_ewma() burst %u is too small ? Try burst %u\n",
burst, 1 + qmin/avpkt);
return -1;
}
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
*/
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 lW = -log(1.0 - 1.0/(1<<Wlog))/xmit_time;

View File

@ -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)
{
struct rtattr *tb[TCA_STAB_MAX + 1];
SPRINT_BUF(b1);
parse_rtattr_nested(tb, TCA_STAB_MAX, rta);
if (tb[TCA_STAB_BASE]) {
struct tc_sizespec s = {0};
memcpy(&s, RTA_DATA(tb[TCA_STAB_BASE]),
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 (tb[TCA_STAB_DATA]) {
unsigned i, j, dlen;
unsigned int i, j, dlen;
__u16 *data = RTA_DATA(tb[TCA_STAB_DATA]);
dlen = RTA_PAYLOAD(tb[TCA_STAB_DATA]) / sizeof(__u16);
fprintf(fp, "\n%sstab data:", prefix);

View File

@ -32,7 +32,7 @@
#define LIBDIR "/usr/lib"
#endif
static struct db_names *cls_names = NULL;
static struct db_names *cls_names;
#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;
double bps = strtod(str, &p);
@ -272,7 +272,7 @@ char * sprint_rate(__u64 rate, char *buf)
return buf;
}
int get_time(unsigned *time, const char *str)
int get_time(unsigned int *time, const char *str)
{
double t;
char *p;
@ -323,7 +323,7 @@ char * sprint_ticks(__u32 ticks, char *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;
char *p;
@ -353,7 +353,7 @@ int get_size(unsigned *size, const char *str)
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, '/');
@ -453,6 +453,7 @@ int action_a2n(char *arg, int *result)
res = TC_ACT_RECLASSIFY;
else {
char dummy;
if (sscanf(arg, "%d%c", &res, &dummy) != 1)
return -1;
}
@ -460,7 +461,7 @@ int action_a2n(char *arg, int *result)
return 0;
}
int get_linklayer(unsigned *val, const char *arg)
int get_linklayer(unsigned int *val, const char *arg)
{
int res;
@ -477,7 +478,7 @@ int get_linklayer(unsigned *val, const char *arg)
return 0;
}
void print_linklayer(char *buf, int len, unsigned linklayer)
void print_linklayer(char *buf, int len, unsigned int linklayer)
{
switch (linklayer) {
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);
return buf;
@ -504,12 +505,13 @@ char *sprint_linklayer(unsigned linklayer, char *buf)
void print_tm(FILE *f, const struct tcf_t *tm)
{
int hz = get_user_hz();
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)
fprintf(f, " used %u sec", (unsigned)(tm->lastuse/hz));
fprintf(f, " used %u sec", (unsigned int)(tm->lastuse/hz));
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)
@ -521,6 +523,7 @@ void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtat
if (tbs[TCA_STATS_BASIC]) {
struct gnet_stats_basic bs = {0};
memcpy(&bs, RTA_DATA(tbs[TCA_STATS_BASIC]), MIN(RTA_PAYLOAD(tbs[TCA_STATS_BASIC]), sizeof(bs)));
fprintf(fp, "%sSent %llu bytes %u pkt",
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]) {
struct gnet_stats_queue q = {0};
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) ",
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]) {
struct gnet_stats_queue q = {0};
memcpy(&q, RTA_DATA(tbs[TCA_STATS_QUEUE]), MIN(RTA_PAYLOAD(tbs[TCA_STATS_QUEUE]), sizeof(q)));
if (!tbs[TCA_STATS_RATE_EST])
fprintf(fp, "\n%s", prefix);