* [Qemu-devel] [PATCH] Always use 10.0.2.2 as host addr for -net user (slirp)
@ 2006-05-01 2:43 Ed Swierk
2006-05-01 10:53 ` Fabrice Bellard
0 siblings, 1 reply; 2+ messages in thread
From: Ed Swierk @ 2006-05-01 2:43 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 900 bytes --]
A couple of serious problems remain in the slirp redirection code
after the patch Paul applied on 23 April.
* If the IP address returned by gethostbyname(gethostname()) is the
address of one of the host's Ethernet interfaces, bringing down that
interface or changing its IP address disrupts redir connections
between the host and VM.
* If the IP address returned by gethostbyname(gethostname()) is
outside the 10.0.2.0/24 subnet, and the user has not manually added
this address to the routing table within the VM (in addition to the
10.0.2.0/24 route added by DHCP), TCP connections from the host to the
VM are never answered, because the response packets are dropped on the
floor.
The attached patch solves both of these problems simply by always
using 10.0.2.2 as our_addr. There seems to be no value in exposing the
host's "real" address to the VM; thanks to NAT, 10.0.2.2 always works.
--Ed
[-- Attachment #2: qemu-nat-bug.patch --]
[-- Type: text/x-patch, Size: 846 bytes --]
diff -BurN qemu-snapshot-2006-04-27_23.orig/slirp/misc.c qemu-snapshot-2006-04-27_23/slirp/misc.c
--- qemu-snapshot-2006-04-27_23.orig/slirp/misc.c 2006-04-23 19:41:17.000000000 +0000
+++ qemu-snapshot-2006-04-27_23/slirp/misc.c 2006-04-27 22:19:40.000000000 +0000
@@ -87,17 +87,7 @@
void
getouraddr()
{
- char buff[256];
- struct hostent *he = NULL;
-
- if (gethostname(buff,256) == 0)
- he = gethostbyname(buff);
- if (he)
- our_addr = *(struct in_addr *)he->h_addr;
- /* If the host doesn't have a useful IP address then use the
- guest side address. */
- if (our_addr.s_addr == 0 || our_addr.s_addr == loopback_addr.s_addr)
- our_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
+ our_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
}
#if SIZEOF_CHAR_P == 8
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] Always use 10.0.2.2 as host addr for -net user (slirp)
2006-05-01 2:43 [Qemu-devel] [PATCH] Always use 10.0.2.2 as host addr for -net user (slirp) Ed Swierk
@ 2006-05-01 10:53 ` Fabrice Bellard
0 siblings, 0 replies; 2+ messages in thread
From: Fabrice Bellard @ 2006-05-01 10:53 UTC (permalink / raw)
To: qemu-devel
I am not sure this patch is sufficient: sometimes our_addr is used to
open socket on the host side and 10.0.2.2 has a meanning only on the VM
side.
Fabrice.
Ed Swierk wrote:
> A couple of serious problems remain in the slirp redirection code
> after the patch Paul applied on 23 April.
>
> * If the IP address returned by gethostbyname(gethostname()) is the
> address of one of the host's Ethernet interfaces, bringing down that
> interface or changing its IP address disrupts redir connections
> between the host and VM.
>
> * If the IP address returned by gethostbyname(gethostname()) is
> outside the 10.0.2.0/24 subnet, and the user has not manually added
> this address to the routing table within the VM (in addition to the
> 10.0.2.0/24 route added by DHCP), TCP connections from the host to the
> VM are never answered, because the response packets are dropped on the
> floor.
>
> The attached patch solves both of these problems simply by always
> using 10.0.2.2 as our_addr. There seems to be no value in exposing the
> host's "real" address to the VM; thanks to NAT, 10.0.2.2 always works.
>
> --Ed
>
>
> ------------------------------------------------------------------------
>
> diff -BurN qemu-snapshot-2006-04-27_23.orig/slirp/misc.c qemu-snapshot-2006-04-27_23/slirp/misc.c
> --- qemu-snapshot-2006-04-27_23.orig/slirp/misc.c 2006-04-23 19:41:17.000000000 +0000
> +++ qemu-snapshot-2006-04-27_23/slirp/misc.c 2006-04-27 22:19:40.000000000 +0000
> @@ -87,17 +87,7 @@
> void
> getouraddr()
> {
> - char buff[256];
> - struct hostent *he = NULL;
> -
> - if (gethostname(buff,256) == 0)
> - he = gethostbyname(buff);
> - if (he)
> - our_addr = *(struct in_addr *)he->h_addr;
> - /* If the host doesn't have a useful IP address then use the
> - guest side address. */
> - if (our_addr.s_addr == 0 || our_addr.s_addr == loopback_addr.s_addr)
> - our_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
> + our_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
> }
>
> #if SIZEOF_CHAR_P == 8
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-05-01 10:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-01 2:43 [Qemu-devel] [PATCH] Always use 10.0.2.2 as host addr for -net user (slirp) Ed Swierk
2006-05-01 10:53 ` Fabrice Bellard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).