From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpxHF-0000Ka-90 for qemu-devel@nongnu.org; Sat, 14 Jul 2012 04:00:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SpxHD-0005Ar-N6 for qemu-devel@nongnu.org; Sat, 14 Jul 2012 04:00:33 -0400 Received: from mout.web.de ([212.227.15.4]:62246) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpxHD-000574-DP for qemu-devel@nongnu.org; Sat, 14 Jul 2012 04:00:31 -0400 Message-ID: <5001271C.7040108@web.de> Date: Sat, 14 Jul 2012 10:00:28 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <1339503122-32264-1-git-send-email-anders@0x63.nu> <4FF624BA.7000208@web.de> <20120713103717.GA5111@gagarin.0x63.nu> <20120713205417.GC5111@gagarin.0x63.nu> In-Reply-To: <20120713205417.GC5111@gagarin.0x63.nu> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig56DD1FAD61A605C0349F041C" Subject: Re: [Qemu-devel] [PATCH v3] slirp: Handle whole 127.0.0.0/8 network as local addresses. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anders Waldenborg Cc: Blue Swirl , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig56DD1FAD61A605C0349F041C Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2012-07-13 22:54, Anders Waldenborg wrote: > Changes so translation of remote address to the host's ip address in > the virtual network happens for all addresses in the 127.0.0.0/8 > network, not just 127.0.0.1. >=20 > This fixes so that hostfwd bound to addresses such as 127.0.0.2 works. >=20 > Signed-off-by: Anders Waldenborg > --- >=20 > On Fri, Jul 13, 2012 at 03:01:14PM +0000, Blue Swirl wrote: >>> Notice that the surrounding code in tcp_subr.c uses tabs for >>> indentation. Should I still use space as the coding style mandates >>> (and which makes checkpatch happy)? >> >> Yes, the goal is to get rid of tabs. >=20 > OK. Thanks for clarifacion and review! >=20 > Patch updated. >=20 > slirp/main.h | 1 + > slirp/slirp.c | 3 +++ > slirp/tcp_subr.c | 7 +++++-- > 3 files changed, 9 insertions(+), 2 deletions(-) >=20 > diff --git a/slirp/main.h b/slirp/main.h > index 028df4b..bf601e2 100644 > --- a/slirp/main.h > +++ b/slirp/main.h > @@ -31,6 +31,7 @@ extern char *exec_shell; > extern u_int curtime; > extern fd_set *global_readfds, *global_writefds, *global_xfds; > extern struct in_addr loopback_addr; > +extern in_addr_t loopback_mask; > extern char *username; > extern char *socket_path; > extern int towrite_max; > diff --git a/slirp/slirp.c b/slirp/slirp.c > index 90473eb..9787104 100644 > --- a/slirp/slirp.c > +++ b/slirp/slirp.c > @@ -29,6 +29,8 @@ > =20 > /* host loopback address */ > struct in_addr loopback_addr; > +/* host loopback network mask */ > +in_addr_t loopback_mask; > =20 > /* emulated hosts use the MAC addr 52:55:IP:IP:IP:IP */ > static const uint8_t special_ethaddr[ETH_ALEN] =3D { > @@ -191,6 +193,7 @@ static void slirp_init_once(void) > #endif > =20 > loopback_addr.s_addr =3D htonl(INADDR_LOOPBACK); > + loopback_mask =3D htonl(IN_CLASSA_NET); > } > =20 > static void slirp_state_save(QEMUFile *f, void *opaque); > diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c > index 0a545c4..6b01f74 100644 > --- a/slirp/tcp_subr.c > +++ b/slirp/tcp_subr.c > @@ -435,8 +435,11 @@ tcp_connect(struct socket *inso) > so->so_fport =3D addr.sin_port; > so->so_faddr =3D addr.sin_addr; > /* Translate connections from localhost to the real hostname */ > - if (so->so_faddr.s_addr =3D=3D 0 || so->so_faddr.s_addr =3D=3D loopba= ck_addr.s_addr) > - so->so_faddr =3D slirp->vhost_addr; > + if (so->so_faddr.s_addr =3D=3D 0 || > + (so->so_faddr.s_addr & loopback_mask) =3D=3D > + (loopback_addr.s_addr & loopback_mask)) { > + so->so_faddr =3D slirp->vhost_addr; > + } Dropping tabs is desired, but as long as slirp is such a mess coding style wise, I prefer keeping the indention depth consistent. I fixed this up while merging it. Out of curiosity: Which host platform requires this? Linux always reports 127.0.0.1 as source, even when you bind the hostfwd rule to a different localhost address. Jan --------------enig56DD1FAD61A605C0349F041C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAlABJxwACgkQitSsb3rl5xRg0QCeKdJgSBlFN9NIAymCUtXlEZh0 HaoAnAuW43Dxc2kJIHwM1Kfpa0sRLDGj =8o5z -----END PGP SIGNATURE----- --------------enig56DD1FAD61A605C0349F041C--