--- linux/include/linux/sysctl.h.udpmasq	Wed Jan  5 07:12:25 2000
+++ linux/include/linux/sysctl.h	Mon Apr  3 14:53:36 2000
@@ -227,7 +227,8 @@
 	NET_IPV4_ICMP_ECHOREPLY_RATE=63,
 	NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES=64,
 	NET_IPV4_IGMP_MAX_MEMBERSHIPS=65,
-	NET_IPV4_ALWAYS_DEFRAG=67
+	NET_IPV4_ALWAYS_DEFRAG=67,
+	NET_IPV4_IP_MASQ_UDP_DLOOSE=68
 };
 
 enum {
--- linux/net/ipv4/sysctl_net_ipv4.c.udpmasq	Wed Oct 27 13:53:42 1999
+++ linux/net/ipv4/sysctl_net_ipv4.c	Mon Apr  3 19:19:22 2000
@@ -46,6 +46,7 @@
 
 /* From ip_masq.c */
 extern int sysctl_ip_masq_debug;
+extern int sysctl_ip_masq_udp_dloose;
 
 extern int sysctl_tcp_timestamps;
 extern int sysctl_tcp_window_scaling;
@@ -149,6 +150,8 @@
 #ifdef CONFIG_IP_MASQUERADE
 	{NET_IPV4_IP_MASQ_DEBUG, "ip_masq_debug",
 	 &sysctl_ip_masq_debug, sizeof(int), 0644, NULL, &proc_dointvec},
+	{NET_IPV4_IP_MASQ_UDP_DLOOSE, "ip_masq_udp_dloose",
+	 &sysctl_ip_masq_udp_dloose, sizeof(int), 0644, NULL, &proc_dointvec},
 #endif
 	{NET_IPV4_IPFRAG_TIME, "ipfrag_time",
 	 &sysctl_ipfrag_time, sizeof(int), 0644, NULL, &proc_dointvec_jiffies, 
--- linux/net/ipv4/ip_masq.c.udpmasq	Mon Apr  3 11:20:35 2000
+++ linux/net/ipv4/ip_masq.c	Tue Apr  4 10:34:42 2000
@@ -74,6 +74,7 @@
 #include <net/tcp.h>
 #include <net/udp.h>
 #include <net/checksum.h>
+#include <net/sock.h>
 #include <net/ip_masq.h>
 
 #ifdef CONFIG_IP_MASQUERADE_MOD
@@ -85,6 +86,7 @@
 #include <linux/ip_masq.h>
 
 int sysctl_ip_masq_debug = 0;
+int sysctl_ip_masq_udp_dloose = 0;
 
 /*
  *	Exported wrapper 
@@ -930,17 +932,29 @@
 	atomic_set(&ms->n_control,0);
 	atomic_set(&ms->refcnt,0);
 
-        if (proto == IPPROTO_UDP && !mport)
-#ifdef CONFIG_IP_MASQUERADE_UDP_LOOSE
-		/*
-		 *	Flag this tunnel as "dest loose"
-		 *	
-		 */
-		ms->flags |= IP_MASQ_F_DLOOSE;
-#else
-                ms->flags |= IP_MASQ_F_NO_DADDR;
-#endif
+        if (proto == IPPROTO_UDP && !mport) {
 
+		switch( sysctl_ip_masq_udp_dloose ) {
+		case 2:
+			/*
+		 	*	Flag this tunnel as "dest loose"
+		 	*	
+		 	*/
+			ms->flags |= IP_MASQ_F_DLOOSE;
+			break;
+		case 1:
+			if( ntohs(sport) < PROT_SOCK ) {
+				ms->flags |= IP_MASQ_F_NO_DADDR;
+			}
+			else {
+				ms->flags |= IP_MASQ_F_DLOOSE;
+			}
+			break;
+		default:
+			ms->flags |= IP_MASQ_F_NO_DADDR;
+			break;
+		}
+	}
         
         /* get masq address from rif */
         ms->maddr	   = maddr;
