patch-2.2.15 linux/net/ipv4/ip_masq.c

Next file: linux/net/ipv4/ip_masq_ftp.c
Previous file: linux/net/ipv4/devinet.c
Back to the patch index
Back to the overall index

diff -u --new-file --recursive --exclude-from ../../exclude v2.2.14/net/ipv4/ip_masq.c linux/net/ipv4/ip_masq.c
@@ -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 
@@ -412,12 +414,6 @@
 #define MASQ_DPORT_PASS	(IP_MASQ_F_NO_DPORT|IP_MASQ_F_DLOOSE)
 
 /*
- *	By default enable dest loose semantics
- */
-#define CONFIG_IP_MASQ_LOOSE_DEFAULT 1
-
-
-/*
  * 	Set masq expiration (deletion) and adds timer,
  *	if timeout==0 cancel expiration.
  *	Warning: it does not check/delete previous timer!
@@ -936,17 +932,29 @@
 	atomic_set(&ms->n_control,0);
 	atomic_set(&ms->refcnt,0);
 
-        if (proto == IPPROTO_UDP && !mport)
-#ifdef CONFIG_IP_MASQ_LOOSE_DEFAULT
-		/*
-		 *	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;

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