]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
network: don't "refresh" iptables rules on rule-less networks
authorLaine Stump <laine@laine.org>
Fri, 21 Sep 2012 19:28:11 +0000 (15:28 -0400)
committerLaine Stump <laine@laine.org>
Sat, 22 Sep 2012 00:10:43 +0000 (20:10 -0400)
The bridge driver implementation of virNetworkUpdate() removes and
re-adds iptables rules any time a network has an <ip>, <forward>, or
<forward>/<interface> element updated. There are some types of
networks that have those elements and yet have no iptables rules
associated with them, and unfortunately the functions that remove/add
iptables rules don't check the type of network before attempting to
remove/add the rules, sometimes leading to an erroneous failure of the
entire update operation.

Under normal circumstances I would refactor the lower level functions
to be more robust, but to avoid code churn as much as possible, I've
just added extra checks directly to networkUpdate().

src/network/bridge_driver.c

index fce17390b904f9e3e897f1551dfab6a896232e7c..6e260f7746a9197d47c3f9b1a7cf677f6d584907 100644 (file)
@@ -2945,9 +2945,12 @@ networkUpdate(virNetworkPtr net,
                 goto cleanup;
         }
 
-        if (section == VIR_NETWORK_SECTION_IP ||
-            section == VIR_NETWORK_SECTION_FORWARD ||
-            section == VIR_NETWORK_SECTION_FORWARD_INTERFACE) {
+        if ((section == VIR_NETWORK_SECTION_IP ||
+             section == VIR_NETWORK_SECTION_FORWARD ||
+             section == VIR_NETWORK_SECTION_FORWARD_INTERFACE) &&
+           (network->def->forwardType == VIR_NETWORK_FORWARD_NONE ||
+            network->def->forwardType == VIR_NETWORK_FORWARD_NAT ||
+            network->def->forwardType == VIR_NETWORK_FORWARD_ROUTE)) {
             /* these could affect the iptables rules */
             networkRemoveIptablesRules(driver, network);
             if (networkAddIptablesRules(driver, network) < 0)