Re: [PATCH] conf: Don't try formating non-existing addresses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 11, 2015 at 03:16:16PM +0200, Martin Kletzander wrote:
Commit a6f9af8292b6 added checking for address colisions between
starting and ending addresses of forwarding addresses, but forgot that
there might be no addresses set at all.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
src/conf/network_conf.c                            | 22 +++++++++++++++++++---
....xml => nat-network-forward-nat-no-address.xml} |  1 -
....xml => nat-network-forward-nat-no-address.xml} |  1 -
tests/networkxml2xmltest.c                         |  1 +
4 files changed, 20 insertions(+), 5 deletions(-)
copy tests/networkxml2xmlin/{nat-network-forward-nat-address.xml => nat-network-forward-nat-no-address.xml} (93%)
copy tests/networkxml2xmlout/{nat-network-forward-nat-address.xml => nat-network-forward-nat-no-address.xml} (93%)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 374d723788e1..f9d894b12046 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -1731,9 +1731,25 @@ virNetworkForwardNatDefParseXML(const char *networkName,
        goto cleanup;
    }

-    /* verify that start <= end */
-    if (virSocketAddrGetRange(&def->addr.start, &def->addr.end, NULL, 0) < 0)
-        goto cleanup;
+    if (addrStart && addrEnd) {
+        /* verify that start <= end */
+        if (virSocketAddrGetRange(&def->addr.start, &def->addr.end, NULL, 0) < 0)
+            goto cleanup;
+    } else {
+        if (addrStart) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("Only start address '%s' specified in <nat> in "
+                             "<forward> in network '%s'"),
+                           addrStart, networkName);
+            goto cleanup;
+        }
+        if (addrEnd) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("Only end address '%s' specified in <nat> in "
+                             "<forward> in network '%s'"),
+                           addrEnd, networkName);

I see the missing 'goto cleanup;' now, consider this squashed in as it
already is in my tree:

diff --git c/src/conf/network_conf.c w/src/conf/network_conf.c
index f9d894b12046..c1cbd76c6807 100644
--- c/src/conf/network_conf.c
+++ w/src/conf/network_conf.c
@@ -1748,6 +1748,7 @@ virNetworkForwardNatDefParseXML(const char *networkName,
                           _("Only end address '%s' specified in <nat> in "
                             "<forward> in network '%s'"),
                           addrEnd, networkName);
+            goto cleanup;
        }
    }

--

Martin

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]