qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH]: UDP-broadcast address-translation error in slirp c


From: Mark Jonckheere
Subject: [Qemu-devel] [PATCH]: UDP-broadcast address-translation error in slirp code.
Date: Tue, 02 May 2006 12:26:27 -0000
User-agent: Mozilla Thunderbird 1.0.7-1.4.1.centos4 (X11/20051007)

Fabrice, Paul,

There has been a lot of changes in the slirp code this last week,
so I'll try once again to submit my UDP broadcast patch. Note, the
patch has been modified from previous submissions: this time I do
only a check for a broadcast address, when the address has been
replaced with our special address.

Description of the problem:

   guest         host
   -----         ----
10.0.2.15 --> 10.0.2.255  # guest sends broadcast packet
10.0.2.15 <-- 10.0.2.255  # host sends reply with invalid source
                          # address, packet is ignored by guest

This should be:

   guest         host
   -----         ----
10.0.2.15 --> 10.0.2.255  # guest sends broadcast packet
10.0.2.15 <-- 10.0.2.2    # host replies with his own address.


Packets with destination address 10.0.2.255 (IP-broadcast) from the
guest to the host are replied by the slirp code with this broadcast
address as source address where it should be the host IP-address
(CTL_ALIAS), since CTL_CMD and CLT_EXEC are not used and CTL_DNS is
excluded because it doesn't make sense to do a broadcast DNS lookup.

Correcting this bug makes it possible for e.g. a Windows 98 guest to
browse the network neigbourhoud and see the share that is published
by the host with the -smb switch.

Greetings,
Mark.
diff -wurb qemu/slirp/udp.c qemu-patched/slirp/udp.c
--- qemu/slirp/udp.c    2005-07-03 19:08:43.000000000 +0200
+++ qemu-patched/slirp/udp.c    2006-05-02 12:19:22.000000000 +0200
@@ -312,8 +312,11 @@
     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) {
         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 = special_addr.s_addr | htonl(CTL_ALIAS);
+    }
     daddr.sin_addr = so->so_laddr;
     daddr.sin_port = so->so_lport;
     

reply via email to

[Prev in Thread] Current Thread [Next in Thread]