|
|
5c27b6 |
From 059b472059add9c1cfd4031a57143e92473976c1 Mon Sep 17 00:00:00 2001
|
|
|
5c27b6 |
Message-Id: <059b472059add9c1cfd4031a57143e92473976c1@dist-git>
|
|
|
5c27b6 |
From: Laine Stump <laine@laine.org>
|
|
|
5c27b6 |
Date: Thu, 13 Apr 2017 14:29:30 -0400
|
|
|
5c27b6 |
Subject: [PATCH] util: use new virNetDev*NetConfig() functions for macvtap
|
|
|
5c27b6 |
setup/teardown
|
|
|
5c27b6 |
|
|
|
5c27b6 |
This patch modifies the macvtap passthrough setup to use
|
|
|
5c27b6 |
virNetDevSaveNetConfig()+virNetDevSetConfig() instead of
|
|
|
5c27b6 |
virNetDevReplaceNetConfig() or virNetDevReplaceMacAddress(), and the
|
|
|
5c27b6 |
teardown to use virNetDevReadNetConfig()+virNetDevSetConfig() instead
|
|
|
5c27b6 |
of virNetDevRestoreNetConfig() or virNetDevRestoreMacAddress().
|
|
|
5c27b6 |
|
|
|
5c27b6 |
Since the older functions only saved/restored the admin MAC and vlan
|
|
|
5c27b6 |
tag (which is incorrect) and the new functions save/restore the VF's
|
|
|
5c27b6 |
own MAC address and vlan tag (correct), this actually fixes a bug
|
|
|
5c27b6 |
(which was introduced by commit cb3fe38c7, which was itself supposed
|
|
|
5c27b6 |
to be a fix for https://bugzilla.redhat.com/1113474 ).
|
|
|
5c27b6 |
|
|
|
5c27b6 |
The downside to this patch is that it causes an *apparent* regression
|
|
|
5c27b6 |
in that bug (because there will once again be an error reported if the
|
|
|
5c27b6 |
interface had previously been used for VFIO device assignment), but in
|
|
|
5c27b6 |
reality, the code hasn't been working for *any* case before this
|
|
|
5c27b6 |
current patch (at least not with any recent kernel). Anyway, that
|
|
|
5c27b6 |
"regression" will be fixed with an upcoming patch that fixes it the
|
|
|
5c27b6 |
*right* way.
|
|
|
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 b91a33638476cf57d910b6056a8fc11921edd029)
|
|
|
5c27b6 |
---
|
|
|
5c27b6 |
src/util/virnetdevmacvlan.c | 40 +++++++++++++++++++++++++---------------
|
|
|
5c27b6 |
1 file changed, 25 insertions(+), 15 deletions(-)
|
|
|
5c27b6 |
|
|
|
5c27b6 |
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
|
|
|
5c27b6 |
index 61da55415..40d64675e 100644
|
|
|
5c27b6 |
--- a/src/util/virnetdevmacvlan.c
|
|
|
5c27b6 |
+++ b/src/util/virnetdevmacvlan.c
|
|
|
5c27b6 |
@@ -1011,20 +1011,22 @@ virNetDevMacVLanCreateWithVPortProfile(const char *ifnameRequested,
|
|
|
5c27b6 |
*/
|
|
|
5c27b6 |
|
|
|
5c27b6 |
if (mode == VIR_NETDEV_MACVLAN_MODE_PASSTHRU) {
|
|
|
5c27b6 |
+ bool setVlan = true;
|
|
|
5c27b6 |
+
|
|
|
5c27b6 |
if (virtPortProfile &&
|
|
|
5c27b6 |
virtPortProfile->virtPortType == VIR_NETDEV_VPORT_PROFILE_8021QBH) {
|
|
|
5c27b6 |
- /* The Cisco enic driver (the only card that uses
|
|
|
5c27b6 |
- * 802.1Qbh) doesn't support IFLA_VFINFO_LIST, which is
|
|
|
5c27b6 |
- * required for virNetDevReplaceNetConfig(), so we must
|
|
|
5c27b6 |
- * use this function (which uses ioctl(SIOCGIFHWADDR)
|
|
|
5c27b6 |
- * instead or virNetDevReplaceNetConfig()
|
|
|
5c27b6 |
+ /* The Cisco enic driver (the only SRIOV-capable card that
|
|
|
5c27b6 |
+ * uses 802.1Qbh) doesn't support IFLA_VFINFO_LIST, which
|
|
|
5c27b6 |
+ * is required to get/set the vlan tag of a VF.
|
|
|
5c27b6 |
*/
|
|
|
5c27b6 |
- if (virNetDevReplaceMacAddress(linkdev, macaddress, stateDir) < 0)
|
|
|
5c27b6 |
- return -1;
|
|
|
5c27b6 |
- } else {
|
|
|
5c27b6 |
- if (virNetDevReplaceNetConfig(linkdev, -1, macaddress, vlan, stateDir) < 0)
|
|
|
5c27b6 |
- return -1;
|
|
|
5c27b6 |
+ setVlan = false;
|
|
|
5c27b6 |
}
|
|
|
5c27b6 |
+
|
|
|
5c27b6 |
+ if (virNetDevSaveNetConfig(linkdev, -1, stateDir, setVlan) < 0)
|
|
|
5c27b6 |
+ return -1;
|
|
|
5c27b6 |
+
|
|
|
5c27b6 |
+ if (virNetDevSetNetConfig(linkdev, -1, NULL, vlan, macaddress, setVlan) < 0)
|
|
|
5c27b6 |
+ return -1;
|
|
|
5c27b6 |
}
|
|
|
5c27b6 |
|
|
|
5c27b6 |
if (ifnameRequested) {
|
|
|
5c27b6 |
@@ -1205,11 +1207,19 @@ int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
|
|
|
5c27b6 |
}
|
|
|
5c27b6 |
|
|
|
5c27b6 |
if (mode == VIR_NETDEV_MACVLAN_MODE_PASSTHRU) {
|
|
|
5c27b6 |
- if (virtPortProfile &&
|
|
|
5c27b6 |
- virtPortProfile->virtPortType == VIR_NETDEV_VPORT_PROFILE_8021QBH)
|
|
|
5c27b6 |
- ignore_value(virNetDevRestoreMacAddress(linkdev, stateDir));
|
|
|
5c27b6 |
- else
|
|
|
5c27b6 |
- ignore_value(virNetDevRestoreNetConfig(linkdev, -1, stateDir));
|
|
|
5c27b6 |
+ virMacAddrPtr MAC = NULL;
|
|
|
5c27b6 |
+ virMacAddrPtr adminMAC = NULL;
|
|
|
5c27b6 |
+ virNetDevVlanPtr vlan = NULL;
|
|
|
5c27b6 |
+
|
|
|
5c27b6 |
+ if (virNetDevReadNetConfig(linkdev, -1, stateDir,
|
|
|
5c27b6 |
+ &adminMAC, &vlan, &MAC) == 0) {
|
|
|
5c27b6 |
+
|
|
|
5c27b6 |
+ ignore_value(virNetDevSetNetConfig(linkdev, -1,
|
|
|
5c27b6 |
+ adminMAC, vlan, MAC, !!vlan));
|
|
|
5c27b6 |
+ VIR_FREE(MAC);
|
|
|
5c27b6 |
+ VIR_FREE(adminMAC);
|
|
|
5c27b6 |
+ virNetDevVlanFree(vlan);
|
|
|
5c27b6 |
+ }
|
|
|
5c27b6 |
}
|
|
|
5c27b6 |
|
|
|
5c27b6 |
virNetlinkEventRemoveClient(0, macaddr, NETLINK_ROUTE);
|
|
|
5c27b6 |
--
|
|
|
5c27b6 |
2.12.2
|
|
|
5c27b6 |
|