[PATCH 23/28] util: make messages consistent in both versions of virNetDevIPRouteAdd()

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

 



---
 src/util/virnetdevip.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c
index 6889f81..5daeed5 100644
--- a/src/util/virnetdevip.c
+++ b/src/util/virnetdevip.c
@@ -315,7 +315,6 @@ virNetDevIPRouteAdd(const char *ifname,
 
     /* If we have no valid network address, then use the default one */
     if (!addr || !VIR_SOCKET_ADDR_VALID(addr)) {
-        VIR_DEBUG("computing default address");
         int family = VIR_SOCKET_ADDR_FAMILY(gateway);
         if (family == AF_INET) {
             if (virSocketAddrParseIPv4(&defaultAddr, VIR_SOCKET_ADDR_IPV4_ALL) < 0)
@@ -328,9 +327,11 @@ virNetDevIPRouteAdd(const char *ifname,
         actualAddr = &defaultAddr;
     }
 
-    toStr = virSocketAddrFormat(actualAddr);
-    viaStr = virSocketAddrFormat(gateway);
-    VIR_DEBUG("Adding route %s/%d via %s", toStr, prefix, viaStr);
+    if (!(toStr = virSocketAddrFormat(actualAddr)))
+        goto cleanup;
+    if (!(viaStr = virSocketAddrFormat(gateway)))
+        goto cleanup;
+    VIR_DEBUG("Adding route to %s/%u via %s on %s", toStr, prefix, viaStr, ifname);
 
     if (virNetDevGetIPAddressBinary(actualAddr, &addrData, &addrDataLen) < 0 ||
         virNetDevGetIPAddressBinary(gateway, &gatewayData, &addrDataLen) < 0)
@@ -376,7 +377,9 @@ virNetDevIPRouteAdd(const char *ifname,
         goto cleanup;
 
     if ((errCode = virNetlinkGetErrorCode(resp, recvbuflen)) < 0) {
-        virReportSystemError(errCode, _("Error adding route to %s"), ifname);
+        virReportSystemError(errCode,
+                             _("Error adding route to %s/%u via %s on %s"),
+                             toStr, prefix, viaStr, ifname);
         goto cleanup;
     }
 
@@ -617,7 +620,8 @@ virNetDevIPRouteAdd(const char *ifname,
                     unsigned int metric)
 {
     virCommandPtr cmd = NULL;
-    char *addrstr = NULL, *gatewaystr = NULL;
+    char *toStr = NULL;
+    char *viaStr = NULL;
     virSocketAddr defaultAddr;
     virSocketAddrPtr actualAddr;
     int ret = -1;
@@ -638,14 +642,16 @@ virNetDevIPRouteAdd(const char *ifname,
         actualAddr = &defaultAddr;
     }
 
-    if (!(addrstr = virSocketAddrFormat(actualAddr)))
+    if (!(toStr = virSocketAddrFormat(actualAddr)))
         goto cleanup;
-    if (!(gatewaystr = virSocketAddrFormat(gateway)))
+    if (!(viaStr = virSocketAddrFormat(gateway)))
         goto cleanup;
+    VIR_DEBUG("Adding route to %s/%u via %s on %s", toStr, prefix, viaStr, ifname);
+
     cmd = virCommandNew(IP_PATH);
     virCommandAddArgList(cmd, "route", "add", NULL);
-    virCommandAddArgFormat(cmd, "%s/%u", addrstr, prefix);
-    virCommandAddArgList(cmd, "via", gatewaystr, "dev", ifname,
+    virCommandAddArgFormat(cmd, "%s/%u", toStr, prefix);
+    virCommandAddArgList(cmd, "via", viaStr, "dev", ifname,
                               "proto", "static", "metric", NULL);
     virCommandAddArgFormat(cmd, "%u", metric);
 
@@ -654,8 +660,8 @@ virNetDevIPRouteAdd(const char *ifname,
 
     ret = 0;
  cleanup:
-    VIR_FREE(addrstr);
-    VIR_FREE(gatewaystr);
+    VIR_FREE(toStr);
+    VIR_FREE(viaStr);
     virCommandFree(cmd);
     return ret;
 }
-- 
2.5.5

--
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]