|
Glauber Costa |
5e6fc5 |
From b0dc78730e54bd3ef96f56466890aa2509a328c3 Mon Sep 17 00:00:00 2001
|
|
Glauber Costa |
5e6fc5 |
From: Jan Kiszka <jan.kiszka@siemens.com>
|
|
Glauber Costa |
5e6fc5 |
Date: Wed, 22 Jul 2009 17:03:52 +0200
|
|
Glauber Costa |
5e6fc5 |
Subject: [PATCH] slirp: Fix guestfwd for incoming data
|
|
Glauber Costa |
5e6fc5 |
|
|
Glauber Costa |
5e6fc5 |
Unless a virtual server address was explicitly defined (which is
|
|
Glauber Costa |
5e6fc5 |
impossible with the legacy -net channel format), guestfwd did not
|
|
Glauber Costa |
5e6fc5 |
properly forwarded host->guest packets. This patch fixes it.
|
|
Glauber Costa |
5e6fc5 |
|
|
Glauber Costa |
5e6fc5 |
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
|
|
Glauber Costa |
5e6fc5 |
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
|
|
Glauber Costa |
5e6fc5 |
---
|
|
Glauber Costa |
5e6fc5 |
net.c | 11 ++++++-----
|
|
Glauber Costa |
5e6fc5 |
slirp/libslirp.h | 2 +-
|
|
Glauber Costa |
5e6fc5 |
slirp/slirp.c | 14 +++++++-------
|
|
Glauber Costa |
5e6fc5 |
3 files changed, 14 insertions(+), 13 deletions(-)
|
|
Glauber Costa |
5e6fc5 |
|
|
Glauber Costa |
5e6fc5 |
diff --git a/net.c b/net.c
|
|
Glauber Costa |
5e6fc5 |
index 90cf912..1c2c7d0 100644
|
|
Glauber Costa |
5e6fc5 |
--- a/net.c
|
|
Glauber Costa |
5e6fc5 |
+++ b/net.c
|
|
Glauber Costa |
5e6fc5 |
@@ -1150,7 +1150,7 @@ static void slirp_smb(SlirpState* s, Monitor *mon, const char *exported_dir,
|
|
Glauber Costa |
5e6fc5 |
snprintf(smb_cmdline, sizeof(smb_cmdline), "%s -s %s",
|
|
Glauber Costa |
5e6fc5 |
SMBD_COMMAND, smb_conf);
|
|
Glauber Costa |
5e6fc5 |
|
|
Glauber Costa |
5e6fc5 |
- if (slirp_add_exec(s->slirp, 0, smb_cmdline, vserver_addr, 139) < 0) {
|
|
Glauber Costa |
5e6fc5 |
+ if (slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 139) < 0) {
|
|
Glauber Costa |
5e6fc5 |
slirp_smb_cleanup(s);
|
|
Glauber Costa |
5e6fc5 |
config_error(mon, "conflicting/invalid smbserver address\n");
|
|
Glauber Costa |
5e6fc5 |
}
|
|
Glauber Costa |
5e6fc5 |
@@ -1239,16 +1239,17 @@ static void slirp_guestfwd(SlirpState *s, Monitor *mon, const char *config_str,
|
|
Glauber Costa |
5e6fc5 |
qemu_free(fwd);
|
|
Glauber Costa |
5e6fc5 |
return;
|
|
Glauber Costa |
5e6fc5 |
}
|
|
Glauber Costa |
5e6fc5 |
- fwd->server = server;
|
|
Glauber Costa |
5e6fc5 |
- fwd->port = port;
|
|
Glauber Costa |
5e6fc5 |
- fwd->slirp = s->slirp;
|
|
Glauber Costa |
5e6fc5 |
|
|
Glauber Costa |
5e6fc5 |
- if (slirp_add_exec(s->slirp, 3, fwd->hd, server, port) < 0) {
|
|
Glauber Costa |
5e6fc5 |
+ if (slirp_add_exec(s->slirp, 3, fwd->hd, &server, port) < 0) {
|
|
Glauber Costa |
5e6fc5 |
config_error(mon, "conflicting/invalid host:port in guest forwarding "
|
|
Glauber Costa |
5e6fc5 |
"rule '%s'\n", config_str);
|
|
Glauber Costa |
5e6fc5 |
qemu_free(fwd);
|
|
Glauber Costa |
5e6fc5 |
return;
|
|
Glauber Costa |
5e6fc5 |
}
|
|
Glauber Costa |
5e6fc5 |
+ fwd->server = server;
|
|
Glauber Costa |
5e6fc5 |
+ fwd->port = port;
|
|
Glauber Costa |
5e6fc5 |
+ fwd->slirp = s->slirp;
|
|
Glauber Costa |
5e6fc5 |
+
|
|
Glauber Costa |
5e6fc5 |
qemu_chr_add_handlers(fwd->hd, guestfwd_can_read, guestfwd_read,
|
|
Glauber Costa |
5e6fc5 |
NULL, fwd);
|
|
Glauber Costa |
5e6fc5 |
return;
|
|
Glauber Costa |
5e6fc5 |
diff --git a/slirp/libslirp.h b/slirp/libslirp.h
|
|
Glauber Costa |
5e6fc5 |
index 3bcc392..93087ed 100644
|
|
Glauber Costa |
5e6fc5 |
--- a/slirp/libslirp.h
|
|
Glauber Costa |
5e6fc5 |
+++ b/slirp/libslirp.h
|
|
Glauber Costa |
5e6fc5 |
@@ -33,7 +33,7 @@ int slirp_add_hostfwd(Slirp *slirp, int is_udp,
|
|
Glauber Costa |
5e6fc5 |
int slirp_remove_hostfwd(Slirp *slirp, int is_udp,
|
|
Glauber Costa |
5e6fc5 |
struct in_addr host_addr, int host_port);
|
|
Glauber Costa |
5e6fc5 |
int slirp_add_exec(Slirp *slirp, int do_pty, const void *args,
|
|
Glauber Costa |
5e6fc5 |
- struct in_addr guest_addr, int guest_port);
|
|
Glauber Costa |
5e6fc5 |
+ struct in_addr *guest_addr, int guest_port);
|
|
Glauber Costa |
5e6fc5 |
|
|
Glauber Costa |
5e6fc5 |
void slirp_connection_info(Slirp *slirp, Monitor *mon);
|
|
Glauber Costa |
5e6fc5 |
|
|
Glauber Costa |
5e6fc5 |
diff --git a/slirp/slirp.c b/slirp/slirp.c
|
|
Glauber Costa |
5e6fc5 |
index 0ce62a3..9be8553 100644
|
|
Glauber Costa |
5e6fc5 |
--- a/slirp/slirp.c
|
|
Glauber Costa |
5e6fc5 |
+++ b/slirp/slirp.c
|
|
Glauber Costa |
5e6fc5 |
@@ -794,19 +794,19 @@ int slirp_add_hostfwd(Slirp *slirp, int is_udp, struct in_addr host_addr,
|
|
Glauber Costa |
5e6fc5 |
}
|
|
Glauber Costa |
5e6fc5 |
|
|
Glauber Costa |
5e6fc5 |
int slirp_add_exec(Slirp *slirp, int do_pty, const void *args,
|
|
Glauber Costa |
5e6fc5 |
- struct in_addr guest_addr, int guest_port)
|
|
Glauber Costa |
5e6fc5 |
+ struct in_addr *guest_addr, int guest_port)
|
|
Glauber Costa |
5e6fc5 |
{
|
|
Glauber Costa |
5e6fc5 |
- if (!guest_addr.s_addr) {
|
|
Glauber Costa |
5e6fc5 |
- guest_addr.s_addr = slirp->vnetwork_addr.s_addr |
|
|
Glauber Costa |
5e6fc5 |
+ if (!guest_addr->s_addr) {
|
|
Glauber Costa |
5e6fc5 |
+ guest_addr->s_addr = slirp->vnetwork_addr.s_addr |
|
|
Glauber Costa |
5e6fc5 |
(htonl(0x0204) & ~slirp->vnetwork_mask.s_addr);
|
|
Glauber Costa |
5e6fc5 |
}
|
|
Glauber Costa |
5e6fc5 |
- if ((guest_addr.s_addr & slirp->vnetwork_mask.s_addr) !=
|
|
Glauber Costa |
5e6fc5 |
+ if ((guest_addr->s_addr & slirp->vnetwork_mask.s_addr) !=
|
|
Glauber Costa |
5e6fc5 |
slirp->vnetwork_addr.s_addr ||
|
|
Glauber Costa |
5e6fc5 |
- guest_addr.s_addr == slirp->vhost_addr.s_addr ||
|
|
Glauber Costa |
5e6fc5 |
- guest_addr.s_addr == slirp->vnameserver_addr.s_addr) {
|
|
Glauber Costa |
5e6fc5 |
+ guest_addr->s_addr == slirp->vhost_addr.s_addr ||
|
|
Glauber Costa |
5e6fc5 |
+ guest_addr->s_addr == slirp->vnameserver_addr.s_addr) {
|
|
Glauber Costa |
5e6fc5 |
return -1;
|
|
Glauber Costa |
5e6fc5 |
}
|
|
Glauber Costa |
5e6fc5 |
- return add_exec(&slirp->exec_list, do_pty, (char *)args, guest_addr,
|
|
Glauber Costa |
5e6fc5 |
+ return add_exec(&slirp->exec_list, do_pty, (char *)args, *guest_addr,
|
|
Glauber Costa |
5e6fc5 |
htons(guest_port));
|
|
Glauber Costa |
5e6fc5 |
}
|
|
Glauber Costa |
5e6fc5 |
|
|
Glauber Costa |
5e6fc5 |
--
|
|
Glauber Costa |
5e6fc5 |
1.6.2.2
|
|
Glauber Costa |
5e6fc5 |
|