Anthony Harivel b3f5422a3b
link: add support for IFLA_VFINFO_LIST and IFLA_VF_STATS (#295)
Add support for decoding Virtual Function (VF) information from netlink
messages. This enables users to retrieve SR-IOV VF details when querying
network interfaces.

The implementation adds:
- VFStats struct containing per-VF traffic statistics (packets, bytes,
  broadcast, multicast, dropped counters for both RX and TX)
- VFInfo struct containing VF configuration (MAC address, VLAN, QoS,
  TX rate limits, spoof check, link state, RSS query, trust settings)
- VFLinkState type with Auto/Enable/Disable constants
- NumVF and VFInfoList fields to LinkAttributes
- Decoding logic for IFLA_NUM_VF and IFLA_VFINFO_LIST nested attributes

The VF information follows the kernel's nested attribute structure.

This is useful for monitoring and managing SR-IOV enabled network
interfaces where the Physical Function (PF) exposes multiple Virtual
Functions to guest VMs or containers.

Signed-off-by: Anthony Harivel <aharivel@redhat.com>
2026-02-08 12:50:40 +01:00
2025-10-30 22:55:44 +01:00
2022-04-12 17:42:36 +02:00
2019-04-04 14:25:20 +02:00
2025-04-15 10:21:45 +02:00
2023-11-27 10:51:30 +01:00
2022-04-12 17:42:36 +02:00
2022-04-12 17:42:36 +02:00
2016-12-28 23:03:34 +01:00
2025-04-15 10:21:45 +02:00
2024-05-10 16:40:56 +02:00
2024-05-10 16:40:56 +02:00
2024-05-15 16:56:49 +02:00
2024-05-10 16:40:56 +02:00
2022-04-12 09:00:30 +02:00
2024-05-10 16:40:56 +02:00

rtnetlink Linux Integration GoDoc Go Report Card

Package rtnetlink allows the kernel's routing tables to be read and altered. Network routes, IP addresses, Link parameters, Neighbor setups, Queueing disciplines, Traffic classes and Packet classifiers may all be controlled. It is based on netlink messages.

A convenient, high-level API wrapper is available using package rtnl.

The base rtnetlink library explicitly only exposes a limited low-level API to rtnetlink. It is not the intention (nor wish) to create an iproute2 replacement.

Unfortunately the errors generated by the kernels netlink interface are not very great.

When in doubt about your message structure it can always be useful to look at the message send by iproute2 using strace -f -esendmsg /bin/ip or similar.

Another (and possibly even more flexible) way would be using nlmon and wireshark. nlmon is a special kernel module which allows you to capture all netlink (not just rtnetlink) traffic inside the kernel. Be aware that this might be overwhelming on a system with a lot of netlink traffic.

# modprobe nlmon
# ip link add type nlmon
# ip link set nlmon0 up

At this point use wireshark or tcpdump on the nlmon0 interface to view all netlink traffic.

Have a look at the examples for common uses of rtnetlink.

If you have any questions or you'd like some guidance, please join us on Gophers Slack in the #networking channel!

Description
Package rtnetlink provides low-level access to the Linux rtnetlink API. MIT Licensed.
Readme 1.4 MiB
Languages
Go 99.8%
Nix 0.2%