tc: Allow to easy change network namespace
Added new '-netns' option to simplify executing following cmd:
ip netns exec NETNS tc OPTIONS COMMAND OBJECT
to
tc -n[etns] NETNS OPTIONS COMMAND OBJECT
e.g.:
tc -net vnet0 qdisc
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
This commit is contained in:
parent
527910c801
commit
67e1d73be1
|
|
@ -2,7 +2,9 @@
|
||||||
.SH NAME
|
.SH NAME
|
||||||
tc \- show / manipulate traffic control settings
|
tc \- show / manipulate traffic control settings
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B tc qdisc [ add | change | replace | link | delete ] dev
|
.B tc
|
||||||
|
.RI "[ " OPTIONS " ]"
|
||||||
|
.B qdisc [ add | change | replace | link | delete ] dev
|
||||||
DEV
|
DEV
|
||||||
.B
|
.B
|
||||||
[ parent
|
[ parent
|
||||||
|
|
@ -13,7 +15,9 @@ qdisc-id ] qdisc
|
||||||
[ qdisc specific parameters ]
|
[ qdisc specific parameters ]
|
||||||
.P
|
.P
|
||||||
|
|
||||||
.B tc class [ add | change | replace | delete ] dev
|
.B tc
|
||||||
|
.RI "[ " OPTIONS " ]"
|
||||||
|
.B class [ add | change | replace | delete ] dev
|
||||||
DEV
|
DEV
|
||||||
.B parent
|
.B parent
|
||||||
qdisc-id
|
qdisc-id
|
||||||
|
|
@ -22,7 +26,9 @@ class-id ] qdisc
|
||||||
[ qdisc specific parameters ]
|
[ qdisc specific parameters ]
|
||||||
.P
|
.P
|
||||||
|
|
||||||
.B tc filter [ add | change | replace | delete ] dev
|
.B tc
|
||||||
|
.RI "[ " OPTIONS " ]"
|
||||||
|
.B filter [ add | change | replace | delete ] dev
|
||||||
DEV
|
DEV
|
||||||
.B [ parent
|
.B [ parent
|
||||||
qdisc-id
|
qdisc-id
|
||||||
|
|
@ -35,21 +41,28 @@ priority filtertype
|
||||||
flow-id
|
flow-id
|
||||||
|
|
||||||
.B tc
|
.B tc
|
||||||
|
.RI "[ " OPTIONS " ]"
|
||||||
.RI "[ " FORMAT " ]"
|
.RI "[ " FORMAT " ]"
|
||||||
.B qdisc show [ dev
|
.B qdisc show [ dev
|
||||||
DEV
|
DEV
|
||||||
.B ]
|
.B ]
|
||||||
.P
|
.P
|
||||||
.B tc
|
.B tc
|
||||||
|
.RI "[ " OPTIONS " ]"
|
||||||
.RI "[ " FORMAT " ]"
|
.RI "[ " FORMAT " ]"
|
||||||
.B class show dev
|
.B class show dev
|
||||||
DEV
|
DEV
|
||||||
.P
|
.P
|
||||||
.B tc filter show dev
|
.B tc
|
||||||
|
.RI "[ " OPTIONS " ]"
|
||||||
|
.B filter show dev
|
||||||
DEV
|
DEV
|
||||||
|
|
||||||
.P
|
.P
|
||||||
.B tc [ -force ] -b\fR[\fIatch\fR] \fB[ filename ]
|
.ti 8
|
||||||
|
.IR OPTIONS " := {"
|
||||||
|
\fB[ -force ] -b\fR[\fIatch\fR] \fB[ filename ] \fR|
|
||||||
|
\fB[ \fB-n\fR[\fIetns\fR] name \fB] \fR}
|
||||||
|
|
||||||
.ti 8
|
.ti 8
|
||||||
.IR FORMAT " := {"
|
.IR FORMAT " := {"
|
||||||
|
|
@ -407,6 +420,38 @@ link
|
||||||
Only available for qdiscs and performs a replace where the node
|
Only available for qdiscs and performs a replace where the node
|
||||||
must exist already.
|
must exist already.
|
||||||
|
|
||||||
|
.SH OPTIONS
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BR "\-b", " \-b filename", " \-batch", " \-batch filename"
|
||||||
|
read commands from provided file or standard input and invoke them.
|
||||||
|
First failure will cause termination of tc.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BR "\-force"
|
||||||
|
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.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BR "\-n" , " \-net" , " \-netns " <NETNS>
|
||||||
|
switches
|
||||||
|
.B tc
|
||||||
|
to the specified network namespace
|
||||||
|
.IR NETNS .
|
||||||
|
Actually it just simplifies executing of:
|
||||||
|
|
||||||
|
.B ip netns exec
|
||||||
|
.IR NETNS
|
||||||
|
.B tc
|
||||||
|
.RI "[ " OPTIONS " ] " OBJECT " { " COMMAND " | "
|
||||||
|
.BR help " }"
|
||||||
|
|
||||||
|
to
|
||||||
|
|
||||||
|
.B tc
|
||||||
|
.RI "-n[etns] " NETNS " [ " OPTIONS " ] " OBJECT " { " COMMAND " | "
|
||||||
|
.BR help " }"
|
||||||
|
|
||||||
.SH FORMAT
|
.SH FORMAT
|
||||||
The show command has additional formatting options:
|
The show command has additional formatting options:
|
||||||
|
|
||||||
|
|
@ -430,16 +475,6 @@ decode filter offset and mask values to equivalent filter commands based on TCP/
|
||||||
.BR "\-iec"
|
.BR "\-iec"
|
||||||
print rates in IEC units (ie. 1K = 1024).
|
print rates in IEC units (ie. 1K = 1024).
|
||||||
|
|
||||||
.TP
|
|
||||||
.BR "\-b", " \-b filename", " \-batch", " \-batch filename"
|
|
||||||
read commands from provided file or standard input and invoke them.
|
|
||||||
First failure will cause termination of tc.
|
|
||||||
|
|
||||||
.TP
|
|
||||||
.BR "\-force"
|
|
||||||
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.
|
|
||||||
|
|
||||||
.SH HISTORY
|
.SH HISTORY
|
||||||
.B tc
|
.B tc
|
||||||
was written by Alexey N. Kuznetsov and added in Linux 2.2.
|
was written by Alexey N. Kuznetsov and added in Linux 2.2.
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,11 @@ TCOBJ= tc.o tc_qdisc.o tc_class.o tc_filter.o tc_util.o \
|
||||||
m_ematch.o emp_ematch.yacc.o emp_ematch.lex.o
|
m_ematch.o emp_ematch.yacc.o emp_ematch.lex.o
|
||||||
|
|
||||||
include ../Config
|
include ../Config
|
||||||
|
|
||||||
|
ifeq ($(IP_CONFIG_SETNS),y)
|
||||||
|
CFLAGS += -DHAVE_SETNS
|
||||||
|
endif
|
||||||
|
|
||||||
SHARED_LIBS ?= y
|
SHARED_LIBS ?= y
|
||||||
|
|
||||||
TCMODULES :=
|
TCMODULES :=
|
||||||
|
|
|
||||||
8
tc/tc.c
8
tc/tc.c
|
|
@ -29,6 +29,7 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "tc_util.h"
|
#include "tc_util.h"
|
||||||
#include "tc_common.h"
|
#include "tc_common.h"
|
||||||
|
#include "namespace.h"
|
||||||
|
|
||||||
int show_stats = 0;
|
int show_stats = 0;
|
||||||
int show_details = 0;
|
int show_details = 0;
|
||||||
|
|
@ -186,7 +187,8 @@ static void usage(void)
|
||||||
fprintf(stderr, "Usage: tc [ OPTIONS ] OBJECT { COMMAND | help }\n"
|
fprintf(stderr, "Usage: tc [ OPTIONS ] OBJECT { COMMAND | help }\n"
|
||||||
" tc [-force] -batch filename\n"
|
" tc [-force] -batch filename\n"
|
||||||
"where OBJECT := { qdisc | class | filter | action | monitor }\n"
|
"where OBJECT := { qdisc | class | filter | action | monitor }\n"
|
||||||
" OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -b[atch] [filename] }\n");
|
" OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -b[atch] [filename] | "
|
||||||
|
"-n[etns] name }\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_cmd(int argc, char **argv)
|
static int do_cmd(int argc, char **argv)
|
||||||
|
|
@ -296,6 +298,10 @@ int main(int argc, char **argv)
|
||||||
if (argc <= 1)
|
if (argc <= 1)
|
||||||
usage();
|
usage();
|
||||||
batch_file = argv[1];
|
batch_file = argv[1];
|
||||||
|
} else if (matches(argv[1], "-netns") == 0) {
|
||||||
|
NEXT_ARG();
|
||||||
|
if (netns_switch(argv[1]))
|
||||||
|
return -1;
|
||||||
} 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;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue