Skip to contentSkip to conversation

: DCCP conntrack/NAT

NETFILTER Patrick McHardy 1 participant 2 messages Nov 17, 2005

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi Ian,

I've updated the DCCP conntrack patch to apply to the current kernel and added NAT support. No further work has be done so far, the state transitions are probably still incomplete and/or wrong, but NAT seems to work in some quick testing.

If you're going to test it, please let me know about problems.

include/linux/netfilter/nfnetlink_conntrack.h +8 -0
index 116fcac..177869e 100644
@@ -71,6 +71,7 @@ enum ctattr_l4proto {
 enum ctattr_protoinfo {
 	CTA_PROTOINFO_UNSPEC,
 	CTA_PROTOINFO_TCP,
+	CTA_PROTOINFO_DCCP,
 	__CTA_PROTOINFO_MAX
 };
 #define CTA_PROTOINFO_MAX (__CTA_PROTOINFO_MAX - 1)
@@ -82,6 +83,13 @@ enum ctattr_protoinfo_tcp {
 };
 #define CTA_PROTOINFO_TCP_MAX (__CTA_PROTOINFO_TCP_MAX - 1)
 
+enum ctattr_protoinfo_dccp {
+	CTA_PROTOINFO_DCCP_UNSPEC,
+	CTA_PROTOINFO_DCCP_STATE,
+	__CTA_PROTOINFO_DCCP_MAX
+};
+#define CTA_PROTOINFO_DCCP_MAX (__CTA_PROTOINFO_DCCP_MAX - 1)
+
 enum ctattr_counters {
 	CTA_COUNTERS_UNSPEC,
 	CTA_COUNTERS_PACKETS,		/* old 64bit counters */
include/linux/netfilter_ipv4/ip_conntrack.h +2 -0
index b3432ab..df974f1 100644
@@ -14,6 +14,7 @@
 #include <linux/netfilter_ipv4/ip_conntrack_icmp.h>
 #include <linux/netfilter_ipv4/ip_conntrack_proto_gre.h>
 #include <linux/netfilter_ipv4/ip_conntrack_sctp.h>
+#include <linux/netfilter_ipv4/ip_conntrack_dccp.h>
 
 /* per conntrack: protocol private data */
 union ip_conntrack_proto {
@@ -22,6 +23,7 @@ union ip_conntrack_proto {
 	struct ip_ct_sctp sctp;
 	struct ip_ct_tcp tcp;
 	struct ip_ct_icmp icmp;
+	struct ip_ct_dccp dccp;
 };
 
 union ip_conntrack_expect_proto {
include/linux/netfilter_ipv4/ip_conntrack_dccp.h new file +28 -0
new file mode 100644
index 0000000..7751057
@@ -0,0 +1,28 @@
+#ifndef _IP_CONNTRACK_DCCP_H
+#define _IP_CONNTRACK_DCCP_H
+
+/* Exposed to userspace over nfnetlink */
+enum dccp_ct_states {
+	CT_DCCP_NONE,
+	CT_DCCP_REQ_SENT,
+	CT_DCCP_RES_RCVD,
+	CT_DCCP_PART_OPEN,
+	CT_DCCP_OPEN,
+	CT_DCCP_CLOSE_REQ,
+	CT_DCCP_CLOSING,
+	CT_DCCP_CLOSED,
+	CT_DCCP_TIME_WAIT,
+	CT_DCCP_IGNORE,
+	CT_DCCP_MAX,
+};
+
+#ifdef __KERNEL__
+
+struct ip_ct_dccp
+{
+	u_int8_t	state;
+};
+
+#endif /* __KERNEL__ */
+
+#endif /* _IP_CONNTRACK_DCCP_H */
include/linux/netfilter_ipv4/ip_conntrack_tuple.h +6 -0
index 2fdabdb..c15a169 100644
@@ -32,6 +32,9 @@ union ip_conntrack_manip_proto
 		u_int16_t port;
 	} sctp;
 	struct {
+		u_int16_t port;
+	} dccp;
+	struct {
 		__be16 key;	/* key is 32bit, pptp only uses 16 */
 	} gre;
 };
@@ -68,6 +71,9 @@ struct ip_conntrack_tuple
 				u_int16_t port;
 			} sctp;
 			struct {
+				u_int16_t port;
+			} dccp;
+			struct {
 				__be16 key;	/* key is 32bit, 
 						 * pptp only uses 16 */
 			} gre;
include/linux/sysctl.h +9 -0
index 6bc03c9..c771634 100644
@@ -477,6 +477,15 @@ enum
  	NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_RECD=25,
  	NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_ACK_SENT=26,
 	NET_IPV4_NF_CONNTRACK_COUNT=27,
+	NET_IPV4_NF_CONNTRACK_DCCP_TIMEOUT_REQ_SENT=28,
+	NET_IPV4_NF_CONNTRACK_DCCP_TIMEOUT_RES_RCVD=29,
+	NET_IPV4_NF_CONNTRACK_DCCP_TIMEOUT_PART_OPEN=30,
+	NET_IPV4_NF_CONNTRACK_DCCP_TIMEOUT_OPEN=31,
+	NET_IPV4_NF_CONNTRACK_DCCP_TIMEOUT_CLOSE_REQ=32,
+	NET_IPV4_NF_CONNTRACK_DCCP_TIMEOUT_CLOSING=33,
+	NET_IPV4_NF_CONNTRACK_DCCP_TIMEOUT_CLOSED=34,
+	NET_IPV4_NF_CONNTRACK_DCCP_TIMEOUT_TIME_WAIT=35,
+	NET_IPV4_NF_CONNTRACK_DCCP_LOOSE=36,
 };
  
 /* /proc/sys/net/ipv6 */
net/ipv4/netfilter/Kconfig +16 -0
index 9d3c8b5..22fb86d 100644
@@ -83,6 +83,14 @@ config IP_NF_CT_PROTO_SCTP
 	  If you want to compile it as a module, say M here and read
 	  <file:Documentation/modules.txt>.  If unsure, say `N'.
 
+config IP_NF_CT_PROTO_DCCP
+	tristate "DCCP protocol connection tracking support (EXPERIMENTAL)"
+	depends on IP_NF_CONNTRACK && EXPERIMENTAL
+	help
+	  This option enables connection tracking support for the DCCP protocol.
+
+	  To compile it as a module, choose M here.  If unsure, say N.
+
 config IP_NF_FTP
 	tristate "FTP protocol support"
 	depends on IP_NF_CONNTRACK
@@ -589,6 +597,14 @@ config IP_NF_NAT_NEEDED
 	depends on IP_NF_NAT != n
 	default y
 
+config IP_NF_NAT_PROTO_DCCP
+	tristate "DCCP protocol NAT support (EXPERIMENTAL)"
+	depends on IP_NF_CT_PROTO_DCCP && IP_NF_NAT && EXPERIMENTAL
+	help
+	  This option enables NAT support for the DCCP protocol.
+
+	  To compile it as a module, choose M here.  If unsure, say N.
+
 config IP_NF_TARGET_MASQUERADE
 	tristate "MASQUERADE target support"
 	depends on IP_NF_NAT
net/ipv4/netfilter/Makefile +5 -1
index 058c48e..b601df3 100644
@@ -17,8 +17,9 @@ obj-$(CONFIG_IP_NF_CONNTRACK) += ip_conn
 obj-$(CONFIG_IP_NF_CONNTRACK_NETLINK) += ip_conntrack_netlink.o
 
 
-# SCTP protocol connection tracking
+# protocol connection tracking helpers
 obj-$(CONFIG_IP_NF_CT_PROTO_SCTP) += ip_conntrack_proto_sctp.o
+obj-$(CONFIG_IP_NF_CT_PROTO_DCCP) += ip_conntrack_proto_dccp.o
 
 # connection tracking helpers
 obj-$(CONFIG_IP_NF_PPTP) += ip_conntrack_pptp.o
@@ -28,6 +29,9 @@ obj-$(CONFIG_IP_NF_FTP) += ip_conntrack_
 obj-$(CONFIG_IP_NF_IRC) += ip_conntrack_irc.o
 obj-$(CONFIG_IP_NF_NETBIOS_NS) += ip_conntrack_netbios_ns.o
 
+# protocol NAT helpers
+obj-$(CONFIG_IP_NF_NAT_PROTO_DCCP) += ip_nat_proto_dccp.o
+
 # NAT helpers 
 obj-$(CONFIG_IP_NF_NAT_PPTP) += ip_nat_pptp.o
 obj-$(CONFIG_IP_NF_NAT_AMANDA) += ip_nat_amanda.o
net/ipv4/netfilter/ip_conntrack_proto_dccp.c new file +741 -0

741 lines not on this page · raw message

net/ipv4/netfilter/ip_nat_proto_dccp.c new file +196 -0

196 lines not on this page · raw message

#1 lore raw
Quoted 6 lines · Patrick McHardy

I've updated the DCCP conntrack patch to apply to the current kernel and added NAT support. No further work has be done so far, the state transitions are probably still incomplete and/or wrong, but NAT seems to work in some quick testing.

If you're going to test it, please let me know about problems.

Already found the first one. If you want to use it on SMP you need to replace DEFINE_SPINLOCK by DEFINE_RWLOCK.

Quoted 6 lines
net/ipv4/netfilter/ip_conntrack_proto_dccp.c new file +0 -0
new file mode 100644
index 0000000..f90e152
@@ -0,0 +1,741 @@

...

Quoted 3 lines
net/ipv4/netfilter/ip_conntrack_proto_dccp.c new file +3 -0
+
+static DEFINE_SPINLOCK(dccp_lock);
+