Skip to content

Commit 2bc7804

Browse files
committed
[NETFILTER]: nf_conntrack: add DCCP protocol support
Add DCCP conntrack helper. Thanks to Gerrit Renker <gerrit@erg.abdn.ac.uk> for review and testing. Signed-off-by: Patrick McHardy <kaber@trash.net>
1 parent d63a650 commit 2bc7804

7 files changed

Lines changed: 883 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#ifndef _NF_CONNTRACK_DCCP_H
2+
#define _NF_CONNTRACK_DCCP_H
3+
4+
/* Exposed to userspace over nfnetlink */
5+
enum ct_dccp_states {
6+
CT_DCCP_NONE,
7+
CT_DCCP_REQUEST,
8+
CT_DCCP_RESPOND,
9+
CT_DCCP_PARTOPEN,
10+
CT_DCCP_OPEN,
11+
CT_DCCP_CLOSEREQ,
12+
CT_DCCP_CLOSING,
13+
CT_DCCP_TIMEWAIT,
14+
CT_DCCP_IGNORE,
15+
CT_DCCP_INVALID,
16+
__CT_DCCP_MAX
17+
};
18+
#define CT_DCCP_MAX (__CT_DCCP_MAX - 1)
19+
20+
enum ct_dccp_roles {
21+
CT_DCCP_ROLE_CLIENT,
22+
CT_DCCP_ROLE_SERVER,
23+
__CT_DCCP_ROLE_MAX
24+
};
25+
#define CT_DCCP_ROLE_MAX (__CT_DCCP_ROLE_MAX - 1)
26+
27+
#ifdef __KERNEL__
28+
#include <net/netfilter/nf_conntrack_tuple.h>
29+
30+
struct nf_ct_dccp {
31+
u_int8_t role[IP_CT_DIR_MAX];
32+
u_int8_t state;
33+
u_int8_t last_pkt;
34+
u_int8_t last_dir;
35+
u_int64_t handshake_seq;
36+
};
37+
38+
#endif /* __KERNEL__ */
39+
40+
#endif /* _NF_CONNTRACK_DCCP_H */

include/linux/netfilter/nfnetlink_conntrack.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ enum ctattr_l4proto {
8080
enum ctattr_protoinfo {
8181
CTA_PROTOINFO_UNSPEC,
8282
CTA_PROTOINFO_TCP,
83+
CTA_PROTOINFO_DCCP,
8384
__CTA_PROTOINFO_MAX
8485
};
8586
#define CTA_PROTOINFO_MAX (__CTA_PROTOINFO_MAX - 1)
@@ -95,6 +96,13 @@ enum ctattr_protoinfo_tcp {
9596
};
9697
#define CTA_PROTOINFO_TCP_MAX (__CTA_PROTOINFO_TCP_MAX - 1)
9798

99+
enum ctattr_protoinfo_dccp {
100+
CTA_PROTOINFO_DCCP_UNSPEC,
101+
CTA_PROTOINFO_DCCP_STATE,
102+
__CTA_PROTOINFO_DCCP_MAX,
103+
};
104+
#define CTA_PROTOINFO_DCCP_MAX (__CTA_PROTOINFO_DCCP_MAX - 1)
105+
98106
enum ctattr_counters {
99107
CTA_COUNTERS_UNSPEC,
100108
CTA_COUNTERS_PACKETS, /* old 64bit counters */

include/net/netfilter/nf_conntrack.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <asm/atomic.h>
2121

2222
#include <linux/netfilter/nf_conntrack_tcp.h>
23+
#include <linux/netfilter/nf_conntrack_dccp.h>
2324
#include <linux/netfilter/nf_conntrack_sctp.h>
2425
#include <linux/netfilter/nf_conntrack_proto_gre.h>
2526
#include <net/netfilter/ipv4/nf_conntrack_icmp.h>
@@ -30,6 +31,7 @@
3031
/* per conntrack: protocol private data */
3132
union nf_conntrack_proto {
3233
/* insert conntrack proto private data here */
34+
struct nf_ct_dccp dccp;
3335
struct ip_ct_sctp sctp;
3436
struct ip_ct_tcp tcp;
3537
struct ip_ct_icmp icmp;

include/net/netfilter/nf_conntrack_tuple.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ union nf_conntrack_man_proto
3939
struct {
4040
__be16 id;
4141
} icmp;
42+
struct {
43+
__be16 port;
44+
} dccp;
4245
struct {
4346
__be16 port;
4447
} sctp;
@@ -77,6 +80,9 @@ struct nf_conntrack_tuple
7780
struct {
7881
u_int8_t type, code;
7982
} icmp;
83+
struct {
84+
__be16 port;
85+
} dccp;
8086
struct {
8187
__be16 port;
8288
} sctp;

net/netfilter/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ config NF_CONNTRACK_EVENTS
8686

8787
If unsure, say `N'.
8888

89+
config NF_CT_PROTO_DCCP
90+
tristate 'DCCP protocol connection tracking support (EXPERIMENTAL)'
91+
depends on EXPERIMENTAL && NF_CONNTRACK
92+
depends on NETFILTER_ADVANCED
93+
help
94+
With this option enabled, the layer 3 independent connection
95+
tracking code will be able to do state tracking on DCCP connections.
96+
97+
If unsure, say 'N'.
98+
8999
config NF_CT_PROTO_GRE
90100
tristate
91101
depends on NF_CONNTRACK

net/netfilter/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ obj-$(CONFIG_NETFILTER_NETLINK_LOG) += nfnetlink_log.o
1313
obj-$(CONFIG_NF_CONNTRACK) += nf_conntrack.o
1414

1515
# SCTP protocol connection tracking
16+
obj-$(CONFIG_NF_CT_PROTO_DCCP) += nf_conntrack_proto_dccp.o
1617
obj-$(CONFIG_NF_CT_PROTO_GRE) += nf_conntrack_proto_gre.o
1718
obj-$(CONFIG_NF_CT_PROTO_SCTP) += nf_conntrack_proto_sctp.o
1819
obj-$(CONFIG_NF_CT_PROTO_UDPLITE) += nf_conntrack_proto_udplite.o

0 commit comments

Comments
 (0)