29 Commits

Author SHA1 Message Date
Terin Stock
5d4f0c437b
feat(route): list with kernel filtering (#262)
A new "ListMatch" function has been added to the RouteService to allow
for kernel-based filtering of the routing tables. The netlink flags
required for getting a route for an IP (eg, rtnl.RouteGetAll) is
different than those required while filtering the table.

This changeset removes the superfluous "netlink.DumpFiltered" flag from
the Get function of RouteService, as this flag is for kernel responses.

Signed-off-by: Terin Stock <terinjokes@gmail.com>
2025-05-11 12:06:36 +02: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
Matt Layher
3f746d924b
rtnetlink: support for RTA_PREF (#137)
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2022-03-13 18:00:51 +01:00
Matt Layher
4cc3c14895
rtnetlink: tidy IP address encoding/decoding, fix attribute error handling (#125)
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2021-07-21 22:56:14 +02:00
Matt Layher
8d122574c7
rtnetlink: add RouteMetrics.InitRwnd field (#104)
Signed-off-by: Matt Layher <mlayher@fastly.com>
2021-01-22 17:32:28 +01:00
Matt Layher
c676dcb476
rtnetlink: add encodeIP netlink attribute IP address helper (#98)
Signed-off-by: Matt Layher <mlayher@fastly.com>
2021-01-19 16:41:33 +01: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
057ddd1f37
rtnetlink: implement MPLSNextHop encoding and decoding
Signed-off-by: Matt Layher <mlayher@fastly.com>
2020-11-18 15:26:31 -05:00
Matt Layher
d3bfe80807
rtnetlink: invalid rtnexthop length crasher found by go-fuzz
Signed-off-by: Matt Layher <mlayher@fastly.com>
2020-11-09 12:12:15 -05:00
Matt Layher
73ac306def
rtnetlink: fix out of bounds route attributes crasher found by go-fuzz
Signed-off-by: Matt Layher <mlayher@fastly.com>
2020-11-09 12:09:08 -05:00
Matt Layher
df6d3b58ab
rtnetlink: fix short rtnexthop crasher found by go-fuzz
Signed-off-by: Matt Layher <mlayher@fastly.com>
2020-11-09 12:03:59 -05:00
Matt Layher
46cdbd0a14
rtnetlink: rewrite route multipath parsing using multipathParser type
Signed-off-by: Matt Layher <mlayher@fastly.com>
2020-11-09 11:37:34 -05:00
Dave Josephsen
bae80799d8 rtnetlink: complete route multipath encoding and decoding logic
Signed-off-by: Dave Josephsen <djosephsen@fastly.com>
Signed-off-by: Matt Layher <mlayher@fastly.com>
2020-10-26 12:43:11 -04:00
Jeroen Simonetti
c293b67934 Add doc 2020-10-02 16:59:15 +02:00
Matt Layher
4e9cdead09
rtnetlink: add RouteMetrics nested attributes within RouteAttributes (#81)
Signed-off-by: Matt Layher <mlayher@fastly.com>
2020-10-02 16:52:24 +02:00
jeremiejig
d699427278
route: Implement support for RTA_MARK (#79)
* module: `go mod tidy`

Signed-off-by: Jeremiejig <me@jeremiejig.fr>

* route: Implement support for RTA_MARK

The RTA_MARK attribute allow to send get request with mark information;
it is useful when having multiple table selected by rule policy
matching on fwmark.

Signed-off-by: Jeremiejig <me@jeremiejig.fr>
2020-07-26 18:59:00 +02:00
Davydov Denis
154ecd4176 - added methods for replace route
Signed-off-by: Davydov Denis <dadmoscow@gmail.com>
2020-04-13 15:44:53 +03: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
Jeroen Simonetti
5df73f7be7
Use netlink attribute en-/decoder infrastructure (#61)
Use netlink attribute en-/decoder infrastructure

This should pave the way for endian aware code.
Ref #56 

Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl>
2019-10-09 17:41:08 +02:00
Anatole Denis
0b6465fc1b route: Implement support for RTA_EXPIRES
The RTA_EXPIRES attribute allows creating self-deleting routes; it is
useful for example when installing routes obtained from a DHCP lease.

The natural zero-value of the attribute needs special care, since it
means the route will be immediately deleted, a very different behaviour
from when the attribute is omitted (where the rule does never expire).
This means we need to separate these cases, which we do by using a
*uint32, where the nil value means the attribute is omitted and any
other values are passed as-is

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2019-10-04 11:32:52 +02:00
Ryan Whelan
cc66aab851 feat: Add Get() to RouteService - Add DumpFiltered flag to request 2019-04-17 10:36:31 -04:00
Ryan Whelan
5855e88896 feat: Add Get() to RouteService 2019-04-17 10:12:37 -04:00
Andrea Barberio
0951830968 [route] Revert #27
In #27 I erroneously computed SrcLen and DstLen believing that it was
the octet-length of the Src and Dst addresses in the attributes. This is
actually the prefix length of Src and Dst, which should be set
independently. Also updated comments to reflect this.

Signed-off-by: Andrea Barberio <insomniac@slackware.it>
2019-04-11 19:44:31 +01:00
Jeroen Simonetti
b0ae3d1ffc route: remove constants 2019-04-10 17:18:07 +02:00
Jeroen Simonetti
66f9b418de Merge branch 'master' into upstream_concurrency
Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl>
2019-04-10 16:57:18 +02:00
Andrea Barberio
fcb754f111 [route] Explicitly set SrcLen and DstLen
Signed-off-by: Andrea Barberio <insomniac@slackware.it>
2019-04-10 14:59:34 +01:00
Jeroen Simonetti
57c0b0b853 Use Execute on all services 2019-04-10 13:04:55 +02:00
Jeroen Simonetti
13fb5559f9 Remove dependancy and add interface check 2019-04-04 13:14:16 +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