807 Commits

Author SHA1 Message Date
Peter Kerzum
d07ce5b169 Ignore SetExtAck() errors also in ExecuteIter(). 2025-09-25 16:38:12 +02:00
Peter Kerzum
e2bf19b272 Always check for EnableErrorMessageReporting and SetExtAck() when creating Netlink sockets. 2025-09-25 16:38:12 +02:00
adrianc
0eeb54f1c8 chore: use assert in devlink tests
this commit transitions the rest of devlink tests
to use assert package where possible.

Signed-off-by: adrianc <adrianc@nvidia.com>
2025-09-11 09:46:39 -07:00
adrianc
c7dbf7ceac chore: bump github actions
bump actions/checkout to v4
bump actions/setup-go to v5

Signed-off-by: adrianc <adrianc@nvidia.com>
2025-09-11 09:44:45 -07:00
Giuseppe Ognibene
481da0d6a4 Add support for ignore-df flag in gretap links
Signed-off-by: Giuseppe Ognibene <ognibenegiuseppe8@gmail.com>
2025-09-04 12:31:30 -07:00
solidDoWant
5f641a7410 Add additional functions for reconfiguring VXLAN interfaces after creation
Signed-off-by: solidDoWant <fred.heinecke@yahoo.com>
2025-09-04 12:27:50 -07:00
adrianc
b85149843e feat: add additional devlink port attributes
Add the following devlink port attributes:

PortNumber: the physical port number
PfNumber: the PF number
VfNumber: the VF number (index)
SfNumber: the SF number (index)
ControllerNumber: the controller number
External: if set, indicates external controller

Signed-off-by: adrianc <adrianc@nvidia.com>
2025-09-02 12:31:49 -07:00
Charlie Camilleri
37e5aafde3 Add DevlinkSplitPort, DevlinkUnsplitPort 2025-09-02 12:31:12 -07:00
Vishvananda Abrams
db0dbb948c tests: fix SEG6 route test on recent kernels
The SEG6 route test was failing on newer kernels:

* Using loopback (`lo`) for SRv6 inline routes no longer preserves the
  `encap seg6` attribute. Switched to a dummy device (`dummy0`) to ensure
  SRv6 routes are accepted.
* Removed the artificial `::` SID from the inline segment list, which
  caused the kernel to drop the SRH.
* Added cleanup to delete the dummy device after the test.
* Updated route checks to use `RouteListFiltered` with `RT_FILTER_OIF|RT_FILTER_DST`
  since modern kernels add extra auto-routes (e.g., fe80::/64), which broke
  the naive `len(routes) == 1` assertion.

These changes make `TestSEG6RouteAddDel` stable across recent kernels while
still validating both INLINE (IPv6) and ENCAP (IPv4) SRv6 routes.
2025-08-30 11:05:32 -07:00
Vishvananda Abrams
7b78f24353 test(conntrack): ensure conntrack hooks for tests
This change ensures that the necessary netfilter hooks are in place for
conntrack tests to run reliably. Previously, the tests would fail in
environments where the host's firewall was not configured to accept
conntrack traffic.

This change introduces a new function, `ensureCtHooksInThisNS`, that
uses `iptables` or `nftables` to install the necessary hooks. This
function is called from `nsCreateAndEnter`, so all tests that use this
function will have a properly configured netns.

This change also removes the `CI` environment variable check from the
tests, as they are now expected to pass in CI environments.
2025-08-30 11:04:06 -07:00
Vishvananda Abrams
79f64fe500 tests: Stabilize TestLinkXdp against race condition
The TestLinkXdp test was observed to be flaky in CI environments.
The failure occurred because the test expects the second call to
LinkSetXdpFdWithFlags with the XDP_FLAGS_UPDATE_IF_NOEXIST flag
to fail with EBUSY, indicating that an XDP program is already
attached.

Due to a race condition, the kernel had not always completed the
attachment from the first LinkSetXdpFd call before the second call
was made. This caused the second call to succeed (returning a nil
error) when it should have failed. The test logic correctly
interpreted this unexpected success as a failure, but logged the
nil error, leading to confusing output.

This commit resolves the flakiness by introducing a retry loop
with a short delay. The test now attempts the second call multiple
times, giving the kernel sufficient time to update the link's XDP
state. This ensures that the test reliably checks for the EBUSY
error as intended.
2025-08-30 10:58:08 -07:00
Vladimir Ermakov
ba05b48cab Fixed IP6tnl encapsulation and ID handling issues:
- Added IP6tnlEncap processing
- Added proper IP6tnlEncap.ID assignment
- Enabled handling of IP6tnlEncap.TC and IP6tnlEncap.FLAGS for serialization support
2025-08-29 16:10:43 -07:00
Albert Jin
b032ea08ec Add support for the expires option of ip route 2025-08-29 15:51:23 -07:00
Alasdair McWilliam
cf66e1d224 link: netkit: Add support for Headroom and Tailroom attributes.
IFLA_NETKIT_HEADROOM and IFLA_NETKIT_TAILROOM attributes were added to
upstream kernel 6.14, allowing Netkit devices to be configured with
appropriate headroom/tailroom space to accommodate additional headers,
packet length changes and so forth.

Signed-off-by: Alasdair McWilliam <alasdair.mcwilliam@isovalent.com>
2025-08-29 15:42:34 -07:00
Nitin Kumar
349c84c717 chore: Bump golang to v1.23 2025-08-27 09:27:42 -07:00
Vishvananda Abrams
1e35ba25dc test: Improve test reliability with proper cleanup and isolation
Refactors test setup and teardown logic to use `t.Cleanup` instead
of `defer`. This ensures that cleanup functions are correctly scoped
to each subtest's lifecycle, improving test isolation and reliability.

The `setUpNetlinkTest` helper function is also improved to correctly
save and restore the original network namespace, ensuring that tests
do not leak state.

To support this, a `Close()` method that returns an error is added to
the `Handle` struct, allowing for proper cleanup of underlying netlink
sockets. The test helpers are updated to use this new method,
preventing resource leaks between tests.

Additionally, a bug in the `netns` tests is fixed where a large
namespace ID could overflow a 32-bit integer, causing spurious
failures on some systems.
2025-08-27 09:24:17 -07:00
Vishvananda Abrams
00c3a3def6 Isolate RuleListFiltered subtests
Refactors the TestRuleListFiltered test to run each subtest in its
own network namespace. This prevents state leakage between subtests,
resolving intermittent test failures caused by rules created in one
test interfering with subsequent tests.

The test logic for verifying all rules is also simplified by moving
the rule listing into the setup phase for that specific test case,
removing conditional logic from the main test loop.

Fixes: #1108
2025-08-27 09:24:17 -07:00
pasteley
7af87bcf82 feat: option to disable VF polling
Introduces a configuration flag to disable Virtual Function polling,
providing users with control over polling behavior for performance
optimization scenarios.

Fixes: #1097

Signed-off-by: pasteley <ceasebeing@gmail.com>
2025-07-29 08:58:21 -07:00
Tobias Klauser
efd156c058 Skip TestSocketXDPGetInfo on EPERM
Skip TestSocketXDPGetInfo rather than failing it when the user lacks
permissions to create AF_XDP sockets.

This allows to run the full test suite as an unprivileged user again.
2025-07-23 09:24:30 -07:00
Tobias Klauser
20a4b9a571 Clean logging up socket tests
Remove a stray fmt.Println in TestUnixSocketDiagInfo and convert any
log.Fatal lines to testing.(*T).Fatal to properly fail tests.
2025-07-22 09:50:59 -07:00
Tobias Klauser
3d9b64dc8d Remove always-nil deserializeFouMsg error return value
The error is always nil. Remove it to simplify the callers.
2025-07-22 09:50:59 -07:00
Tobias Klauser
7a3403a870 Don't log on unknown fou or ipset attributes
The library doesn't log anywhere else for (yet) unknown attributes.
These may appear any time a new kernel is used which adds new attributes.
2025-07-22 09:50:59 -07:00
Nitin Kumar
9f36d6654a fix: Pass TestXfrmStateWithPcpunumWithoutSADir on higher kernels 2025-07-20 09:23:12 -07:00
Radek Zajic
212ea54671 socket: add functions for unspecified platforms 2025-07-20 09:22:13 -07:00
Nitin Kumar
81eeb7146f fix: Allow TCA_OPTIONS with NLA_F_NESTED and NLA_F_NET_BYTEORDER flag 2025-07-19 12:24:47 -07:00
Dimitar Schkodrov
e1e2602148 Implement the Temporary() method on errDumpInterrupted
This is minimal, non-breaking, and preserves compatibility with older retry detection patterns.
2025-06-24 10:39:38 -07:00
Wolfgang Nagele
78aca1ace5 Add SRv6 support for End.DT46 2025-06-22 15:20:46 -07:00
peterk-akamai
7adcc3735c Fix bug in modify U32 filter, correct the number of Keys in Sel
When `func (h *Handle) filterModify(...)` handles an `U32` filter, it also corrects the endiannes for the `Mask` and `Val` in the filter's `Sel.Keys`. For this it creates a new Keys slice and copies the values from the old one. This new slice is created with an incorrect size, likely the intention was to specify its capacity, but instead the size is specified.

The old code happens to work correctly in practice when the number of keys is a power of 2. Otherwise empty (match all) keys are added to the end to make the number a power of 2.

This commit fixes the issue. It was well tested, here's an excerpt:

- Create a U32 filter with 5 Keys. The content of keys is irrelevant, only the number matters.
- Print the filter back with `tc filter show ...`.

The old behaviour:

```
filter parent ffff: protocol all pref 49150 u32 chain 0 fh 800::601 order 1537 key ht 800 bkt 0 *flowid :1 not_in_hw
  match 40000000/60000000 at 0
  match 07010723/ffffffff at 24
  match 07450767/ffffffff at 28
  match 07890733/ffffffff at 32
  match 07420801/ffe00000 at 36
  match 00000000/00000000 at 0
  match 00000000/00000000 at 0
  match 00000000/00000000 at 0
```
The last 3 entries were added by netlink.

New behaviour:
```
filter parent ffff: protocol all pref 49150 u32 chain 0 fh 800::801 order 2049 key ht 800 bkt 0 flowid :1 not_in_hw
  match 60000000/f0000000 at 0
  match 07010723/ffffffff at 24
  match 07450767/ffffffff at 28
  match 07890733/ffffffff at 32
  match 07400000/ffe00000 at 36
```
2025-06-20 09:58:53 -07:00
Gwendolyn
17daef607c vlan: add support for flags and qos maps
Signed-off-by: Gwendolyn <me@gwendolyn.dev>
v1.3.1
2025-05-09 11:59:25 -07:00
lwintermelon
b929916209 filter: add classid and port range support for flower 2025-05-09 11:58:54 -07:00
zlava
06c2c01f6a feat: add vlanid - tunnelid mapping support 2025-05-09 11:52:33 -07:00
bingshen.wbs
c4bb4f91d6 rdma: support rdma metrics: resource and statistic
Signed-off-by: bingshen.wbs <bingshen.wbs@alibaba-inc.com>
2025-05-09 11:48:52 -07:00
charlie
e9f11f77b9 bugfix: parse ipv4 src/dst error 2025-05-09 11:41:09 -07:00
Benjamin Leggett
1f4f72c917 Mimic ipset C code for determining correct default ipset revision
Signed-off-by: Benjamin Leggett <benjamin.leggett@solo.io>
2025-05-09 11:39:54 -07:00
lwintermelon
2426b0576c qdisc: fix wrong type info of tc_sfq_qopt 2025-05-09 11:29:26 -07:00
Gwendolyn
a2e4b9a6ec veth: allow configuring peer attributes beyond namespace and address
Signed-off-by: Gwendolyn <me@gwendolyn.dev>
2025-05-09 11:11:58 -07:00
gongguan
9d88d8385b feat: add support for RtoMin lock 2025-04-25 12:38:46 -07:00
Daniel Borkmann
6b5dd30007 geneve: Support setting/getting source port range
Add support for geneve feature to specify source port range, see
kernel commits:

- e1f95b1992b8 ("geneve: Allow users to specify source port range")
- 5a41a00cd5d5 ("geneve, specs: Add port range to rt_link specification")

This is exactly equivalent on what is done in case of vxlan today.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2025-04-25 12:02:59 -07:00
zlava
d85a66b0d8 feat: add IFLA_INET6_ADDR_GEN_MODE support 2025-04-14 15:15:50 -07:00
Julian Wiedmann
5a4ec4bea5 addr_linux: don't require label to be prefixed with interface name
This requirement limits the usefulness of labels (given the total label
length can only be 15 characters).

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
2025-04-09 10:21:29 -07:00
kayos@tcp.direct
38b12299c1 tests: Improve address unit test infrastructure
Signed-off-by: kayos@tcp.direct <kayos@tcp.direct>
2025-04-03 08:32:13 +03:00
Andrey Smirnov
cb48698f25 fix: add missing CLOEXEC flag
Some calls were already using it, some were not, but fix the remaining
ones.

Without this flag, the file descriptor would to the child process after
fork/exec.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
2025-03-27 22:15:54 -07:00
Junhuang Hong
5d6ad2bde7 add SRv6 support for END.DT4 2025-03-27 22:09:14 -07:00
Ivan Tsvetkov
14e2f0a5ba tuntap: add support for dynamically managing multi-queue FDs
Introduce AddQueues and RemoveQueues methods for attaching and detaching
queue file descriptors to an existing TUN/TAP interface in multi-queue mode.
This enables controlled testing of disabled queues and fine-grained queue
management without relying on interface recreation.

Signed-off-by: Ivan Tsvetkov <ivanfromearth@gmail.com>
2025-03-27 21:30:11 -07:00
Ivan Tsvetkov
298a362432 tuntap: parse additional netlink attributes for flags and queues
Signed-off-by: Ivan Tsvetkov <ivanfromearth@gmail.com>
2025-03-27 21:30:11 -07:00
James Lamanna
7740709424 Add support for ARP/ND Timestamps when retriving neighbors
On Linux, Netlink provides NDA_CACHEINFO which carries timestamps about
when ARP/ND was updated, used, and confirmed.

Expose these fields in the Neigh type
2025-03-26 11:54:52 -07:00
ChinmayaSharma-hue
8b05c6bd4c Added PCPU and SA fields to XfrmState 2025-03-26 11:31:48 -07:00
Mateusz Zalega
1f910b7a22 Support "sample" filter action
This change adds support for packet sampling using "psample" kernel
module.
2025-03-26 11:10:41 -07:00
Dylan Reimerink
dc4f225935 Add OifIndex option for RouteGetWithOptions
The `RouteGetWithOptions` function currently has a `Oif` option which
gets translated from link name to link index via a `LinkByName` call.
This adds unnecessary overhead when the link index is already known.

This commit adds a new `OifIndex` option to `RouteGetWithOptions` which
can be specified instead of `Oif` to skip the internal link index
translation.

Signed-off-by: Dylan Reimerink <dylan.reimerink@isovalent.com>
2025-03-26 11:00:25 -07:00
Sebastiaan van Stijn
6f000f5d02 go.mod: github.com/vishvananda/netns v0.0.5
- Adding file path for nerdctl and finch

full diff: https://github.com/vishvananda/netns/compare/v0.0.4...v0.0.5

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-26 10:54:39 -07:00