From nobody Wed Feb 11 10:17:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1489178318110587.364843300877; Fri, 10 Mar 2017 12:38:38 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2AKZbin039302; Fri, 10 Mar 2017 15:35:37 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2AKZIq1018936 for ; Fri, 10 Mar 2017 15:35:18 -0500 Received: from vhost2.laine.org (ovpn-116-174.phx2.redhat.com [10.3.116.174]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2AKZHiZ012172 for ; Fri, 10 Mar 2017 15:35:18 -0500 From: Laine Stump To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 15:34:55 -0500 Message-Id: <20170310203512.15478-3-laine@laine.org> In-Reply-To: <20170310203512.15478-1-laine@laine.org> References: <20170310203512.15478-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/19] util: remove unused args from virNetDevSetVfConfig() 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This function is only called in two places, and the ifindex, nltarget_kernel, and getPidFunc args are never used (and never will be). ifindex - we always know the name of the device, and never know the ifindex - if we really did need the ifindex we would have to get it from the name using virNetDevGetIndex(). In practice, we just send -1 to virNetDevSetVfConfig(), which doesn't bother to learn the real ifindex (you only need a name *or* an ifindex for the netlink command to succeed, not both). nltarget_kernel - messages to set the config of an SRIOV VF will always go to netlink in the kernel, not to another user process, so this arg is always true (there are other uses of netlink messages where the message might need to go to another user process, but never in the case of RTM_SETLINK for SRIOV). getPidFunc - this arg is only used if nltarget_kernel is false, and it never is. None of this has any functional effect, it just makes it easier to follow what's happening when virNetDevSetVfConfig() is called. --- src/util/virnetdev.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 75f969d..30a4a01 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1378,20 +1378,18 @@ static struct nla_policy ifla_vf_policy[IFLA_VF_MAX= +1] =3D { =20 =20 static int -virNetDevSetVfConfig(const char *ifname, int ifindex, int vf, - bool nltarget_kernel, const virMacAddr *macaddr, - int vlanid, uint32_t (*getPidFunc)(void)) +virNetDevSetVfConfig(const char *ifname, int vf, + const virMacAddr *macaddr, int vlanid) { int rc =3D -1; struct nlmsghdr *resp =3D NULL; struct nlmsgerr *err; unsigned int recvbuflen =3D 0; - uint32_t pid =3D 0; struct nl_msg *nl_msg; struct nlattr *vfinfolist, *vfinfo; struct ifinfomsg ifinfo =3D { .ifi_family =3D AF_UNSPEC, - .ifi_index =3D ifindex + .ifi_index =3D -1, }; =20 if (!macaddr && vlanid < 0) @@ -1445,15 +1443,7 @@ virNetDevSetVfConfig(const char *ifname, int ifindex= , int vf, nla_nest_end(nl_msg, vfinfo); nla_nest_end(nl_msg, vfinfolist); =20 - if (!nltarget_kernel) { - pid =3D getPidFunc(); - if (pid =3D=3D 0) { - rc =3D -1; - goto cleanup; - } - } - - if (virNetlinkCommand(nl_msg, &resp, &recvbuflen, 0, pid, + if (virNetlinkCommand(nl_msg, &resp, &recvbuflen, 0, 0, NETLINK_ROUTE, 0) < 0) goto cleanup; =20 @@ -1471,13 +1461,13 @@ virNetDevSetVfConfig(const char *ifname, int ifinde= x, int vf, =20 virReportSystemError(-err->error, _("Cannot set interface MAC/vlanid to %s/= %d " - "for ifname %s ifindex %d vf %d"), + "for ifname %s vf %d"), (macaddr ? virMacAddrFormat(macaddr, macstr) : "(unchanged)"), vlanid, ifname ? ifname : "(unspecified)", - ifindex, vf); + vf); goto cleanup; } break; @@ -1593,7 +1583,6 @@ virNetDevReplaceVfConfig(const char *pflinkdev, int v= f, char *path =3D NULL; char macstr[VIR_MAC_STRING_BUFLEN]; char *fileData =3D NULL; - int ifindex =3D -1; bool pfIsOnline; =20 /* Assure that PF is online prior to twiddling with the VF. It @@ -1633,8 +1622,7 @@ virNetDevReplaceVfConfig(const char *pflinkdev, int v= f, goto cleanup; } =20 - ret =3D virNetDevSetVfConfig(pflinkdev, ifindex, vf, true, - macaddress, vlanid, NULL); + ret =3D virNetDevSetVfConfig(pflinkdev, vf, macaddress, vlanid); =20 cleanup: VIR_FREE(path); @@ -1653,7 +1641,6 @@ virNetDevRestoreVfConfig(const char *pflinkdev, char *vlan =3D NULL; virMacAddr oldmac; int vlanid =3D -1; - int ifindex =3D -1; =20 if (virAsprintf(&path, "%s/%s_vf%d", stateDir, pflinkdev, vf) < 0) @@ -1696,8 +1683,7 @@ virNetDevRestoreVfConfig(const char *pflinkdev, } =20 /*reset mac and remove file-ignore results*/ - rc =3D virNetDevSetVfConfig(pflinkdev, ifindex, vf, true, - &oldmac, vlanid, NULL); + rc =3D virNetDevSetVfConfig(pflinkdev, vf, &oldmac, vlanid); ignore_value(unlink(path)); =20 cleanup: --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list