patch-2.4.2 linux/net/ipv4/udp.c

Next file: linux/net/ipv6/addrconf.c
Previous file: linux/net/ipv4/tcp_timer.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.1/linux/net/ipv4/udp.c linux/net/ipv4/udp.c
@@ -69,31 +69,9 @@
  *		2 of the License, or (at your option) any later version.
  */
  
-/* RFC1122 Status:
-   4.1.3.1 (Ports):
-     SHOULD send ICMP_PORT_UNREACHABLE in response to datagrams to 
-       an un-listened port. (OK)
-   4.1.3.2 (IP Options)
-     MUST pass IP options from IP -> application (OK)
-     MUST allow application to specify IP options (OK)
-   4.1.3.3 (ICMP Messages)
-     MUST pass ICMP error messages to application (OK -- except when SO_BSDCOMPAT is set)
-   4.1.3.4 (UDP Checksums)
-     MUST provide facility for checksumming (OK)
-     MAY allow application to control checksumming (OK)
-     MUST default to checksumming on (OK)
-     MUST discard silently datagrams with bad csums (OK, except during debugging)
-   4.1.3.5 (UDP Multihoming)
-     MUST allow application to specify source address (OK)
-     SHOULD be able to communicate the chosen src addr up to application
-       when application doesn't choose (DOES - use recvmsg cmsgs)
-   4.1.3.6 (Invalid Addresses)
-     MUST discard invalid source addresses (OK -- done in the new routing code)
-     MUST only send datagrams with one of our addresses (OK)
-*/
-
 #include <asm/system.h>
 #include <asm/uaccess.h>
+#include <asm/ioctls.h>
 #include <linux/types.h>
 #include <linux/fcntl.h>
 #include <linux/socket.h>
@@ -161,7 +139,7 @@
 		next:;
 		}
 		result = best;
-		for(;; result += UDP_HTABLE_SIZE) {
+		for(i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++, result += UDP_HTABLE_SIZE) {
 			if (result > sysctl_local_port_range[1])
 				result = sysctl_local_port_range[0]
 					+ ((result - sysctl_local_port_range[0]) &
@@ -169,6 +147,8 @@
 			if (!udp_lport_inuse(result))
 				break;
 		}
+		if (i >= (1 << 16) / UDP_HTABLE_SIZE)
+			goto fail;
 gotit:
 		udp_port_rover = snum = result;
 	} else {

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)