On Fri, 2011-02-18 at 17:19 +0000, Carlos wrote:
> I
> am changing the vif-common file to automatically configure anti-spoofing
> rules for ipv6. With xm commands work well everything.
>
> The ipv6 is recorded correctly in "xen-store" when the domain starts
> with "xm create" but with "xl create" doesn't.
I prototyped adding parsing and formatting for IPv6 addresses but then I
looked at what xend does and it simply passes the ip= string through
without any introspection, so lets do that in xl too.
Does the following fix the issue?
If preference is for libxl/xl to actually understand the IPv6 addresses
I still have the prototype code which I could resurrect.
Ian.
8<---------------------
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1298281384 0
# Node ID 44ba31b97a1f0f2628298e285d9eb64ab39eeeac
# Parent c529d4d7d79ba3fe69ffb6cbacac5c9e3e5cf246
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>
diff -r c529d4d7d79b -r 44ba31b97a1f tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Thu Feb 17 10:02:52 2011 +0000
+++ b/tools/libxl/libxl.c Mon Feb 21 09:43:04 2011 +0000
@@ -30,8 +30,6 @@
#include <stdint.h>
#include <inttypes.h>
#include <assert.h>
-
-#include <arpa/inet.h>
#include "libxl.h"
#include "libxl_utils.h"
@@ -1125,7 +1123,7 @@ int libxl_device_nic_init(libxl_device_n
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;
@@ -1185,16 +1183,11 @@ int libxl_device_nic_add(libxl_ctx *ctx,
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 c529d4d7d79b -r 44ba31b97a1f tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl Thu Feb 17 10:02:52 2011 +0000
+++ b/tools/libxl/libxl.idl Mon Feb 21 09:43:04 2011 +0000
@@ -218,7 +218,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 -r c529d4d7d79b -r 44ba31b97a1f tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py Thu Feb 17 10:02:52 2011 +0000
+++ b/tools/libxl/libxltypes.py Mon Feb 21 09:43:04 2011 +0000
@@ -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 -r c529d4d7d79b -r 44ba31b97a1f tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Thu Feb 17 10:02:52 2011 +0000
+++ b/tools/libxl/xl_cmdimpl.c Mon Feb 21 09:43:04 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>
@@ -828,7 +827,8 @@ static void parse_config_data(const char
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);
@@ -4247,10 +4247,8 @@ int main_networkattach(int argc, char **
} 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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|