* 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>
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>
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>
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.
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>
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>
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.
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