diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2012-08-06 13:59:59 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-08-06 13:59:59 -0500 |
commit | 22d48de65c88c42e3cb2b000491dc6089a240e2a (patch) | |
tree | 41876ecb213a7f0a7dba600a24f662ab397dd0fe | |
parent | f777501cc9e8f3a91da076e937b5565510eb4420 (diff) | |
parent | 648cd33e73cbbbf19e278101e6a9e071cb154c05 (diff) | |
download | hqemu-22d48de65c88c42e3cb2b000491dc6089a240e2a.zip hqemu-22d48de65c88c42e3cb2b000491dc6089a240e2a.tar.gz |
Merge remote-tracking branch 'kiszka/queues/slirp' into staging
* kiszka/queues/slirp:
slirp: Handle whole 127.0.0.0/8 network as local addresses.
-rw-r--r-- | slirp/main.h | 1 | ||||
-rw-r--r-- | slirp/slirp.c | 3 | ||||
-rw-r--r-- | 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..025b374 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; + } /* Close the accept() socket, set right state */ if (inso->so_state & SS_FACCEPTONCE) { |