Commit Graph

47 Commits

Author SHA1 Message Date
Serhey Popovych
c14f9d92ee treewide: Use addattr_nest()/addattr_nest_end() to handle nested attributes
We have helper routines to support nested attribute addition into
netlink buffer: use them instead of open coding.

Use addattr_nest_compat()/addattr_nest_compat_end() where appropriate.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2018-02-02 15:01:09 -08:00
Nishanth Devarajan
927e3cfb52 tc: B.W limits can now be specified in %.
This patch adapts the tc command line interface to allow bandwidth limits
to be specified as a percentage of the interface's capacity.

Adding this functionality requires passing the specified device string to
each class/qdisc which changes the prototype for a couple of functions: the
.parse_qopt and .parse_copt interfaces. The device string is a required
parameter for tc-qdisc and tc-class, and when not specified, the kernel
returns ENODEV. In this patch, if the user tries to specify a bandwidth
percentage without naming the device, we return an error from userspace.

Signed-off-by: Nishanth Devarajan<ndev2021@gmail.com>
2017-11-24 11:22:13 -08:00
Stephen Hemminger
913352fe54 drop unneeded include of syslog.h
Only arpd uses syslog

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-11-12 16:22:36 -08:00
Stephen Hemminger
e4beb52787 netem: use fixed rather than floating point for scaling
Don't need to do floating point math to compute scaled random.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-11-07 11:15:34 +09:00
Stephen Hemminger
268a9eee98 netem: fix code indentation
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-10-11 18:08:15 -07:00
Phil Sutter
a754de3ccd tc/q_netem: Don't dereference possibly NULL pointer
Assuming 'opt' might be NULL, move the call to RTA_PAYLOAD to after the
check since it dereferences its parameter.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2017-08-24 14:49:44 -07:00
Phil Sutter
d17b136f7d Use C99 style initializers everywhere
This big patch was compiled by vimgrepping for memset calls and changing
to C99 initializer if applicable. One notable exception is the
initialization of union bpf_attr in tc/tc_bpf.c: changing it would break
for older gcc versions (at least <=3.4.6).

Calls to memset for struct rtattr pointer fields for parse_rtattr*()
were just dropped since they are not needed.

The changes here allowed the compiler to discover some unused variables,
so get rid of them, too.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: David Ahern <dsa@cumulusnetworks.com>
2016-07-20 12:05:24 -07:00
Stephen Hemminger
32a121cba2 tc: code cleanup
Use checkpatch to fix whitespace and other style issues.
2016-03-21 11:48:36 -07:00
Stephen Hemminger
753ef5bbd6 tc: remove extra whitespace
No blank lines at EOF, or trailing whitespace.
2015-10-23 15:43:28 -07:00
Stephen Hemminger
3d0b7439df whitespace cleanup
Remove all trailing whitespace and space before tabs.
2014-12-20 15:47:17 -08:00
Jay Vosburgh
3757185b29 tc/netem: loss gemodel options fixes
First, the default value for 1-k is documented as being 0, but is
currently being set to 1. (100%).  This causes all packets to be dropped
in the good state if 1-k is not explicitly specified.  Fix this by setting
the default to 0.

	Second, the 1-h option is parsed correctly, however, the kernel is
expecting "h", not 1-h.  Fix this by inverting the "1-h" percentage before
sending to and after receiving from the kernel.  This does change the
behavior, but makes it consistent with the netem documentation and the
literature on the Gilbert-Elliot model, which refer to "1-h" and "1-k,"
not "h" or "k" directly.

	Last, fix a minor formatting issue for the options reporting.

Signed-off-by: Jay Vosburgh <jay.vosburgh@canonical.com>
2014-08-04 10:15:10 -07:00
Jay Vosburgh
8f9672af7a tc/netem: fix loss state display and p14 parsing
The display of the entire netem loss state is shown as if it
were gemodel state, as the loss state information is assigned to the
wrong pointer.  Correct this by assigning the loss state to the correct
pointer.

	Additionally, attempting to set netem loss state will result in
random values in the p14 state probability because the option value
passed to the kernel by tc netem is not parsed or initialized.  Fix this
by supplying a default value of 0 for p14 and parsing the p14 value if
one is supplied.

Signed-off-by: Jay Vosburgh <jay.vosburgh@canonical.com>
2014-05-09 12:06:58 -07:00
Yang Yingliang
dad2f72bef netem: add 64bit rates support
netem support 64bit rates start from linux-3.13.
Add 64bit rates support in tc tools.

tc qdisc show dev eth0
qdisc netem 1: dev eth4 root refcnt 2 limit 1000 rate 35Gbit

Cc: Eric Dumazet <edumazet@google.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Acked-by: Eric Dumazet <edumazet@google.com>
2014-01-20 12:32:15 -08:00
Stephen Hemminger
d1f28cf181 ip: make local functions static 2013-02-12 11:38:35 -08:00
Johannes Naab
e72ca3fbb0 iproute2: tc netem rate: allow negative packet/cell overhead
by fixing the parsing of command-line tokens

Signed-off-by: Johannes Naab <jn@stusta.de>
2013-02-04 09:06:50 -08:00
Vijay Subramanian
1070205dc0 tc-netem: Add support for ECN packet marking
This patch provides support for marking packets with ECN instead of
dropping them with netem. This makes it possible to make use of the
netem ECN marking feature that was added recently to the kernel.

Signed-off-by: Vijay Subramanian <subramanian.vijay@gmail.com>
2012-05-22 14:10:21 -07:00
Vijay Subramanian
14a1c164d1 netem: Fail cleanly if user input is wrong
(Resending patch since it looks like my earlier mail did not make it to
netdev).

netem reordering requires that the delay parameter be given. Currently, if no
delay is given, tc prints the error message but still installs the qdisc. Fix
this by printing the usage and failing cleanly.

Signed-off-by: Vijay Subramanian <subramanian.vijay@gmail.com>
2012-01-20 11:21:58 -08:00
Hagen Paul Pfeifer
6b8dc4deea tc: netem rate shaping and cell extension
This patch add rate shaping as well as cell support. The link-rate can be
specified via rate options. Three optional arguments control the cell
knobs: packet-overhead, cell-size, cell-overhead. To ratelimit eth0 root
queue to 5kbit/s, with a 20 byte packet overhead, 100 byte cell size and
a 5 byte per cell overhead:

	tc qdisc add dev eth0 root netem rate 5kbit 20 100 5

Signed-off-by: Hagen Paul Pfeifer <hagen@jauu.net>
2012-01-19 14:28:27 -08:00
Eric Dumazet
d060de7f8d netem: fix a typo in explain()
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
2011-12-24 11:21:33 -08:00
Stephen Hemminger
3c7950af59 netem: add support for 4 state and GE loss model
Incorporate support for new loss models.
2011-12-22 17:08:11 -08:00
Thomas Jarosch
fcbd0165fc tc: Use correct variable type for get_distribution() result
get_distribution() returns an int.

cppcheck reported:
[tc/q_netem.c:243]: (style) Checking if unsigned variable 'dist_size' is less than zero.

The mismatch actually rendered the error checking
after get_distribution() ineffective.

Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
2011-11-23 14:46:24 -08:00
Stephen Hemminger
59a935d204 Update email address of netem 2011-04-12 14:24:01 -07:00
Florian Westphal
8d8de1139c tc: remove stale code
remove unused #define and "ok" statements.

Signed-off-by: Florian Westphal <fwestphal@astaro.com>
2010-01-21 10:13:01 -08:00
Stephen Hemminger
985f4578c6 Fix warning about strtod() return value 2009-12-26 10:20:50 -08:00
Stephen Hemminger
c1b81cb5fe netem potential dist table overflow
Fix possible stack overflow when given distribution table that is
too large.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-12-12 15:02:51 -08:00
Stephen Hemminger
aa27f88c84 Add TC_LIB_DIR environment variable.
Don't hardcode /usr/lib/tc as a path

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-06-20 15:31:40 -07:00
Patrick McHardy
bd29e35d9d Add sprint_ticks() function and use in CBQ
[IPROUTE]: Add sprint_ticks() function and use in CBQ

Add helper function to print ticks to avoid assumptions about clock
resolution in CBQ.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-03-13 14:42:18 -07:00
Patrick McHardy
8f34caafbd Replace "usec" by "time" in function names
[IPROUTE]: Replace "usec" by "time" in function names

Rename functions containing "usec" since they don't necessarily return
usec units anymore.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-03-13 14:42:17 -07:00
Stephen Hemminger
40076f622e netem parameters to change command
When using tc to change netem attributes, only those values
on the command line should be passed down, others should
remain unchanged.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2007-01-09 15:46:55 -08:00
Stephen Hemminger
ae665a522b Remove trailing whitespace
Go through source files and remove all trailing whitespace

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-12-05 10:10:22 -08:00
Stephen Hemminger
fa56513034 Trap possible overflow in usec values to netem
If user asks for large usec value it could overflow 32 bits.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-10-19 13:10:26 -07:00
shemminger
e9bc3c40d0 Always send reorder message (for compatiablity)
and parse response correctly with netem.
2005-12-10 00:01:02 +00:00
shemminger
a31a5d5904 Add corrupt option for netem 2005-12-09 23:27:44 +00:00
shemminger
ea8fc1047d Netem support for reorder
Update include files and add support for TCP_CONG
2005-06-22 18:27:49 +00:00
net[shemminger]!shemminger
1d2d1cb522 Import patch thomas.1
(Logical change 1.147)
2005-03-10 19:00:42 +00:00
osdl.net!shemminger
fb9b1d0f6a fix potential memory corruption
(Logical change 1.136)
2005-02-07 18:15:04 +00:00
17!tgraf
1a1d22a722 Use NLMSG_TAIL
(Logical change 1.127)
2005-01-18 01:24:18 +00:00
net[shemminger]!kaber
95812b56a5 : prevent tc crashes
(Logical change 1.81)
2004-09-28 18:35:49 +00:00
osdl.net!shemminger
f2f99e2eef no longer need xstats stub
(Logical change 1.77)
2004-08-31 17:45:21 +00:00
osdl.net!shemminger
2e21655e39 Use getline() and nested attributes.
(Logical change 1.73)
2004-08-30 20:54:46 +00:00
osdl.net!shemminger
b7be3d0cd2 Cleanup cli for new version.
2004/08/09 16:46:47-07:00 osdl.net!shemminger
Add distribution table loading (undebugged as yet).

(Logical change 1.71)
2004-08-23 20:21:21 +00:00
osdl.net!shemminger
025dc69a25 Fix errors in netem scheduler when using PSCHED_CLOCK_CPU,
correct value before passing to kernel.

(Logical change 1.63)
2004-08-09 17:12:23 +00:00
osdl.net!shemminger
31fa60e00f Replace rate with jitter
(Logical change 1.55)
2004-07-12 21:03:29 +00:00
osdl.net!shemminger
7b9868343a Fix netem display of rate and limit.
(Logical change 1.50)
2004-07-02 20:40:35 +00:00
osdl.net!shemminger
ffb79d0691 Add new rate and duplicate arguments.
(Logical change 1.41)
2004-07-01 11:02:04 +00:00
osdl.net!shemminger
309a4c90a5 Rename netsim to netem in latest code.
2004/06/28 13:39:57-07:00 osdl.net!shemminger
Rename: tc/q_netsim.c -> tc/q_netem.c

(Logical change 1.39)
2004-06-28 20:41:55 +00:00
osdl.net!shemminger
d3bc14fba8 Initial revision 2004-06-28 20:37:01 +00:00