[netfilter-cvslog] r3753 - in trunk/patch-o-matic-ng/mms-conntrack-nat: . linux-2.6.11 linux-2.6.11/net/ipv4/netfilter

laforge at netfilter.org laforge at netfilter.org
Wed Mar 2 13:00:01 CET 2005


Author: laforge at netfilter.org
Date: 2005-03-02 13:00:00 +0100 (Wed, 02 Mar 2005)
New Revision: 3753

Added:
   trunk/patch-o-matic-ng/mms-conntrack-nat/linux-2.6.11/
Removed:
   trunk/patch-o-matic-ng/mms-conntrack-nat/linux-2.6.11/Documentation/
   trunk/patch-o-matic-ng/mms-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/Config.in.ladd
   trunk/patch-o-matic-ng/mms-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/Config.in.ladd_2
Modified:
   trunk/patch-o-matic-ng/mms-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/ip_conntrack_mms.c
   trunk/patch-o-matic-ng/mms-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/ip_nat_mms.c
Log:
add incomplete 2.6.11 branch


Copied: trunk/patch-o-matic-ng/mms-conntrack-nat/linux-2.6.11 (from rev 3749, trunk/patch-o-matic-ng/mms-conntrack-nat/linux)

Deleted: trunk/patch-o-matic-ng/mms-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/Config.in.ladd
===================================================================
--- trunk/patch-o-matic-ng/mms-conntrack-nat/linux/net/ipv4/netfilter/Config.in.ladd	2005-03-01 20:30:53 UTC (rev 3749)
+++ trunk/patch-o-matic-ng/mms-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/Config.in.ladd	2005-03-02 12:00:00 UTC (rev 3753)
@@ -1,8 +0,0 @@
-          define_tristate CONFIG_IP_NF_NAT_IRC $CONFIG_IP_NF_NAT
-        fi
-      fi
-      if [ "$CONFIG_IP_NF_MMS" = "m" ]; then
-        define_tristate CONFIG_IP_NF_NAT_MMS m
-      else
-        if [ "$CONFIG_IP_NF_MMS" = "y" ]; then
-          define_tristate CONFIG_IP_NF_NAT_MMS $CONFIG_IP_NF_NAT

Deleted: trunk/patch-o-matic-ng/mms-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/Config.in.ladd_2
===================================================================
--- trunk/patch-o-matic-ng/mms-conntrack-nat/linux/net/ipv4/netfilter/Config.in.ladd_2	2005-03-01 20:30:53 UTC (rev 3749)
+++ trunk/patch-o-matic-ng/mms-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/Config.in.ladd_2	2005-03-02 12:00:00 UTC (rev 3753)
@@ -1,2 +0,0 @@
-  dep_tristate '  IRC protocol support' CONFIG_IP_NF_IRC $CONFIG_IP_NF_CONNTRACK
-  dep_tristate '  MMS protocol support' CONFIG_IP_NF_MMS $CONFIG_IP_NF_CONNTRACK

Modified: trunk/patch-o-matic-ng/mms-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/ip_conntrack_mms.c
===================================================================
--- trunk/patch-o-matic-ng/mms-conntrack-nat/linux/net/ipv4/netfilter/ip_conntrack_mms.c	2005-03-01 20:30:53 UTC (rev 3749)
+++ trunk/patch-o-matic-ng/mms-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/ip_conntrack_mms.c	2005-03-02 12:00:00 UTC (rev 3753)
@@ -21,6 +21,10 @@
  *
  *      The SDP project people are reverse-engineering MMS:
  *      http://get.to/sdp
+ *
+ *  2005-02-13: Harald Welte <laforge at netfilter.org>
+ *  	- port to 2.6.x
+ *  	- update to work with post 2.6.11 helper API changes
  */
 
 #include <linux/config.h>
@@ -35,24 +39,22 @@
 #include <linux/netfilter_ipv4/ip_conntrack_helper.h>
 #include <linux/netfilter_ipv4/ip_conntrack_mms.h>
 
-DECLARE_LOCK(ip_mms_lock);
-struct module *ip_conntrack_mms = THIS_MODULE;
 
 #define MAX_PORTS 8
 static int ports[MAX_PORTS];
 static int ports_c;
-#ifdef MODULE_PARM
-MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i");
-#endif
+module_param_array(ports, int, &ports_c, 0400);
+MODULE_PARM_DESC(ports, "port numbers of MMS");
 
+static char mms_buffer[65536];
+static DECLARE_LOCK(mms_buffer_lock);
+
 #if 0 
 #define DEBUGP printk
 #else
 #define DEBUGP(format, args...)
 #endif
 
-EXPORT_SYMBOL(ip_mms_lock);
-
 MODULE_AUTHOR("Filip Sneppe <filip.sneppe at cronos.be>");
 MODULE_DESCRIPTION("Microsoft Windows Media Services (MMS) connection tracking module");
 MODULE_LICENSE("GPL");
@@ -140,17 +142,22 @@
 
 
 /* FIXME: This should be in userspace.  Later. */
-static int help(const struct iphdr *iph, size_t len,
+static int help(struct sk_buff **pskb,
 		struct ip_conntrack *ct,
 		enum ip_conntrack_info ctinfo)
 {
-	/* tcplen not negative guaranteed by ip_conntrack_tcp.c */
-	struct tcphdr *tcph = (void *)iph + iph->ihl * 4;
+	int ret;
+	struct tcphdr _tcph, *th;
+	char *data;
+	unsigned int datalen;
+
+
+	//struct tcphdr *tcph = (void *)iph + iph->ihl * 4;
 	const char *data = (const char *)tcph + tcph->doff * 4;
-	unsigned int tcplen = len - iph->ihl * 4;
-	unsigned int datalen = tcplen - tcph->doff * 4;
+	//unsigned int tcplen = len - iph->ihl * 4;
+	//unsigned int datalen = tcplen - tcph->doff * 4;
 	int dir = CTINFO2DIR(ctinfo);
-	struct ip_conntrack_expect expect, *exp = &expect; 
+	struct ip_conntrack_expect *exp;
 	struct ip_ct_mms_expect *exp_mms_info = &exp->help.exp_mms_info;
 	
 	u_int32_t mms_ip;
@@ -167,11 +174,25 @@
 	}
 
 	/* Not whole TCP header? */
-	if (tcplen < sizeof(struct tcphdr) || tcplen < tcph->doff*4) {
-		DEBUGP("ip_conntrack_mms: tcplen = %u\n", (unsigned)tcplen);
+	th = skb_header_pointer(*pskb, (*pskb)->nh.iph->ihl*4,
+				sizeof(_tcph), &_tcph);
+	if (!th)
 		return NF_ACCEPT;
-	}
 
+	/* No data ? */
+	dataoff = (*pskb)->nh.iph->ihl*4 + th->doff*4;
+	datalen = (*pskb)->len - dataoff;
+	if (dataoff >= (*pskb)->len)
+		return NF_ACCEPT;
+
+	LOCK_BH(&mms_buffer_lock);
+	mb_ptr = skb_header_pointer(*pskb, dataoff,
+				    (*pskb)->len - dataoff, mms_buffer);
+	BUG_ON(mb_ptr == NULL);
+
+	data = mb_ptr;
+
+#if 0
 	/* Checksum invalid?  Ignore. */
 	/* FIXME: Source route IP option packets --RR */
 	if (tcp_v4_check(tcph, tcplen, iph->saddr, iph->daddr,
@@ -181,57 +202,69 @@
 		       NIPQUAD(iph->daddr));
 		return NF_ACCEPT;
 	}
+#endif
 	
-	/* Only look at packets with 0x00030002/196610 on bytes 36->39 of TCP payload */
-	/* FIXME: There is an issue with only looking at this packet: before this packet, 
-	   the client has already sent a packet to the server with the server's hostname 
-	   according to the client (think of it as the "Host: " header in HTTP/1.1). The 
-	   server will break the connection if this doesn't correspond to its own host 
-	   header. The client can also connect to an IP address; if it's the server's IP
-	   address, it will not break the connection. When doing DNAT on a connection 
-	   where the client uses a server's IP address, the nat module should detect
-	   this and change this string accordingly to the DNATed address. This should
-	   probably be done by checking for an IP address, then storing it as a member
-	   of struct ip_ct_mms_expect and checking for it in ip_nat_mms...
-	   */
-	if( (MMS_SRV_MSG_OFFSET < datalen) && 
+	/* Only look at packets with 0x00030002/196610 on bytes 36->39 of TCP
+	 * payload */
+
+	/* FIXME: There is an issue with only looking at this packet: before
+	 * this packet, the client has already sent a packet to the server with
+	 * the server's hostname according to the client (think of it as the
+	 * "Host: " header in HTTP/1.1). The server will break the connection
+	 * if this doesn't correspond to its own host header. The client can
+	 * also connect to an IP address; if it's the server's IP address, it
+	 * will not break the connection. When doing DNAT on a connection where
+	 * the client uses a server's IP address, the nat module should detect
+	 * this and change this string accordingly to the DNATed address. This
+	 * should probably be done by checking for an IP address, then storing
+	 * it as a member of struct ip_ct_mms_expect and checking for it in
+	 * ip_nat_mms...
+	 */
+	if ((MMS_SRV_MSG_OFFSET < datalen) && 
 	    ((*(u32 *)(data+MMS_SRV_MSG_OFFSET)) == MMS_SRV_MSG_ID)) {
 		DEBUGP("ip_conntrack_mms: offset 37: %u %u %u %u, datalen:%u\n", 
 		       (u8)*(data+36), (u8)*(data+37), 
 		       (u8)*(data+38), (u8)*(data+39),
 		       datalen);
-		if(parse_mms(data, datalen, &mms_ip, &mms_proto, &mms_port,
+		if (parse_mms(data, datalen, &mms_ip, &mms_proto, &mms_port,
 		             &mms_string_b, &mms_string_e, &mms_padding_e))
-			if(net_ratelimit())
+			if (net_ratelimit())
 				/* FIXME: more verbose debugging ? */
 				printk(KERN_WARNING
-				       "ip_conntrack_mms: Unable to parse data payload\n");
+				       "ip_conntrack_mms: Unable to parse "
+				       "data payload\n");
 
-		memset(&expect, 0, sizeof(expect));
-
 		sprintf(mms_proto_string, "(%u)", mms_proto);
-		DEBUGP("ip_conntrack_mms: adding %s expectation %u.%u.%u.%u -> %u.%u.%u.%u:%u\n",
+		DEBUGP("ip_conntrack_mms: adding %s expectation "
+		       "%u.%u.%u.%u -> %u.%u.%u.%u:%u\n",
 		       mms_proto == IPPROTO_TCP ? "TCP"
 		       : mms_proto == IPPROTO_UDP ? "UDP":mms_proto_string,
 		       NIPQUAD(ct->tuplehash[!dir].tuple.src.ip),
 		       NIPQUAD(mms_ip),
 		       mms_port);
 		
-		/* it's possible that the client will just ask the server to tunnel
-		   the stream over the same TCP session (from port 1755): there's 
-		   shouldn't be a need to add an expectation in that case, but it
-		   makes NAT packet mangling so much easier */
-		LOCK_BH(&ip_mms_lock);
+		/* it's possible that the client will just ask the server to
+		 * tunnel the stream over the same TCP session (from port
+		 * 1755): there's shouldn't be a need to add an expectation in
+		 * that case, but it makes NAT packet mangling so much easier
+		 * */
 
 		DEBUGP("ip_conntrack_mms: tcph->seq = %u\n", tcph->seq);
+
+		exp = ip_conntrack_expect_alloc();
+		if (!exp) {
+			ret = NF_DROP;
+			goto out;
+		}
 		
-		exp->seq = ntohl(tcph->seq) + (mms_string_b - data);
+		//exp->seq = ntohl(tcph->seq) + (mms_string_b - data);
 		exp_mms_info->len     = (mms_string_e  - mms_string_b);
 		exp_mms_info->padding = (mms_padding_e - mms_string_e);
 		exp_mms_info->port    = mms_port;
 		
-		DEBUGP("ip_conntrack_mms: wrote info seq=%u (ofs=%u), len=%d, padding=%u\n",
-		       exp->seq, (mms_string_e - data), exp_mms_info->len, exp_mms_info->padding);
+		DEBUGP("ip_conntrack_mms: wrote info seq=%u (ofs=%u), "
+		       "len=%d, padding=%u\n", exp->seq, (mms_string_e - data),
+		       exp_mms_info->len, exp_mms_info->padding);
 		
 		exp->tuple = ((struct ip_conntrack_tuple)
 		              { { ct->tuplehash[!dir].tuple.src.ip, { 0 } },
@@ -241,13 +274,21 @@
 		             );
 		exp->mask  = ((struct ip_conntrack_tuple)
 		             { { 0xFFFFFFFF, { 0 } },
-		               { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFFFF }});
+		               { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }});
 		exp->expectfn = NULL;
-		ip_conntrack_expect_related(ct, &expect);
-		UNLOCK_BH(&ip_mms_lock);
+		exp->master = ct;
+
+		if (ip_nat_mms_hook)
+			ret = ip_nat_mms_hook(pskb, ctinfo, ..., exp);
+		else if (ip_conntrack_expect_related(exp) != 0) {
+			ip_conntrack_expect_free(exp);
+			ret = NF_DROP;
+		}
+		goto out;
 	}
-
-	return NF_ACCEPT;
+out:
+	UNLOCK_BH(&mms_buffer_lock);
+	return ret;
 }
 
 static struct ip_conntrack_helper mms[MAX_PORTS];

Modified: trunk/patch-o-matic-ng/mms-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/ip_nat_mms.c
===================================================================
--- trunk/patch-o-matic-ng/mms-conntrack-nat/linux/net/ipv4/netfilter/ip_nat_mms.c	2005-03-01 20:30:53 UTC (rev 3749)
+++ trunk/patch-o-matic-ng/mms-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/ip_nat_mms.c	2005-03-02 12:00:00 UTC (rev 3753)
@@ -21,6 +21,11 @@
  *
  *      The SDP project people are reverse-engineering MMS:
  *      http://get.to/sdp
+ *
+ *  2005-02-13: Harald Welte <laforge at netfilter.org>
+ *  	- port to 2.6.x
+ *  	- update to work with post 2.6.11 helper API changes
+
  */
 
 /* FIXME: issue with UDP & fragmentation with this URL: 
@@ -57,22 +62,10 @@
 #define DUMP_BYTES(address, counter)
 #endif
 
-#define MAX_PORTS 8
-static int ports[MAX_PORTS];
-static int ports_c = 0;
-
-#ifdef MODULE_PARM
-MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i");
-#endif
-
 MODULE_AUTHOR("Filip Sneppe <filip.sneppe at cronos.be>");
 MODULE_DESCRIPTION("Microsoft Windows Media Services (MMS) NAT module");
 MODULE_LICENSE("GPL");
 
-DECLARE_LOCK_EXTERN(ip_mms_lock);
-
-/* FIXME: Time out? --RR */
-
 static int mms_data_fixup(const struct ip_ct_mms_expect *ct_mms_info,
                           struct ip_conntrack *ct,
                           struct sk_buff **pskb,
@@ -93,7 +86,8 @@
 
 	int zero_padding;
 
-	char buffer[28];         /* "\\255.255.255.255\UDP\65635" * 2 (for unicode) */
+	char buffer[28];         /* "\\255.255.255.255\UDP\65635" * 2 
+				    (for unicode) */
 	char unicode_buffer[75]; /* 27*2 (unicode) + 20 + 1 */
 	char proto_string[6];
 	
@@ -103,7 +97,8 @@
 	mms_proto = expect->tuple.dst.protonum;
 	sprintf(proto_string, "%u", mms_proto);
 	
-	DEBUGP("ip_nat_mms: mms_data_fixup: info (seq %u + %u) in %u, proto %s\n",
+	DEBUGP("ip_nat_mms: mms_data_fixup: info (seq %u + %u) "
+	       "in %u, proto %s\n",
 	       expect->seq, ct_mms_info->len, ntohl(tcph->seq),
 	       mms_proto == IPPROTO_UDP ? "UDP"
 	       : mms_proto == IPPROTO_TCP ? "TCP":proto_string);
@@ -116,7 +111,8 @@
 	for (port = ct_mms_info->port; port != 0; port++) {
 		t.dst.u.tcp.port = htons(port);
 		if (ip_conntrack_change_expect(expect, &t) == 0) {
-			DEBUGP("ip_nat_mms: mms_data_fixup: using port %d\n", port);
+			DEBUGP("ip_nat_mms: mms_data_fixup: using port %d\n",
+				port); 
 			break;
 		}
 	}
@@ -136,8 +132,10 @@
 	for (i=0; i<strlen(buffer); ++i)
 		*(unicode_buffer+i*2)=*(buffer+i);
 	
-	DEBUGP("ip_nat_mms: mms_data_fixup: padding: %u len: %u\n", ct_mms_info->padding, ct_mms_info->len);
-	DEBUGP("ip_nat_mms: mms_data_fixup: offset: %u\n", MMS_SRV_UNICODE_STRING_OFFSET+ct_mms_info->len);
+	DEBUGP("ip_nat_mms: mms_data_fixup: padding: %u len: %u\n", 
+		ct_mms_info->padding, ct_mms_info->len);
+	DEBUGP("ip_nat_mms: mms_data_fixup: offset: %u\n", 
+		MMS_SRV_UNICODE_STRING_OFFSET+ct_mms_info->len);
 	DUMP_BYTES(data+MMS_SRV_UNICODE_STRING_OFFSET, 60);
 	
 	/* add end of packet to it */
@@ -153,8 +151,9 @@
 		*(unicode_buffer+i*2+j+k)= (char)0;
 	
 	DEBUGP("ip_nat_mms: mms_data_fixup: zero_padding = %u\n", zero_padding);
-	DEBUGP("ip_nat_mms: original=> chunkLenLV=%u chunkLenLM=%u messageLength=%u\n",
-	       *mms_chunkLenLV, *mms_chunkLenLM, *mms_messageLength);
+	DEBUGP("ip_nat_mms: original=> chunkLenLV=%u chunkLenLM=%u "
+	       "messageLength=%u\n", *mms_chunkLenLV, *mms_chunkLenLM,
+	       *mms_messageLength);
 	
 	/* explanation, before I forget what I did:
 	   strlen(buffer)*2 + ct_mms_info->padding + 4 must be divisable by 8;
@@ -165,13 +164,15 @@
 	*mms_chunkLenLV    = *mms_chunkLenLM+2;
 	*mms_messageLength = *mms_chunkLenLV*8;
 	
-	DEBUGP("ip_nat_mms: modified=> chunkLenLV=%u chunkLenLM=%u messageLength=%u\n",
-	       *mms_chunkLenLV, *mms_chunkLenLM, *mms_messageLength);
+	DEBUGP("ip_nat_mms: modified=> chunkLenLV=%u chunkLenLM=%u"
+	       " messageLength=%u\n", *mms_chunkLenLV, *mms_chunkLenLM,
+	       *mms_messageLength);
 	
 	ip_nat_mangle_tcp_packet(pskb, ct, ctinfo, 
 	                         expect->seq - ntohl(tcph->seq),
-	                         ct_mms_info->len + ct_mms_info->padding, unicode_buffer,
-	                         strlen(buffer)*2 + ct_mms_info->padding + zero_padding);
+	                         ct_mms_info->len + ct_mms_info->padding,
+				 unicode_buffer, strlen(buffer)*2 +
+				 ct_mms_info->padding + zero_padding);
 	DUMP_BYTES(unicode_buffer, 60);
 	
 	return 1;
@@ -197,7 +198,8 @@
 
 	newdstip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip;
 	newsrcip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip;
-	DEBUGP("ip_nat_mms: mms_nat_expected: hook %s: newsrc->newdst %u.%u.%u.%u->%u.%u.%u.%u\n",
+	DEBUGP("ip_nat_mms: mms_nat_expected: hook %s: "
+	       "newsrc->newdst %u.%u.%u.%u->%u.%u.%u.%u\n",
 	       hooknum == NF_IP_POST_ROUTING ? "POSTROUTING"
 	       : hooknum == NF_IP_PRE_ROUTING ? "PREROUTING"
 	       : hooknum == NF_IP_LOCAL_OUT ? "OUTPUT" : "???",
@@ -208,7 +210,8 @@
 	else
 		newip = newdstip;
 
-	DEBUGP("ip_nat_mms: mms_nat_expected: IP to %u.%u.%u.%u\n", NIPQUAD(newip));
+	DEBUGP("ip_nat_mms: mms_nat_expected: IP to %u.%u.%u.%u\n",
+		NIPQUAD(newip));
 
 	mr.rangesize = 1;
 	/* We don't want to manip the per-protocol, just the IPs. */
@@ -242,14 +245,16 @@
 	dir = CTINFO2DIR(ctinfo);
 	if (!((hooknum == NF_IP_POST_ROUTING && dir == IP_CT_DIR_ORIGINAL)
 	    ||(hooknum == NF_IP_PRE_ROUTING && dir == IP_CT_DIR_REPLY))) {
-		DEBUGP("ip_nat_mms: mms_nat_help: not touching dir %s at hook %s\n",
+		DEBUGP("ip_nat_mms: mms_nat_help: not touching dir %s"
+		       "at hook %s\n",
 		       dir == IP_CT_DIR_ORIGINAL ? "ORIG" : "REPLY",
 		       hooknum == NF_IP_POST_ROUTING ? "POSTROUTING"
 		       : hooknum == NF_IP_PRE_ROUTING ? "PREROUTING"
 		       : hooknum == NF_IP_LOCAL_OUT ? "OUTPUT" : "???");
 		return NF_ACCEPT;
 	}
-	DEBUGP("ip_nat_mms: mms_nat_help: beyond not touching (dir %s at hook %s)\n",
+	DEBUGP("ip_nat_mms: mms_nat_help: beyond not touching "
+	       "(dir %s at hook %s)\n",
 	       dir == IP_CT_DIR_ORIGINAL ? "ORIG" : "REPLY",
 	       hooknum == NF_IP_POST_ROUTING ? "POSTROUTING"
 	       : hooknum == NF_IP_PRE_ROUTING ? "PREROUTING"
@@ -257,13 +262,14 @@
 	
 	datalen = (*pskb)->len - iph->ihl * 4 - tcph->doff * 4;
 	
-	DEBUGP("ip_nat_mms: mms_nat_help: %u+%u=%u %u %u\n", exp->seq, ct_mms_info->len,
-	       exp->seq + ct_mms_info->len,
+	DEBUGP("ip_nat_mms: mms_nat_help: %u+%u=%u %u %u\n", exp->seq,
+		ct_mms_info->len, exp->seq + ct_mms_info->len,
 	       ntohl(tcph->seq),
 	       ntohl(tcph->seq) + datalen);
 	
 	LOCK_BH(&ip_mms_lock);
-	/* Check wether the whole IP/proto/port pattern is carried in the payload */
+	/* Check wether the whole IP/proto/port pattern is carried in the
+	 * payload */
 	if (between(exp->seq + ct_mms_info->len,
 	    ntohl(tcph->seq),
 	    ntohl(tcph->seq) + datalen)) {
@@ -288,62 +294,16 @@
 	return NF_ACCEPT;
 }
 
-static struct ip_nat_helper mms[MAX_PORTS];
-static char mms_names[MAX_PORTS][10];
-
-/* Not __exit: called from init() */
-static void fini(void)
+static void __exit fini(void)
 {
-	int i;
-
-	for (i = 0; (i < MAX_PORTS) && ports[i]; i++) {
-		DEBUGP("ip_nat_mms: unregistering helper for port %d\n", ports[i]);
-		ip_nat_helper_unregister(&mms[i]);
-	}
+	ip_nat_mms_hook = NULL;
+	synchronize_net();
 }
 
 static int __init init(void)
 {
-	int i, ret = 0;
-	char *tmpname;
-
-	if (ports[0] == 0)
-		ports[0] = MMS_PORT;
-
-	for (i = 0; (i < MAX_PORTS) && ports[i]; i++) {
-
-		memset(&mms[i], 0, sizeof(struct ip_nat_helper));
-
-		mms[i].tuple.dst.protonum = IPPROTO_TCP;
-		mms[i].tuple.src.u.tcp.port = htons(ports[i]);
-		mms[i].mask.dst.protonum = 0xFFFF;
-		mms[i].mask.src.u.tcp.port = 0xFFFF;
-		mms[i].help = mms_nat_help;
-		mms[i].me = THIS_MODULE;
-		mms[i].flags = 0;
-		mms[i].expect = mms_nat_expected;
-
-		tmpname = &mms_names[i][0];
-		if (ports[i] == MMS_PORT)
-			sprintf(tmpname, "mms");
-		else
-			sprintf(tmpname, "mms-%d", i);
-		mms[i].name = tmpname;
-
-		DEBUGP("ip_nat_mms: register helper for port %d\n",
-				ports[i]);
-		ret = ip_nat_helper_register(&mms[i]);
-
-		if (ret) {
-			printk("ip_nat_mms: error registering "
-			       "helper for port %d\n", ports[i]);
-			fini();
-			return ret;
-		}
-		ports_c++;
-	}
-
-	return ret;
+	BUG_ON(ip_nat_mms_hook);
+	ip_nat_mms_hook = &mms_nat_help;
 }
 
 module_init(init);




More information about the netfilter-cvslog mailing list