render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
3e5111
From e8dcdd23e5f77d0207203da165d6ba0c561a51e2 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <e8dcdd23e5f77d0207203da165d6ba0c561a51e2@dist-git>
5c27b6
From: Laine Stump <laine@redhat.com>
3e5111
Date: Sun, 23 Apr 2017 21:32:05 -0400
5c27b6
Subject: [PATCH] util: allow ignoring SIOCSIFHWADDR when errno is EPERM
5c27b6
5c27b6
Commit f4ef3a71 made a variation of virNetDevSetMAC that would return
5c27b6
without logging an error message if errno was set to
5c27b6
EADDRNOTAVAIL. This errno is set by some SRIOV VF drivers (in
5c27b6
particular igbvf) when they fail to set the device's MAC address due
5c27b6
to the PF driver refusing the request. This is useful if we want to
5c27b6
try a different method of setting the VF MAC address before giving up
5c27b6
(Commit 86556e16 actually does this, setting the desired MAC address
5c27b6
to the "admin MAC in the PF, then detaching and reattaching the VF
5c27b6
netdev driver to force a reinit of the MAC address).
5c27b6
5c27b6
During testing of Bug 1442040 it was discovered that the ixgbe driver
5c27b6
returns EPERM in this situation, so this patch changes the exception
5c27b6
case for silent+non-terminal failure to account for this difference.
5c27b6
3e5111
Completes resolution to: https://bugzilla.redhat.com/1415609 (RHEL 7.4)
3e5111
                         https://bugzilla.redhat.com/1442040 (RHEL 7.3.z)
5c27b6
5c27b6
(cherry picked from commit 997134fb8b17eef6eba439303b382b239996208b)
5c27b6
---
5c27b6
 src/util/virnetdev.c | 14 +++++++++-----
5c27b6
 1 file changed, 9 insertions(+), 5 deletions(-)
5c27b6
5c27b6
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
3e5111
index 170e34827..9aa9c9f88 100644
5c27b6
--- a/src/util/virnetdev.c
5c27b6
+++ b/src/util/virnetdev.c
5c27b6
@@ -226,7 +226,8 @@ int virNetDevExists(const char *ifname)
5c27b6
  * virNetDevSetMACInternal:
5c27b6
  * @ifname: interface name to set MTU for
5c27b6
  * @macaddr: MAC address
5c27b6
- * @quiet: true if a failure to set MAC address with errno == EADDRNOTAVAIL
5c27b6
+ * @quiet: true if a failure to set MAC address with
5c27b6
+ *         errno == EADDRNOTAVAIL || errno == EPERM
5c27b6
  *         should be silent (still returns error, but without log)
5c27b6
  *
5c27b6
  * This function sets the @macaddr for a given interface @ifname.
5c27b6
@@ -258,7 +259,8 @@ virNetDevSetMACInternal(const char *ifname,
5c27b6
 
5c27b6
     if (ioctl(fd, SIOCSIFHWADDR, &ifr) < 0) {
5c27b6
 
5c27b6
-        if (quiet && errno == EADDRNOTAVAIL)
5c27b6
+        if (quiet &&
5c27b6
+            (errno == EADDRNOTAVAIL || errno == EPERM))
5c27b6
             goto cleanup;
5c27b6
 
5c27b6
         virReportSystemError(errno,
5c27b6
@@ -305,7 +307,8 @@ virNetDevSetMACInternal(const char *ifname,
5c27b6
         ifr.ifr_addr.sa_len = VIR_MAC_BUFLEN;
5c27b6
 
5c27b6
         if (ioctl(s, SIOCSIFLLADDR, &ifr) < 0) {
5c27b6
-            if (quiet && errno == EADDRNOTAVAIL)
5c27b6
+            if (quiet &&
5c27b6
+                (errno == EADDRNOTAVAIL || errno == EPERM))
5c27b6
                 goto cleanup;
5c27b6
 
5c27b6
             virReportSystemError(errno,
3e5111
@@ -2229,11 +2232,12 @@ virNetDevSetNetConfig(const char *linkdev, int vf,
5c27b6
             int retries = 100;
5c27b6
 
5c27b6
             /* if pfDevOrig == NULL, this isn't a VF, so we've failed */
5c27b6
-            if (!pfDevOrig || errno != EADDRNOTAVAIL)
5c27b6
+            if (!pfDevOrig ||
5c27b6
+                (errno != EADDRNOTAVAIL && errno != EPERM))
5c27b6
                 goto cleanup;
5c27b6
 
5c27b6
             /* Otherwise this is a VF, and virNetDevSetMAC failed with
5c27b6
-             * EADDRNOTAVAIL, which could be due to the
5c27b6
+             * EADDRNOTAVAIL/EPERM, which could be due to the
5c27b6
              * "administratively set" flag being set in the PF for
5c27b6
              * this VF.  When this happens, we can attempt to use an
5c27b6
              * alternate method to set the VF MAC: first set it into
5c27b6
-- 
5c27b6
2.12.2
5c27b6