Blob Blame History Raw
From 1a50c04ec7f5f1b1eeffd22543eaba1169910407 Mon Sep 17 00:00:00 2001
Message-Id: <1a50c04ec7f5f1b1eeffd22543eaba1169910407@dist-git>
From: Laine Stump <laine@laine.org>
Date: Thu, 13 Apr 2017 14:29:20 -0400
Subject: [PATCH] util: remove unused args from virNetDevSetVfConfig()

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.

Resolves: https://bugzilla.redhat.com/1442040 (RHEL 7.3.z)
Resolves: https://bugzilla.redhat.com/1415609 (RHEL 7.4)

(cherry picked from commit 0a583c26f766d973c08d05ddf0b8fb297eb10f4f)
---
 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 75f969ded..30a4a01ee 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] = {
 
 
 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 = -1;
     struct nlmsghdr *resp = NULL;
     struct nlmsgerr *err;
     unsigned int recvbuflen = 0;
-    uint32_t pid = 0;
     struct nl_msg *nl_msg;
     struct nlattr *vfinfolist, *vfinfo;
     struct ifinfomsg ifinfo = {
         .ifi_family = AF_UNSPEC,
-        .ifi_index  = ifindex
+        .ifi_index  = -1,
     };
 
     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);
 
-    if (!nltarget_kernel) {
-        pid = getPidFunc();
-        if (pid == 0) {
-            rc = -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;
 
@@ -1471,13 +1461,13 @@ virNetDevSetVfConfig(const char *ifname, int ifindex, int vf,
 
             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 vf,
     char *path = NULL;
     char macstr[VIR_MAC_STRING_BUFLEN];
     char *fileData = NULL;
-    int ifindex = -1;
     bool pfIsOnline;
 
     /* Assure that PF is online prior to twiddling with the VF.  It
@@ -1633,8 +1622,7 @@ virNetDevReplaceVfConfig(const char *pflinkdev, int vf,
         goto cleanup;
     }
 
-    ret = virNetDevSetVfConfig(pflinkdev, ifindex, vf, true,
-                                macaddress, vlanid, NULL);
+    ret = virNetDevSetVfConfig(pflinkdev, vf, macaddress, vlanid);
 
  cleanup:
     VIR_FREE(path);
@@ -1653,7 +1641,6 @@ virNetDevRestoreVfConfig(const char *pflinkdev,
     char *vlan = NULL;
     virMacAddr oldmac;
     int vlanid = -1;
-    int ifindex = -1;
 
     if (virAsprintf(&path, "%s/%s_vf%d",
                     stateDir, pflinkdev, vf) < 0)
@@ -1696,8 +1683,7 @@ virNetDevRestoreVfConfig(const char *pflinkdev,
     }
 
     /*reset mac and remove file-ignore results*/
-    rc = virNetDevSetVfConfig(pflinkdev, ifindex, vf, true,
-                              &oldmac, vlanid, NULL);
+    rc = virNetDevSetVfConfig(pflinkdev, vf, &oldmac, vlanid);
     ignore_value(unlink(path));
 
  cleanup:
-- 
2.12.2