Commit Graph

681 Commits

Author SHA1 Message Date
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
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
Li Chun
acdc658b86 Add "default" dst while no DST attr responsed from nl
Signed-off-by: Li Chun <chun2.li@intel.com>
2023-06-03 21:11:57 -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
major1201
7350a0539f Support ipset test entry existence 2023-04-20 10:46:28 -07:00
Nikolay Aleksandrov
ced5aaba43 rule: add support for FRA_PROTOCOL
Add support for ip rules' FRA_PROTOCOL attribute and also check for it
when testing rules. The default ip rule protocol is RTPROT_UNSPEC (0) so
we set the attribute only when it is >0.

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
2023-03-16 09:30:32 -07:00
Ivan Kolodyazhny
70ca0345ee Support dst_port and src_port attributes in flower filter 2023-02-06 10:37:46 -08:00
Ivan Kolodyazhny
130828cd57 Add Flower ip_proto attribute support 2023-02-06 10:37:46 -08:00
Ivan Kolodyazhny
05506ada9f Implement filter goto action support 2023-01-30 09:12:08 -08:00
Ivan Kolodyazhny
378a404a26 Implement chains support
This patch implements both tc and filter chains.

We also need to align tc filter delition implementation
with iprote2 to delete filters withichain by passing
additional bits during filter deletion call.
2022-12-14 10:59:49 -08:00
Ivan Kolodyazhny
e20cb98f77 Support skip_hw/skip_sw flags
This feature could not be tested with virtual interfaces that's why
unit-tests aren't added into this change.
2022-12-14 08:41:50 -08:00
Ivan Kolodyazhny
7f2b136d34 qdisc ingress_block support 2022-12-13 09:41:45 -08:00
Evgeniy Zakharochkin
e0988fd129 Fix adding ipset entry comment 2022-12-12 09:07:43 -08:00
Hu Jun
d3c0a2caa5 - fixes vishvananda/netlink#815
- changes: 1. set userTmpl.Family to correct family 2. add Selector to XfrmState which is corresponding to XfrmUsersaInfo.Sel

- update *XfrmAddress.ToIPNet method to support 0.0.0.0/0 and ::/0 correctly
- update xfrmStateFromXfrmUsersaInfo to get XfrmState.Selector
- extend TestXfrmStateAddGetDel for v6ov4 and v4ov6 cases
2022-11-07 14:26:36 -08:00
Steffen Vogel
d3b7a6fadd Add firewall mark option to RouteGetOptions
This option allows performing FIB lookups for a particular
firewall mark. It is equivalent to iproute2's 'ip route get mark'
option.
2022-11-07 10:26:17 -08:00
Surya Seetharaman
8e1ce9665a Add labelFilter for conntrack
This PR adds support for filtering flows
based on conntrack labels. It adds two
filters `ConntrackMatchLabels` &&
`ConntackUnmatchLabels` through which user can
provide a list of labels as type "bytes" which
will then be compared to flow.Labels to see if
any matches were found.

ConntrackMatchLabels: Every label passed should
be contained in flow.Labels for a match to be true
ConntrackUmmatchLabels: Every label passed should
not be contained in the flow.Labels for a match to
be true

Signed-off-by: Surya Seetharaman <suryaseetharaman.9@gmail.com>
2022-11-03 10:05:53 -07:00
Noah
eab52eee5a Add XfrmPolicyGet to unspecified operations 2022-11-03 09:19:10 -07:00
Dave Setzke
b4d07e8343 Use ndmsg payload for neighbor subscribe requests 2022-11-03 09:05:21 -07:00
chengzhycn
d3b8a16e9b add actions support for fwfilter
Signed-off-by: chengzhycn <chengzhycn@gmail.com>
2022-10-27 09:19:20 -07:00
chengzhycn
8baf7b0c69 add support for skbedit mask 2022-10-26 18:47:10 -07:00
chengzhycn
337a587de1 fix RouteList can't list routes properly when unspecifying link
Signed-off-by: chengzhycn <chengzhycn@gmail.com>
2022-10-26 10:42:34 -07:00
Damien Tournoud
8715fe718d ipset: Expose MaxElements to IpsetCreate 2022-09-15 11:54:47 -07:00
Damien Tournoud
d44b87fd4d ipset: Add support for IPv6 2022-08-12 20:31:58 +02:00
Tobias Klauser
afa2eb2a66 Use IFLA_* consts defined in golang.org/x/sys/unix
Use the constants provided in the golang.org/x/sys/unix package instead
of locally defining them, as done in commit c94808a88b ("link: add
support for IFLA_GRO_MAX_SIZE").

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2022-08-07 20:12:18 +02:00
Manjiri Gadagkar
6e2993d135 RouteGetWithOptions: Add UID option 2022-08-02 12:21:20 +02: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