static void usage(void)
{
- fprintf(stderr, "Usage: tc class [ add | del | change | replace | show ] dev STRING\n");
- fprintf(stderr, " [ classid CLASSID ] [ root | parent CLASSID ]\n");
- fprintf(stderr, " [ [ QDISC_KIND ] [ help | OPTIONS ] ]\n");
- fprintf(stderr, "\n");
- fprintf(stderr, " tc class show [ dev STRING ] [ root | parent CLASSID ]\n");
- fprintf(stderr, "Where:\n");
- fprintf(stderr, "QDISC_KIND := { prio | cbq | etc. }\n");
- fprintf(stderr, "OPTIONS := ... try tc class add <desired QDISC_KIND> help\n");
+ fprintf(stderr,
+ "Usage: tc class [ add | del | change | replace | show ] dev STRING\n"
+ " [ classid CLASSID ] [ root | parent CLASSID ]\n"
+ " [ [ QDISC_KIND ] [ help | OPTIONS ] ]\n"
+ "\n"
+ " tc class show [ dev STRING ] [ root | parent CLASSID ]\n"
+ "Where:\n"
+ "QDISC_KIND := { prio | cbq | etc. }\n"
+ "OPTIONS := ... try tc class add <desired QDISC_KIND> help\n");
}
static int tc_class_modify(int cmd, unsigned int flags, int argc, char **argv)
};
struct qdisc_util *q = NULL;
struct tc_estimator est = {};
- char d[16] = {};
- char k[16] = {};
+ char d[IFNAMSIZ] = {};
+ char k[FILTER_NAMESZ] = {};
while (argc > 0) {
if (strcmp(*argv, "dev") == 0) {
fprintf(stderr, "Error: Qdisc \"%s\" is classless.\n", k);
return 1;
}
- if (q->parse_copt(q, argc, argv, &req.n))
+ if (q->parse_copt(q, argc, argv, &req.n, d))
return 1;
} else {
if (argc) {
if (d[0]) {
ll_init_map(&rth);
- if ((req.t.tcm_ifindex = ll_name_to_index(d)) == 0) {
- fprintf(stderr, "Cannot find device \"%s\"\n", d);
- return 1;
- }
+ req.t.tcm_ifindex = ll_name_to_index(d);
+ if (!req.t.tcm_ifindex)
+ return -nodev(d);
}
if (rtnl_talk(&rth, &req.n, NULL) < 0)
return 0;
}
-int filter_ifindex;
-__u32 filter_qdisc;
-__u32 filter_classid;
+static int filter_ifindex;
+static __u32 filter_qdisc;
+static __u32 filter_classid;
static void graph_node_add(__u32 parent_id, __u32 id, void *data,
int len)
char cls_id_str[256] = {};
struct rtattr *tb[TCA_MAX + 1];
struct qdisc_util *q;
- char str[100] = {};
+ char str[300] = {};
hlist_for_each_safe(n, tmp_cls, root_list) {
struct hlist_node *c, *tmp_chld;
graph_indent(buf, cls, 0, 0);
print_tc_classid(cls_id_str, sizeof(cls_id_str), cls->id);
- sprintf(str, "+---(%s)", cls_id_str);
+ snprintf(str, sizeof(str),
+ "+---(%s)", cls_id_str);
strcat(buf, str);
parse_rtattr(tb, TCA_MAX, (struct rtattr *)cls->data,
}
}
-int print_class(const struct sockaddr_nl *who,
- struct nlmsghdr *n, void *arg)
+int print_class(struct nlmsghdr *n, void *arg)
{
FILE *fp = (FILE *)arg;
struct tcmsg *t = NLMSG_DATA(n);
static int tc_class_list(int argc, char **argv)
{
struct tcmsg t = { .tcm_family = AF_UNSPEC };
- char d[16] = {};
+ char d[IFNAMSIZ] = {};
char buf[1024] = {0};
filter_qdisc = 0;
ll_init_map(&rth);
if (d[0]) {
- if ((t.tcm_ifindex = ll_name_to_index(d)) == 0) {
- fprintf(stderr, "Cannot find device \"%s\"\n", d);
- return 1;
- }
+ t.tcm_ifindex = ll_name_to_index(d);
+ if (!t.tcm_ifindex)
+ return -nodev(d);
filter_ifindex = t.tcm_ifindex;
}