|
|
5c27b6 |
From 1a50c04ec7f5f1b1eeffd22543eaba1169910407 Mon Sep 17 00:00:00 2001
|
|
|
5c27b6 |
Message-Id: <1a50c04ec7f5f1b1eeffd22543eaba1169910407@dist-git>
|
|
|
5c27b6 |
From: Laine Stump <laine@laine.org>
|
|
|
5c27b6 |
Date: Thu, 13 Apr 2017 14:29:20 -0400
|
|
|
5c27b6 |
Subject: [PATCH] util: remove unused args from virNetDevSetVfConfig()
|
|
|
5c27b6 |
|
|
|
5c27b6 |
This function is only called in two places, and the ifindex,
|
|
|
5c27b6 |
nltarget_kernel, and getPidFunc args are never used (and never will
|
|
|
5c27b6 |
be).
|
|
|
5c27b6 |
|
|
|
5c27b6 |
ifindex - we always know the name of the device, and never know the
|
|
|
5c27b6 |
ifindex - if we really did need the ifindex we would have to get it
|
|
|
5c27b6 |
from the name using virNetDevGetIndex(). In practice, we just send -1
|
|
|
5c27b6 |
to virNetDevSetVfConfig(), which doesn't bother to learn the real
|
|
|
5c27b6 |
ifindex (you only need a name *or* an ifindex for the netlink command
|
|
|
5c27b6 |
to succeed, not both).
|
|
|
5c27b6 |
|
|
|
5c27b6 |
nltarget_kernel - messages to set the config of an SRIOV VF will
|
|
|
5c27b6 |
always go to netlink in the kernel, not to another user process, so
|
|
|
5c27b6 |
this arg is always true (there are other uses of netlink messages
|
|
|
5c27b6 |
where the message might need to go to another user process, but never
|
|
|
5c27b6 |
in the case of RTM_SETLINK for SRIOV).
|
|
|
5c27b6 |
|
|
|
5c27b6 |
getPidFunc - this arg is only used if nltarget_kernel is false, and it
|
|
|
5c27b6 |
never is.
|
|
|
5c27b6 |
|
|
|
5c27b6 |
None of this has any functional effect, it just makes it easier to
|
|
|
5c27b6 |
follow what's happening when virNetDevSetVfConfig() is called.
|
|
|
5c27b6 |
|
|
|
5c27b6 |
Resolves: https://bugzilla.redhat.com/1442040 (RHEL 7.3.z)
|
|
|
5c27b6 |
Resolves: https://bugzilla.redhat.com/1415609 (RHEL 7.4)
|
|
|
5c27b6 |
|
|
|
5c27b6 |
(cherry picked from commit 0a583c26f766d973c08d05ddf0b8fb297eb10f4f)
|
|
|
5c27b6 |
---
|
|
|
5c27b6 |
src/util/virnetdev.c | 30 ++++++++----------------------
|
|
|
5c27b6 |
1 file changed, 8 insertions(+), 22 deletions(-)
|
|
|
5c27b6 |
|
|
|
5c27b6 |
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
|
|
|
5c27b6 |
index 75f969ded..30a4a01ee 100644
|
|
|
5c27b6 |
--- a/src/util/virnetdev.c
|
|
|
5c27b6 |
+++ b/src/util/virnetdev.c
|
|
|
5c27b6 |
@@ -1378,20 +1378,18 @@ static struct nla_policy ifla_vf_policy[IFLA_VF_MAX+1] = {
|
|
|
5c27b6 |
|
|
|
5c27b6 |
|
|
|
5c27b6 |
static int
|
|
|
5c27b6 |
-virNetDevSetVfConfig(const char *ifname, int ifindex, int vf,
|
|
|
5c27b6 |
- bool nltarget_kernel, const virMacAddr *macaddr,
|
|
|
5c27b6 |
- int vlanid, uint32_t (*getPidFunc)(void))
|
|
|
5c27b6 |
+virNetDevSetVfConfig(const char *ifname, int vf,
|
|
|
5c27b6 |
+ const virMacAddr *macaddr, int vlanid)
|
|
|
5c27b6 |
{
|
|
|
5c27b6 |
int rc = -1;
|
|
|
5c27b6 |
struct nlmsghdr *resp = NULL;
|
|
|
5c27b6 |
struct nlmsgerr *err;
|
|
|
5c27b6 |
unsigned int recvbuflen = 0;
|
|
|
5c27b6 |
- uint32_t pid = 0;
|
|
|
5c27b6 |
struct nl_msg *nl_msg;
|
|
|
5c27b6 |
struct nlattr *vfinfolist, *vfinfo;
|
|
|
5c27b6 |
struct ifinfomsg ifinfo = {
|
|
|
5c27b6 |
.ifi_family = AF_UNSPEC,
|
|
|
5c27b6 |
- .ifi_index = ifindex
|
|
|
5c27b6 |
+ .ifi_index = -1,
|
|
|
5c27b6 |
};
|
|
|
5c27b6 |
|
|
|
5c27b6 |
if (!macaddr && vlanid < 0)
|
|
|
5c27b6 |
@@ -1445,15 +1443,7 @@ virNetDevSetVfConfig(const char *ifname, int ifindex, int vf,
|
|
|
5c27b6 |
nla_nest_end(nl_msg, vfinfo);
|
|
|
5c27b6 |
nla_nest_end(nl_msg, vfinfolist);
|
|
|
5c27b6 |
|
|
|
5c27b6 |
- if (!nltarget_kernel) {
|
|
|
5c27b6 |
- pid = getPidFunc();
|
|
|
5c27b6 |
- if (pid == 0) {
|
|
|
5c27b6 |
- rc = -1;
|
|
|
5c27b6 |
- goto cleanup;
|
|
|
5c27b6 |
- }
|
|
|
5c27b6 |
- }
|
|
|
5c27b6 |
-
|
|
|
5c27b6 |
- if (virNetlinkCommand(nl_msg, &resp, &recvbuflen, 0, pid,
|
|
|
5c27b6 |
+ if (virNetlinkCommand(nl_msg, &resp, &recvbuflen, 0, 0,
|
|
|
5c27b6 |
NETLINK_ROUTE, 0) < 0)
|
|
|
5c27b6 |
goto cleanup;
|
|
|
5c27b6 |
|
|
|
5c27b6 |
@@ -1471,13 +1461,13 @@ virNetDevSetVfConfig(const char *ifname, int ifindex, int vf,
|
|
|
5c27b6 |
|
|
|
5c27b6 |
virReportSystemError(-err->error,
|
|
|
5c27b6 |
_("Cannot set interface MAC/vlanid to %s/%d "
|
|
|
5c27b6 |
- "for ifname %s ifindex %d vf %d"),
|
|
|
5c27b6 |
+ "for ifname %s vf %d"),
|
|
|
5c27b6 |
(macaddr
|
|
|
5c27b6 |
? virMacAddrFormat(macaddr, macstr)
|
|
|
5c27b6 |
: "(unchanged)"),
|
|
|
5c27b6 |
vlanid,
|
|
|
5c27b6 |
ifname ? ifname : "(unspecified)",
|
|
|
5c27b6 |
- ifindex, vf);
|
|
|
5c27b6 |
+ vf);
|
|
|
5c27b6 |
goto cleanup;
|
|
|
5c27b6 |
}
|
|
|
5c27b6 |
break;
|
|
|
5c27b6 |
@@ -1593,7 +1583,6 @@ virNetDevReplaceVfConfig(const char *pflinkdev, int vf,
|
|
|
5c27b6 |
char *path = NULL;
|
|
|
5c27b6 |
char macstr[VIR_MAC_STRING_BUFLEN];
|
|
|
5c27b6 |
char *fileData = NULL;
|
|
|
5c27b6 |
- int ifindex = -1;
|
|
|
5c27b6 |
bool pfIsOnline;
|
|
|
5c27b6 |
|
|
|
5c27b6 |
/* Assure that PF is online prior to twiddling with the VF. It
|
|
|
5c27b6 |
@@ -1633,8 +1622,7 @@ virNetDevReplaceVfConfig(const char *pflinkdev, int vf,
|
|
|
5c27b6 |
goto cleanup;
|
|
|
5c27b6 |
}
|
|
|
5c27b6 |
|
|
|
5c27b6 |
- ret = virNetDevSetVfConfig(pflinkdev, ifindex, vf, true,
|
|
|
5c27b6 |
- macaddress, vlanid, NULL);
|
|
|
5c27b6 |
+ ret = virNetDevSetVfConfig(pflinkdev, vf, macaddress, vlanid);
|
|
|
5c27b6 |
|
|
|
5c27b6 |
cleanup:
|
|
|
5c27b6 |
VIR_FREE(path);
|
|
|
5c27b6 |
@@ -1653,7 +1641,6 @@ virNetDevRestoreVfConfig(const char *pflinkdev,
|
|
|
5c27b6 |
char *vlan = NULL;
|
|
|
5c27b6 |
virMacAddr oldmac;
|
|
|
5c27b6 |
int vlanid = -1;
|
|
|
5c27b6 |
- int ifindex = -1;
|
|
|
5c27b6 |
|
|
|
5c27b6 |
if (virAsprintf(&path, "%s/%s_vf%d",
|
|
|
5c27b6 |
stateDir, pflinkdev, vf) < 0)
|
|
|
5c27b6 |
@@ -1696,8 +1683,7 @@ virNetDevRestoreVfConfig(const char *pflinkdev,
|
|
|
5c27b6 |
}
|
|
|
5c27b6 |
|
|
|
5c27b6 |
/*reset mac and remove file-ignore results*/
|
|
|
5c27b6 |
- rc = virNetDevSetVfConfig(pflinkdev, ifindex, vf, true,
|
|
|
5c27b6 |
- &oldmac, vlanid, NULL);
|
|
|
5c27b6 |
+ rc = virNetDevSetVfConfig(pflinkdev, vf, &oldmac, vlanid);
|
|
|
5c27b6 |
ignore_value(unlink(path));
|
|
|
5c27b6 |
|
|
|
5c27b6 |
cleanup:
|
|
|
5c27b6 |
--
|
|
|
5c27b6 |
2.12.2
|
|
|
5c27b6 |
|