]> xenbits.xensource.com Git - libvirt.git/commitdiff
virnetdev: Fix regression in setting VLAN tag
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 22 Apr 2022 12:15:47 +0000 (14:15 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 5 May 2022 11:21:07 +0000 (13:21 +0200)
In the past, we did set VLAN tag on <interface type='direct'/>.
However, during rewrite (v8.1.0-rc1~191) virNetDevSetVfConfig()
was changed and a condition that was responsible for calling
a function that sets VLAN tag was changed accidentally resulting
in VLAN tag not being set anymore.

However, because of other changes in the same patchset, it may
happen that @adminMac is NULL (this is to work around yet another
broken SRIOV driver), and thus we must refrain from setting MAC
and have to set VLAN tag only.

Fixes: 73961771a1cfec3c0f43caec9d117d2fbcc7af39
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2075383
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virnetdev.c

index 5e60bf068f6506c4c0782abe715c6d6b0cbe721c..93f836cd92b13af946f2cbb999ebbac804d71604 100644 (file)
@@ -1682,7 +1682,8 @@ virNetDevSetVfConfig(const char *ifname,
 {
     int ret = -1;
 
-    if ((ret = virNetDevSetVfMac(ifname, vf, macaddr, allowRetry)) < 0)
+    if (macaddr &&
+        (ret = virNetDevSetVfMac(ifname, vf, macaddr, allowRetry)) < 0)
         return ret;
     if ((ret = virNetDevSetVfVlan(ifname, vf, vlanid)) < 0)
         return ret;
@@ -2365,7 +2366,7 @@ virNetDevSetNetConfig(const char *linkdev, int vf,
         }
     }
 
-    if (adminMAC) {
+    if (adminMAC || vlanTag) {
         /* Set vlanTag and admin MAC using an RTM_SETLINK request sent to
          * PFdevname+VF#, if mac != NULL this will set the "admin MAC" via
          * the PF, *not* the actual VF MAC - the admin MAC only takes