Resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=1316465
An attempt to simplify the code for the VIR_NETWORK_FORWARD_BRIDGE
case of networkUpdateState in commit b61db335 (first in release
1.2.14) resulted in networks based on macvtap bridge mode being
erroneously marked as inactive any time libvirtd was restarted.
The problem is that the original code had differentiated between a
network using tap devices to connect to an existing host-bridge device
(forward mode of VIR_NETWORK_FORWARD_BRIDGE and a non-NULL
def->bridge), and one using macvtap bridge mode to connect to any
ethernet device (still forward mode VIR_NETWORK_FORWARD_BRIDGE, but
null def->bridge), but the changed code assumed that all networks with
VIR_NETWORK_FORWARD_BRIDGE were tap + host-bridge networks, so a null
def->bridge was interpreted as "inactive".
This patch restores the original code in networkUpdateState, as well
as fixing two other pre-existing similar problems - the cases for
VIR_NETWORK_FORWARD_BRIDGE in both networkStartNetwork and
networkShutdownNetwork have always made the same mistake - treating
macvtap-bridge-mode networks as tap+host-bridge.
---
src/network/bridge_driver.c | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 01c2ed6..b164334 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -406,7 +406,8 @@ networkUpdateState(virNetworkObjPtr obj,
break;
case VIR_NETWORK_FORWARD_BRIDGE:
- if (!(obj->def->bridge && virNetDevExists(obj->def->bridge)
== 1)) {
+ if (obj->def->bridge) {
+ if (virNetDevExists(obj->def->bridge) != 1)
obj->active = 0;
break;
}
@@ -2490,10 +2491,15 @@ networkStartNetwork(virNetworkDriverStatePtr driver,
break;
case VIR_NETWORK_FORWARD_BRIDGE:
- if (networkStartNetworkBridge(network) < 0)
- goto cleanup;
- break;
-
+ if (network->def->bridge) {
+ if (networkStartNetworkBridge(network) < 0)
+ goto cleanup;
+ break;
+ }
+ /* intentionally fall through to the macvtap/direct case for
+ * VIR_NETWORK_FORWARD_BRIDGE with no bridge device defined
+ * (since that is macvtap bridge mode).
+ */
case VIR_NETWORK_FORWARD_PRIVATE:
case VIR_NETWORK_FORWARD_VEPA:
case VIR_NETWORK_FORWARD_PASSTHROUGH:
@@ -2562,9 +2568,14 @@ networkShutdownNetwork(virNetworkDriverStatePtr driver,
break;
case VIR_NETWORK_FORWARD_BRIDGE:
- ret = networkShutdownNetworkBridge(network);
- break;
-
+ if (network->def->bridge) {
+ ret = networkShutdownNetworkBridge(network);
+ break;
+ }
+ /* intentionally fall through to the macvtap/direct case for
+ * VIR_NETWORK_FORWARD_BRIDGE with no bridge device defined
+ * (since that is macvtap bridge mode).
+ */
case VIR_NETWORK_FORWARD_PRIVATE:
case VIR_NETWORK_FORWARD_VEPA:
case VIR_NETWORK_FORWARD_PASSTHROUGH:
@@ -4691,8 +4702,8 @@ networkGetNetworkAddress(const char *netname, char **netaddr)
if ((dev_name = netdef->bridge))
break;
/*
- * fall through if netdef->bridge wasn't set, since this is
- * also a direct-mode interface.
+ * fall through if netdef->bridge wasn't set, since that is
+ * macvtap bridge mode network.
*/
case VIR_NETWORK_FORWARD_PRIVATE:
case VIR_NETWORK_FORWARD_VEPA:
--
2.5.0