24 Commits

Author SHA1 Message Date
Mateusz Urbanek
310581b9c6
feat: expose JoinGroup and LeaveGroup for connection (#306)
Expose a lower-level JoinGroup and LeaveGroup interface.
This enables the use of newer APIs for watching IPv4 and IPv6 rule
changes via netlink groups.

Example:

```go
conn.JoinGroup(unix.RTNLGRP_IPV4_RULE)
conn.JoinGroup(unix.RTNLGRP_IPV6_RULE)

conn.LeaveGroup(unix.RTNLGRP_IPV4_RULE)
conn.LeaveGroup(unix.RTNLGRP_IPV6_RULE)
```

Signed-off-by: Mateusz Urbanek <mateusz.urbanek@siderolabs.com>
2026-03-17 10:57:13 +01:00
Tom Payne
3da278d2a4
Return equal-length slices from Receive (#298)
Signed-off-by: Tom Payne <tpayne@akamai.com>
2026-02-08 12:55:06 +01:00
boussole
d045a249b7
rtnetlink: fix Link ListByKind response (#233)
the linux kernel handles a RTM_GETLINK request even in case of incorrect
kind filter. if it finds requested kind it responds with
a list of this kind of links and marks every message in a response
by NLM_F_DUMP_FILTERED flag. Otherwise it sends all available links
w/o NLF_F_DUMP_FILTERED. So, looks much better to return to a callee
empty link list if there are no links of requested kind.

Signed-off-by: Andrey Grafin <conquistador@yandex-team.ru>
Co-authored-by: Andrey Grafin <conquistador@yandex-team.ru>
2024-12-17 20:32:45 +01:00
Ben Kochie
8026e5db33
Fix Go mod path (#226)
In order to update to v2.0.0, we need to update the module path per the
Go module documentation.
* https://go.dev/doc/modules/major-version

Fixes: https://github.com/jsimonetti/rtnetlink/issues/225

This can be released as v2.0.1

Signed-off-by: SuperQ <superq@gmail.com>
2024-05-10 16:40:56 +02:00
Florian Lehner
a833fb5b68
add netlink/rule (#139)
* add netlink/rule

Signed-off-by: Florian Lehner <dev@der-flo.net>

* Add some fuzzing corpus

Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl>

Co-authored-by: Jeroen Simonetti <jeroen@simonetti.nl>
2022-04-12 09:00:30 +02:00
Matt Layher
5ecc0c63ac
rtnetlink: expose Conn.SetOption from underlying netlink.Conn (#123)
Signed-off-by: Matt Layher <mdlayher@gmail.com>

Co-authored-by: Jeroen Simonetti <jsimonetti@users.noreply.github.com>
2021-07-14 15:25:21 +02:00
Matt Layher
f05e8793e9
rtnetlink: remove outdated Go version warning on Conn.SetReadDeadline (#122)
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2021-07-14 15:23:27 +02:00
Julian Kornberger
bde56ed163
Cleanup (#94)
* Clean up code and remove code duplication
* Apply gofmt

Signed-off-by: Julian Kornberger <jk+github@digineo.de>
2020-12-16 14:43:43 +01:00
Matt Layher
1282c153f2 rtnetlink: expose Conn.SetReadDeadline (#69)
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2020-01-12 18:05:16 +01:00
Florian Lehner
d21b2cb70d resolve GOOS dependency (#63)
* resolve GOOS dependency

Signed-off-by: Lehner Florian <dev@der-flo.net>

* exclude internal constants from linter

Signed-off-by: Lehner Florian <dev@der-flo.net>
2019-10-19 19:25:34 +02:00
Matt Layher
57a9b72b72 rtnetlink: simplify switch cases in unpackMessages
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2019-04-11 14:40:40 -04:00
Jeroen Simonetti
6da5888ef9 neigh: first commit for neigh service
Fixes #28

Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl>
2019-04-10 22:06:08 +02:00
Jeroen Simonetti
3e13785264 Unexport newConn
Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl>
2019-04-10 17:40:19 +02:00
Jeroen Simonetti
0fde162496 conn: remove constants 2019-04-10 17:12:13 +02:00
Jeroen Simonetti
029370a6e6 Use upstreams goroutine safe execution
This will change the way messages are send and received to a
goroutine concurrent safe netlink.Execute call.

Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl>
2019-04-10 09:47:48 +02:00
Ryan Whelan
192bbe2104 Basic RouteService (#12)
* Basic RouteService

* Netlink header flag name changed in netlink lib

* Add fallthrough for RTM_GETROUTE and RTM_DELROUTE message parsing

* RouteService tests

* Update conn_test to use new netlink header flag names

* Fix off-by-one bug in AddressMessage.UnmarshalBinary()

* Update address test for off-by-one bug in AddressMessage.UnmarshalBinary()

* Fix case statement in messageUnmarshall
2019-03-27 13:47:19 +01:00
Jeroen Simonetti
f719cfd1d2 rtnetlink: remove unused pkgs 2017-12-03 21:26:58 +01:00
Jeroen Simonetti
07196347d4 const: localise constant values 2017-12-03 21:24:33 +01:00
Jeroen Simonetti
6ffa5173f6 const: fix constant map and add ADDR constants 2017-11-30 00:10:35 +01:00
Jeroen Simonetti
0ec3c1fdfc const: alias some constants to their syscall variants 2017-11-29 23:44:17 +01:00
Jeroen Simonetti
444984d397 conn: fix switch to fallthrough and add default for no match 2017-11-28 13:12:18 +01:00
Jeroen Simonetti
a550456e01 conn: remove debug statement 2017-01-19 10:45:43 +01:00
Jeroen Simonetti
799b64bcf8 address: Implement Address service 2017-01-19 10:43:01 +01:00
Jeroen Simonetti
71cee12f7a link: New, Delete, Get, Set and List implemented (#2) 2016-12-30 21:14:48 +01:00