From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FiDGD-00019w-0y for qemu-devel@nongnu.org; Mon, 22 May 2006 12:28:01 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FiDGB-00019g-Bd for qemu-devel@nongnu.org; Mon, 22 May 2006 12:28:00 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FiDGB-00019d-4c for qemu-devel@nongnu.org; Mon, 22 May 2006 12:27:59 -0400 Received: from [147.11.1.11] (helo=mail.wrs.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FiDKC-0008TW-Er for qemu-devel@nongnu.org; Mon, 22 May 2006 12:32:08 -0400 Received: from ALA-MAIL03.corp.ad.wrs.com (ala-mail03 [147.11.57.144]) by mail.wrs.com (8.13.6/8.13.3) with ESMTP id k4MGRulb023692 for ; Mon, 22 May 2006 09:27:56 -0700 (PDT) Message-ID: <4471E68C.1020001@windriver.com> Date: Mon, 22 May 2006 11:27:56 -0500 From: Jason Wessel MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030409080803050503030304" Subject: [Qemu-devel] [PATCH] Fix udp slirp to always set from address and port 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 This is a multi-part message in MIME format. --------------030409080803050503030304 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Attached is a patch to always set the from address and port when using slirp "-net user" type networking. It fixes the case so that the target can boot from udp NFS as well as the case where different instances of an application over time go through the same redirection port with different source ports or addresses. A possible approach for the future if advanced use cases are required is to allow specification of 3 different categories of redirection access. 1) Dynamic port and address (the default with this patch) 2) Dynamic port with static address 3) Dynamic address with static port 4) static port and address The last 3 would mainly be for security type options if you wanted to restrict things. Items 2-4 can go into a ToDo list somewhere. signed-off-by: jason.wessel@windriver.com Jason. --------------030409080803050503030304 Content-Type: text/plain; name="always_set_udp_faddr.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="always_set_udp_faddr.patch" Index: qemu/slirp/udp.c =================================================================== --- qemu.orig/slirp/udp.c +++ qemu/slirp/udp.c @@ -205,8 +205,6 @@ udp_input(m, iphlen) /* udp_last_so = so; */ so->so_laddr = ip->ip_src; so->so_lport = uh->uh_sport; - so->so_faddr = ip->ip_dst; /* XXX */ - so->so_fport = uh->uh_dport; /* XXX */ if ((so->so_iptos = udp_tos(so)) == 0) so->so_iptos = ip->ip_tos; @@ -216,6 +214,13 @@ udp_input(m, iphlen) * and if it is, do the fork_exec() etc. */ } + /* Always reset the from address as it can change, + * as with NFS for example where it will talk to + * the same destination port with multiple source + * addresses. Or different gdb session to kgdboe. + */ + so->so_faddr = ip->ip_dst; /* XXX */ + so->so_fport = uh->uh_dport; /* XXX */ iphlen += sizeof(struct udphdr); m->m_len -= iphlen; --------------030409080803050503030304--