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

[Xen-changelog] [xen-unstable] xl/libxl: treat vif "ip" fields as a simple string



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1298653435 0
# Node ID 0ddaa54ae3dbe1326e356cb2af5f454a9ba7a297
# Parent  54fe1011f86be2ffeaba3b6e883392ea56bbb750
xl/libxl: treat vif "ip" fields as a simple string

Currently we parse the string as an IPv4 address but this does not
handle IPv6. We then format the IP address as a string into xenstore.
Rather than add further parsing and formatting to support IPv6 simply
treat the field as a string, which it turns out is all xend does.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---


diff -r 54fe1011f86b -r 0ddaa54ae3db tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Fri Feb 25 11:29:45 2011 +0000
+++ b/tools/libxl/libxl.c       Fri Feb 25 17:03:55 2011 +0000
@@ -31,8 +31,6 @@
 #include <inttypes.h>
 #include <assert.h>
 
-#include <arpa/inet.h>
-
 #include "libxl.h"
 #include "libxl_utils.h"
 #include "libxl_internal.h"
@@ -1175,7 +1173,7 @@
     nic_info->mac[5] = r[2];
     nic_info->ifname = NULL;
     nic_info->bridge = strdup("xenbr0");
-    nic_info->ip.s_addr = 0UL;
+    nic_info->ip = NULL;
     if ( asprintf(&nic_info->script, "%s/vif-bridge",
                libxl_xen_script_dir_path()) < 0 )
         return ERROR_FAIL;
@@ -1235,16 +1233,11 @@
     flexarray_append(back, libxl__sprintf(&gc, "%02x:%02x:%02x:%02x:%02x:%02x",
                                                  nic->mac[0], nic->mac[1], 
nic->mac[2],
                                                  nic->mac[3], nic->mac[4], 
nic->mac[5]));
-    if (nic->ip.s_addr != 0UL) {
-        char dst[INET_ADDRSTRLEN];
-        const char *addr = inet_ntop(AF_INET, &nic->ip.s_addr, &dst[0], 
INET_ADDRSTRLEN);
-        if (addr) {
-            flexarray_append(back, "ip");
-            flexarray_append(back, libxl__strdup(&gc, addr));
-        } else {
-            LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "Unable to format IP address");
-        }
+    if (nic->ip) {
+        flexarray_append(back, "ip");
+        flexarray_append(back, libxl__strdup(&gc, nic->ip));
     }
+
     flexarray_append(back, "bridge");
     flexarray_append(back, libxl__strdup(&gc, nic->bridge));
     flexarray_append(back, "handle");
diff -r 54fe1011f86b -r 0ddaa54ae3db tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl     Fri Feb 25 11:29:45 2011 +0000
+++ b/tools/libxl/libxl.idl     Fri Feb 25 17:03:55 2011 +0000
@@ -220,7 +220,7 @@
     ("mtu", integer),
     ("model", string),
     ("mac", libxl_mac),
-    ("ip", inaddr_ip),
+    ("ip", string),
     ("bridge", string),
     ("ifname", string),
     ("script", string),
diff -r 54fe1011f86b -r 0ddaa54ae3db tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py Fri Feb 25 11:29:45 2011 +0000
+++ b/tools/libxl/libxltypes.py Fri Feb 25 17:03:55 2011 +0000
@@ -159,8 +159,6 @@
 
 string = Builtin("char *", namespace = None, destructor_fn = "free")
 
-inaddr_ip = Builtin("struct in_addr", namespace = None)
-
 class OrderedDict(dict):
     """A dictionary which remembers insertion order.
 
diff -r 54fe1011f86b -r 0ddaa54ae3db tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Fri Feb 25 11:29:45 2011 +0000
+++ b/tools/libxl/xl_cmdimpl.c  Fri Feb 25 17:03:55 2011 +0000
@@ -30,7 +30,6 @@
 #include <signal.h>
 #include <sys/socket.h>
 #include <sys/select.h>
-#include <arpa/inet.h>
 #include <sys/utsname.h> /* for utsname in xl info */
 #include <xenctrl.h>
 #include <ctype.h>
@@ -843,7 +842,8 @@
                     else
                         nic->nictype = NICTYPE_VIF;
                 } else if (!strcmp(p, "ip")) {
-                    inet_pton(AF_INET, p2 + 1, &nic->ip);
+                    free(nic->ip);
+                    nic->ip = strdup(p2 + 1);
                 } else if (!strcmp(p, "script")) {
                     free(nic->script);
                     nic->script = strdup(p2 + 1);
@@ -4257,10 +4257,8 @@
         } else if (!strncmp("bridge=", *argv, 7)) {
             nic.bridge = (*argv) + 7;
         } else if (!strncmp("ip=", *argv, 3)) {
-            if (!inet_aton((*argv) + 3, &(nic.ip))) {
-                fprintf(stderr, "Invalid parameter `ip'.\n");
-                return 1;
-            }
+            free(nic.ip);
+            nic.ip = strdup((*argv) + 3);
         } else if (!strncmp("script=", *argv, 6)) {
             nic.script = (*argv) + 6;
         } else if (!strncmp("backend=", *argv, 8)) {

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.