Blame qemu-slirp-Fix-guestfwd-for-incoming-data.patch

Mark McLoughlin 661451
From 57ab33ece875e62e47d09e52bcd0d9d108594729 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
Mark McLoughlin 661451
(cherry picked from commit bb53fc5394201c0cbe3c89a1c9fa5fbd6a3b832c)
Mark McLoughlin 661451
Glauber Costa 5e6fc5
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Glauber Costa 5e6fc5
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Mark McLoughlin 661451
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Mark McLoughlin 661451
Fedora-patch: qemu-slirp-Fix-guestfwd-for-incoming-data.patch
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
Mark McLoughlin a4e945
index a34f1d3..7e1edf6 100644
Glauber Costa 5e6fc5
--- a/net.c
Glauber Costa 5e6fc5
+++ b/net.c
Mark McLoughlin a4e945
@@ -1170,7 +1170,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
     }
Mark McLoughlin a4e945
@@ -1259,16 +1259,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
-- 
Mark McLoughlin a4e945
1.6.2.5
Glauber Costa 5e6fc5