Commit 11656f1b authored by osdl.net!shemminger's avatar osdl.net!shemminger

Style fix.

2005/03/04 18:46:32-08:00 net[shemminger]!shemminger
Import patch iproute-batch.1.050209.patch

(Logical change 1.162)
parent 044ebf35
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
#include "tc_util.h" #include "tc_util.h"
#include "tc_common.h" #include "tc_common.h"
static void usage(void) __attribute__((noreturn)); static int usage(void);
static void usage(void) static int usage(void)
{ {
fprintf(stderr, "Usage: tc qdisc [ add | del | replace | change | get ] dev STRING\n"); fprintf(stderr, "Usage: tc qdisc [ add | del | replace | change | get ] dev STRING\n");
fprintf(stderr, " [ handle QHANDLE ] [ root | ingress | parent CLASSID ]\n"); fprintf(stderr, " [ handle QHANDLE ] [ root | ingress | parent CLASSID ]\n");
...@@ -38,7 +38,7 @@ static void usage(void) ...@@ -38,7 +38,7 @@ static void usage(void)
fprintf(stderr, "Where:\n"); fprintf(stderr, "Where:\n");
fprintf(stderr, "QDISC_KIND := { [p|b]fifo | tbf | prio | cbq | red | etc. }\n"); fprintf(stderr, "QDISC_KIND := { [p|b]fifo | tbf | prio | cbq | red | etc. }\n");
fprintf(stderr, "OPTIONS := ... try tc qdisc add <desired QDISC_KIND> help\n"); fprintf(stderr, "OPTIONS := ... try tc qdisc add <desired QDISC_KIND> help\n");
exit(-1); return -1;
} }
int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv) int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv)
...@@ -81,14 +81,14 @@ int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv) ...@@ -81,14 +81,14 @@ int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv)
} else if (strcmp(*argv, "root") == 0) { } else if (strcmp(*argv, "root") == 0) {
if (req.t.tcm_parent) { if (req.t.tcm_parent) {
fprintf(stderr, "Error: \"root\" is duplicate parent ID\n"); fprintf(stderr, "Error: \"root\" is duplicate parent ID\n");
exit(-1); return -1;
} }
req.t.tcm_parent = TC_H_ROOT; req.t.tcm_parent = TC_H_ROOT;
#ifdef TC_H_INGRESS #ifdef TC_H_INGRESS
} else if (strcmp(*argv, "ingress") == 0) { } else if (strcmp(*argv, "ingress") == 0) {
if (req.t.tcm_parent) { if (req.t.tcm_parent) {
fprintf(stderr, "Error: \"ingress\" is a duplicate parent ID\n"); fprintf(stderr, "Error: \"ingress\" is a duplicate parent ID\n");
exit(-1); return -1;
} }
req.t.tcm_parent = TC_H_INGRESS; req.t.tcm_parent = TC_H_INGRESS;
strncpy(k, "ingress", sizeof(k)-1); strncpy(k, "ingress", sizeof(k)-1);
...@@ -128,42 +128,45 @@ int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv) ...@@ -128,42 +128,45 @@ int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv)
if (q) { if (q) {
if (q->parse_qopt(q, argc, argv, &req.n)) if (q->parse_qopt(q, argc, argv, &req.n))
exit(1); return 1;
} else { } else {
if (argc) { if (argc) {
if (matches(*argv, "help") == 0) if (matches(*argv, "help") == 0)
usage(); usage();
fprintf(stderr, "Garbage instead of arguments \"%s ...\". Try \"tc qdisc help\".\n", *argv); fprintf(stderr, "Garbage instead of arguments \"%s ...\". Try \"tc qdisc help\".\n", *argv);
exit(-1); return -1;
} }
} }
if (rtnl_open(&rth, 0) < 0) { if (!is_batch_mode)
fprintf(stderr, "Cannot open rtnetlink\n"); if (rtnl_open(&rth, 0) < 0) {
rtnl_close(&rth); fprintf(stderr, "Cannot open rtnetlink\n");
exit(1); rtnl_close(&rth);
} return 1;
}
if (d[0]) { if (d[0]) {
int idx; int idx;
ll_init_map(&rth); ll_init_map(&(is_batch_mode?g_rth:rth));
if ((idx = ll_name_to_index(d)) == 0) { if ((idx = ll_name_to_index(d)) == 0) {
fprintf(stderr, "Cannot find device \"%s\"\n", d); fprintf(stderr, "Cannot find device \"%s\"\n", d);
rtnl_close(&rth); rtnl_close(&rth);
exit(1); return 1;
} }
req.t.tcm_ifindex = idx; req.t.tcm_ifindex = idx;
} }
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) { if (rtnl_talk(&(is_batch_mode?g_rth:rth), &req.n, 0, 0, NULL, NULL, NULL) < 0) {
rtnl_close(&rth); if (!is_batch_mode)
exit(2); rtnl_close(&rth);
return 2;
} }
rtnl_close(&rth); if (!is_batch_mode)
rtnl_close(&rth);
return 0; return 0;
} }
...@@ -280,35 +283,39 @@ int tc_qdisc_list(int argc, char **argv) ...@@ -280,35 +283,39 @@ int tc_qdisc_list(int argc, char **argv)
argc--; argv++; argc--; argv++;
} }
if (rtnl_open(&rth, 0) < 0) { if (!is_batch_mode)
fprintf(stderr, "Cannot open rtnetlink\n"); if (rtnl_open(&rth, 0) < 0) {
exit(1); fprintf(stderr, "Cannot open rtnetlink\n");
} return 1;
}
ll_init_map(&rth);
ll_init_map(&(is_batch_mode?g_rth:rth));
if (d[0]) { if (d[0]) {
if ((t.tcm_ifindex = ll_name_to_index(d)) == 0) { if ((t.tcm_ifindex = ll_name_to_index(d)) == 0) {
fprintf(stderr, "Cannot find device \"%s\"\n", d); fprintf(stderr, "Cannot find device \"%s\"\n", d);
rtnl_close(&rth); rtnl_close(&rth);
exit(1); return 1;
} }
filter_ifindex = t.tcm_ifindex; filter_ifindex = t.tcm_ifindex;
} }
if (rtnl_dump_request(&rth, RTM_GETQDISC, &t, sizeof(t)) < 0) { if (rtnl_dump_request(&(is_batch_mode?g_rth:rth), RTM_GETQDISC, &t, sizeof(t)) < 0) {
perror("Cannot send dump request"); perror("Cannot send dump request");
rtnl_close(&rth); if (!is_batch_mode)
exit(1); rtnl_close(&rth);
return 1;
} }
if (rtnl_dump_filter(&rth, print_qdisc, stdout, NULL, NULL) < 0) { if (rtnl_dump_filter(&(is_batch_mode?g_rth:rth), print_qdisc, stdout, NULL, NULL) < 0) {
fprintf(stderr, "Dump terminated\n"); fprintf(stderr, "Dump terminated\n");
rtnl_close(&rth); if (!is_batch_mode)
exit(1); rtnl_close(&rth);
return 1;
} }
rtnl_close(&rth); if (!is_batch_mode)
rtnl_close(&rth);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment