Skip to contentSkip to conversation

: UDP-broadcast address-translation error in slirp code.

PATCH New Mark Jonckheere 1 participant 1 message May 2, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : UDP-broadcast address-translation error in slirp code.

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.

slirp/udp.c +4 -1
diff -wurb qemu/slirp/udp.c qemu-patched/slirp/udp.c
@@ -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;