From nobody Mon Apr 29 09:19:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1492723748703341.3773893734983; Thu, 20 Apr 2017 14:29:08 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE0E019D39D; Thu, 20 Apr 2017 21:29:06 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5EE2777D4D; Thu, 20 Apr 2017 21:29:06 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BF29418523C5; Thu, 20 Apr 2017 21:29:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3KLT4Fh024444 for ; Thu, 20 Apr 2017 17:29:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4CF3B7842B; Thu, 20 Apr 2017 21:29:04 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-148.phx2.redhat.com [10.3.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B8AC7E472 for ; Thu, 20 Apr 2017 21:29:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AE0E019D39D Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=laine.org Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AE0E019D39D From: Laine Stump To: libvir-list@redhat.com Date: Thu, 20 Apr 2017 17:28:59 -0400 Message-Id: <20170420212859.13005-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] util: allow ignoring SIOCSIFHWADDR when errno is EPERM X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 20 Apr 2017 21:29:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Laine Stump Commit f4ef3a71 made a variation of virNetDevSetMAC that would return without logging an error message if errno was set to EADDRNOTAVAIL. This errno is set by some SRIOV VF drivers (in particular igbvf) when they fail to set the device's MAC address due to the PF driver refusing the request. This is useful if we want to try a different method of setting the VF MAC address before giving up (Commit 86556e16 actually does this, setting the desired MAC address to the "admin MAC in the PF, then detaching and reattaching the VF netdev driver to force a reinit of the MAC address). During testing of Bug 1442040 t was discovered that the ixgbe driver returns EPERM in this situation, so this patch changes the exception case for silent+non-terminal failure to account for this difference. Completes resolution to: https://bugzilla.redhat.com/1415609 (RHEL 7.4) https://bugzilla.redhat.com/1442040 (RHEL 7.3.z) --- NB: I could also change it to be silent on *any* error, but this could lead to situations where the actual cause of a failure to set the MAC address is obscured to the point of being unable to figure out the problem (because the error would instead show up when the kernel is trying to initialize the MAC address as it reattached the VF net driver, for example). Limiting the errno's that warrant the silent treatment allows us to give more useful error reporting in these other cases. src/util/virnetdev.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 170e348..9aa9c9f 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -226,7 +226,8 @@ int virNetDevExists(const char *ifname) * virNetDevSetMACInternal: * @ifname: interface name to set MTU for * @macaddr: MAC address - * @quiet: true if a failure to set MAC address with errno =3D=3D EADDRNOT= AVAIL + * @quiet: true if a failure to set MAC address with + * errno =3D=3D EADDRNOTAVAIL || errno =3D=3D EPERM * should be silent (still returns error, but without log) * * This function sets the @macaddr for a given interface @ifname. @@ -258,7 +259,8 @@ virNetDevSetMACInternal(const char *ifname, =20 if (ioctl(fd, SIOCSIFHWADDR, &ifr) < 0) { =20 - if (quiet && errno =3D=3D EADDRNOTAVAIL) + if (quiet && + (errno =3D=3D EADDRNOTAVAIL || errno =3D=3D EPERM)) goto cleanup; =20 virReportSystemError(errno, @@ -305,7 +307,8 @@ virNetDevSetMACInternal(const char *ifname, ifr.ifr_addr.sa_len =3D VIR_MAC_BUFLEN; =20 if (ioctl(s, SIOCSIFLLADDR, &ifr) < 0) { - if (quiet && errno =3D=3D EADDRNOTAVAIL) + if (quiet && + (errno =3D=3D EADDRNOTAVAIL || errno =3D=3D EPERM)) goto cleanup; =20 virReportSystemError(errno, @@ -2229,11 +2232,12 @@ virNetDevSetNetConfig(const char *linkdev, int vf, int retries =3D 100; =20 /* if pfDevOrig =3D=3D NULL, this isn't a VF, so we've failed = */ - if (!pfDevOrig || errno !=3D EADDRNOTAVAIL) + if (!pfDevOrig || + (errno !=3D EADDRNOTAVAIL && errno !=3D EPERM)) goto cleanup; =20 /* Otherwise this is a VF, and virNetDevSetMAC failed with - * EADDRNOTAVAIL, which could be due to the + * EADDRNOTAVAIL/EPERM, which could be due to the * "administratively set" flag being set in the PF for * this VF. When this happens, we can attempt to use an * alternate method to set the VF MAC: first set it into --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list