network,udev: configure SR-IOV VF attribute one-by-one

When a [SR-IOV] section has no setting, e.g.
```ini
[SR-IOV]
VirtualFunction=0
```
then the kernel previously replied -EINVAL, as we send a rtnl message
with an empty IFLA_VF_INFO container.
See See do_setvfinfo() in net/core/rtnetlink.c of the kernel.

When a [SR-IOV] section that has an unsupported settings by the
interface driver, then previously the kernel partially applied
settings and returned -EOPNOTSUPP. E.f.
```ini
[SR-IOV]
VirtualFunction=0
LinkState=auto
Trust=true
MACAddress=02:01:00:3e:61:34
```
and the interface does not support configuring the link state, then
the MAC address is assigned, but the trust is not applied:
```
enp3s0f0: Failed to configure SR-IOV virtual function 0, ignoring: Operation not supported
    vf 0     link/ether 02:01:00:3e:61:34 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state auto, trust off
```

To fix such issues, this makes networkd/udevd send each attribute
for VF one-by-one.

Fixes #37257 and #37275.
This commit is contained in:
Yu Watanabe
2025-04-30 15:47:19 +09:00
parent c8b3f1d47d
commit 371005ac98
6 changed files with 148 additions and 51 deletions
+8 -1
View File
@@ -5,6 +5,7 @@
#include "alloc-util.h"
#include "hash-funcs.h"
#include "netif-sriov.h"
typedef struct Link Link;
typedef struct NetDev NetDev;
@@ -44,7 +45,13 @@ typedef enum RequestType {
REQUEST_TYPE_SET_LINK_MAC, /* Setting MAC address. */
REQUEST_TYPE_SET_LINK_MASTER, /* Setting IFLA_MASTER. */
REQUEST_TYPE_SET_LINK_MTU, /* Setting MTU. */
REQUEST_TYPE_SRIOV,
_REQUEST_TYPE_SRIOV_BASE,
REQUEST_TYPE_SRIOV_VF_MAC = _REQUEST_TYPE_SRIOV_BASE + SR_IOV_VF_MAC,
REQUEST_TYPE_SRIOV_VF_SPOOFCHK = _REQUEST_TYPE_SRIOV_BASE + SR_IOV_VF_SPOOFCHK,
REQUEST_TYPE_SRIOV_VF_RSS_QUERY_EN = _REQUEST_TYPE_SRIOV_BASE + SR_IOV_VF_RSS_QUERY_EN,
REQUEST_TYPE_SRIOV_VF_TRUST = _REQUEST_TYPE_SRIOV_BASE + SR_IOV_VF_TRUST,
REQUEST_TYPE_SRIOV_VF_LINK_STATE = _REQUEST_TYPE_SRIOV_BASE + SR_IOV_VF_LINK_STATE,
REQUEST_TYPE_SRIOV_VF_VLAN_LIST = _REQUEST_TYPE_SRIOV_BASE + SR_IOV_VF_VLAN_LIST,
REQUEST_TYPE_TC_CLASS,
REQUEST_TYPE_TC_QDISC,
REQUEST_TYPE_UP_DOWN,