aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2011-02-25 17:03:55 +0000
committerIan Campbell <ian.campbell@citrix.com>2011-02-25 17:03:55 +0000
commitc544f6db0cff898a5a1a99c4d19beaffd40738c6 (patch)
treec246c31af0b88ed5c6cbc29509555f452ca90315
parent69ec10d36ae688cbca3d31b9e3af146db8411879 (diff)
downloadxen-c544f6db0cff898a5a1a99c4d19beaffd40738c6.tar.gz
xen-c544f6db0cff898a5a1a99c4d19beaffd40738c6.tar.bz2
xen-c544f6db0cff898a5a1a99c4d19beaffd40738c6.zip
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@citrix.com> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
-rw-r--r--tools/libxl/libxl.c17
-rw-r--r--tools/libxl/libxl.idl2
-rw-r--r--tools/libxl/libxltypes.py2
-rw-r--r--tools/libxl/xl_cmdimpl.c10
4 files changed, 10 insertions, 21 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 1f7a529dbc..d0b2f74912 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -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 @@ int libxl_device_nic_init(libxl_device_nic *nic_info, int devnum)
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 @@ int libxl_device_nic_add(libxl_ctx *ctx, uint32_t domid, libxl_device_nic *nic)
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 --git a/tools/libxl/libxl.idl b/tools/libxl/libxl.idl
index 2cfede4dc2..377417a8c8 100644
--- a/tools/libxl/libxl.idl
+++ b/tools/libxl/libxl.idl
@@ -220,7 +220,7 @@ libxl_device_nic = Struct("device_nic", [
("mtu", integer),
("model", string),
("mac", libxl_mac),
- ("ip", inaddr_ip),
+ ("ip", string),
("bridge", string),
("ifname", string),
("script", string),
diff --git a/tools/libxl/libxltypes.py b/tools/libxl/libxltypes.py
index 53b0d25392..9c9e6427e7 100644
--- a/tools/libxl/libxltypes.py
+++ b/tools/libxl/libxltypes.py
@@ -159,8 +159,6 @@ domid = UInt(32)
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 --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 9822e99401..0fad4711ce 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -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 @@ static void parse_config_data(const char *configfile_filename_report,
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 @@ int main_networkattach(int argc, char **argv)
} 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)) {