From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JqSoO-00057I-Ml for qemu-devel@nongnu.org; Mon, 28 Apr 2008 08:50:28 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JqSoN-000573-QA for qemu-devel@nongnu.org; Mon, 28 Apr 2008 08:50:28 -0400 Received: from [199.232.76.173] (port=42568 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JqSoN-000570-M4 for qemu-devel@nongnu.org; Mon, 28 Apr 2008 08:50:27 -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 1JqSoN-0005jV-7G for qemu-devel@nongnu.org; Mon, 28 Apr 2008 08:50:27 -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 m3SCoMQO024449 for ; Mon, 28 Apr 2008 05:50:24 -0700 (PDT) Message-ID: <4815C80E.1020104@windriver.com> Date: Mon, 28 Apr 2008 07:50:22 -0500 From: Jason Wessel MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Fix regression against commit 4259 References: <48139F0A.6090706@windriver.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 andrzej zaborowski wrote: > Hi, > > On 26/04/2008, Jason Wessel wrote: >> Stuart Brady found a regression based on the 4259 commit where >> DNS via slirp to the special address does not work properly. >> >> I verified that DNS to the default special address 10.0.2.3 does not >> work. When using the "special address" for DNS it must be treated as >> a special case. In the original 4259, I did not have a test case for >> the loopback DNS. The translation logic should be used in this case >> as well as for any loopback directed requests. > > Thanks for the fix, I committed it with a tiny change but I'm not sure > if the special case shouldn't be CTL_ALIAS, i.e. the condition would > be: > > else if (addr->sin_addr.s_addr == loopback_addr.s_addr || > (ntohl(so->so_faddr.s_addr) & 0xff) != CTL_ALIAS) It would seem reasonable to implement it this way. > > and perhaps this shouldn't be for udp only? It is already udp only because we are in the udp.c :-) > Also, in > ((so->so_faddr.s_addr & htonl(CTL_DNS)) == htonl(CTL_DNS)), masking > with htonl(CTL_DNS) is probably not what we want. > I would certainly agree with you here, while it works, it is less efficient and not exactly what we want. I retested all the different cases with the patch you recommended (see below) and all the test cases pass. Thanks, Jason. #### CLIP HERE #### Signed-off-by: Jason Wessel --- slirp/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/slirp/udp.c +++ b/slirp/udp.c @@ -322,7 +322,7 @@ int udp_output(struct socket *so, struct if ((so->so_faddr.s_addr & htonl(0x000000ff)) == htonl(0xff)) saddr.sin_addr.s_addr = alias_addr.s_addr; else if (addr->sin_addr.s_addr == loopback_addr.s_addr || - ((so->so_faddr.s_addr & htonl(CTL_DNS)) == htonl(CTL_DNS))) + (ntohl(so->so_faddr.s_addr) & 0xff) != CTL_ALIAS) saddr.sin_addr.s_addr = so->so_faddr.s_addr; } daddr.sin_addr = so->so_laddr;