]> git.ipfire.org Git - thirdparty/libvirt.git/commit
Ignore EPERM on implicit clearing of VF VLAN ID
authorDmitrii Shcherbakov <dmitrii.shcherbakov@canonical.com>
Tue, 1 Feb 2022 08:28:53 +0000 (11:28 +0300)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 3 Feb 2022 15:52:05 +0000 (16:52 +0100)
commit09cdd16a9bf73bc1f75fe774216c71f9ebc78c88
tree3af50d6691fb973576eba94639c64831c2a3103a
parent73961771a1cfec3c0f43caec9d117d2fbcc7af39
Ignore EPERM on implicit clearing of VF VLAN ID

SmartNIC DPUs may not expose some privileged eswitch operations
to the hypervisor hosts. For example, this happens with Bluefield
devices running in the ECPF (default) mode for security reasons. While
VF MAC address programming is possible via an RTM_SETLINK operation,
trying to set a VLAN ID in the same operation will fail with EPERM.

The equivalent ip link commands below provide an illustration:

1. This works:

sudo ip link set enp130s0f0 vf 2 mac de:ad:be:ef:ca:fe

2. Setting (or clearing) a VLAN fails with EPERM:

sudo ip link set enp130s0f0 vf 2 vlan 0
RTNETLINK answers: Operation not permitted

3. This is what Libvirt attempts to do today (when trying to clear a
   VF VLAN at the same time as programming a VF MAC).

sudo ip link set enp130s0f0 vf 2 vlan 0 mac de:ad:be:ef:ca:fe
RTNETLINK answers: Operation not permitted

If setting an explicit VLAN ID results in an EPERM, clearing a VLAN
(setting a VLAN ID to 0) can be handled gracefully by ignoring the
EPERM error with the rationale being that if we cannot set this state
in the first place, we cannot clear it either.

In order to keep explicit clearing of VLAN ID working as it used to
be passing a NULL pointer for VLAN ID is used.

Signed-off-by: Dmitrii Shcherbakov <dmitrii.shcherbakov@canonical.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virnetdev.c
tests/virnetdevtest.c