From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JjoIp-0003ct-Aj for qemu-devel@nongnu.org; Thu, 10 Apr 2008 00:22:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JjoIo-0003bD-7A for qemu-devel@nongnu.org; Thu, 10 Apr 2008 00:22:22 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JjoIn-0003am-9q for qemu-devel@nongnu.org; Thu, 10 Apr 2008 00:22:21 -0400 Received: from mail.windriver.com ([147.11.1.11] helo=mail.wrs.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JjoIm-0003rz-OG for qemu-devel@nongnu.org; Thu, 10 Apr 2008 00:22:21 -0400 Received: from ALA-MAIL03.corp.ad.wrs.com (ala-mail03 [147.11.57.144]) by mail.wrs.com (8.13.6/8.13.6) with ESMTP id m3A4MHZD013371 for ; Wed, 9 Apr 2008 21:22:18 -0700 (PDT) From: Jason Wessel Date: Wed, 9 Apr 2008 23:22:22 -0500 Message-Id: <1207801343-15955-2-git-send-email-jason.wessel@windriver.com> In-Reply-To: <1207801343-15955-1-git-send-email-jason.wessel@windriver.com> References: <1207801343-15955-1-git-send-email-jason.wessel@windriver.com> Subject: [Qemu-devel] [PATCH 1/2] Fix slirp udp source address contamination Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org When using slirp the "special address" translation should only be used when the source address is the loopback, else the udp packets show up with the wrong source address and cannot be routed back to the original source by applications running inside the QEMU instance. The problem can be observed by using kgdboe from inside QEMU where you add a port redirection with slirp networking such as "-redir udp:4445::6443". Using a second host or connecting gdb to the IP address address of the host that the QEMU instance is running on instead of using the loopback address will fail because the source address will get translated when it goes through the redirection. With the patch, you can connect to kgdboe via the loopback on port 4445 or from another host. Signed-off-by: Jason Wessel --- slirp/udp.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/slirp/udp.c b/slirp/udp.c index c48923b..0dd7da6 100644 --- a/slirp/udp.c +++ b/slirp/udp.c @@ -318,7 +318,8 @@ int udp_output(struct socket *so, struct mbuf *m, struct sockaddr_in saddr, daddr; saddr = *addr; - if ((so->so_faddr.s_addr & htonl(0xffffff00)) == special_addr.s_addr) { + if ((so->so_faddr.s_addr & htonl(0xffffff00)) == special_addr.s_addr && + addr->sin_addr.s_addr == htonl(0x7f000001)) { saddr.sin_addr.s_addr = so->so_faddr.s_addr; if ((so->so_faddr.s_addr & htonl(0x000000ff)) == htonl(0xff)) saddr.sin_addr.s_addr = alias_addr.s_addr; -- 1.5.4