|
|
a4b897 |
commit 53e34d82748442625618582eb88512fc4ee49c2e
|
|
|
a4b897 |
Author: Pavel Šimerda <psimerda@redhat.com>
|
|
|
a4b897 |
Date: Thu May 28 12:17:39 2015 +0200
|
|
|
a4b897 |
|
|
|
a4b897 |
backport selected tc features and documentation
|
|
|
a4b897 |
|
|
|
a4b897 |
diff --git a/man/man8/tc.8 b/man/man8/tc.8
|
|
|
a4b897 |
index e0acfeb..cc839d9 100644
|
|
|
a4b897 |
--- a/man/man8/tc.8
|
|
|
a4b897 |
+++ b/man/man8/tc.8
|
|
|
a4b897 |
@@ -2,7 +2,9 @@
|
|
|
a4b897 |
.SH NAME
|
|
|
a4b897 |
tc \- show / manipulate traffic control settings
|
|
|
a4b897 |
.SH SYNOPSIS
|
|
|
a4b897 |
-.B tc qdisc [ add | change | replace | link | delete ] dev
|
|
|
a4b897 |
+.B tc
|
|
|
a4b897 |
+.RI "[ " OPTIONS " ]"
|
|
|
a4b897 |
+.B qdisc [ add | change | replace | link | delete ] dev
|
|
|
a4b897 |
DEV
|
|
|
a4b897 |
.B
|
|
|
a4b897 |
[ parent
|
|
|
a4b897 |
@@ -13,7 +15,9 @@ qdisc-id ] qdisc
|
|
|
a4b897 |
[ qdisc specific parameters ]
|
|
|
a4b897 |
.P
|
|
|
a4b897 |
|
|
|
a4b897 |
-.B tc class [ add | change | replace | delete ] dev
|
|
|
a4b897 |
+.B tc
|
|
|
a4b897 |
+.RI "[ " OPTIONS " ]"
|
|
|
a4b897 |
+.B class [ add | change | replace | delete ] dev
|
|
|
a4b897 |
DEV
|
|
|
a4b897 |
.B parent
|
|
|
a4b897 |
qdisc-id
|
|
|
a4b897 |
@@ -22,7 +26,9 @@ class-id ] qdisc
|
|
|
a4b897 |
[ qdisc specific parameters ]
|
|
|
a4b897 |
.P
|
|
|
a4b897 |
|
|
|
a4b897 |
-.B tc filter [ add | change | replace | delete ] dev
|
|
|
a4b897 |
+.B tc
|
|
|
a4b897 |
+.RI "[ " OPTIONS " ]"
|
|
|
a4b897 |
+.B filter [ add | change | replace | delete ] dev
|
|
|
a4b897 |
DEV
|
|
|
a4b897 |
.B [ parent
|
|
|
a4b897 |
qdisc-id
|
|
|
a4b897 |
@@ -35,21 +41,28 @@ priority filtertype
|
|
|
a4b897 |
flow-id
|
|
|
a4b897 |
|
|
|
a4b897 |
.B tc
|
|
|
a4b897 |
+.RI "[ " OPTIONS " ]"
|
|
|
a4b897 |
.RI "[ " FORMAT " ]"
|
|
|
a4b897 |
.B qdisc show [ dev
|
|
|
a4b897 |
DEV
|
|
|
a4b897 |
.B ]
|
|
|
a4b897 |
.P
|
|
|
a4b897 |
.B tc
|
|
|
a4b897 |
+.RI "[ " OPTIONS " ]"
|
|
|
a4b897 |
.RI "[ " FORMAT " ]"
|
|
|
a4b897 |
.B class show dev
|
|
|
a4b897 |
DEV
|
|
|
a4b897 |
.P
|
|
|
a4b897 |
-.B tc filter show dev
|
|
|
a4b897 |
+.B tc
|
|
|
a4b897 |
+.RI "[ " OPTIONS " ]"
|
|
|
a4b897 |
+.B filter show dev
|
|
|
a4b897 |
DEV
|
|
|
a4b897 |
|
|
|
a4b897 |
.P
|
|
|
a4b897 |
-.B tc [ -force ] -b\fR[\fIatch\fR] \fB[ filename ]
|
|
|
a4b897 |
+.ti 8
|
|
|
a4b897 |
+.IR OPTIONS " := {"
|
|
|
a4b897 |
+\fB[ -force ] [ -OK ] -b\fR[\fIatch\fR] \fB[ filename ] \fR|
|
|
|
a4b897 |
+\fB[ \fB-n\fR[\fIetns\fR] name \fB] \fR}
|
|
|
a4b897 |
|
|
|
a4b897 |
.ti 8
|
|
|
a4b897 |
.IR FORMAT " := {"
|
|
|
a4b897 |
@@ -407,6 +420,44 @@ link
|
|
|
a4b897 |
Only available for qdiscs and performs a replace where the node
|
|
|
a4b897 |
must exist already.
|
|
|
a4b897 |
|
|
|
a4b897 |
+.SH OPTIONS
|
|
|
a4b897 |
+
|
|
|
a4b897 |
+.TP
|
|
|
a4b897 |
+.BR "\-b", " \-b filename", " \-batch", " \-batch filename"
|
|
|
a4b897 |
+read commands from provided file or standard input and invoke them.
|
|
|
a4b897 |
+First failure will cause termination of tc.
|
|
|
a4b897 |
+
|
|
|
a4b897 |
+.TP
|
|
|
a4b897 |
+.BR "\-force"
|
|
|
a4b897 |
+don't terminate tc on errors in batch mode.
|
|
|
a4b897 |
+If there were any errors during execution of the commands, the application return code will be non zero.
|
|
|
a4b897 |
+
|
|
|
a4b897 |
+.TP
|
|
|
a4b897 |
+.BR "\-OK"
|
|
|
a4b897 |
+in batch mode, print
|
|
|
a4b897 |
+.B OK
|
|
|
a4b897 |
+and a new line on standard output after each successfully interpreted command.
|
|
|
a4b897 |
+
|
|
|
a4b897 |
+.TP
|
|
|
a4b897 |
+.BR "\-n" , " \-net" , " \-netns " <NETNS>
|
|
|
a4b897 |
+switches
|
|
|
a4b897 |
+.B tc
|
|
|
a4b897 |
+to the specified network namespace
|
|
|
a4b897 |
+.IR NETNS .
|
|
|
a4b897 |
+Actually it just simplifies executing of:
|
|
|
a4b897 |
+
|
|
|
a4b897 |
+.B ip netns exec
|
|
|
a4b897 |
+.IR NETNS
|
|
|
a4b897 |
+.B tc
|
|
|
a4b897 |
+.RI "[ " OPTIONS " ] " OBJECT " { " COMMAND " | "
|
|
|
a4b897 |
+.BR help " }"
|
|
|
a4b897 |
+
|
|
|
a4b897 |
+to
|
|
|
a4b897 |
+
|
|
|
a4b897 |
+.B tc
|
|
|
a4b897 |
+.RI "-n[etns] " NETNS " [ " OPTIONS " ] " OBJECT " { " COMMAND " | "
|
|
|
a4b897 |
+.BR help " }"
|
|
|
a4b897 |
+
|
|
|
a4b897 |
.SH FORMAT
|
|
|
a4b897 |
The show command has additional formatting options:
|
|
|
a4b897 |
|
|
|
a4b897 |
diff --git a/tc/Makefile b/tc/Makefile
|
|
|
a4b897 |
index 0277760..af6a277 100644
|
|
|
a4b897 |
--- a/tc/Makefile
|
|
|
a4b897 |
+++ b/tc/Makefile
|
|
|
a4b897 |
@@ -3,6 +3,11 @@ TCOBJ= tc.o tc_qdisc.o tc_class.o tc_filter.o tc_util.o \
|
|
|
a4b897 |
m_ematch.o emp_ematch.yacc.o emp_ematch.lex.o
|
|
|
a4b897 |
|
|
|
a4b897 |
include ../Config
|
|
|
a4b897 |
+
|
|
|
a4b897 |
+ifeq ($(IP_CONFIG_SETNS),y)
|
|
|
a4b897 |
+ CFLAGS += -DHAVE_SETNS
|
|
|
a4b897 |
+endif
|
|
|
a4b897 |
+
|
|
|
a4b897 |
SHARED_LIBS ?= y
|
|
|
a4b897 |
|
|
|
a4b897 |
TCMODULES :=
|
|
|
a4b897 |
diff --git a/tc/tc.c b/tc/tc.c
|
|
|
a4b897 |
index b43bb47..4aaec21 100644
|
|
|
a4b897 |
--- a/tc/tc.c
|
|
|
a4b897 |
+++ b/tc/tc.c
|
|
|
a4b897 |
@@ -29,6 +29,7 @@
|
|
|
a4b897 |
#include "utils.h"
|
|
|
a4b897 |
#include "tc_util.h"
|
|
|
a4b897 |
#include "tc_common.h"
|
|
|
a4b897 |
+#include "namespace.h"
|
|
|
a4b897 |
|
|
|
a4b897 |
int show_stats = 0;
|
|
|
a4b897 |
int show_details = 0;
|
|
|
a4b897 |
@@ -186,7 +187,8 @@ static void usage(void)
|
|
|
a4b897 |
fprintf(stderr, "Usage: tc [ OPTIONS ] OBJECT { COMMAND | help }\n"
|
|
|
a4b897 |
" tc [-force] [-OK] -batch filename\n"
|
|
|
a4b897 |
"where OBJECT := { qdisc | class | filter | action | monitor }\n"
|
|
|
a4b897 |
- " OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -b[atch] [filename] }\n");
|
|
|
a4b897 |
+ " OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -b[atch] [filename] | "
|
|
|
a4b897 |
+ "-n[etns] name }\n");
|
|
|
a4b897 |
}
|
|
|
a4b897 |
|
|
|
a4b897 |
static int do_cmd(int argc, char **argv)
|
|
|
a4b897 |
@@ -299,6 +301,10 @@ int main(int argc, char **argv)
|
|
|
a4b897 |
if (argc <= 1)
|
|
|
a4b897 |
usage();
|
|
|
a4b897 |
batch_file = argv[1];
|
|
|
a4b897 |
+ } else if (matches(argv[1], "-netns") == 0) {
|
|
|
a4b897 |
+ NEXT_ARG();
|
|
|
a4b897 |
+ if (netns_switch(argv[1]))
|
|
|
a4b897 |
+ return -1;
|
|
|
a4b897 |
} else {
|
|
|
a4b897 |
fprintf(stderr, "Option \"%s\" is unknown, try \"tc -help\".\n", argv[1]);
|
|
|
a4b897 |
return -1;
|