From db162cb2b8bb3fa6b94c5c4b4646a95876f07279 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Thu, 12 Jun 2008 13:47:38 +0000 Subject: [PATCH] Fix saving of iptables rules --- ChangeLog | 4 ++++ src/qemu_driver.c | 29 ++++++++++++++--------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index ad9f0848c1..532782234a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Jun 12 14:46:08 BST 2008 Daniel P. Berrange + + * src/qemu_driver.c: Fix saving of iptables rules + Thu Jun 12 11:18:08 BST 2008 Daniel P. Berrange * src/qemu_conf.c: Deal with failure due to inactive virtual diff --git a/src/qemu_driver.c b/src/qemu_driver.c index adb4d5892d..aae0df380b 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -1259,7 +1259,7 @@ qemudAddIptablesRules(virConnectPtr conn, if (!driver->iptables && !(driver->iptables = iptablesContextNew())) { qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "%s", _("failed to allocate space for IP tables support")); - return 1; + return 0; } @@ -1319,23 +1319,22 @@ qemudAddIptablesRules(virConnectPtr conn, } - /* The remaining rules are only needed for IP forwarding */ - if (!network->def->forward) { - iptablesSaveRules(driver->iptables); - return 1; + if (network->def->forward) { + /* If masquerading is enabled, set up the rules*/ + if (network->def->forwardMode == QEMUD_NET_FORWARD_NAT && + !qemudAddMasqueradingIptablesRules(conn, driver, network)) + goto err8; + /* else if routing is enabled, set up the rules*/ + else if (network->def->forwardMode == QEMUD_NET_FORWARD_ROUTE && + !qemudAddRoutingIptablesRules(conn, driver, network)) + goto err8; } - /* If masquerading is enabled, set up the rules*/ - if (network->def->forwardMode == QEMUD_NET_FORWARD_NAT) { - if (qemudAddMasqueradingIptablesRules(conn, driver, network)) - return 1; - } - /* else if routing is enabled, set up the rules*/ - else if (network->def->forwardMode == QEMUD_NET_FORWARD_ROUTE) { - if (qemudAddRoutingIptablesRules(conn, driver, network)) - return 1; - } + iptablesSaveRules(driver->iptables); + + return 1; + err8: iptablesRemoveForwardAllowCross(driver->iptables, network->bridge); err7: -- GitLab