21 Commits

Author SHA1 Message Date
Andrey Smirnov
cff2178760
feat: add support for address priority (#256)
This allows to set route priority/metric for prefix routes created
automatically when an address is assigned.

E.g. `10.0.0.0/8` with metric `32` would generate a route:

```
10.0.0.0/8 via <if> metric 32
```

The default metric is zero. A custom metric allows to prefer
one interface over another when the prefixes overlap.

See https://github.com/siderolabs/talos/issues/10696

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
2025-04-15 10:06:46 +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
Jeroen Simonetti
61ed88fc1e
Rename CacheInfo Prefered (#224)
Fix a typo in the CacheInfo struct.

Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl>
2024-05-10 09:01:40 +02:00
James Tucker
d380b50506
rtnetlink: add address label encoding (#138)
Signed-off-by: James Tucker <jftucker@gmail.com>
2022-04-08 16:16:09 -04: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
af39de65d6
rtnetlink: make AddressMessage.Attributes optional via pointer (#124)
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2021-07-14 15:52:44 +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
Jeroen Simonetti
31febcbb33
Change address message to ignore empty ip's (#74)
This will not marshal the following attributes when empty:
- Local (was already ignored)
- Broadcast
- Anycast
- Multicast

Fixes: #73

Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl>
2020-03-19 15:28:06 +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
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
Jeroen Simonetti
00c3908f53
addr: add more flexibility in Address.Delete (#38)
Breaking change.

Because deleting an address requires more information then was
available we allow for users to construct the request message.

Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl>
2019-04-11 23:25:09 +02: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
a9df9a003b Remove IFA_FLAGS constant
golang/x/sys/unix was updated to include the unix.IFA_FLAGS constant

Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl>
2019-04-10 19:17:53 +02:00
Ryan Whelan
4d6cd27f32 fix: Null ifaLocal causes error from kernel (#19)
* fix: Null ifaLocal causes error from kernel

Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl>
2019-04-10 18:41:15 +02:00
Jeroen Simonetti
5fefddd5d6 address: remove constants 2019-04-10 17:17:00 +02:00
Jeroen Simonetti
57c0b0b853 Use Execute on all services 2019-04-10 13:04:55 +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
799b64bcf8 address: Implement Address service 2017-01-19 10:43:01 +01:00