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>
Change route scope decision to be based on gateway. This should
make more sense because a link without a gateway should reside
on the same subnet.
Signed-off-by: Brad Beam <brad.beam@talos-systems.com>
In looking through the documentation and iproute2 code, `RTM_SETLINK`
seems to only be used in a handful of special cases, whereas `RTM_NEWLINK`
is used across the board for both new link creation as well as modification.
Signed-off-by: Brad Beam <brad.beam@talos-systems.com>
* rtnl: add ParseAddr and MustParseAddr helpers, add usage examples
Signed-off-by: Timo Beckers <timo@incline.eu>
* addr_*_test - test ParseAddr and MustParseAddr
Signed-off-by: Timo Beckers <timo@incline.eu>
* Examples: use first ParseCIDR return value as IP address
Signed-off-by: Timo Beckers <timo@incline.eu>
To prevent having to maintain byte slices for both endian types
in our tests, we skip tests when running on big-endian systems.
Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl>
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>
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>
Added `RouteDel` to support route deletion.
Also added `RouteAddSrc` to support adding routes with a source parameter.
Signed-off-by: Andrea Barberio <insomniac@slackware.it>
Allows enslaving ifaces to bridges.
Required the change to make MTU an optional attr to prevent EINVAL from the kernal. If we need to support setting the MTU to 0, the field will have to be a ptr on the LinkAttribute struct.