[pve-devel] [PATCH] Added patch to make ipv6 life easier.

Wolfgang Bumiller w.bumiller at proxmox.com
Thu May 21 14:08:09 CEST 2015


Copy of the patch notes:
[PATCH] friendlier ai_flag hints for ipv6 hosts

*) Do not use AI_ADDRCONFIG on listening sockets, because this flag
makes it impossible to explicitly listen on '127.0.0.1' if no global
ipv4 address is configured additionally, making this a very
uncomfortable option.
*) Add AI_V4MAPPED hint for connecting sockets for a similar purpose.

If your system is globally only connected via ipv6 you still want to be
able to use '127.0.0.1' and 'localhost'.
Specifically, PVE - unless explicitly asking for insecure mode - uses
loopback addresses with QEMU for live migrations tunneled over SSH.
These fail to start because AI_ADDRCONFIG makes getaddrinfo refuse to
work with '127.0.0.1'.

As for the AI_V4MAPPED flag the situation is similar.

I also want to point out that glibc explicitly sidesteps POSIX standards
when passing 0 as hints by then assuming both AI_V4MAPPED and
AI_ADDRCONFIG (the latter being a rather weird choice IMO), while
according to POSIX.1-2001 it should be assumed 0. (glibc considers its
choice an improvement.)
Since either AI_CANONNAME or AI_PASSIVE are passed in our cases, glibc's
default flags in turn are disabled again unless explicitly added, which
I do with this patch.
---
 ...1-friendlier-ai_flag-hints-for-ipv6-hosts.patch | 66 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 2 files changed, 67 insertions(+)
 create mode 100644 debian/patches/0001-friendlier-ai_flag-hints-for-ipv6-hosts.patch

diff --git a/debian/patches/0001-friendlier-ai_flag-hints-for-ipv6-hosts.patch b/debian/patches/0001-friendlier-ai_flag-hints-for-ipv6-hosts.patch
new file mode 100644
index 0000000..4b7dd9c
--- /dev/null
+++ b/debian/patches/0001-friendlier-ai_flag-hints-for-ipv6-hosts.patch
@@ -0,0 +1,66 @@
+From dea9f9c5d03983bb6a9c75f093b2f9c49e4a5397 Mon Sep 17 00:00:00 2001
+From: Wolfgang Bumiller <w.bumiller at proxmox.com>
+Date: Thu, 21 May 2015 10:48:21 +0200
+Subject: [PATCH] friendlier ai_flag hints for ipv6 hosts
+
+*) Do not use AI_ADDRCONFIG on listening sockets, because this flag
+makes it impossible to explicitly listen on '127.0.0.1' if no global
+ipv4 address is configured additionally, making this a very
+uncomfortable option.
+*) Add AI_V4MAPPED hint for connecting sockets for a similar purpose.
+
+If your system is globally only connected via ipv6 you still want to be
+able to use '127.0.0.1' and 'localhost'.
+Specifically, PVE - unless explicitly asking for insecure mode - uses
+loopback addresses with QEMU for live migrations tunneled over SSH.
+These fail to start because AI_ADDRCONFIG makes getaddrinfo refuse to
+work with '127.0.0.1'.
+
+As for the AI_V4MAPPED flag the situation is similar.
+
+I also want to point out that glibc explicitly sidesteps POSIX standards
+when passing 0 as hints by then assuming both AI_V4MAPPED and
+AI_ADDRCONFIG (the latter being a rather weird choice IMO), while
+according to POSIX.1-2001 it should be assumed 0. (glibc considers its
+choice an improvement.)
+Since either AI_CANONNAME or AI_PASSIVE are passed in our cases, glibc's
+default flags in turn are disabled again unless explicitly added, which
+I do with this patch.
+---
+ util/qemu-sockets.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
+index 6b97dc1..f99b013 100644
+--- a/util/qemu-sockets.c
++++ b/util/qemu-sockets.c
+@@ -114,7 +114,7 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp)
+     int slisten, rc, to, port_min, port_max, p;
+ 
+     memset(&ai,0, sizeof(ai));
+-    ai.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
++    ai.ai_flags = AI_PASSIVE;
+     ai.ai_family = PF_UNSPEC;
+     ai.ai_socktype = SOCK_STREAM;
+ 
+@@ -308,7 +308,7 @@ static struct addrinfo *inet_parse_connect_opts(QemuOpts *opts, Error **errp)
+ 
+     memset(&ai, 0, sizeof(ai));
+ 
+-    ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
++    ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;
+     ai.ai_family = PF_UNSPEC;
+     ai.ai_socktype = SOCK_STREAM;
+ 
+@@ -404,7 +404,7 @@ int inet_dgram_opts(QemuOpts *opts, Error **errp)
+ 
+     /* lookup peer addr */
+     memset(&ai,0, sizeof(ai));
+-    ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
++    ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;
+     ai.ai_family = PF_UNSPEC;
+     ai.ai_socktype = SOCK_DGRAM;
+ 
+-- 
+2.1.4
+
diff --git a/debian/patches/series b/debian/patches/series
index 51b8c2f..5041ded 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -34,3 +34,4 @@ virtio-balloon-dimmfix2.patch
 virtio-balloon-dimmfix3.patch
 add-qmp-get-link-status.patch
 virtio-scsi_fix_assert.patch
+0001-friendlier-ai_flag-hints-for-ipv6-hosts.patch
-- 
2.1.4





More information about the pve-devel mailing list