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: [EMAIL PROTECTED]

Jason.
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;
_______________________________________________
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel

Reply via email to