Commit Graph

117 Commits

Author SHA1 Message Date
konradh
9453b0562a link: add INNER_PROTO_INHERIT support for Geneve 2024-03-20 14:21:27 -07:00
Kuroame
916f9685fa Change behavior of Subscribe to non-blocking. Fix test.
When listening for IPv6 address changes, I found that subscribe is not returning when there is message in the socket. After some researching, I found that libnl suggest setting socket to non-blocking when subscribing to groups. (Ref)[https://www.infradead.org/~tgr/libnl/doc/core.html#:~:text=best%20to%20put%20the%20socket%20in%20non-blocking%20mode]

Also fixed test related to BareUDP, which requires "bareudp" kmod. (Ref)[https://www.kernelconfig.io/config_bareudp]
2024-03-01 13:38:14 -08:00
steiler
8ac83962db Link: Fix LinkByName with long (>15 char) name by using altnames 2024-02-29 23:58:15 -08:00
Sebastian Sch
a008cbde48 Add support for alternative names
This commit add the support for alternative names.

* exposing the attributes in the link object.
* adding the add and delete functions
* allow LinkByName() to also find devices by altname like `ip link`

Signed-off-by: Sebastian Sch <sebassch@gmail.com>
2024-02-20 15:41:36 -08:00
tc
f1333cd79a support netkit
netkit device is merged to Linux upstream:
https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=22360fad5889cbefe1eca695b0cc0273ab280b56

this PR add support to manage a netkit device in Golang

authored-by: tangchen <tangchen.1@bytedance.com>
2023-11-27 10:22:01 -08:00
Tobias Klauser
40e139bb96 Enable extended error message reporting in tests
This causes the NETLINK_EXT_ACK socket option to be set and extended
error messages to be reported in errors. This should help debug test
failures.

Also use errors.Is to check for errors because using extended error
reporting, the errors no longer match exactly.
2023-10-24 09:29:12 -07:00
Robin Gögge
6afddb37c1 Fix FlowBased support for Geneve
The IFLA_GENEVE_COLLECT_METADATA netlink attribute shouldn't have any a
payload. For Geneve devices also other attributes can be set next to
FlowBased, however the VNI needs to be 0.

This commit also adds a test for creating a Geneve device in FlowBased
mode.

Signed-off-by: Robin Gögge <r.goegge@isovalent.com>
2023-08-07 21:01:33 +02:00
Nicholas Hollett
1b5637395d Support setting GSO Max Segment count
This allows for ip link set $link gso_max_segs $maxSegs type operations.
2023-07-17 19:36:57 +02:00
Robin Gögge
16d31db235 Fix FlowBased support for Iptun
IFLA_IPTUN_COLLECT_METADATA is a "flag" netlink attribute, and shouldn't
have any payload. This also needs to be considered when parsing netlink
messages for Iptun.

This fixes Iptun link, by crafting and parsing messages accordingly and
adds a test.

Signed-off-by: Robin Gögge <r.goegge@isovalent.com>
2023-07-14 14:09:04 +02:00
Robin Gögge
88c0defd46 Add FlowBased support for Ip6tnl
Ip6tnl devices support IFLA_IPTUN_COLLECT_METADATA (collect_md/external
mode). This commit adds support for this and a respective test.

Signed-off-by: Robin Gögge <r.goegge@isovalent.com>
2023-07-14 14:08:02 +02:00
Daniel Borkmann
a8a91c0504 link: add TSOMaxSize and TSOMaxSegs to link attributes
This is a read-only netlink attribute which has been added in 5.19
kernel. This is useful to query in order to probe if a given driver
supports IPv6 BIG TCP.

  [0] https://lore.kernel.org/netdev/20220513183408.686447-2-eric.dumazet@gmail.com/

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2023-06-16 08:52:39 -07:00
Daniel Borkmann
2b008399a4 link: add LinkSetGSOIPv4MaxSize and LinkSetGROIPv4MaxSize
Add two new methods to allow setting GSO and GRO max size attributes only.
They make it much easier to enable IPv4 BIG TCP [0].

The equivalent iproute2 commands are:

$ ip link set $link gso_ipv4_max_size $maxSize
$ ip link set $link gro_ipv4_max_size $maxSize

Also add tests for them. We already do support the IPv6 counterpart via
543bb1cade ("link: add LinkSetGSOMaxSize and LinkSetGROMaxSize").

  [0] https://lore.kernel.org/netdev/cover.1674921359.git.lucien.xin@gmail.com/

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2023-06-14 23:26:06 -07:00
Marcelo Guerrero Viveros
55c8b9515a Add support for setting default vlan on a bridge
This pr allows to change the default vlan on a bridge. It is
currently set to 1 by default. A value of 0 means no default vlan.

Signed-off-by: Marcelo Guerrero Viveros <marguerr@redhat.com>
2023-04-20 10:47:44 -07:00
Eyal Birger
7e7feb220f link: Add FlowBased support to Gretun
GRE L3 devices support "FlowBased" ("collect_md"/"external") mode.
Add support for this configuration and relevant test.

Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
2022-08-02 12:16:27 +02:00
Eyal Birger
d0aef2fdcd link: fix FlowBased support in Gretap
IFLA_GRE_COLLECT_METADATA is a "flag" netlink attribute. As such it should
not be sent with a data payload.

Fix gretap link to send this flag correctly and re-enable tests.

Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
2022-08-02 12:15:32 +02:00
Nikolay Aleksandrov
543bb1cade link: add LinkSetGSOMaxSize and LinkSetGROMaxSize
Add two new methods to allow setting GSO and GRO max size attributes only.
They make it much easier to enable BIG TCP[1].
The equivalent iproute2 commands are:
$ ip link set $link gso_max_size $maxSize
$ ip link set $link gro_max_size $maxSize

Also add tests for them.

[1] https://patchwork.kernel.org/project/netdevbpf/cover/20220513183408.686447-1-eric.dumazet@gmail.com/

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
2022-06-07 09:11:27 -07:00
Nikolay Aleksandrov
c94808a88b link: add support for IFLA_GRO_MAX_SIZE
Add support for the new IFLA_GRO_MAX_SIZE attribute which is needed to
enable BIG TCP[1] properly. Define the attribute in the local link
attributes (nl/link_linux.go) because it isn't yet present in Go's
x/sys/unix package. Also add a test for it.

[1] https://patchwork.kernel.org/project/netdevbpf/cover/20220513183408.686447-1-eric.dumazet@gmail.com/

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
2022-06-02 16:02:03 -07:00
Tobias Klauser
866f5f32e3 Fix TestLinkAddDelXfrmiNoId
Adding an xfrmi link with if_id 0 results in EINVAL being returned, see
[1]. Adjust TestLinkAddDelXfrmiNoId accordingly to expect an error.

[1] 8efd0d9c31/net/xfrm/xfrm_interface.c (L645-L648)

Fixes: f7fd7af437 ("Only set IFLA_XFRM_IF_ID if not 0")
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2022-05-31 09:13:25 -07:00
Vishvananda Abrams
523ee65ce3 fix the tests to run again 2022-01-12 16:05:20 -06:00
Tobias Urdin
650dca95af Export LinkModify function
When the LinkModify was merged in [1] a function
that exports it outside of pkgHandle was never
added like is available for LinkAdd, LinkDel etc.

Update testing to use exported LinkModify that
itself calls the pkgHandle.LinkModify function.

[1] https://github.com/vishvananda/netlink/pull/541
2021-11-18 08:18:26 -08:00
张祖建
b8aac10bba fix staticcheck issues 2021-09-21 09:10:48 -05:00
TheDiveO
626202eca8 Provide handle Close() and deprecate Delete() 2021-09-18 09:03:48 -07:00
bersoare
7992ad9959 add support for bareudp link type 2021-09-17 10:14:18 -07:00
dennisafa
d1e684a60b Ability to set multicast attribute on a link 2021-05-30 12:51:51 +02:00
Bjorn Svensson
6063cc66d7 Add allmulti to link attributes
Provide the status of the allmulticast option via the highlevel
link attributes instead of requiring raw flag handling.

Avoid comparing all rawflags before and after in tests due to that
the IFF_RUNNING flag might change independenly.

Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
2021-05-08 09:10:00 -07:00
Moshe Litvin
88079d98e6 1. Fixed endianity probem with geneve VNI (ID)
2. Parse remote IP
3. Added unit test to test geneve paramters against "ip link"
2020-12-06 12:36:32 -08:00
Stephen Hassard
d185ffdb62 Add Geneve link support
Heavily based on the existing Gretap support
2020-11-21 23:35:49 -08:00
Jaime Caamaño Ruiz
02121dbd7e Add LinkSetMacvlanMode 2020-09-24 21:35:02 -04:00
Konstantin Baranov
337442361b Allow placing veth peer into a namespace
Creating a veth pair across namespaces now is a multistep process.
Doing it in one shot with this change is clearer as current
namespace never sees peer IF. Also, moving peer into a namespace
may be rather slow, so better avoided.
2020-09-14 10:57:23 -04:00
Miguel Duarte Barroso
7484f55b22 tuntap: use the owner / group parameters
Set the tuntap owner / group via syscall on the opened file
descriptor.

Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2020-09-14 10:54:17 -04:00
Dennis Marttinen
9690c54307 Add support for configuring bridge ageing time
Signed-off-by: Dennis Marttinen <dennis@weave.works>
2020-09-14 10:49:43 -04:00
Dmitrii Okunev
dc0e1b988c feature: Add wireguard link type
Added type "Wireguard" which implements link type "wireguard".

See also https://www.wireguard.com/

Signed-off-by: Dmitrii Okunev <xaionaro@fb.com>
2020-06-04 09:01:02 -07:00
Daniel Gollub
12f2829c35 Add LinkModify support
Signed-off-by: Daniel Gollub <dgollub@att.com>
2020-06-03 11:55:45 -07:00
Alex Forster
27f2b32dc6 Configure numrxqueues/numtxqueues on veth peer (fixes #536) 2020-06-03 11:23:51 -07:00
stffabi
5f2fc868c2 Add BridgeSetVlanFiltering to change VlanFiltering on an existing bridge
Signed-off-by: stffabi <stffabi@pm.me>
2020-02-18 12:46:31 -05:00
Takushi Fujiwara
2ec5bdc52b Change LinkSetMaster's master argument type. (*Bridge -> Link)
LinkSetMaster also works with Bond device.
So this PR changes the type of master argument to Link.
2019-09-30 07:54:47 -07:00
Yakushi Fujiwara
ac5f4df047 Add support for parsing IFLA_BOND_ARP_IP_TARGET 2019-09-24 13:57:46 -07:00
Oleg Senin
6b3a223c53 Add ip6tnl support 2019-09-24 13:56:29 -07:00
Takushi Fujiwara
205a160d2e Add bond slave information
This PR refers to PR@lebauce and add some changes.
- Added some tests to retrieve bond slave information.
- Link.BondSlave is changed to LinkSlave interface.
- BondSlaveState.String() returns UPPER case. (same as iproute2)
- BondSlaveMiiStatus.String() returns UPPER case. (same as iproute2)
2019-09-16 08:52:39 -07:00
bingshen.wbs
14bd2e6fd2 support ipvlan flag
Signed-off-by: bingshen.wbs <bingshen.wbs@alibaba-inc.com>
2019-07-25 03:37:08 +02:00
Anton Aksola
df01369528 add support for link groups (IFLA_GROUP) 2019-07-13 20:34:27 -07:00
Martynas Pumputis
99a56c251a veth: Set peer hardware addr when creating
This commit extends LinkAdd function for Veth by allowing to specify
peer hardware addr.

Signed-off-by: Martynas Pumputis <m@lambda.lt>
2019-06-18 07:33:17 -07:00
Sargun Dhillon
d50d15ce3f Set Link TX / RX Queues on Deserialization
This deserializes the tx queue, and rx queue count on link
deserialization. We already supported it on serialization.

Signed-off-by: Sargun Dhillon <sargun@sargun.me>
2019-06-12 19:02:44 -07:00
Archana Shinde
db99c040b9 tuntap: Return TunTapLink instead of GenericLink
For tuntap interfaces, return a TunTap Interface instead of
a Generic link when retrieving the interface.
Use netlink extended attributes to populate the Link attributes
for the tuntap link.
In case of older tun driver which does not provide these
attributes, use sysfs to retrieve these attributes.

This commit also adds Owner and Group attributes for the TunTap
Link.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2019-06-03 12:01:21 -07:00
soyking
fafc1e7b60 support vlan protocol 2019-05-03 14:23:34 -07:00
Andrei Vagin
adb577d4a4 Add support for IFLA_GSO_*
IFLA_GSO_MAX_SIZE - maximum GSO segment size
IFLA_GSO_MAX_SEGS - maximum number of GSO segments

Signed-off-by: Andrei Vagin <avagin@google.com>
2019-03-17 17:31:49 -07:00
Matt Ellison
1e2e7ab670 Add Support for Virtual XFRM Interfaces
XFRM interfaces are available in Linux Kernel 4.19+

When an IF_ID is applied to a XFRM policy and state, the corresponding
traffic will be sent through the virtual interface with the same IF_ID.
2019-01-05 11:40:40 -08:00
Julian Kornberger
023a6dafdc Make go vet happier 2018-11-08 14:21:39 -08:00
Div Arora
2cbcf73e3d Add a test for Vlan filtering support for bridges. 2018-07-23 11:15:57 -07:00
semicomplete
ee06b1df73 add vti6 support
Signed-off-by: semicomplete <example@example.com>
2018-06-19 08:48:34 -07:00