Commit Graph

15 Commits

Author SHA1 Message Date
Rob Murray 084abd93d3 Add ErrDumpInterrupted
Add a specific error to report that a netlink response had
NLM_F_DUMP_INTR set, indicating that the set of results may be
incomplete or inconsistent.

unix.EINTR was previously returned (with no results) when the
NLM_F_DUMP_INTR flag was set. Now, errors.Is(err, unix.EINTR) will
still work. But, this will be a breaking change for any code that's
checking for equality with unix.EINTR.

Return results with ErrDumpInterrupted. Results may be incomplete
or inconsistent, but give the caller the option of using them.

Look for NLM_F_DUMP_INTR in more places:
- linkSubscribeAt, neighSubscribeAt, routeSubscribeAt
  - can do an initial dump, which may report inconsistent results
  -> if there's an error callback, call it with ErrDumpInterrupted
- socketDiagXDPExecutor
  - makes an NLM_F_DUMP request, without using Execute()
  -> give it the same behaviour as functions that do use Execute()

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-09-22 00:00:40 -07:00
Hasan Mahmood a57a7bd6b2 Add handle support for socket 2024-08-06 10:13:40 -07:00
Quan Tian 1e68b2710d Revert "Change behavior of `Subscribe` to non-blocking. Fix test."
This reverts commit 916f9685fa.
2024-05-23 09:21:30 -07:00
Asutorufa d237ee16c3 SocketGet support udp and ipv6
Signed-off-by: Asutorufa <16442314+Asutorufa@users.noreply.github.com>
2024-03-29 09:33:44 -07:00
frei-0xff 3e28e6db88 Added SocketDestroy function. 2024-03-28 11:51:11 -07:00
Kuroame 916f9685fa Change behavior of `Subscribe` to non-blocking. Fix test.
When listening for IPv6 address changes, I found that subscribe is not returning when there is message in the socket. After some researching, I found that libnl suggest setting socket to non-blocking when subscribing to groups. (Ref)[https://www.infradead.org/~tgr/libnl/doc/core.html#:~:text=best%20to%20put%20the%20socket%20in%20non-blocking%20mode]

Also fixed test related to BareUDP, which requires "bareudp" kmod. (Ref)[https://www.kernelconfig.io/config_bareudp]
2024-03-01 13:38:14 -08:00
Sven Rebhan ec7bcb248e Implement unix socket diagnostics 2024-02-21 09:21:27 -08:00
Sven Rebhan 06219cde3e Implement UDP socket diagnostics
Signed-off-by: Sven Rebhan <srebhan@influxdata.com>
2024-01-26 09:08:48 -08:00
Neo Zhuo 14e832ae1e feat: support diag TCP with only socket returns
For something like statistics that just requires socket info only
2021-05-30 12:58:56 +02: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
Oliver Herms 85be4431fe SocketDiagTCPInfo: Add support for BBR information 2020-11-26 10:01:29 -08:00
Oleg Senin e499154279 Add SocketDiagTCPInfo with some constants and structs to get tcp_info via sock_diag
Add simple test for SocketDiagTCPInfo
2020-09-24 21:34:23 -04:00
Daniel Borkmann b1e9859792 netlink: enforce similar pid checks as in iproute2
iproute2's own netlink library asserts that the sockaddr sender pid
has to be the one of the kernel [0]. It also doesn't bail out on pid
mismatch but only skips the message instead. We've seen cases where
the latter had a pid 0; in such case we should skip to the next nl
message instead of hard bail out.

  [0] https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/lib/libnetlink.c
      rtnl_dump_filter_l(), __rtnl_talk_iov()

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2019-07-18 17:26:53 -07:00
Ian Bishop 0e3b74dbe2 replace syscall with golang.org/x/sys/unix 2017-10-26 09:45:08 -07:00
Sebastien Boving a3f0be6352 Add support for tcp diags. 2017-02-04 16:48:17 -08:00