Commit Graph

707 Commits

Author SHA1 Message Date
Asutorufa
d237ee16c3 SocketGet support udp and ipv6
Signed-off-by: Asutorufa <16442314+Asutorufa@users.noreply.github.com>
2024-03-29 09:33:44 -07:00
frei-0xff
3e28e6db88 Added SocketDestroy function. 2024-03-28 11:51:11 -07:00
foyerunix
aafe841692 Filter RouteListFiltered response by requested IP family in 2024-03-27 08:56:09 -07:00
konradh
0e685ffcfc link: add don't fragment support to Geneve 2024-03-20 14:21:27 -07:00
konradh
9453b0562a link: add INNER_PROTO_INHERIT support for Geneve 2024-03-20 14:21:27 -07:00
Christian Worm Mortensen
70def89fcb Allow link argument to AddrAdd, AddReplace and AddrDel to be nil 2024-03-04 10:50:31 -08:00
Date Huang
0cd15d9a7a bridge: add/del vlan range
Signed-off-by: Date Huang <tjjh89017@hotmail.com>
2024-03-04 10:45:37 -08: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
Maxime Soulé
7f562ed576 RouteUpdate gains NlFlags field
It allows to distinguish between a new created route or a replaced one.

Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>
2024-03-01 13:06:15 -08:00
Kangjie Xu
8fa22700b3 qdisc: add statistics for qdisc
qdisc statistics is exposed in netlink response but not parsed, here we
parse it and expose it via struct QdiscStatistics.

Signed-off-by: Kangjie Xu <kanxu@ebay.com>
2024-03-01 12:50:42 -08:00
steiler
8ac83962db Link: Fix LinkByName with long (>15 char) name by using altnames 2024-02-29 23:58:15 -08:00
Maxime Soulé
124bb8e721 Add RouteChange API
Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>
2024-02-26 09:50:43 -08:00
Hasan Mahmood
6ab7f5a376 Use local handle, not package handle for link lookups 2024-02-23 09:54:32 -08:00
Hasan Mahmood
42d9a053ea Add IifIndex option to RouteGetOptions 2024-02-23 09:54:32 -08:00
Sven Rebhan
ec7bcb248e Implement unix socket diagnostics 2024-02-21 09:21:27 -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
Yury Kulazhenkov
5daafafd95 Add functions to work with devlink device parameters
Functions added:

DevlinkGetDeviceParams - get all parameters for device
DevlinkGetDeviceParamByName - get specific parameter for device
DevlinkSetDeviceParam - set parameter for device

Signed-off-by: Yury Kulazhenkov <ykulazhenkov@nvidia.com>
2024-02-12 10:28:25 -08:00
Yury Kulazhenkov
857968af11 Add support for VDPA devices management
Current implementation support
following functions:
- VDPANewDev
- VDPADelDev
- VDPAGetDevList
- VDPAGetDevByName
- VDPAGetDevConfigList
- VDPAGetDevConfigByName
- VDPAGetDevVStats
- VDPAGetMGMTDevList
- VDPAGetMGMTDevByBusAndName

Signed-off-by: Yury Kulazhenkov <ykulazhenkov@nvidia.com>
2024-01-29 10:29:44 -08:00
Sven Rebhan
06219cde3e Implement UDP socket diagnostics
Signed-off-by: Sven Rebhan <srebhan@influxdata.com>
2024-01-26 09:08:48 -08:00
Tao Li
8d48f50f55 Added ip6tnlEncap to insert ip6tnl encap route
This commit added support to allow the operation of ip6tnl encapsulation.
It is equivalent to the iproute2 command, e.g., ip route add 192.168.99.0/24 encap ip6 dst 2001:db8:: dev ip6-tunnel
The limitation include that the options field defined in encap nl route attribute is not implenmented yet.
Testcase is included.
2024-01-23 10:47:39 -08:00
adrianc
36b61ad22c Add support to get devlink resources
- Update nl package with new netlink attribute types and consts
- Define structs to model devlink device resources
- Add DevlinkGetDeviceResources method to return device resources
- Add basic test

Signed-off-by: adrianc <adrianc@nvidia.com>
2024-01-22 11:23:43 -08:00
adrianc
2bbba08be2 Add ParseRouteAttrAsMap helper function
This will allow to parse nl attributes, returning a map
for easy access to each attribute.

Signed-off-by: adrianc <adrianc@nvidia.com>
2024-01-22 11:23:43 -08:00
adrianc
51f9bba1cd Allow NLMSG_DONE with no data
certain implementations in kernel return NLMSG_DONE
with no data. If that is the case, assume no error occured.

Signed-off-by: adrianc <adrianc@nvidia.com>
2024-01-21 09:25:04 -08:00
Kevin Sheldrake
4287122432 Add Clsact qdisc
Straight copy from jrfastab's fork, but applied to newer main.

Signed-off-by: Kevin Sheldrake <kevin.sheldrake@isovalent.com>
2023-12-06 10:59:38 -08:00
liuhao.0912
0ced838538 enable rule statistic and time statistic for flower actions 2023-11-27 10:42:39 -08:00
tc
004274e828 add tc flower pedit action
add pedit action in tc flower to support installing netlink hardware offload rules

authored-by: tangchen <tangchen.1@bytedance.com>
2023-11-27 10:36:18 -08:00
Daniel Borkmann
d649c02e2b fq: Fix to set missing TCA_FQ_PLIMIT attribute
The qdiscPayload() function was missing the TCA_FQ_PLIMIT attribute
for the Fq Qdisc. Therefore, it could not be changed via the library.
Fix this up, so that QdiscReplace() with different qdisc.PacketLimit
works now.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2023-11-27 10:24:12 -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
adrianc
95ab6696a5 fix: check for ext ACK TLVs
checking for Extended ACK in nlmsghdr flags
should be done with bitwise AND op instead of OR op

Signed-off-by: adrianc <adrianc@nvidia.com>
2023-11-12 12:14:56 -08:00
adrianc
aa4f20db57 fix: check nlmsghdr flags for interrupt
fail if NLM_F_DUMP_INTR flag is set

Signed-off-by: adrianc <adrianc@nvidia.com>
2023-11-12 12:06:03 -08:00
Tobias Klauser
77df5d35f7 Make xfrm linux-only
The xfrm framework is linux-only. Only implement the respective types
for GOOS=linux to avoid dependencies to x/sys/unix on non-linux or
non-unix platforms. Provide dummy XfrmPolicy and XfrmState types for the
globally defined XfrmPolicy* and XfrmState* functions.
2023-10-24 10:58:52 -07:00
Tobias Klauser
ccef072df0 Mark skipUnlessRoot and minKernelRequired as test helpers
With this, the skip message will display the position of the
helper invocation (i.e. the test that caused the skip) instead of the
position of the t.Skip call in minKernelRequired the helper.
2023-10-24 10:52:43 -07:00
Tobias Klauser
d18d70b0d9 Use inbound policy in TestXfrmPolicyWithOptional
Since kernel commit
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3d776e31c841b
optional tunnel/BEET mode templates in outbound policies are rejected.

Use an inbound policy instead to fix the test failure on newer kernels.
2023-10-24 09:29:12 -07:00
Tobias Klauser
586148b818 Use valid Tos value in TestRouteFilterAllTables and TestRouteExtraFields
TestRouteFilterAllTables and TestRouteExtraFields started failing a
while ago after GitHub actions images bumped the kernel version from
5.15.x to 6.2.x [1].

This is because newer kernels containing commit [2] started rejecting
Tos values with the ECN bits set to non-zero, this leads to the
following error being reported when adding routes:

    invalid argument: Invalid dsfield (tos): ECN bits must be 0

Fix this by using a valid Tos value in TestRouteFilterAllTables and
TestRouteExtraFields.

[1] https://github.com/vishvananda/netlink/pull/773#issuecomment-1754436653
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f55fbb6afb8d
2023-10-24 09:29:12 -07:00
Tobias Klauser
7b4e1dec46 nl: avoid trailing NULL byte in error messages
Use unix.ByteSliceToString to convert the NULL-terminated
NLMSGERR_ATTR_MSG error message.
2023-10-24 09:29:12 -07: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
Bernardo Soares
a4fcbb7aeb add support for bridge port neighbor suppression
this PR adds support for setting neigh_suppress attribute to a member port of a bridge
2023-09-21 20:24:56 -07:00
Dave Setzke
229a10237c Add ReceiveBufferSize and force option to *Subscribe
When there are a large number of existing results for the link, neighbor, and
address subscribe functions with ListExisting are likely to fail with ENOBUFS.
This takes the AddrSubscribeOptions ReceiveBufferSize, already applied
to LinkSubscribeOptions, and applies it to NeighSubscribeOptions and
RouteSubscribeOptions. The ReceiveTimeout option was also added to each.

Added a SetReceiveBufferSize to the nl_linux socket API.

The existing addr_linux subscribe function was modified so instead of setting
the ReceiveBufferSize on the netlink pkghandle, it is set on the socket
associated with the subscription. The new implementations also only change the
receive buffer size on the socket.

Lastly, a new ReceiveBufferForceSize option was applied to all four of the
modified Subscribe functions.
2023-09-21 19:50:55 -07:00
Daniel Xu
3cc961ec4d Add ReceiveBufferSize to LinkSubscribeOptions
Sometimes with `ListExisting` enabled and enough interfaces configured,
netlink will try to send more data than the buffer can hold and the
caller will get back ENOBUFS. Thus, it's useful to be able to configure
the netlink buffer size.
2023-09-21 19:50:55 -07:00
Marcelo Guerrero
63484bbf69 Add support to manage the vlan protocol on a vf
This allows users to get and set the vlan protocol on a vf
Signed-off-by: Marcelo Guerrero <marguerr@redhat.com>
2023-09-05 08:20:06 -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
Derek Dagit
dbf1bd04f9 Linux rule list results have Family populated
Fixes #708
2023-07-28 08:26:29 -07: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 Jarry
19c6398aa9 link: allow isolating bridge ports
This is the equivalent of:

	bridge link set dev <foo> isolated on|off

Add more bridge port netlink attributes Imported from
include/uapi/linux/if_link.h in Linux v6.3.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
2023-07-16 12:21:30 +02:00
btwotch
b4489369dd proc-event-linux: remove unused struct 2023-07-14 14:26:23 +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
Tobias Klauser
78ac5704cf go.mod: bump golang.org/x/sys to v0.10.0
Use a tagged relase rather than an intermediate version.
2023-07-05 17:42:06 +02:00
Yutaro Hayakawa
bd5868794c Support fibmatch flag for RouteGetWithOptions
Support `ip route get fibmatch` equivalent with RouteGetWithOptions by
adding FIBMatch flag to RouteGetOptions.

Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
2023-07-05 17:39:32 +02:00
Tobias Klauser
77712cff87 Use IFLA_G{S,R}O_IPV4_MAX_SIZE constants from golang.org/x/sys/unix
Commit 2b008399a4 ("link: add LinkSetGSOIPv4MaxSize and
LinkSetGROIPv4MaxSize") introduced the use of these constants, but they
were added only recently to the golang.org/x/sys/unix package. Update
its version in go.mod and use the pre-defined constants instead of
duplicating them.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2023-06-21 15:13:34 -07:00