Commit Graph

19 Commits

Author SHA1 Message Date
张祖建
b8aac10bba fix staticcheck issues 2021-09-21 09:10:48 -05:00
Tobias Klauser
4ef7bcbf15 Don't re-initialize or shadow package level var native to fix data race
The package level var native (holding the native endianness) is
initialized at package load time. Thus there is no need to re-initalize
it in functions using it, e.g. (*Handle).filterModify, parseU32Data,
parseFwData, parseBpfData and parseMatchAllData.

This fixes a data race between these functions and any read access of
var native, e.g. in LinkDeserialize as reported in issue #633.

Also don't re-declare local variables shadowing the global package-level
var.

Fixes #633

Signed-off-by: Tobias Klauser <tobias@cilium.io>
2021-05-10 07:24:37 -07:00
Ivan Milchev
2dd616d00b implemented handling of uint64 for HTB class rate/ceil 2021-03-09 16:12:16 -08:00
Chun Chen
339a215d65 Fix NewHtbClass
- Prio and Quantum should be set equal to the input params
- Fix buffer and cbuffer due to incorrect hz
- Fix Xmittime which is also not equal the behavior of c library.
C library converts time to uint32 to drop precision before multiply
tick_in_usec. ref https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/tc/tc_core.c#n62
2020-09-15 14:32:20 -04:00
Francis Begyn
01d9156030 Service curves fix
There was something off with the math for the ServiceCurves. The set value was 8
times too large and the returned one was 8 times too small.

This is now fixed in `class.go` and `class_linux.go` so the user can just set the rate in bit and
it will match the tc show output.
2020-01-27 15:49:46 -08:00
Julian Kornberger
e137ed6e2c Replace nl.NewRtAttrChild with method on struct 2018-10-30 10:31:19 -07:00
Francis Begyn
1006cf4f24 Implementation of HFSC
Testing and functionality for the use of HFSC has been implemented.
The use of service curves is implenented closely as to how they behave
with the TC implementation.
Automated checks and testing were succesful.
2018-07-16 12:14:02 -07:00
Taku Fukushima
85aa3b74a4 Add statistics to class attributes
This patch adds ClassStatistics, a struct that represents the stats
of a class based on genric networking stats for netlink, to ClassAttrs.
The parsers for rtattrs in type of TCA_STATS and TCA_STATS2 are
introduced as well and the stats are appropriately parsed as a part
of ClassAttrs struct.

The practical tests for stats are not contained in this patch yet since
it requires the actual packet sending/receiving in the random timing,
which makes the tests complicated and flaky. Once we figure it out how
to test them in the proper way, they shall be added.

Signed-off-by: Taku Fukushima <taku@soracom.jp>
2018-03-27 21:08:57 -07:00
yandd
aa48b8cff0 Fix CalcRtable array parameter bug 2017-11-13 09:27:51 -08:00
Ian Bishop
0e3b74dbe2 replace syscall with golang.org/x/sys/unix 2017-10-26 09:45:08 -07:00
Vish Ishaya
0bc457d244 fix darwin build by moving code (#138)
Fixes issue #135
2016-06-15 08:44:14 -07:00
Alessandro Boch
f116a3048a Use package empty handle for pkg APIs (#117)
- Package methods only need an empty handle.
  Not a regular Handle with a couple of
  sockets creation/delete.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-05-09 16:55:00 -07:00
Alessandro Boch
14f41c27fa Provide netlink handle (#104)
- Ties to a netlink socket. All client requests
  will re-use same socket. Socket released at
  handle deletion.
- Also network namespace can be specified during
  handle creation. Socket will be opened on the
  specified network namespace.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-05-08 11:35:49 -07:00
Vishvananda Ishaya
adb0f53af6 Cleanup from golint and go vet 2016-03-19 17:12:26 -07:00
chantra
d14228b8a5 Do not use nl specific types in class.go 2016-01-13 22:08:44 -08:00
chantra
683203e227 Make htb class work on older kernels (2.6) 2015-12-25 23:19:37 -08:00
chantra
bc12fcdc7f Add ClassReplace and ClassChange
Along with unittests
2015-11-14 23:16:33 -05:00
chantra
19a1f20ae8 [class] refactor class functions to use a common classModify function
This prevents duplicated code and make adding other commands such as replace, change easier
2015-11-13 22:51:07 -05:00
chantra
ef0cd12f0c Add TC Class support 2015-09-10 22:50:54 -07:00