提交 22d48de6 编写于 作者: A Anthony Liguori

Merge remote-tracking branch 'kiszka/queues/slirp' into staging

* kiszka/queues/slirp:
  slirp: Handle whole 127.0.0.0/8 network as local addresses.
...@@ -31,6 +31,7 @@ extern char *exec_shell; ...@@ -31,6 +31,7 @@ extern char *exec_shell;
extern u_int curtime; extern u_int curtime;
extern fd_set *global_readfds, *global_writefds, *global_xfds; extern fd_set *global_readfds, *global_writefds, *global_xfds;
extern struct in_addr loopback_addr; extern struct in_addr loopback_addr;
extern in_addr_t loopback_mask;
extern char *username; extern char *username;
extern char *socket_path; extern char *socket_path;
extern int towrite_max; extern int towrite_max;
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
/* host loopback address */ /* host loopback address */
struct in_addr loopback_addr; 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 */ /* emulated hosts use the MAC addr 52:55:IP:IP:IP:IP */
static const uint8_t special_ethaddr[ETH_ALEN] = { static const uint8_t special_ethaddr[ETH_ALEN] = {
...@@ -191,6 +193,7 @@ static void slirp_init_once(void) ...@@ -191,6 +193,7 @@ static void slirp_init_once(void)
#endif #endif
loopback_addr.s_addr = htonl(INADDR_LOOPBACK); loopback_addr.s_addr = htonl(INADDR_LOOPBACK);
loopback_mask = htonl(IN_CLASSA_NET);
} }
static void slirp_state_save(QEMUFile *f, void *opaque); static void slirp_state_save(QEMUFile *f, void *opaque);
......
...@@ -435,8 +435,11 @@ tcp_connect(struct socket *inso) ...@@ -435,8 +435,11 @@ tcp_connect(struct socket *inso)
so->so_fport = addr.sin_port; so->so_fport = addr.sin_port;
so->so_faddr = addr.sin_addr; so->so_faddr = addr.sin_addr;
/* Translate connections from localhost to the real hostname */ /* Translate connections from localhost to the real hostname */
if (so->so_faddr.s_addr == 0 || so->so_faddr.s_addr == loopback_addr.s_addr) if (so->so_faddr.s_addr == 0 ||
so->so_faddr = slirp->vhost_addr; (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 */ /* Close the accept() socket, set right state */
if (inso->so_state & SS_FACCEPTONCE) { if (inso->so_state & SS_FACCEPTONCE) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册