From: Jan Kiszka <jan.kiszka@web.de>
To: Anders Waldenborg <anders@0x63.nu>
Cc: Blue Swirl <blauwirbel@gmail.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3] slirp: Handle whole 127.0.0.0/8 network as local addresses.
Date: Sat, 14 Jul 2012 10:07:08 +0200 [thread overview]
Message-ID: <500128AC.4090202@web.de> (raw)
In-Reply-To: <5001271C.7040108@web.de>
[-- Attachment #1: Type: text/plain, Size: 3225 bytes --]
On 2012-07-14 10:00, Jan Kiszka wrote:
> 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.
>>
>> This fixes so that hostfwd bound to addresses such as 127.0.0.2 works.
>>
>> Signed-off-by: Anders Waldenborg <anders@0x63.nu>
>> ---
>>
>> 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.
>>
>> OK. Thanks for clarifacion and review!
>>
>> Patch updated.
>>
>> slirp/main.h | 1 +
>> slirp/slirp.c | 3 +++
>> slirp/tcp_subr.c | 7 +++++--
>> 3 files changed, 9 insertions(+), 2 deletions(-)
>>
>> 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 @@
>>
>> /* host loopback address */
>> struct in_addr loopback_addr;
>> +/* host loopback network mask */
>> +in_addr_t loopback_mask;
>>
>> /* emulated hosts use the MAC addr 52:55:IP:IP:IP:IP */
>> static const uint8_t special_ethaddr[ETH_ALEN] = {
>> @@ -191,6 +193,7 @@ static void slirp_init_once(void)
>> #endif
>>
>> loopback_addr.s_addr = htonl(INADDR_LOOPBACK);
>> + loopback_mask = htonl(IN_CLASSA_NET);
>> }
>>
>> 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 = addr.sin_port;
>> so->so_faddr = addr.sin_addr;
>> /* Translate connections from localhost to the real hostname */
>> - if (so->so_faddr.s_addr == 0 || so->so_faddr.s_addr == loopback_addr.s_addr)
>> - so->so_faddr = slirp->vhost_addr;
>> + if (so->so_faddr.s_addr == 0 ||
>> + (so->so_faddr.s_addr & loopback_mask) ==
>> + (loopback_addr.s_addr & loopback_mask)) {
>> + so->so_faddr = 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.
Ah, found the test case: binding the host-side initiator of the
connection to some other localhost address provides a before-after effect.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
prev parent reply other threads:[~2012-07-14 8:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-12 12:12 [Qemu-devel] [PATCH] slirp: Handle whole 127.0.0.0/8 network as local addresses Anders Waldenborg
2012-07-05 23:35 ` Jan Kiszka
2012-07-13 10:37 ` [Qemu-devel] [PATCH v2] " Anders Waldenborg
2012-07-13 15:01 ` Blue Swirl
2012-07-13 20:54 ` [Qemu-devel] [PATCH v3] " Anders Waldenborg
2012-07-14 8:00 ` Jan Kiszka
2012-07-14 8:07 ` Jan Kiszka [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=500128AC.4090202@web.de \
--to=jan.kiszka@web.de \
--cc=anders@0x63.nu \
--cc=blauwirbel@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).