Dmitrii Shcherbakov 09cdd16a9b 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>
2022-02-03 16:52:05 +01:00
..
2020-06-10 14:00:38 +02:00
2021-07-15 14:50:48 +02:00
2021-09-09 18:06:13 +02:00
2021-09-09 18:06:13 +02:00
2021-09-09 18:06:13 +02:00
2021-09-09 18:06:13 +02:00
2021-09-09 18:06:13 +02:00
2022-01-18 15:19:47 +01:00
2021-09-09 18:06:13 +02:00
2019-10-15 11:25:25 +02:00
2020-07-10 09:40:58 +02:00
2021-09-09 18:06:13 +02:00
2022-01-12 11:43:30 +01:00
2022-01-12 11:43:30 +01:00
2022-01-19 13:57:59 +01:00
2021-09-09 18:06:13 +02:00
2021-09-09 18:06:13 +02:00
2019-10-15 11:25:25 +02:00
2021-09-09 18:06:13 +02:00
2021-10-21 17:34:04 +01:00
2021-11-08 14:32:32 +01:00
2021-12-13 14:44:01 +01:00
2021-09-09 18:06:13 +02:00
2021-12-13 14:44:01 +01:00
2019-10-15 11:25:25 +02:00
2019-10-15 11:25:25 +02:00
2021-09-09 18:06:13 +02:00
2021-09-09 18:06:13 +02:00
2021-12-13 14:44:01 +01:00
2017-04-27 14:13:19 +02:00
2020-11-27 16:28:31 +01:00
2021-09-09 18:06:13 +02:00
2021-09-09 18:06:13 +02:00
2016-09-14 13:18:07 +02:00
2021-09-17 14:28:00 +02:00
2021-12-13 14:44:01 +01:00
2021-09-09 18:06:13 +02:00
2021-09-09 18:06:13 +02:00
2021-09-09 18:06:13 +02:00
2021-09-09 18:06:13 +02:00