From: Jason Wessel <jason.wessel@windriver.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/2] Fix slirp udp source address contamination
Date: Wed, 9 Apr 2008 23:22:22 -0500 [thread overview]
Message-ID: <1207801343-15955-2-git-send-email-jason.wessel@windriver.com> (raw)
In-Reply-To: <1207801343-15955-1-git-send-email-jason.wessel@windriver.com>
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 <jason.wessel@windriver.com>
---
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
next prev parent reply other threads:[~2008-04-10 4:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-10 4:22 [Qemu-devel] [PATCH 0/2] slirp udp fixes Jason Wessel
2008-04-10 4:22 ` Jason Wessel [this message]
2008-04-10 4:22 ` [Qemu-devel] [PATCH 2/2] Fix slirp mac address init Jason Wessel
2008-04-12 12:44 ` Aurelien Jarno
2008-04-12 14:21 ` Jason Wessel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1207801343-15955-2-git-send-email-jason.wessel@windriver.com \
--to=jason.wessel@windriver.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).