833 Commits

Author SHA1 Message Date
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
tc 31feb1b4c7 pedit: Fix EncodeActions to add TcGen for pedit action
TcGen was missing in pedit action and the kernel cannont correctly process pedit action.

Signed-off-by: Chen Tang <tangchen.1@bytedance.com>
2025-03-26 10:53:47 -07:00
Tim Rozet 9b61d26766 Add support for MTU Lock
When adding a route with "mtu lock <mtu>" path MTU discovery (PMTUD)
will not be tried and packets will be sent without DF bit set. Upon
receiving an ICMP needs frag due to PMTUD, the kernel will not install a
cached route and lower the MTU.

Signed-off-by: Tim Rozet <trozet@redhat.com>
2025-03-26 10:48:12 -07:00
Jordan Rife 0e7078ed04 netkit: Allow setting MAC address in L2 mode
Signed-off-by: Jordan Rife <jrife@google.com>
2025-03-03 14:47:20 -08:00
Daniel Borkmann 0af32151e7 vxlan: Fix parseVxlanData for source port range
binary.Read() != nil check means error case, so the vxlan.Port{Low,High}
are never populated. Fix the check.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2025-02-21 11:44:27 -08:00
Sven Rebhan 9f534ef909 fix: Use correct offset for unix socket diagnosis
Signed-off-by: Sven Rebhan <srebhan@influxdata.com>
2025-02-20 11:25:08 -08:00
Leon Hwang 655392bc77 Fix parsing 4-bytes attribute
What if the data length of attribute is 4? The attribute will be ignored,
because `i+4 < len(data)`.

Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
2025-02-09 08:26:17 -08:00
Daman Arora 62fb240731 conntrack: prevent potential memory leak
Currently, the ConntrackDeleteFilters captures all flow entries
it fails to delete and reports them as errors. This behavior
can potentially lead to memory leaks in high-traffic systems,
where thousands of conntrack flow entries are cleared in a single
batch. With this commit, instead of returning all the un-deleted
flow entries, we now return a single error message for all of them.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
2025-02-06 09:46:18 -08:00
Albin Kerouanton 7c2350bd14 Add IFLA_PARENT_DEV_NAME / IFLA_PARENT_DEV_BUS_NAME to links
These attributes are supported since kernel v5.14 (see [1]). Here's
what iproute2 shows:

```
$ ip -d link show eth0
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 65535 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    ... parentbus virtio parentdev virtio0
```

[1]: https://github.com/torvalds/linux/commit/00e77ed8e64d5f271c1f015c7153545980d48a76

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-01-27 16:21:08 -08:00
Adrian Moisey 3642538757 Preserve results when NLM_F_DUMP_INTR is set
Similar to https://github.com/vishvananda/netlink/pull/1018, but for
ConntrackDeleteFilters()

Relates to https://github.com/kubernetes/kubernetes/issues/129562
2025-01-20 22:11:48 -08:00
Dylan Reimerink 86d2f69adc link_linux: Add deserialization of IFF_RUNNING flag
Add deserialization of the `IFF_RUNNING` link flag which translates to
`net.FlagRunning`.

Signed-off-by: Dylan Reimerink <dylan.reimerink@isovalent.com>
2025-01-20 22:07:01 -08:00
wangling94 68cf136ebe 1. filter match support vlanId and srcMac, dstMac.
2. filter action support vlan pop/push.
2025-01-16 11:56:41 -08:00
Dylan Reimerink 56a588b0cd .github/workflows: Bump CI Go version to v1.22
Update the Go version we test against to Go v1.22 which is currently the
oldest version still receiving security updates.

Signed-off-by: Dylan Reimerink <dylan.reimerink@isovalent.com>
2025-01-16 10:04:49 -08:00
WeidiDeng 391c850512 disable broadcast if broadcast is set to net.IPv4zero
remove comments about broadcast when deleting address

remove another comment about broadcast auto calculation
2025-01-09 19:51:00 -08:00
wangling142 26ee0e2abe 1. fix rule test failed when rule add slow. 2024-12-27 11:12:53 -08:00
Jordan Rife 976bd8de7d Add support for IFLA_NETKIT_SCRUB and IFLA_NETKIT_PEER_SCRUB
Link: https://lore.kernel.org/bpf/20241004101335.117711-1-daniel@iogearbox.net/T/#u
2024-10-21 20:13:24 -07:00
Rob Murray 084abd93d3 Add ErrDumpInterrupted
Add a specific error to report that a netlink response had
NLM_F_DUMP_INTR set, indicating that the set of results may be
incomplete or inconsistent.

unix.EINTR was previously returned (with no results) when the
NLM_F_DUMP_INTR flag was set. Now, errors.Is(err, unix.EINTR) will
still work. But, this will be a breaking change for any code that's
checking for equality with unix.EINTR.

Return results with ErrDumpInterrupted. Results may be incomplete
or inconsistent, but give the caller the option of using them.

Look for NLM_F_DUMP_INTR in more places:
- linkSubscribeAt, neighSubscribeAt, routeSubscribeAt
  - can do an initial dump, which may report inconsistent results
  -> if there's an error callback, call it with ErrDumpInterrupted
- socketDiagXDPExecutor
  - makes an NLM_F_DUMP request, without using Execute()
  -> give it the same behaviour as functions that do use Execute()

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-09-22 00:00:40 -07:00
feng a01829657b Fix FouList attribute body truncated error with kernel 5.2+
fou module added a bunch of new attributes in commit
https://github.com/torvalds/linux/commit/1713cb37bf671e5d98919536941a8b56337874fd

which caused the old parsing logic failed, fix and add support for these attrributes.
2024-09-09 10:36:41 -07:00
Daman Arora b1ce50cfa9 capture and return errors in ConntrackDeleteFilters
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2024-09-05 11:07:32 -07:00
Rob Murray e194da52b1 Fix SetSendTimeout/SetReceiveTimeout
They were implemented using SO_SNDTIMEO/SO_RCVTIMEO on the
socket descriptor - but that doesn't work now the socket is
non-blocking. Instead, set deadlines on the file read/write.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-09-04 15:52:52 -07:00
Matus Petrulak 0cd1f7961c Fix: Do not crash when enumerating tc filters with unknown actionType
for example actionType "vlan"

#987
2024-09-04 15:52:09 -07:00
Etienne Champetier 92645823f3 Fix deprecated comments
Signed-off-by: Etienne Champetier <e.champetier@ateme.com>
2024-08-26 11:35:36 -07:00
世界 6f57139475 Fix recvfrom goroutine leak v1.3.0 2024-08-23 12:41:44 -07:00
Sebastiaan van Stijn 298ff277ed Handle: add ConntrackDeleteFilter alias for backward compat
Commit c96b03b4be changed the signature
of this method to accept a list of filters and renamed it to
ConntrackDeleteFilters (plural).

This patch

- adds back ConntrackDeleteFilter as an alias
- marks it as deprecated in favor of the new version.
- adds missing stubs for other platforms

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-23 12:31:44 -07:00
Percy Wegmann 5b0b9d8260 rule: add Rule.Type to allow adding/listing unreachable (RTN_UNREACHABLE) rules
Updates #710

Co-authored-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Signed-off-by: Percy Wegmann <percy@tailscale.com>
2024-08-23 12:10:14 -07:00