mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-10-20 08:04:53 +00:00
tc: add oneline mode
Add initial support for oneline mode in tc; actions, filters and qdiscs will be gradually updated in the follow-up patches. Signed-off-by: Roman Mashak <mrv@mojatatu.com> Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
parent
8c5bf7f0e6
commit
6e8634eb13
@ -95,7 +95,8 @@ tc \- show / manipulate traffic control settings
|
|||||||
\fB[ \fB-n\fR[\fIetns\fR] name \fB] \fR|
|
\fB[ \fB-n\fR[\fIetns\fR] name \fB] \fR|
|
||||||
\fB[ \fB-nm \fR| \fB-nam\fR[\fIes\fR] \fB] \fR|
|
\fB[ \fB-nm \fR| \fB-nam\fR[\fIes\fR] \fB] \fR|
|
||||||
\fB[ \fR{ \fB-cf \fR| \fB-c\fR[\fIonf\fR] \fR} \fB[ filename ] \fB] \fR
|
\fB[ \fR{ \fB-cf \fR| \fB-c\fR[\fIonf\fR] \fR} \fB[ filename ] \fB] \fR
|
||||||
\fB[ -t\fR[imestamp\fR] \fB\] \fR| \fB[ -t\fR[short\fR] \fB]\fR }
|
\fB[ -t\fR[imestamp\fR] \fB\] \fR| \fB[ -t\fR[short\fR] \fR| \fB[
|
||||||
|
-o\fR[neline\fR] \fB]\fR }
|
||||||
|
|
||||||
.ti 8
|
.ti 8
|
||||||
.IR FORMAT " := {"
|
.IR FORMAT " := {"
|
||||||
@ -648,6 +649,18 @@ First failure will cause termination of tc.
|
|||||||
don't terminate tc on errors in batch mode.
|
don't terminate tc on errors in batch mode.
|
||||||
If there were any errors during execution of the commands, the application return code will be non zero.
|
If there were any errors during execution of the commands, the application return code will be non zero.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BR "\-o" , " \-oneline"
|
||||||
|
output each record on a single line, replacing line feeds
|
||||||
|
with the
|
||||||
|
.B '\e'
|
||||||
|
character. This is convenient when you want to count records
|
||||||
|
with
|
||||||
|
.BR wc (1)
|
||||||
|
or to
|
||||||
|
.BR grep (1)
|
||||||
|
the output.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BR "\-n" , " \-net" , " \-netns " <NETNS>
|
.BR "\-n" , " \-net" , " \-netns " <NETNS>
|
||||||
switches
|
switches
|
||||||
|
8
tc/tc.c
8
tc/tc.c
@ -42,6 +42,8 @@ int force;
|
|||||||
bool use_names;
|
bool use_names;
|
||||||
int json;
|
int json;
|
||||||
int color;
|
int color;
|
||||||
|
int oneline;
|
||||||
|
const char *_SL_;
|
||||||
|
|
||||||
static char *conf_file;
|
static char *conf_file;
|
||||||
|
|
||||||
@ -191,7 +193,7 @@ static void usage(void)
|
|||||||
"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] | -b[atch] [filename] | -n[etns] name |\n"
|
" OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -b[atch] [filename] | -n[etns] name |\n"
|
||||||
" -nm | -nam[es] | { -cf | -conf } path } |\n"
|
" -nm | -nam[es] | { -cf | -conf } path } |\n"
|
||||||
" -j[son] -p[retty] -c[olor]\n");
|
" -o[neline] -j[son] -p[retty] -c[olor]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_cmd(int argc, char **argv, void *buf, size_t buflen)
|
static int do_cmd(int argc, char **argv, void *buf, size_t buflen)
|
||||||
@ -487,6 +489,8 @@ int main(int argc, char **argv)
|
|||||||
++timestamp_short;
|
++timestamp_short;
|
||||||
} else if (matches(argv[1], "-json") == 0) {
|
} else if (matches(argv[1], "-json") == 0) {
|
||||||
++json;
|
++json;
|
||||||
|
} else if (matches(argv[1], "-oneline") == 0) {
|
||||||
|
++oneline;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Option \"%s\" is unknown, try \"tc -help\".\n", argv[1]);
|
fprintf(stderr, "Option \"%s\" is unknown, try \"tc -help\".\n", argv[1]);
|
||||||
return -1;
|
return -1;
|
||||||
@ -494,6 +498,8 @@ int main(int argc, char **argv)
|
|||||||
argc--; argv++;
|
argc--; argv++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_SL_ = oneline ? "\\" : "\n";
|
||||||
|
|
||||||
if (color & !json)
|
if (color & !json)
|
||||||
enable_color();
|
enable_color();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user