19 Commits

Author SHA1 Message Date
Jeroen Simonetti
4f94b95172
chore: fix CI issues (#257)
* chore: fix CI issues
* chore: fix golangci-lint version issue

---------

Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl>
2025-04-15 10:21:45 +02:00
Birol Bilgin
bd79d59a97
Add LinkDriver interface and Driver package (#221)
* Add attr validation

This commit removes unix.IFLA_UNSPEC and introduces checks for the interface name,
the link type and the queue disc fields.
Interface name validation is necessary to prevent an 'invalid argument' error
when creating a link with an empty name. Other checks were added to be consistent with the ip tools.

Signed-off-by: Birol Bilgin <birolbilgin@gmail.com>

* Add network namespace type

This commit introduces the NetNS struct and integrates network namespace capabilities into link attributes.
This enhancement facilitates the creation of links, such as veth pairs, across different network namespaces
without the need to execute directly within those namespaces.

Signed-off-by: Birol Bilgin <birolbilgin@gmail.com>

* Add LinkDriver interface

This commit introduces a Driver interface and changes Data and SlaveData fields within the LinkInfo struct
as LinkDriver to accommodate driver-specific data encoding, addressing the limitation
where LinkInfo.Data and SlaveData fields were merely byte slices without support for specific data encoding.

Drivers are registered globally with the RegisterDriver function.
For un-registered drivers, the default LinkData driver is used.

Signed-off-by: Birol Bilgin <birolbilgin@gmail.com>

* Add Driver Package

This commit introduces the 'driver' package, which contains specific implementations of the LinkDriver interface.
It also includes the implementation of the Linux bond driver as LinkDriver and the bond slave driver as LinkSlaveDriver.

Signed-off-by: Birol Bilgin <birolbilgin@gmail.com>

* Add Netkit and Veth drivers

This commit adds Netkit and Veth drivers.

Signed-off-by: Birol Bilgin <birolbilgin@gmail.com>

---------

Signed-off-by: Birol Bilgin <birolbilgin@gmail.com>
2024-05-10 08:51:09 +02:00
SUN Haoyu
f070a40baa
Add new attributes to LinkAttributes with decoder. (#153)
Signed-off-by: Haoyu Sun <hasun@redhat.com>
2022-10-09 01:59:02 +02:00
Ben Kochie
6ffd7597d2
Improve LinkStats error message (#152)
* Add the value received to make it easier to debug.
* Include the message type in the message.

Signed-off-by: SuperQ <superq@gmail.com>
2022-10-06 17:28:01 +02:00
Jeroen Simonetti
b237973d78
support kernel 5.19 and up (#146)
Kernel 5.19 added an attribute in the LinkStats64.
794c24e992

This will fix running on kernels 5.19 and above.

Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl>
2022-08-23 13:12:31 +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
51db9f1201
Skip tests on big-endian systems (#62)
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>
2019-10-09 19:23:56 +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
Ryan Whelan
5802935ca8 Added Master Attr to Links
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.
2019-04-23 22:26:53 -04:00
Yuri Pimenov
b03757ba37 Support 64bit link stats 2019-04-18 11:36:15 +03:00
Matt Layher
c2e7cb1b6c rtnetlink: use unix.IFLA_* constants
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2019-04-12 16:07:02 -04:00
Jeroen Simonetti
7d913f5072 Dont marshal empty LinkAttributes
Fixes #18

When marshaling a LinkMessage the default values for LinkAttributes
causes netlink errors. By using a pointer to check if
LinkAttributes are set or not and only marshaling them if not nil
we prevent causing these errors.

Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl>
2019-04-09 21:18:01 +02:00
Andrea Barberio
426cc8e981 [link] Use the Change field
So far the LinkMessage.Change field was unused and recommended to be set
to 0xffffffff. This field  is actually necessary to change specific flags.

Signed-off-by: Andrea Barberio <insomniac@slackware.it>
2019-04-09 17:24:51 +01:00
Jeroen Simonetti
1c55f6e4a1 Add simple linkstats tests
Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl>
2019-04-08 15:07:13 +02:00
Ryan Whelan
acd79fa8ea L3 Interfaces do not have L2 addresses (#13)
* L3 Interfaces do not have hardware addresses

* tests: L3 Interfaces do not have hardware addresses
2019-04-01 17:05:26 +02:00
Terin Stock
87df7d5131 feat: add OperationalState and LinkInfo attributes (#11)
Add support for parsing two additional LinkAttributes necessary for
creating and managing interfaces: OperationState and LinkInfo.

OperationalState allows for the UP/DOWN state of the interface to be
determined and controlled. This addition allows for interfaces to be
created and then brought up programatically.

LinkInfo contains driver specific configuration, such as those for
bridges or tunnels. This additional configuration is stored as nested
Netlink messages on the Data and SlaveData members.
2018-11-15 21:02:09 +01:00
Terin Stock
3629fb389e fix: loosen LinkAttribute length checks (#8)
Loosen the LinkAttribute length checks, to parse links that store
information other than MAC addresses in the Address or Broadcast fields.

This change, for example, now allows IPIP, GRE over IP, 6to4, and IP
over Infiniband.

The fields continue to be net.HardwareAddr, which may result in slightly
unusual representations when printed as a string. This type can be cast
to other byte slice types by users, if necessary.

Fix: #7
2018-11-13 09:36:08 +01:00
Jeroen Simonetti
799b64bcf8 address: Implement Address service 2017-01-19 10:43:01 +01:00
Jeroen Simonetti
088293c311 link: add marshal and unmarshall tests 2016-12-31 01:48:07 +01:00