Commit Graph

68 Commits (d826e14e2792247ad0b4c34c56f0c07d0870fdaa)

Author SHA1 Message Date
Lomanic d826e14e27 [net][linux] Fix #1198 "f.ReadDir undefined" on Go 1.15 by redefining a custom readDir according to go version
Using os.File.Readdir pre Go 1.16 and os.File.ReadDir post Go 1.16
3 years ago
mmorel-35 1e6b445a8a gofumpt 3 years ago
Matthieu MOREL b673968d5d
enable errorlint linter 3 years ago
shirou d2e27c1712 fix dependabot v2 deletion. 3 years ago
shirou 0969c9436b delete v2 directory, move v3 to top #1078 3 years ago
Disconnect3d 5c1a9e709d net_linux.go: decode port as 16-bit uint
Changes the port parsing from `/proc/net/*` files records from parsing them as 64-bit integers to parse them as 16-bit unsigned integers.

While this is mostly a cosmetic change, it will also make so that the code fails faster in case the entry is malformed (for whatever reason).

Note that the returned value is still casted to uint32 when an  `Addr` object is created.
It seems to me that the `Addr.port` field should be changed to `uint16` but maybe some other APIs/systems wants it to be `uint32` and also changing it there may require changes in users code if they update. This being said I am not changing that field's type.
5 years ago
gtosh4 936d3b27f1
Don't ignore context for io counters 5 years ago
Brian C. Williams f00df5cffe Add WithoutUids funcs 5 years ago
Lomanic 6a8ab0308e [net][linux] Go fmt net/net_linux.go 6 years ago
chi-chi weng 809306b78a
Fix the net.ConnectionsMax BUG
`connectionsList, err := net.ConnectionsMax("tcp4", 1000)`
when you run net.ConnectionsMax,you will find some proc is not equal with the `netstat -lptn`
6 years ago
Curtis Mattoon 648bf4eebc Adds ConntrackStats to get conntrack summary stats 6 years ago
Joe Stringer f87d9813da [net][linux] Support socket tables in nested namespaces
Signed-off-by: Joe Stringer <joe@cilium.io>
6 years ago
Iskander Sharipov 3684fce88a net: use multi-value case clause instead of fallthrough
Found using https://go-critic.github.io/overview#emptyFallthrough-ref
7 years ago
shirou 4c73494c78 Add WithContext functions. 7 years ago
Daniel Nelson 6abd227e48
[net] linux: skip if not exist error on getProcInodesAll 7 years ago
shirou e01a14e318 [net] linux: skip if permission error on getProcInodesAll
This fixes #433
8 years ago
WAKAYAMA Shirou 09e9859714 [net]linux: return err. 8 years ago
better88 86af477d1a err omit in getProcInodes 8 years ago
Alexander Blagoev b32353f094 Add comments with a short explanation and link to the PR request 8 years ago
Alexander Blagoev 531f9507d2 Read /proc/net files with a single read syscall.
The /proc/net files are not guaranteed to be consistent, they are only
consitent on the row level. This is probably one of the reasons why
consequent read calls might return duplicate entries - the kernel is
changing the file as it is being read. In certain situations this might
lead to loop like situations - the same net entry is being returned when
reading the file as new connections are added to the kernel tcp table, i.e
there can be a lot of duplications.

This commit is trying to reduce the duplications, by fetching the contents
of the net files with a single read syscall.
8 years ago
shirou c251591dc7 Merge pull request #355 from sean-/fix-lint-errors
Fix lint errors
8 years ago
shirou 9af92986dd Merge pull request #358 from ablagoev/optimize-net-connections
Fromat socketType properly in tcp duplication check key
8 years ago
Alexander Blagoev 5a0a97f400 Fromat socketType properly in tcp duplication check key 8 years ago
shirou b066db40c7 Merge pull request #356 from ablagoev/optimize-net-connections
Optimize memory usage for net.Connections on Linux
8 years ago
Alexander Blagoev 11e78812ae Build duplicate tcp connection ID in Connections for better readbility 8 years ago
Alexander Blagoev f7dd4f97c7 Improve /proc/net/dev parsing to include all edge cases 8 years ago
Alexander Blagoev 51e4fb77cf Add socket state to TCP connection key 8 years ago
Alexander Blagoev daaadd4f1e Optimize memory usage for net.Connections on Linux 8 years ago
Sean Chittenden 23a4ae3369
`gofmt -s -w .` 8 years ago
Toshi Piazza 5e1c2fa23b Fixes memory leak 8 years ago
Peter De Cleyn e8fc31359b Added support to alias interfaces (e.g., ifname0:1) 8 years ago
Conor Branagan 276c873f0d Fast duplication check in inodes processing.
Instead of encoding a JSON string of each connection (non-trivial at high
connection volumes) we can use the connTmp struct for map look-ups if we
eliminate the unused `uids` field.

Also switches to using the empty struct instead of bool for zero memory
overhead.
8 years ago
WAKAYAMA Shirou 42156fdf0d [net]linux: fix NetFilterCounters filename 8 years ago
Conor Branagan 198e65c801 Add ConnectionsMax function that limits connections per pid.
The goal is to improve performance of connection fetching connections across
all processes when some processes can have several hundred or thousands of file
descriptors. Right now when you have many thousands of fds the process spends
lots of time inside the syscalls from Readdir and Readlink.

The public API works as before with two new functions:

- `ConnectionsMax`
- `ConnectionsPidMax`

Each function takes an additional int argument that sets the max number of fds
read per process.
8 years ago
Cameron Sparr d74d84e593 Fix /proc/net/dev dropOut and fifoOut indices
fixes #284
8 years ago
Jean Kahrs e004ef15e1 remove unused code 9 years ago
Jean Kahrs ab24c97439 break import cycle 9 years ago
Jean Kahrs cba0992ab3 add Uids field to net_linux 9 years ago
sandlbn 480ccb89e1 Added support for linux net interface fifo errors 9 years ago
Shirou WAKAYAMA 4bb84648bf JSON representation is renamed to fit Google JSON style, camelCase. 9 years ago
Shirou WAKAYAMA ea152ea901 [BREAKING CHANGE] rename functions to pass golint. ex) net.NetIOCounters -> net.IOCounters 9 years ago
Shirou WAKAYAMA 34b63e671b [net]linux: add a test and fix private field name. 9 years ago
Shirou WAKAYAMA 31439aa6b5 [net]linux: fix valious bugs in NetConnections. 9 years ago
Shirou WAKAYAMA e4ddff09d5 [net]linux: add process_unix for NetConnections. 9 years ago
Shirou WAKAYAMA 32c62b5d48 [net]linux: implement processInet(). 9 years ago
Shirou WAKAYAMA 6c352016d8 [net]linux: start replacing lsof. still work in progress. 9 years ago
Shirou WAKAYAMA d680853370 net,process[linux]: add process.NetIOCounter and net.NetIOCounterByFile. 9 years ago
Masayoshi Sekimura 3a1fa5dc80 format go program with go 1.5.2 "go fmt" 9 years ago
shirou f58654fa1c Merge pull request #122 from jimmystewpot/add_netfilter
Add nf_conntrack counter support
9 years ago
Matt Holcomb 21ccfe6b60 using HostProc for protocounters in linux 9 years ago