: Netfilter Update part II
Subsystems (3)
cover : Netfilter Update part II
Hi Dave,
following is part two of my netfilter update for 2.6.20, containing NAT support for nf_conntrack and ports of all conntrack/NAT helpers. With these patches nf_conntrack is finally a full replacement for ip_conntrack, which is now scheduled for removal in 2.6.22 after some stabilization of the new code.
You can also pull these patches from
http://people.netfilter.org/~kaber/nf-2.6.20-nat.git
Please apply, thanks.
Documentation/feature-removal-schedule.txt | 9 include/linux/inet.h | 4 include/linux/netfilter.h | 2 include/linux/netfilter/nf_conntrack_amanda.h | 10 include/linux/netfilter/nf_conntrack_ftp.h | 20 include/linux/netfilter/nf_conntrack_h323.h | 92 include/linux/netfilter/nf_conntrack_h323_asn1.h | 98 include/linux/netfilter/nf_conntrack_h323_types.h | 951 ++++ include/linux/netfilter/nf_conntrack_irc.h | 15 include/linux/netfilter/nf_conntrack_pptp.h | 321 + include/linux/netfilter/nf_conntrack_proto_gre.h | 112 include/linux/netfilter/nf_conntrack_sip.h | 41 include/linux/netfilter/nf_conntrack_tftp.h | 20 include/linux/netfilter_ipv4/Kbuild | 2 include/linux/netfilter_ipv4/ip_conntrack_ftp.h | 40 include/linux/netfilter_ipv4/ip_conntrack_h323.h | 2 include/linux/netfilter_ipv4/ip_conntrack_helper_h323_asn1.h | 98 include/linux/netfilter_ipv4/ip_conntrack_helper_h323_types.h | 939 ---- include/net/netfilter/ipv4/nf_conntrack_ipv4.h | 22 include/net/netfilter/nf_conntrack.h | 38 include/net/netfilter/nf_conntrack_expect.h | 10 include/net/netfilter/nf_conntrack_helper.h | 2 include/net/netfilter/nf_conntrack_tuple.h | 34 include/net/netfilter/nf_nat.h | 77 include/net/netfilter/nf_nat_core.h | 27 include/net/netfilter/nf_nat_helper.h | 32 include/net/netfilter/nf_nat_protocol.h | 70 include/net/netfilter/nf_nat_rule.h | 35 net/core/utils.c | 10 net/ipv4/netfilter/Kconfig | 123 net/ipv4/netfilter/Makefile | 24 net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.c | 874 ---- net/ipv4/netfilter/ip_conntrack_helper_h323_types.c | 1926 --------- net/ipv4/netfilter/ip_nat_proto_icmp.c | 4 net/ipv4/netfilter/ip_nat_standalone.c | 6 net/ipv4/netfilter/ipt_MASQUERADE.c | 29 net/ipv4/netfilter/ipt_NETMAP.c | 4 net/ipv4/netfilter/ipt_REDIRECT.c | 6 net/ipv4/netfilter/ipt_SAME.c | 12 net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 23 net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 5 net/ipv4/netfilter/nf_nat_amanda.c | 78 net/ipv4/netfilter/nf_nat_core.c | 647 +++ net/ipv4/netfilter/nf_nat_ftp.c | 179 net/ipv4/netfilter/nf_nat_h323.c | 596 +++ net/ipv4/netfilter/nf_nat_helper.c | 433 ++ net/ipv4/netfilter/nf_nat_irc.c | 101 net/ipv4/netfilter/nf_nat_pptp.c | 315 + net/ipv4/netfilter/nf_nat_proto_gre.c | 179 net/ipv4/netfilter/nf_nat_proto_icmp.c | 86 net/ipv4/netfilter/nf_nat_proto_tcp.c | 148 net/ipv4/netfilter/nf_nat_proto_udp.c | 138 net/ipv4/netfilter/nf_nat_proto_unknown.c | 54 net/ipv4/netfilter/nf_nat_rule.c | 343 + net/ipv4/netfilter/nf_nat_sip.c | 283 + net/ipv4/netfilter/nf_nat_snmp_basic.c | 1332 ++++++ net/ipv4/netfilter/nf_nat_standalone.c | 406 ++ net/ipv4/netfilter/nf_nat_tftp.c | 52 net/ipv6/netfilter/Kconfig | 2 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 2 net/ipv6/netfilter/nf_conntrack_reasm.c | 26 net/netfilter/Kconfig | 170 net/netfilter/Makefile | 10 net/netfilter/nf_conntrack_amanda.c | 237 + net/netfilter/nf_conntrack_core.c | 84 net/netfilter/nf_conntrack_ecache.c | 6 net/netfilter/nf_conntrack_expect.c | 78 net/netfilter/nf_conntrack_ftp.c | 32 net/netfilter/nf_conntrack_h323_asn1.c | 874 ++++ net/netfilter/nf_conntrack_h323_main.c | 1856 +++++++++ net/netfilter/nf_conntrack_h323_types.c | 1927 ++++++++++ net/netfilter/nf_conntrack_helper.c | 17 net/netfilter/nf_conntrack_irc.c | 281 + net/netfilter/nf_conntrack_netbios_ns.c | 125 net/netfilter/nf_conntrack_netlink.c | 85 net/netfilter/nf_conntrack_pptp.c | 607 +++ net/netfilter/nf_conntrack_proto.c | 12 net/netfilter/nf_conntrack_proto_gre.c | 305 + net/netfilter/nf_conntrack_proto_sctp.c | 3 net/netfilter/nf_conntrack_proto_tcp.c | 17 net/netfilter/nf_conntrack_proto_udp.c | 5 net/netfilter/nf_conntrack_sip.c | 530 ++ net/netfilter/nf_conntrack_standalone.c | 79 net/netfilter/nf_conntrack_tftp.c | 159 84 files changed, 14937 insertions(+), 4131 deletions(-)
Patrick McHardy:
[NET]: Accept wildcard delimiters in in[46]_pton
[NETFILTER]: nf_conntrack: fix NF_CONNTRACK_PROC_COMPAT dependency [NETFILTER]: nf_conntrack: fix helper structure alignment [NETFILTER]: nf_conntrack: endian annotations
[NETFILTER]: nf_conntrack: automatic helper assignment for expectations [NETFILTER]: Kconfig: improve conntrack selection
[NETFILTER]: nf_conntrack: add module aliases to IPv4 conntrack names [NETFILTER]: Add NAT support for nf_conntrack
[NETFILTER]: nf_nat: add FTP NAT helper port
[NETFILTER]: nf_conntrack: add helper function for expectation initialization [NETFILTER]: nf_conntrack/nf_nat: add amanda helper port [NETFILTER]: nf_conntrack/nf_nat: add H.323 helper port [NETFILTER]: nf_conntrack/nf_nat: add IRC helper port [NETFILTER]: nf_conntrack: add NetBIOS name service helper port [NETFILTER]: nf_conntrack/nf_nat: add PPTP helper port [NETFILTER]: nf_conntrack/nf_nat: add SIP helper port [NETFILTER]: nf_conntrack/nf_nat: add TFTP helper port [NETFILTER]: nf_nat: add SNMP NAT helper port
[NETFILTER]: Mark old IPv4-only connection tracking scheduled for removal [NETFILTER]: nf_conntrack: EXPORT_SYMBOL cleanup
PATCH 1/20 : Accept wildcard delimiters in in[46]_pton
[NET]: Accept wildcard delimiters in in[46]_pton
Accept -1 as delimiter to abort parsing without an error at the first unknown character. This is needed by the upcoming nf_conntrack SIP helper, where addresses are delimited by either '\r' or '\n' characters.
---
commit 0166e0457531e1e5260463477c30dd16b81ab606
tree f752c1e10f845935f865bb1670c64d70c2cd2acd
parent 5465ae68b5ec11b2820db3f9b4c6fd94f113da44
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:33:52 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:33:52 +0100
include/linux/inet.h | 4 ++-- net/core/utils.c | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-)
include/linux/inet.h +2 -2
@@ -46,7 +46,7 @@ #ifdef __KERNEL__#include <linux/types.h> extern __be32 in_aton (const char *str); -extern int in4_pton (const char *src,int srclen,u8 *dst,char delim,const char **end); -extern int in6_pton (const char *src,int srclen,u8 *dst,char delim,const char **end); +extern int in4_pton (const char *src,int srclen,u8 *dst,int delim,const char **end); +extern int in6_pton (const char *src,int srclen,u8 *dst,int delim,const char **end);#endif #endif /* _LINUX_INET_H */
net/core/utils.c +6 -4
@@ -88,7 +88,7 @@ #define IN6PTON_DELIM 0x10000000#define IN6PTON_NULL 0x20000000/* first/tail */ #define IN6PTON_UNKNOWN 0x40000000 -static inline int digit2bin (char c,char delim) +static inline int digit2bin (char c,int delim) {if (c == delim || c =='\0' )return IN6PTON_DELIM ;
@@ -99,7 +99,7 @@ static inline int digit2bin(char c, charreturn IN6PTON_UNKNOWN ; } -static inline int xdigit2bin (char c,char delim) +static inline int xdigit2bin (char c,int delim) {if (c == delim || c =='\0' )return IN6PTON_DELIM ;
@@ -113,12 +113,14 @@ static inline int xdigit2bin(char c, chareturn (IN6PTON_XDIGIT | (c -'a' +10 ));if (c >='A' && c <='F' )return (IN6PTON_XDIGIT | (c -'A' +10 )); +if (delim ==-1 ) +return IN6PTON_DELIM ;return IN6PTON_UNKNOWN ; }int in4_pton (const char *src,int srclen,u8 *dst, -char delim,const char **end) +int delim,const char **end) {const char *s;u8 *d;
@@ -173,7 +175,7 @@ EXPORT_SYMBOL(in4_pton);int in6_pton (const char *src,int srclen,u8 *dst, -char delim,const char **end) +int delim,const char **end) {const char *s, *tok =NULL ;u8 *d, *dc =NULL ;
PATCH 2/20 : nf_conntrack: fix NF_CONNTRACK_PROC_COMPAT dependency
In reply to Patrick McHardy[NETFILTER]: nf_conntrack: fix NF_CONNTRACK_PROC_COMPAT dependency
NF_CONNTRACK_PROC_COMPAT depends on NF_CONNTRACK_IPV4, not NF_CONNTRACK.
---
commit 66d2cd318d32a8b3a876714f104477ba9aa6b87a
tree c9157c066030213ea7929456f7047fb2c35def9a
parent 0166e0457531e1e5260463477c30dd16b81ab606
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:33:53 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:33:53 +0100
net/ipv4/netfilter/Kconfig | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/ipv4/netfilter/Kconfig +1 -1
@@ -21,7 +21,7 @@ config NF_CONNTRACK_IPV4 config NF_CONNTRACK_PROC_COMPAT bool "proc/sysctl compatibility with old connection tracking" - depends on NF_CONNTRACK + depends on NF_CONNTRACK_IPV4 default y help This option enables /proc and sysctl compatibility with the old
PATCH 3/20 : nf_conntrack: fix helper structure alignment
In reply to Patrick McHardy[NETFILTER]: nf_conntrack: fix helper structure alignment
Adding the alignment to the size doesn't make any sense, what it should do is align the size of the conntrack structure to the alignment requirements of the helper structure and return an aligned pointer in nfct_help().
---
commit fd155ea4144ef3b1d15705284b9513b42870e363
tree 9af3909df2ab29b89de1fe66ebd20b6d134728c0
parent 66d2cd318d32a8b3a876714f104477ba9aa6b87a
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:33:54 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:33:54 +0100
include/net/netfilter/nf_conntrack.h | 1 + net/netfilter/nf_conntrack_helper.c | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-)
include/net/netfilter/nf_conntrack.h +1 -0
@@ -273,6 +273,7 @@ static inline struct nf_conn_help *nfct_if (!(ct->features &NF_CT_F_HELP ))return NULL ; + offset =ALIGN (offset, __alignof__(struct nf_conn_help ));return (struct nf_conn_help *) ((void *)ct + offset); }
net/netfilter/nf_conntrack_helper.c +5 -4
@@ -97,13 +97,14 @@ static inline int unhelp(struct nf_conntint nf_conntrack_helper_register (struct nf_conntrack_helper *me) { -int ret; +int size, ret; +BUG_ON (me->timeout ==0 ); + size =ALIGN (sizeof (struct nf_conn ), __alignof__(struct nf_conn_help )) + +sizeof (struct nf_conn_help ); ret =nf_conntrack_register_cache (NF_CT_F_HELP ,"nf_conntrack:help" , -sizeof (struct nf_conn ) - +sizeof (struct nf_conn_help ) - + __alignof__(struct nf_conn_help )); + size);if (ret <0 ) {printk (KERN_ERR "nf_conntrack_helper_register: Unable to create slab cache for conntracks\n" );return ret;
PATCH 4/20 : nf_conntrack: endian annotations
In reply to Patrick McHardy[NETFILTER]: nf_conntrack: endian annotations
Resync with Al Viro's ip_conntrack annotations and fix a missed spot in ip_nat_proto_icmp.c.
---
commit 3dc28b1e6e6e9e4f9064ab33fa57b56ccb9a7a67
tree 1230abd39b6ace1910a53c3881ba412ad4811469
parent fd155ea4144ef3b1d15705284b9513b42870e363
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:33:56 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:33:56 +0100
include/net/netfilter/nf_conntrack_tuple.h | 18 ++++++------ net/ipv4/netfilter/ip_nat_proto_icmp.c | 4 +-- net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 8 ++--- net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 2 + net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 2 + net/ipv6/netfilter/nf_conntrack_reasm.c | 26 ++++++++--------- net/netfilter/nf_conntrack_core.c | 6 +--- net/netfilter/nf_conntrack_ftp.c | 10 +++--- net/netfilter/nf_conntrack_netlink.c | 37 ++++++++++++------------ net/netfilter/nf_conntrack_proto_sctp.c | 2 + net/netfilter/nf_conntrack_proto_tcp.c | 8 ++--- 11 files changed, 58 insertions(+), 65 deletions(-)
include/net/netfilter/nf_conntrack_tuple.h +9 -9
@@ -26,8 +26,8 @@ #define NF_CT_TUPLE_L3SIZE 4network order! */ union nf_conntrack_man_l3proto {u_int32_t all[NF_CT_TUPLE_L3SIZE ]; -u_int32_t ip; -u_int32_t ip6[4 ]; +__be32 ip; +__be32 ip6[4 ]; };/* The protocol-specific manipulable parts of the tuple: always in
@@ -38,16 +38,16 @@ union nf_conntrack_man_protou_int16_t all;struct { -u_int16_t port; +__be16 port; } tcp;struct { -u_int16_t port; +__be16 port; } udp;struct { -u_int16_t id; +__be16 id; } icmp;struct { -u_int16_t port; +__be16 port; } sctp; };
@@ -77,16 +77,16 @@ struct nf_conntrack_tupleu_int16_t all;struct { -u_int16_t port; +__be16 port; } tcp;struct { -u_int16_t port; +__be16 port; } udp;struct {u_int8_t type, code; } icmp;struct { -u_int16_t port; +__be16 port; } sctp; } u;
net/ipv4/netfilter/ip_nat_proto_icmp.c +2 -2
@@ -24,8 +24,8 @@ icmp_in_range(const struct ip_conntrack_ const union ip_conntrack_manip_proto *min, const union ip_conntrack_manip_proto *max) { - return (tuple->src.u.icmp.id >= min->icmp.id - && tuple->src.u.icmp.id <= max->icmp.id); + return ntohs(tuple->src.u.icmp.id) >= ntohs(min->icmp.id) && + ntohs(tuple->src.u.icmp.id) <= ntohs(max->icmp.id); } static int
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +3 -5
@@ -41,7 +41,7 @@ #endifstatic int ipv4_pkt_to_tuple (const struct sk_buff *skb,unsigned int nhoff,struct nf_conntrack_tuple *tuple) { -u_int32_t _addrs[2 ], *ap; +__be32 _addrs[2 ], *ap; ap =skb_header_pointer (skb, nhoff + offsetof(struct iphdr , saddr),sizeof (u_int32_t) *2 , _addrs);if (ap ==NULL )
@@ -410,10 +410,8 @@ static int ipv4_nfattr_to_tuple(struct nif (nfattr_bad_size (tb,CTA_IP_MAX , cta_min_ip))return -EINVAL ; - t->src.u3.ip = - *(u_int32_t *)NFA_DATA (tb[CTA_IP_V4_SRC -1 ]); - t->dst.u3.ip = - *(u_int32_t *)NFA_DATA (tb[CTA_IP_V4_DST -1 ]); + t->src.u3.ip = *(__be32 *)NFA_DATA (tb[CTA_IP_V4_SRC -1 ]); + t->dst.u3.ip = *(__be32 *)NFA_DATA (tb[CTA_IP_V4_DST -1 ]);return 0 ; }
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +1 -1
@@ -311,7 +311,7 @@ static int icmp_nfattr_to_tuple(struct n tuple->dst.u.icmp.code = *(u_int8_t *)NFA_DATA (tb[CTA_PROTO_ICMP_CODE -1 ]); tuple->src.u.icmp.id = - *(u_int16_t *)NFA_DATA (tb[CTA_PROTO_ICMP_ID -1 ]); + *(__be16 *)NFA_DATA (tb[CTA_PROTO_ICMP_ID -1 ]);if (tuple->dst.u.icmp.type >=sizeof (invmap) || !invmap[tuple->dst.u.icmp.type])
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +1 -1
@@ -287,7 +287,7 @@ static int icmpv6_nfattr_to_tuple(struct tuple->dst.u.icmp.code = *(u_int8_t *)NFA_DATA (tb[CTA_PROTO_ICMPV6_CODE -1 ]); tuple->src.u.icmp.id = - *(u_int16_t *)NFA_DATA (tb[CTA_PROTO_ICMPV6_ID -1 ]); + *(__be16 *)NFA_DATA (tb[CTA_PROTO_ICMPV6_ID -1 ]);if (tuple->dst.u.icmp.type <128 || tuple->dst.u.icmp.type - 128 >= sizeof(invmap)
net/ipv6/netfilter/nf_conntrack_reasm.c +13 -13
@@ -72,7 +72,7 @@ struct nf_ct_frag6_queuestruct hlist_node list;struct list_head lru_list;/* lru list member */ -__u32 id;/* fragment id */ +__be32 id;/* fragment id */ struct in6_addr saddr;struct in6_addr daddr;
@@ -115,28 +115,28 @@ static __inline__ void fq_unlink(structwrite_unlock (&nf_ct_frag6_lock); } -static unsigned int ip6qhashfn (u32 id,struct in6_addr *saddr, +static unsigned int ip6qhashfn (__be32 id,struct in6_addr *saddr,struct in6_addr *daddr) {u32 a, b, c; - a = saddr->s6_addr32[0 ]; - b = saddr->s6_addr32[1 ]; - c = saddr->s6_addr32[2 ]; + a = (__force u32 )saddr->s6_addr32[0 ]; + b = (__force u32 )saddr->s6_addr32[1 ]; + c = (__force u32 )saddr->s6_addr32[2 ]; a +=JHASH_GOLDEN_RATIO ; b +=JHASH_GOLDEN_RATIO ; c += nf_ct_frag6_hash_rnd;__jhash_mix (a, b, c); - a += saddr->s6_addr32[3 ]; - b += daddr->s6_addr32[0 ]; - c += daddr->s6_addr32[1 ]; + a += (__force u32 )saddr->s6_addr32[3 ]; + b += (__force u32 )daddr->s6_addr32[0 ]; + c += (__force u32 )daddr->s6_addr32[1 ];__jhash_mix (a, b, c); - a += daddr->s6_addr32[2 ]; - b += daddr->s6_addr32[3 ]; - c += id; + a += (__force u32 )daddr->s6_addr32[2 ]; + b += (__force u32 )daddr->s6_addr32[3 ]; + c += (__force u32 )id;__jhash_mix (a, b, c);return c & (FRAG6Q_HASHSZ -1 );
@@ -338,7 +338,7 @@ #endifstatic struct nf_ct_frag6_queue * -nf_ct_frag6_create (unsigned int hash,u32 id,struct in6_addr *src,struct in6_addr *dst) +nf_ct_frag6_create (unsigned int hash,__be32 id,struct in6_addr *src,struct in6_addr *dst) {struct nf_ct_frag6_queue *fq;
@@ -366,7 +366,7 @@ oom: }static __inline__struct nf_ct_frag6_queue * -fq_find (u32 id,struct in6_addr *src,struct in6_addr *dst) +fq_find (__be32 id,struct in6_addr *src,struct in6_addr *dst) {struct nf_ct_frag6_queue *fq;struct hlist_node *n;
net/netfilter/nf_conntrack_core.c +2 -4
@@ -936,10 +936,8 @@ int nf_ct_port_nfattr_to_tuple(struct nfif (nfattr_bad_size (tb,CTA_PROTO_MAX , cta_min_proto))return -EINVAL ; - t->src.u.tcp.port = - *(u_int16_t *)NFA_DATA (tb[CTA_PROTO_SRC_PORT -1 ]); - t->dst.u.tcp.port = - *(u_int16_t *)NFA_DATA (tb[CTA_PROTO_DST_PORT -1 ]); + t->src.u.tcp.port = *(__be16 *)NFA_DATA (tb[CTA_PROTO_SRC_PORT -1 ]); + t->dst.u.tcp.port = *(__be16 *)NFA_DATA (tb[CTA_PROTO_DST_PORT -1 ]);return 0 ; }
net/netfilter/nf_conntrack_ftp.c +5 -5
@@ -173,7 +173,7 @@ static int try_rfc959(const char *data,/* Grab port: number up to delimiter */ static int get_port (const char *data,int start,size_t dlen,char delim, -u_int16_t *port) +__be16 *port) {u_int16_t tmp_port =0 ;int i;
@@ -502,12 +502,12 @@ static int help(struct sk_buff **pskb, .u = { .tcp = { 0 }}, }, .dst = { .protonum = 0xFF, - .u = { .tcp = { 0xFFFF }}, + .u = { .tcp = { __constant_htons(0xFFFF) }}, }, };if (cmd.l3num ==PF_INET ) { - exp->mask.src.u3.ip =0xFFFFFFFF ; - exp->mask.dst.u3.ip =0xFFFFFFFF ; + exp->mask.src.u3.ip =htonl (0xFFFFFFFF ); + exp->mask.dst.u3.ip =htonl (0xFFFFFFFF ); }else {memset (exp->mask.src.u3.ip6,0xFF ,sizeof (exp->mask.src.u3.ip6));
@@ -588,7 +588,7 @@ static int __init nf_conntrack_ftp_init( ftp[i][j].tuple.src.u.tcp.port =htons (ports[i]); ftp[i][j].tuple.dst.protonum =IPPROTO_TCP ; ftp[i][j].mask.src.l3num =0xFFFF ; - ftp[i][j].mask.src.u.tcp.port =0xFFFF ; + ftp[i][j].mask.src.u.tcp.port =htons (0xFFFF ); ftp[i][j].mask.dst.protonum =0xFF ; ftp[i][j].max_expected =1 ; ftp[i][j].timeout =5 *60 ;/* 5 Minutes */
net/netfilter/nf_conntrack_netlink.c +18 -19
@@ -113,7 +113,7 @@ ctnetlink_dump_tuples(struct sk_buff *skstatic inline int ctnetlink_dump_status (struct sk_buff *skb,const struct nf_conn *ct) { -u_int32_t status =htonl ((u_int32_t ) ct->status); +__be32 status =htonl ((u_int32_t ) ct->status);NFA_PUT (skb,CTA_STATUS ,sizeof (status), &status);return 0 ;
@@ -125,7 +125,7 @@ static inline int ctnetlink_dump_timeout(struct sk_buff *skb, const struct nf_conn *ct) { long timeout_l = ct->timeout.expires - jiffies; -u_int32_t timeout; +__be32 timeout;if (timeout_l <0 ) timeout =0 ;
@@ -196,7 +196,7 @@ ctnetlink_dump_counters(struct sk_buff * {enum ctattr_type type = dir ?CTA_COUNTERS_REPLY :CTA_COUNTERS_ORIG ;struct nfattr *nest_count =NFA_NEST (skb, type); -u_int32_t tmp; +__be32 tmp; tmp =htonl (ct->counters[dir].packets);NFA_PUT (skb,CTA_COUNTERS32_PACKETS ,sizeof (u_int32_t), &tmp);
@@ -219,7 +219,7 @@ #ifdef CONFIG_NF_CONNTRACK_MARKstatic inline int ctnetlink_dump_mark (struct sk_buff *skb,const struct nf_conn *ct) { -u_int32_t mark =htonl (ct->mark); +__be32 mark =htonl (ct->mark);NFA_PUT (skb,CTA_MARK ,sizeof (u_int32_t), &mark);return 0 ;
@@ -234,7 +234,7 @@ #endifstatic inline int ctnetlink_dump_id (struct sk_buff *skb,const struct nf_conn *ct) { -u_int32_t id =htonl (ct->id); +__be32 id =htonl (ct->id);NFA_PUT (skb,CTA_ID ,sizeof (u_int32_t), &id);return 0 ;
@@ -245,7 +245,7 @@ nfattr_failure:static inline int ctnetlink_dump_use (struct sk_buff *skb,const struct nf_conn *ct) { -u_int32_t use =htonl (atomic_read (&ct->ct_general.use)); +__be32 use =htonl (atomic_read (&ct->ct_general.use));NFA_PUT (skb,CTA_USE ,sizeof (u_int32_t), &use);return 0 ;
@@ -610,12 +610,12 @@ ctnetlink_parse_nat(struct nfattr *nat,return -EINVAL ;if (tb[CTA_NAT_MINIP -1 ]) - range->min_ip = *(u_int32_t *)NFA_DATA (tb[CTA_NAT_MINIP -1 ]); + range->min_ip = *(__be32 *)NFA_DATA (tb[CTA_NAT_MINIP -1 ]);if (!tb[CTA_NAT_MAXIP -1 ]) range->max_ip = range->min_ip;else - range->max_ip = *(u_int32_t *)NFA_DATA (tb[CTA_NAT_MAXIP -1 ]); + range->max_ip = *(__be32 *)NFA_DATA (tb[CTA_NAT_MAXIP -1 ]);if (range->min_ip) range->flags |=IP_NAT_RANGE_MAP_IPS ;
@@ -688,7 +688,7 @@ ctnetlink_del_conntrack(struct sock *ctn ct =nf_ct_tuplehash_to_ctrack (h);if (cda[CTA_ID -1 ]) { -u_int32_t id =ntohl (*(u_int32_t *)NFA_DATA (cda[CTA_ID -1 ])); +u_int32_t id =ntohl (*(__be32 *)NFA_DATA (cda[CTA_ID -1 ]));if (ct->id != id) {nf_ct_put (ct);return -ENOENT ;
@@ -781,7 +781,7 @@ static inline int ctnetlink_change_status(struct nf_conn *ct, struct nfattr *cda[]) { unsigned long d; -unsigned status =ntohl (*(u_int32_t *)NFA_DATA (cda[CTA_STATUS -1 ])); +unsigned int status =ntohl (*(__be32 *)NFA_DATA (cda[CTA_STATUS -1 ])); d = ct->status ^ status;if (d & (IPS_EXPECTED |IPS_CONFIRMED |IPS_DYING ))
@@ -880,7 +880,7 @@ ctnetlink_change_helper(struct nf_conn *static inline int ctnetlink_change_timeout (struct nf_conn *ct,struct nfattr *cda[]) { -u_int32_t timeout =ntohl (*(u_int32_t *)NFA_DATA (cda[CTA_TIMEOUT -1 ])); +u_int32_t timeout =ntohl (*(__be32 *)NFA_DATA (cda[CTA_TIMEOUT -1 ]));if (!del_timer (&ct->timeout))return -ETIME ;
@@ -942,7 +942,7 @@ ctnetlink_change_conntrack(struct nf_con#if defined(CONFIG_NF_CONNTRACK_MARK )if (cda[CTA_MARK -1 ]) - ct->mark =ntohl (*(u_int32_t *)NFA_DATA (cda[CTA_MARK -1 ])); + ct->mark =ntohl (*(__be32 *)NFA_DATA (cda[CTA_MARK -1 ]));#endif return 0 ;
@@ -963,7 +963,7 @@ ctnetlink_create_conntrack(struct nfattrif (!cda[CTA_TIMEOUT -1 ]) goto err; - ct->timeout.expires =ntohl (*(u_int32_t *)NFA_DATA (cda[CTA_TIMEOUT -1 ])); + ct->timeout.expires =ntohl (*(__be32 *)NFA_DATA (cda[CTA_TIMEOUT -1 ])); ct->timeout.expires = jiffies + ct->timeout.expires *HZ ; ct->status |=IPS_CONFIRMED ;
@@ -982,7 +982,7 @@ ctnetlink_create_conntrack(struct nfattr#if defined(CONFIG_NF_CONNTRACK_MARK )if (cda[CTA_MARK -1 ]) - ct->mark =ntohl (*(u_int32_t *)NFA_DATA (cda[CTA_MARK -1 ])); + ct->mark =ntohl (*(__be32 *)NFA_DATA (cda[CTA_MARK -1 ]));#endif help =nfct_help (ct);
@@ -1117,8 +1117,8 @@ ctnetlink_exp_dump_expect(struct sk_buff const struct nf_conntrack_expect *exp) {struct nf_conn *master = exp->master; -u_int32_t timeout =htonl ((exp->timeout.expires - jiffies) /HZ ); -u_int32_t id =htonl (exp->id); +__be32 timeout =htonl ((exp->timeout.expires - jiffies) /HZ ); +__be32 id =htonl (exp->id);if (ctnetlink_exp_dump_tuple (skb, &exp->tuple,CTA_EXPECT_TUPLE ) <0 ) goto nfattr_failure;
@@ -1296,7 +1296,7 @@ ctnetlink_get_expect(struct sock *ctnl,return -ENOENT ;if (cda[CTA_EXPECT_ID -1 ]) { -u_int32_t id = *(u_int32_t *)NFA_DATA (cda[CTA_EXPECT_ID -1 ]); +__be32 id = *(__be32 *)NFA_DATA (cda[CTA_EXPECT_ID -1 ]);if (exp->id !=ntohl (id)) {nf_conntrack_expect_put (exp);return -ENOENT ;
@@ -1351,8 +1351,7 @@ ctnetlink_del_expect(struct sock *ctnl,return -ENOENT ;if (cda[CTA_EXPECT_ID -1 ]) { -u_int32_t id = - *(u_int32_t *)NFA_DATA (cda[CTA_EXPECT_ID -1 ]); +__be32 id = *(__be32 *)NFA_DATA (cda[CTA_EXPECT_ID -1 ]);if (exp->id !=ntohl (id)) {nf_conntrack_expect_put (exp);return -ENOENT ;
net/netfilter/nf_conntrack_proto_sctp.c +1 -1
@@ -217,7 +217,7 @@ #define for_each_sctp_chunk(skb, sch, _sfor (offset = dataoff +sizeof (sctp_sctphdr_t), count =0 ; \ offset < skb->len && \ (sch =skb_header_pointer (skb, offset,sizeof (_sch), &_sch)); \ - offset += (htons (sch->length) +3 ) & ~3 , count++) + offset += (ntohs (sch->length) +3 ) & ~3 , count++)/* Some validity checks to make sure the chunks are fine */ static int do_basic_checks(struct nf_conn *conntrack,
net/netfilter/nf_conntrack_proto_tcp.c +3 -5
@@ -474,8 +474,8 @@ static void tcp_sack(const struct sk_buf/* Fast path for timestamp-only option */ if (length ==TCPOLEN_TSTAMP_ALIGNED *4 - && *(__u32 *)ptr == -__constant_ntohl ((TCPOPT_NOP <<24 ) + && *(__be32 *)ptr == +__constant_htonl ((TCPOPT_NOP <<24 ) | (TCPOPT_NOP <<16 ) | (TCPOPT_TIMESTAMP <<8 ) |TCPOLEN_TIMESTAMP ))
@@ -506,9 +506,7 @@ static void tcp_sack(const struct sk_buffor (i =0 ; i < (opsize -TCPOLEN_SACK_BASE ); i +=TCPOLEN_SACK_PERBLOCK ) { -memcpy (&tmp, (__u32 *)(ptr + i) +1 , -sizeof (__u32)); - tmp =ntohl (tmp); + tmp =ntohl (*((__be32 *)(ptr+i)+1 ));if (after (tmp, *sack)) *sack = tmp;
PATCH 5/20 : nf_conntrack: automatic helper assignment for expectations
In reply to Patrick McHardy[NETFILTER]: nf_conntrack: automatic helper assignment for expectations
Some helpers (namely H.323) manually assign further helpers to expected connections. This is not possible with nf_conntrack anymore since we need to know whether a helper is used at allocation time.
Handle the helper assignment centrally, which allows to perform the correct allocation and as a nice side effect eliminates the need for the H.323 helper to fiddle with nf_conntrack_lock.
Mid term the allocation scheme really needs to be redesigned since we do both the helper and expectation lookup _twice_ for every new connection.
---
commit fff1e474556ff5fcae813c7b73a0a95c2b7143fc
tree 7f00d21c569f225d6990741a96a2905a0a02d788
parent 3dc28b1e6e6e9e4f9064ab33fa57b56ccb9a7a67
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:33:57 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:33:57 +0100
include/net/netfilter/nf_conntrack_expect.h | 3 +++ net/netfilter/nf_conntrack_core.c | 19 ++++++++++++++----- net/netfilter/nf_conntrack_ftp.c | 1 + net/netfilter/nf_conntrack_helper.c | 3 ++- net/netfilter/nf_conntrack_netlink.c | 1 + 5 files changed, 21 insertions(+), 6 deletions(-)
include/net/netfilter/nf_conntrack_expect.h +3 -0
@@ -22,6 +22,9 @@ struct nf_conntrack_expectvoid (*expectfn)(struct nf_conn *new,struct nf_conntrack_expect *this); +/* Helper to assign to new connection */ +struct nf_conntrack_helper *helper; +/* The conntrack of the master connection */ struct nf_conn *master;
net/netfilter/nf_conntrack_core.c +14 -5
@@ -545,10 +545,10 @@ static int early_drop(struct list_head *static struct nf_conn *__nf_conntrack_alloc (const struct nf_conntrack_tuple *orig,const struct nf_conntrack_tuple *repl, -const struct nf_conntrack_l3proto *l3proto) +const struct nf_conntrack_l3proto *l3proto, +u_int32_t features) {struct nf_conn *conntrack =NULL ; -u_int32_t features =0 ;struct nf_conntrack_helper *helper;if (unlikely (!nf_conntrack_hash_rnd_initted)) {
@@ -574,7 +574,7 @@ __nf_conntrack_alloc(const struct nf_con }/* find features needed by this conntrack. */ - features = l3proto->get_features (orig); + features |= l3proto->get_features (orig);/* FIXME: protect helper list per RCU */ read_lock_bh (&nf_conntrack_lock);
@@ -624,7 +624,7 @@ struct nf_conn *nf_conntrack_alloc(conststruct nf_conntrack_l3proto *l3proto; l3proto =__nf_ct_l3proto_find (orig->src.l3num); -return __nf_conntrack_alloc (orig, repl, l3proto); +return __nf_conntrack_alloc (orig, repl, l3proto,0 ); }void nf_conntrack_free (struct nf_conn *conntrack)
@@ -649,13 +649,20 @@ init_conntrack(const struct nf_conntrackstruct nf_conn *conntrack;struct nf_conntrack_tuple repl_tuple;struct nf_conntrack_expect *exp; +u_int32_t features =0 ;if (!nf_ct_invert_tuple (&repl_tuple, tuple, l3proto, l4proto)) {DEBUGP ("Can't invert tuple.\n" );return NULL ; } - conntrack =__nf_conntrack_alloc (tuple, &repl_tuple, l3proto); +read_lock_bh (&nf_conntrack_lock); + exp =__nf_conntrack_expect_find (tuple); +if (exp && exp->helper) + features =NF_CT_F_HELP ; +read_unlock_bh (&nf_conntrack_lock); + + conntrack =__nf_conntrack_alloc (tuple, &repl_tuple, l3proto, features);if (conntrack ==NULL ||IS_ERR (conntrack)) {DEBUGP ("Can't allocate conntrack.\n" );return (struct nf_conntrack_tuple_hash *)conntrack;
@@ -676,6 +683,8 @@ init_conntrack(const struct nf_conntrack/* Welcome, Mr. Bond. We've been expecting you... */ __set_bit (IPS_EXPECTED_BIT , &conntrack->status); conntrack->master = exp->master; +if (exp->helper) +nfct_help (conntrack)->helper = exp->helper;#ifdef CONFIG_NF_CONNTRACK_MARK conntrack->mark = exp->master->mark;#endif
net/netfilter/nf_conntrack_ftp.c +1 -0
@@ -516,6 +516,7 @@ static int help(struct sk_buff **pskb, } exp->expectfn =NULL ; + exp->helper =NULL ; exp->flags =0 ;/* Now, NAT might want to mangle the packet, and register the
net/netfilter/nf_conntrack_helper.c +2 -1
@@ -129,7 +129,8 @@ void nf_conntrack_helper_unregister(stru/* Get rid of expectations */ list_for_each_entry_safe (exp, tmp, &nf_conntrack_expect_list, list) {struct nf_conn_help *help =nfct_help (exp->master); -if (help->helper == me &&del_timer (&exp->timeout)) { +if ((help->helper == me || exp->helper == me) && +del_timer (&exp->timeout)) {nf_ct_unlink_expect (exp);nf_conntrack_expect_put (exp); }
net/netfilter/nf_conntrack_netlink.c +1 -0
@@ -1447,6 +1447,7 @@ ctnetlink_create_expect(struct nfattr *c exp->expectfn =NULL ; exp->flags =0 ; exp->master = ct; + exp->helper =NULL ;memcpy (&exp->tuple, &tuple,sizeof (struct nf_conntrack_tuple ));memcpy (&exp->mask, &mask,sizeof (struct nf_conntrack_tuple ));
PATCH 6/20 : Kconfig: improve conntrack selection
In reply to Patrick McHardy[NETFILTER]: Kconfig: improve conntrack selection
Improve the connection tracking selection (well, the user experience, not really the aesthetics) by offering one option to enable connection tracking and a choice between the implementations.
---
commit 03143a9731c29b2c5bd72881d76471d9d68922d0
tree e21b3fa96fd59e2688c323bc42861a1883ec40d5
parent fff1e474556ff5fcae813c7b73a0a95c2b7143fc
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:33:58 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:33:58 +0100
net/ipv4/netfilter/Kconfig | 14 ------------ net/netfilter/Kconfig | 50 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 44 insertions(+), 20 deletions(-)
net/ipv4/netfilter/Kconfig +0 -14
@@ -31,20 +31,6 @@ config NF_CONNTRACK_PROC_COMPAT If unsure, say Y. # connection tracking, helpers and protocols -config IP_NF_CONNTRACK - tristate "Connection tracking (required for masq/NAT)" - ---help--- - Connection tracking keeps a record of what packets have passed - through your machine, in order to figure out how they are related - into connections. - - This is required to do Masquerading or other kinds of Network - Address Translation (except for Fast NAT). It can also be used to - enhance packet filtering (see `Connection state match support' - below). - - To compile it as a module, choose M here. If unsure, say N. - config IP_NF_CT_ACCT bool "Connection tracking flow accounting" depends on IP_NF_CONNTRACK
net/netfilter/Kconfig +44 -6
63 lines not on this page · raw message
PATCH 7/20 : nf_conntrack: add module aliases to IPv4 conntrack names
In reply to Patrick McHardy[NETFILTER]: nf_conntrack: add module aliases to IPv4 conntrack names
---
commit 970f82888147acc34d493064dfe66d4374063e90
tree faccd8e1da38a3324f5fe1a9a8e4c29881474775
parent 03143a9731c29b2c5bd72881d76471d9d68922d0
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:33:59 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:33:59 +0100
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 1 + net/netfilter/nf_conntrack_ftp.c | 1 + net/netfilter/nf_conntrack_netlink.c | 1 + net/netfilter/nf_conntrack_proto_sctp.c | 1 + 4 files changed, 4 insertions(+), 0 deletions(-)
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +1 -0
@@ -446,6 +446,7 @@ #endif };MODULE_ALIAS ("nf_conntrack-" __stringify(AF_INET )); +MODULE_ALIAS ("ip_conntrack" );MODULE_LICENSE ("GPL" );static int __init nf_conntrack_l3proto_ipv4_init (void )
net/netfilter/nf_conntrack_ftp.c +1 -0
@@ -34,6 +34,7 @@ #include <linux/netfilter/nf_conntrack_fMODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Rusty Russell <[email protected]>" );MODULE_DESCRIPTION ("ftp connection tracking helper" ); +MODULE_ALIAS ("ip_conntrack_ftp" );/* This is slow, but it's simple. --RR */ static char *ftp_buffer;
net/netfilter/nf_conntrack_netlink.c +1 -0
@@ -1544,6 +1544,7 @@ static struct nfnetlink_subsystem ctnl_e .cb = ctnl_exp_cb, }; +MODULE_ALIAS ("ip_conntrack_netlink" );MODULE_ALIAS_NFNL_SUBSYS (NFNL_SUBSYS_CTNETLINK );MODULE_ALIAS_NFNL_SUBSYS (NFNL_SUBSYS_CTNETLINK_EXP );
net/netfilter/nf_conntrack_proto_sctp.c +1 -0
@@ -716,3 +716,4 @@ module_exit(nf_conntrack_proto_sctp_finiMODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Kiran Kumar Immidi" );MODULE_DESCRIPTION ("Netfilter connection tracking protocol helper for SCTP" ); +MODULE_ALIAS ("ip_conntrack_proto_sctp" );
PATCH 8/20 : Add NAT support for nf_conntrack
In reply to Patrick McHardy[NETFILTER]: Add NAT support for nf_conntrack
Add NAT support for nf_conntrack. Joint work of Jozsef Kadlecsik, Yasuyuki Kozakai, Martin Josefsson and myself.
---
commit 1c341bc77a3d189d65ce0455640ac03a1dc293da
tree 57109aec020a31d86ed8df9642a70d7e425d6ee2
parent 970f82888147acc34d493064dfe66d4374063e90
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:04 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:04 +0100
include/linux/netfilter.h | 2 include/net/netfilter/ipv4/nf_conntrack_ipv4.h | 20 - include/net/netfilter/nf_conntrack.h | 29 + include/net/netfilter/nf_conntrack_expect.h | 2 include/net/netfilter/nf_nat.h | 77 +++ include/net/netfilter/nf_nat_core.h | 27 + include/net/netfilter/nf_nat_helper.h | 32 + include/net/netfilter/nf_nat_protocol.h | 70 +++ include/net/netfilter/nf_nat_rule.h | 35 + net/ipv4/netfilter/Kconfig | 30 + net/ipv4/netfilter/Makefile | 7 net/ipv4/netfilter/ip_nat_standalone.c | 6 net/ipv4/netfilter/ipt_MASQUERADE.c | 29 + net/ipv4/netfilter/ipt_NETMAP.c | 4 net/ipv4/netfilter/ipt_REDIRECT.c | 6 net/ipv4/netfilter/ipt_SAME.c | 12 net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 7 net/ipv4/netfilter/nf_nat_core.c | 647 ++++++++++++++++++++++++ net/ipv4/netfilter/nf_nat_helper.c | 433 ++++++++++++++++ net/ipv4/netfilter/nf_nat_proto_icmp.c | 86 +++ net/ipv4/netfilter/nf_nat_proto_tcp.c | 148 +++++ net/ipv4/netfilter/nf_nat_proto_udp.c | 138 +++++ net/ipv4/netfilter/nf_nat_proto_unknown.c | 54 ++ net/ipv4/netfilter/nf_nat_rule.c | 343 +++++++++++++ net/ipv4/netfilter/nf_nat_standalone.c | 406 +++++++++++++++ net/netfilter/nf_conntrack_core.c | 23 + net/netfilter/nf_conntrack_netlink.c | 46 +- net/netfilter/nf_conntrack_proto_tcp.c | 2 net/netfilter/nf_conntrack_standalone.c | 5 29 files changed, 2667 insertions(+), 59 deletions(-)
include/linux/netfilter.h +1 -1
@@ -357,7 +357,7 @@ extern void (*ip_nat_decode_session)(strstatic inline void nf_nat_decode_session (struct sk_buff *skb,struct flowi *fl,int family) { -#ifdef CONFIG_IP_NF_NAT_NEEDED +#if defined(CONFIG_IP_NF_NAT_NEEDED ) || defined(CONFIG_NF_NAT_NEEDED )void (*decodefn)(struct sk_buff *,struct flowi *);if (family ==AF_INET && (decodefn = ip_nat_decode_session) !=NULL )
include/net/netfilter/ipv4/nf_conntrack_ipv4.h +7 -13
@@ -9,29 +9,23 @@#ifndef _NF_CONNTRACK_IPV4_H#define _NF_CONNTRACK_IPV4_H -#ifdef CONFIG_IP_NF_NAT_NEEDED -#include <linux/netfilter_ipv4/ip_nat.h> +#ifdef CONFIG_NF_NAT_NEEDED +#include <net/netfilter/nf_nat.h> /* per conntrack: nat application helper private data */ -union ip_conntrack_nat_help { +union nf_conntrack_nat_help {/* insert nat helper private data here */ }; -struct nf_conntrack_ipv4_nat { -struct ip_nat_info info; -union ip_conntrack_nat_help help; +struct nf_conn_nat { +struct nf_nat_info info; +union nf_conntrack_nat_help help;#if defined(CONFIG_IP_NF_TARGET_MASQUERADE ) || \ defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE )int masq_index;#endif }; -#endif /* CONFIG_IP_NF_NAT_NEEDED */ - -struct nf_conntrack_ipv4 { -#ifdef CONFIG_IP_NF_NAT_NEEDED -struct nf_conntrack_ipv4_nat *nat; -#endif -}; +#endif /* CONFIG_NF_NAT_NEEDED */ /* Returns new sk_buff, or NULL */ struct sk_buff *
include/net/netfilter/nf_conntrack.h +28 -1
@@ -264,18 +264,45 @@ nf_conntrack_unregister_cache(u_int32_t/* valid combinations: * basic: nf_conn, nf_conn .. nf_conn_help -* nat: nf_conn .. nf_conn_nat, nf_conn .. nf_conn_nat, nf_conn help +* nat: nf_conn .. nf_conn_nat, nf_conn .. nf_conn_nat .. nf_conn help */ +#ifdef CONFIG_NF_NAT_NEEDED +static inline struct nf_conn_nat *nfct_nat (const struct nf_conn *ct) +{ +unsigned int offset =sizeof (struct nf_conn ); + +if (!(ct->features &NF_CT_F_NAT )) +return NULL ; + + offset =ALIGN (offset, __alignof__(struct nf_conn_nat )); +return (struct nf_conn_nat *) ((void *)ct + offset); +} +static inline struct nf_conn_help *nfct_help (const struct nf_conn *ct) {unsigned int offset =sizeof (struct nf_conn );if (!(ct->features &NF_CT_F_HELP ))return NULL ; +if (ct->features &NF_CT_F_NAT ) { + offset =ALIGN (offset, __alignof__(struct nf_conn_nat )); + offset +=sizeof (struct nf_conn_nat ); + } offset =ALIGN (offset, __alignof__(struct nf_conn_help ));return (struct nf_conn_help *) ((void *)ct + offset); } +#else /* No NAT */ +static inline struct nf_conn_help *nfct_help (const struct nf_conn *ct) +{ +unsigned int offset =sizeof (struct nf_conn ); + +if (!(ct->features &NF_CT_F_HELP )) +return NULL ; + offset =ALIGN (offset, __alignof__(struct nf_conn_help )); +return (struct nf_conn_help *) ((void *)ct + offset); +} +#endif /* CONFIG_NF_NAT_NEEDED */ #endif /* __KERNEL__ */ #endif /* _NF_CONNTRACK_H */
include/net/netfilter/nf_conntrack_expect.h +1 -1
@@ -43,7 +43,7 @@ struct nf_conntrack_expect#ifdef CONFIG_NF_NAT_NEEDED /* This is the original per-proto part, used to map the * expected connection the way the recipient expects. */ -union nf_conntrack_manip_proto saved_proto; +union nf_conntrack_man_proto saved_proto;/* Direction relative to the master connection. */ enum ip_conntrack_dir dir;#endif
include/net/netfilter/nf_nat.h new file +77 -0
77 lines not on this page · raw message
include/net/netfilter/nf_nat_core.h new file +27 -0
@@ -0,0 +1,27 @@ +#ifndef _NF_NAT_CORE_H +#define _NF_NAT_CORE_H +#include <linux/list.h> +#include <net/netfilter/nf_conntrack.h> + +/* This header used to share core functionality between the standalone +NAT module, and the compatibility layer's use of NAT for masquerading. */ + +extern unsigned int nf_nat_packet (struct nf_conn *ct, +enum ip_conntrack_info ctinfo, +unsigned int hooknum, +struct sk_buff **pskb); + +extern int nf_nat_icmp_reply_translation (struct nf_conn *ct, +enum ip_conntrack_info ctinfo, +unsigned int hooknum, +struct sk_buff **pskb); + +static inline int nf_nat_initialized (struct nf_conn *ct, +enum nf_nat_manip_type manip) +{ +if (manip ==IP_NAT_MANIP_SRC ) +return test_bit (IPS_SRC_NAT_DONE_BIT , &ct->status); +else +return test_bit (IPS_DST_NAT_DONE_BIT , &ct->status); +} +#endif /* _NF_NAT_CORE_H */
include/net/netfilter/nf_nat_helper.h new file +32 -0
@@ -0,0 +1,32 @@ +#ifndef _NF_NAT_HELPER_H +#define _NF_NAT_HELPER_H +/* NAT protocol helper routines. */ + +#include <net/netfilter/nf_conntrack.h> + +struct sk_buff ; + +/* These return true or false. */ +extern int nf_nat_mangle_tcp_packet (struct sk_buff **skb, +struct nf_conn *ct, +enum ip_conntrack_info ctinfo, +unsigned int match_offset, +unsigned int match_len, +const char *rep_buffer, +unsigned int rep_len); +extern int nf_nat_mangle_udp_packet (struct sk_buff **skb, +struct nf_conn *ct, +enum ip_conntrack_info ctinfo, +unsigned int match_offset, +unsigned int match_len, +const char *rep_buffer, +unsigned int rep_len); +extern int nf_nat_seq_adjust (struct sk_buff **pskb, +struct nf_conn *ct, +enum ip_conntrack_info ctinfo); + +/* Setup NAT on this expected conntrack so it follows master, but goes +* to port ct->master->saved_proto. */ +extern void nf_nat_follow_master (struct nf_conn *ct, +struct nf_conntrack_expect *this); +#endif
include/net/netfilter/nf_nat_protocol.h new file +70 -0
70 lines not on this page · raw message
include/net/netfilter/nf_nat_rule.h new file +35 -0
@@ -0,0 +1,35 @@ +#ifndef _NF_NAT_RULE_H +#define _NF_NAT_RULE_H +#include <net/netfilter/nf_conntrack.h> +#include <net/netfilter/nf_nat.h> +#include <linux/netfilter_ipv4/ip_tables.h> + +/* Compatibility definitions for ipt_FOO modules */ +#define ip_nat_range nf_nat_range +#define ip_conntrack_tuple nf_conntrack_tuple +#define ip_conntrack_get nf_ct_get +#define ip_conntrack nf_conn +#define ip_nat_setup_info nf_nat_setup_info +#define ip_nat_multi_range_compat nf_nat_multi_range_compat +#define ip_ct_iterate_cleanup nf_ct_iterate_cleanup +#define IP_NF_ASSERT NF_CT_ASSERT + +extern int nf_nat_rule_init (void )__init ; +extern void nf_nat_rule_cleanup (void ); +extern int nf_nat_rule_find (struct sk_buff **pskb, +unsigned int hooknum, +const struct net_device *in, +const struct net_device *out, +struct nf_conn *ct, +struct nf_nat_info *info); + +extern unsigned int +alloc_null_binding (struct nf_conn *ct, +struct nf_nat_info *info, +unsigned int hooknum); + +extern unsigned int +alloc_null_binding_confirmed (struct nf_conn *ct, +struct nf_nat_info *info, +unsigned int hooknum); +#endif /* _NF_NAT_RULE_H */
net/ipv4/netfilter/Kconfig +23 -7
@@ -6,7 +6,7 @@ menu "IP: Netfilter Configuration" depends on INET && NETFILTER config NF_CONNTRACK_IPV4 - tristate "IPv4 support for new connection tracking (EXPERIMENTAL)" + tristate "IPv4 support for new connection tracking (required for NAT) (EXPERIMENTAL)" depends on EXPERIMENTAL && NF_CONNTRACK ---help--- Connection tracking keeps a record of what packets have passed
@@ -387,7 +387,7 @@ config IP_NF_TARGET_TCPMSS To compile it as a module, choose M here. If unsure, say N. -# NAT + specific targets +# NAT + specific targets: ip_conntrack config IP_NF_NAT tristate "Full NAT" depends on IP_NF_IPTABLES && IP_NF_CONNTRACK
@@ -398,14 +398,30 @@ config IP_NF_NAT To compile it as a module, choose M here. If unsure, say N. +# NAT + specific targets: nf_conntrack +config NF_NAT + tristate "Full NAT" + depends on IP_NF_IPTABLES && NF_CONNTRACK + help + The Full NAT option allows masquerading, port forwarding and other + forms of full Network Address Port Translation. It is controlled by + the `nat' table in iptables: see the man page for iptables(8). + + To compile it as a module, choose M here. If unsure, say N. + config IP_NF_NAT_NEEDED bool - depends on IP_NF_NAT != n + depends on IP_NF_NAT + default y + +config NF_NAT_NEEDED + bool + depends on NF_NAT default y config IP_NF_TARGET_MASQUERADE tristate "MASQUERADE target support" - depends on IP_NF_NAT + depends on (NF_NAT || IP_NF_NAT) help Masquerading is a special case of NAT: all outgoing connections are changed to seem to come from a particular interface's address, and
@@ -417,7 +433,7 @@ config IP_NF_TARGET_MASQUERADE config IP_NF_TARGET_REDIRECT tristate "REDIRECT target support" - depends on IP_NF_NAT + depends on (NF_NAT || IP_NF_NAT) help REDIRECT is a special case of NAT: all incoming connections are mapped onto the incoming interface's address, causing the packets to
@@ -428,7 +444,7 @@ config IP_NF_TARGET_REDIRECT config IP_NF_TARGET_NETMAP tristate "NETMAP target support" - depends on IP_NF_NAT + depends on (NF_NAT || IP_NF_NAT) help NETMAP is an implementation of static 1:1 NAT mapping of network addresses. It maps the network address part, while keeping the host
@@ -439,7 +455,7 @@ config IP_NF_TARGET_NETMAP config IP_NF_TARGET_SAME tristate "SAME target support" - depends on IP_NF_NAT + depends on (NF_NAT || IP_NF_NAT) help This option adds a `SAME' target, which works like the standard SNAT target, but attempts to give clients the same IP for all connections.
net/ipv4/netfilter/Makefile +7 -0
@@ -5,7 +5,12 @@ # # objects for the standalone - connection tracking / NAT ip_conntrack-objs := ip_conntrack_standalone.o ip_conntrack_core.o ip_conntrack_proto_generic.o ip_conntrack_proto_tcp.o ip_conntrack_proto_udp.o ip_conntrack_proto_icmp.o ip_nat-objs := ip_nat_core.o ip_nat_helper.o ip_nat_proto_unknown.o ip_nat_proto_tcp.o ip_nat_proto_udp.o ip_nat_proto_icmp.o +nf_nat-objs := nf_nat_core.o nf_nat_helper.o nf_nat_proto_unknown.o nf_nat_proto_tcp.o nf_nat_proto_udp.o nf_nat_proto_icmp.o +ifneq ($(CONFIG_NF_NAT),) +iptable_nat-objs := nf_nat_rule.o nf_nat_standalone.o +else iptable_nat-objs := ip_nat_rule.o ip_nat_standalone.o +endif ip_conntrack_pptp-objs := ip_conntrack_helper_pptp.o ip_conntrack_proto_gre.o ip_nat_pptp-objs := ip_nat_helper_pptp.o ip_nat_proto_gre.o
@@ -16,6 +21,7 @@ ip_nat_h323-objs := ip_nat_helper_h323.o # connection tracking obj-$(CONFIG_IP_NF_CONNTRACK) += ip_conntrack.o obj-$(CONFIG_IP_NF_NAT) += ip_nat.o +obj-$(CONFIG_NF_NAT) += nf_nat.o # conntrack netlink interface obj-$(CONFIG_IP_NF_CONNTRACK_NETLINK) += ip_conntrack_netlink.o
@@ -50,6 +56,7 @@ # the three instances of ip_tables obj-$(CONFIG_IP_NF_FILTER) += iptable_filter.o obj-$(CONFIG_IP_NF_MANGLE) += iptable_mangle.o obj-$(CONFIG_IP_NF_NAT) += iptable_nat.o +obj-$(CONFIG_NF_NAT) += iptable_nat.o obj-$(CONFIG_IP_NF_RAW) += iptable_raw.o # matches
net/ipv4/netfilter/ip_nat_standalone.c +0 -6
@@ -44,12 +44,6 @@ #else #define DEBUGP(format, args...)#endif -#define HOOKNAME (hooknum) ((hooknum) == NF_IP_POST_ROUTING ? "POST_ROUTING" \ - : ((hooknum) == NF_IP_PRE_ROUTING ? "PRE_ROUTING" \ - : ((hooknum) == NF_IP_LOCAL_OUT ? "LOCAL_OUT" \ - : ((hooknum) == NF_IP_LOCAL_IN ? "LOCAL_IN" \ - : "*ERROR*"))) -#ifdef CONFIG_XFRM static void nat_decode_session (struct sk_buff *skb,struct flowi *fl) {
net/ipv4/netfilter/ipt_MASQUERADE.c +27 -2
@@ -2,7 +2,7 @@(depending on route). */ /* (C) 1999-2001 Paul `Rusty' Russell -* (C) 2002-2004 Netfilter Core Team <[email protected]> +* (C) 2002-2006 Netfilter Core Team <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -20,7 +20,11 @@ #include <net/ip.h>#include <net/checksum.h> #include <net/route.h> #include <linux/netfilter_ipv4.h> +#ifdef CONFIG_NF_NAT_NEEDED +#include <net/netfilter/nf_nat_rule.h> +#else #include <linux/netfilter_ipv4/ip_nat_rule.h> +#endif #include <linux/netfilter_ipv4/ip_tables.h> MODULE_LICENSE ("GPL" );
@@ -65,23 +69,33 @@ masquerade_target(struct sk_buff **pskb,const struct xt_target *target, const void *targinfo) { +#ifdef CONFIG_NF_NAT_NEEDED + struct nf_conn_nat *nat; +#endif struct ip_conntrack *ct;enum ip_conntrack_info ctinfo; -const struct ip_nat_multi_range_compat *mr;struct ip_nat_range newrange; +const struct ip_nat_multi_range_compat *mr;struct rtable *rt;__be32 newsrc;IP_NF_ASSERT (hooknum ==NF_IP_POST_ROUTING ); ct =ip_conntrack_get (*pskb, &ctinfo); +#ifdef CONFIG_NF_NAT_NEEDED + nat =nfct_nat (ct); +#endif IP_NF_ASSERT (ct && (ctinfo ==IP_CT_NEW || ctinfo ==IP_CT_RELATED || ctinfo ==IP_CT_RELATED +IP_CT_IS_REPLY ));/* Source address is 0.0.0.0 - locally generated packet that is * probably not supposed to be masqueraded. */ +#ifdef CONFIG_NF_NAT_NEEDED +if (ct->tuplehash[IP_CT_DIR_ORIGINAL ].tuple.src.u3.ip ==0 ) +#else if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip == 0) +#endif return NF_ACCEPT ; mr = targinfo;
@@ -93,7 +107,11 @@ masquerade_target(struct sk_buff **pskb, }write_lock_bh (&masq_lock); +#ifdef CONFIG_NF_NAT_NEEDED + nat->masq_index = out->ifindex; +#else ct->nat.masq_index = out->ifindex; +#endif write_unlock_bh (&masq_lock);/* Transfer from original range. */
@@ -109,10 +127,17 @@ masquerade_target(struct sk_buff **pskb,static inline int device_cmp (struct ip_conntrack *i,void *ifindex) { +#ifdef CONFIG_NF_NAT_NEEDED +struct nf_conn_nat *nat =nfct_nat (i); +#endif int ret;read_lock_bh (&masq_lock); +#ifdef CONFIG_NF_NAT_NEEDED + ret = (nat->masq_index == (int )(long )ifindex); +#else ret = (i->nat.masq_index == (int )(long )ifindex); +#endif read_unlock_bh (&masq_lock);return ret;
net/ipv4/netfilter/ipt_NETMAP.c +4 -0
@@ -15,7 +15,11 @@ #include <linux/module.h>#include <linux/netdevice.h> #include <linux/netfilter.h> #include <linux/netfilter_ipv4.h> +#ifdef CONFIG_NF_NAT_NEEDED +#include <net/netfilter/nf_nat_rule.h> +#else #include <linux/netfilter_ipv4/ip_nat_rule.h> +#endif #define MODULENAME "NETMAP"MODULE_LICENSE ("GPL" );
net/ipv4/netfilter/ipt_REDIRECT.c +5 -1
@@ -1,6 +1,6 @@/* Redirect. Simple mapping which alters dst to a local IP address. */ /* (C) 1999-2001 Paul `Rusty' Russell -* (C) 2002-2004 Netfilter Core Team <[email protected]> +* (C) 2002-2006 Netfilter Core Team <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -18,7 +18,11 @@ #include <linux/inetdevice.h>#include <net/protocol.h> #include <net/checksum.h> #include <linux/netfilter_ipv4.h> +#ifdef CONFIG_NF_NAT_NEEDED +#include <net/netfilter/nf_nat_rule.h> +#else #include <linux/netfilter_ipv4/ip_nat_rule.h> +#endif MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Netfilter Core Team <[email protected]>" );
net/ipv4/netfilter/ipt_SAME.c +11 -1
@@ -34,7 +34,11 @@ #include <linux/inetdevice.h>#include <net/protocol.h> #include <net/checksum.h> #include <linux/netfilter_ipv4.h> +#ifdef CONFIG_NF_NAT_NEEDED +#include <net/netfilter/nf_nat_rule.h> +#else #include <linux/netfilter_ipv4/ip_nat_rule.h> +#endif #include <linux/netfilter_ipv4/ipt_SAME.h> MODULE_LICENSE ("GPL" );
@@ -152,11 +156,17 @@ same_target(struct sk_buff **pskb,Here we calculate the index in same->iparray which holds the ipaddress we should use */ +#ifdef CONFIG_NF_NAT_NEEDED + tmpip =ntohl (t->src.u3.ip); + +if (!(same->info &IPT_SAME_NODST )) + tmpip +=ntohl (t->dst.u3.ip); +#else tmpip =ntohl (t->src.ip);if (!(same->info &IPT_SAME_NODST )) tmpip +=ntohl (t->dst.ip); - +#endif aindex = tmpip % same->ipnum; new_ip =htonl (same->iparray[aindex]);
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +5 -2
@@ -111,10 +111,10 @@ ipv4_prepare(struct sk_buff **pskb, unsireturn NF_ACCEPT ; } -int nat_module_is_loaded =0 ; +int nf_nat_module_is_loaded =0 ;static u_int32_t ipv4_get_features (const struct nf_conntrack_tuple *tuple) { -if (nat_module_is_loaded) +if (nf_nat_module_is_loaded)return NF_CT_F_NAT ;return NF_CT_F_BASIC ;
@@ -532,3 +532,6 @@ module_init(nf_conntrack_l3proto_ipv4_inmodule_exit (nf_conntrack_l3proto_ipv4_fini);EXPORT_SYMBOL (nf_ct_ipv4_gather_frags); +#ifdef CONFIG_NF_NAT_NEEDED +EXPORT_SYMBOL (nf_nat_module_is_loaded); +#endif
net/ipv4/netfilter/nf_nat_core.c new file +647 -0
647 lines not on this page · raw message
net/ipv4/netfilter/nf_nat_helper.c new file +433 -0
433 lines not on this page · raw message
net/ipv4/netfilter/nf_nat_proto_icmp.c new file +86 -0
86 lines not on this page · raw message
net/ipv4/netfilter/nf_nat_proto_tcp.c new file +148 -0
148 lines not on this page · raw message
net/ipv4/netfilter/nf_nat_proto_udp.c new file +138 -0
138 lines not on this page · raw message
net/ipv4/netfilter/nf_nat_proto_unknown.c new file +54 -0
54 lines not on this page · raw message
net/ipv4/netfilter/nf_nat_rule.c new file +343 -0
343 lines not on this page · raw message
net/ipv4/netfilter/nf_nat_standalone.c new file +406 -0
406 lines not on this page · raw message
net/netfilter/nf_conntrack_core.c +22 -1
@@ -579,7 +579,8 @@ __nf_conntrack_alloc(const struct nf_con/* FIXME: protect helper list per RCU */ read_lock_bh (&nf_conntrack_lock); helper =__nf_ct_helper_find (repl); -if (helper) +/* NAT might want to assign a helper later */ +if (helper || features &NF_CT_F_NAT ) features |=NF_CT_F_HELP ;read_unlock_bh (&nf_conntrack_lock);
@@ -850,6 +851,26 @@ int nf_ct_invert_tuplepr(struct nf_connt orig->dst.protonum)); } +/* Alter reply tuple (maybe alter helper). This is for NAT, and is +implicitly racy: see __nf_conntrack_confirm */ +void nf_conntrack_alter_reply (struct nf_conn *ct, +const struct nf_conntrack_tuple *newreply) +{ +struct nf_conn_help *help =nfct_help (ct); + +write_lock_bh (&nf_conntrack_lock); +/* Should be unconfirmed, so not in hash table yet */ +NF_CT_ASSERT (!nf_ct_is_confirmed (ct)); + +DEBUGP ("Altering reply tuple of %p to " , ct); +NF_CT_DUMP_TUPLE (newreply); + + ct->tuplehash[IP_CT_DIR_REPLY ].tuple = *newreply; +if (!ct->master && help && help->expecting ==0 ) + help->helper =__nf_ct_helper_find (newreply); +write_unlock_bh (&nf_conntrack_lock); +} +/* Refresh conntrack for this many jiffies and do accounting if do_acct is 1 */ void __nf_ct_refresh_acct(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
net/netfilter/nf_conntrack_netlink.c +25 -21
104 lines not on this page · raw message
net/netfilter/nf_conntrack_standalone.c +4 -1
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
PATCH 9/20 : nf_nat: add FTP NAT helper port
In reply to Patrick McHardy[NETFILTER]: nf_nat: add FTP NAT helper port
Add FTP NAT helper.
Split out from Jozsef's big nf_nat patch with a few small fixes by myself.
---
commit c36fe54cbb2515da933901095b4df503d9943bfd
tree bbf545c88377c653114b4fb759e3e52438690962
parent 1c341bc77a3d189d65ce0455640ac03a1dc293da
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:05 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:05 +0100
include/linux/netfilter/nf_conntrack_ftp.h | 20 +-- include/linux/netfilter_ipv4/ip_conntrack_ftp.h | 40 +++++ include/net/netfilter/nf_conntrack.h | 2 net/ipv4/netfilter/Kconfig | 25 ++- net/ipv4/netfilter/Makefile | 5 + net/ipv4/netfilter/nf_nat_ftp.c | 179 +++++++++++++++++++++++ net/netfilter/nf_conntrack_ftp.c | 20 +-- 7 files changed, 260 insertions(+), 31 deletions(-)
include/linux/netfilter/nf_conntrack_ftp.h +10 -10
@@ -3,16 +3,16 @@ #define _NF_CONNTRACK_FTP_H/* FTP tracking. */ /* This enum is exposed to userspace */ -enum ip_ct_ftp_type +enum nf_ct_ftp_type {/* PORT command from client */ -IP_CT_FTP_PORT , +NF_CT_FTP_PORT ,/* PASV response from server */ -IP_CT_FTP_PASV , +NF_CT_FTP_PASV ,/* EPRT command from client */ -IP_CT_FTP_EPRT , +NF_CT_FTP_EPRT ,/* EPSV response from server */ -IP_CT_FTP_EPSV , +NF_CT_FTP_EPSV , };#ifdef __KERNEL__
@@ -21,23 +21,23 @@ #define FTP_PORT 21#define NUM_SEQ_TO_REMEMBER 2/* This structure exists only once per master */ -struct ip_ct_ftp_master { +struct nf_ct_ftp_master {/* Valid seq positions for cmd matching after newline */ u_int32_t seq_aft_nl[IP_CT_DIR_MAX ][NUM_SEQ_TO_REMEMBER ];/* 0 means seq_match_aft_nl not set */ int seq_aft_nl_num[IP_CT_DIR_MAX ]; }; -struct ip_conntrack_expect ; +struct nf_conntrack_expect ;/* For NAT to hook in when we find a packet which describes what other * connection we should expect. */ -extern unsigned int (*ip_nat_ftp_hook)(struct sk_buff **pskb, +extern unsigned int (*nf_nat_ftp_hook)(struct sk_buff **pskb,enum ip_conntrack_info ctinfo, -enum ip_ct_ftp_type type, +enum nf_ct_ftp_type type,unsigned int matchoff,unsigned int matchlen, -struct ip_conntrack_expect *exp, +struct nf_conntrack_expect *exp,u32 *seq);#endif /* __KERNEL__ */
include/linux/netfilter_ipv4/ip_conntrack_ftp.h +39 -1
@@ -1,6 +1,44 @@#ifndef _IP_CONNTRACK_FTP_H#define _IP_CONNTRACK_FTP_H +/* FTP tracking. */ -#include <linux/netfilter/nf_conntrack_ftp.h> +/* This enum is exposed to userspace */ +enum ip_ct_ftp_type +{ +/* PORT command from client */ +IP_CT_FTP_PORT , +/* PASV response from server */ +IP_CT_FTP_PASV , +/* EPRT command from client */ +IP_CT_FTP_EPRT , +/* EPSV response from server */ +IP_CT_FTP_EPSV , +}; + +#ifdef __KERNEL__ + +#define FTP_PORT 21 + +#define NUM_SEQ_TO_REMEMBER 2 +/* This structure exists only once per master */ +struct ip_ct_ftp_master { +/* Valid seq positions for cmd matching after newline */ +u_int32_t seq_aft_nl[IP_CT_DIR_MAX ][NUM_SEQ_TO_REMEMBER ]; +/* 0 means seq_match_aft_nl not set */ +int seq_aft_nl_num[IP_CT_DIR_MAX ]; +}; + +struct ip_conntrack_expect ; + +/* For NAT to hook in when we find a packet which describes what other +* connection we should expect. */ +extern unsigned int (*ip_nat_ftp_hook)(struct sk_buff **pskb, +enum ip_conntrack_info ctinfo, +enum ip_ct_ftp_type type, +unsigned int matchoff, +unsigned int matchlen, +struct ip_conntrack_expect *exp, +u32 *seq); +#endif /* __KERNEL__ */ #endif /* _IP_CONNTRACK_FTP_H */
include/net/netfilter/nf_conntrack.h +1 -1
@@ -45,7 +45,7 @@ #include <linux/netfilter/nf_conntrack_f/* per conntrack: application helper private data */ union nf_conntrack_help {/* insert conntrack helper private data (master) here */ -struct ip_ct_ftp_master ct_ftp_info; +struct nf_ct_ftp_master ct_ftp_info; };#include <linux/types.h>
net/ipv4/netfilter/Kconfig +17 -8
@@ -477,20 +477,29 @@ config IP_NF_NAT_SNMP_BASIC To compile it as a module, choose M here. If unsure, say N. +# If they want FTP, set to $CONFIG_IP_NF_NAT (m or y), +# or $CONFIG_IP_NF_FTP (m or y), whichever is weaker. +# From kconfig-language.txt: +# +# <expr> '&&' <expr> (6) +# +# (6) Returns the result of min(/expr/, /expr/). +config IP_NF_NAT_FTP + tristate + depends on IP_NF_IPTABLES && IP_NF_CONNTRACK && IP_NF_NAT + default IP_NF_NAT && IP_NF_FTP + +config NF_NAT_FTP + tristate + depends on IP_NF_IPTABLES && NF_CONNTRACK && NF_NAT + default NF_NAT && NF_CONNTRACK_FTP + config IP_NF_NAT_IRC tristate depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n default IP_NF_NAT if IP_NF_IRC=y default m if IP_NF_IRC=m -# If they want FTP, set to $CONFIG_IP_NF_NAT (m or y), -# or $CONFIG_IP_NF_FTP (m or y), whichever is weaker. Argh. -config IP_NF_NAT_FTP - tristate - depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n - default IP_NF_NAT if IP_NF_FTP=y - default m if IP_NF_FTP=m - config IP_NF_NAT_TFTP tristate depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n
net/ipv4/netfilter/Makefile +4 -1
@@ -40,7 +40,7 @@ obj-$(CONFIG_IP_NF_IRC) += ip_conntrack_ obj-$(CONFIG_IP_NF_SIP) += ip_conntrack_sip.o obj-$(CONFIG_IP_NF_NETBIOS_NS) += ip_conntrack_netbios_ns.o -# NAT helpers +# NAT helpers (ip_conntrack) obj-$(CONFIG_IP_NF_NAT_H323) += ip_nat_h323.o obj-$(CONFIG_IP_NF_NAT_PPTP) += ip_nat_pptp.o obj-$(CONFIG_IP_NF_NAT_AMANDA) += ip_nat_amanda.o
@@ -49,6 +49,9 @@ obj-$(CONFIG_IP_NF_NAT_FTP) += ip_nat_ft obj-$(CONFIG_IP_NF_NAT_IRC) += ip_nat_irc.o obj-$(CONFIG_IP_NF_NAT_SIP) += ip_nat_sip.o +# NAT helpers (nf_conntrack) +obj-$(CONFIG_NF_NAT_FTP) += nf_nat_ftp.o + # generic IP tables obj-$(CONFIG_IP_NF_IPTABLES) += ip_tables.o
net/ipv4/netfilter/nf_nat_ftp.c new file +179 -0
179 lines not on this page · raw message
net/netfilter/nf_conntrack_ftp.c +10 -10
@@ -51,7 +51,7 @@ module_param(loose, bool, 0600); unsigned int (*nf_nat_ftp_hook)(struct sk_buff **pskb, enum ip_conntrack_info ctinfo, - enum ip_ct_ftp_type type, + enum nf_ct_ftp_type type, unsigned int matchoff, unsigned int matchlen, struct nf_conntrack_expect *exp,
@@ -74,7 +74,7 @@ static struct ftp_search {size_t plen;char skip;char term; -enum ip_ct_ftp_type ftptype; +enum nf_ct_ftp_type ftptype;int (*getnum)(const char *,size_t ,struct nf_conntrack_man *,char ); } search[IP_CT_DIR_MAX][2] = { [IP_CT_DIR_ORIGINAL] = {
@@ -83,7 +83,7 @@ static struct ftp_search { .plen = sizeof("PORT") - 1, .skip = ' ', .term = '\r', - .ftptype = IP_CT_FTP_PORT, + .ftptype = NF_CT_FTP_PORT, .getnum = try_rfc959, }, {
@@ -91,7 +91,7 @@ static struct ftp_search { .plen = sizeof("EPRT") - 1, .skip = ' ', .term = '\r', - .ftptype = IP_CT_FTP_EPRT, + .ftptype = NF_CT_FTP_EPRT, .getnum = try_eprt, }, },
@@ -101,7 +101,7 @@ static struct ftp_search { .plen = sizeof("227 ") - 1, .skip = '(', .term = ')', - .ftptype = IP_CT_FTP_PASV, + .ftptype = NF_CT_FTP_PASV, .getnum = try_rfc959, }, {
@@ -109,7 +109,7 @@ static struct ftp_search { .plen = sizeof("229 ") - 1, .skip = '(', .term = ')', - .ftptype = IP_CT_FTP_EPSV, + .ftptype = NF_CT_FTP_EPSV, .getnum = try_epsv_response, }, },
@@ -320,7 +320,7 @@ #endif }/* Look up to see if we're just after a \n. */ -static int find_nl_seq (u32 seq,const struct ip_ct_ftp_master *info,int dir) +static int find_nl_seq (u32 seq,const struct nf_ct_ftp_master *info,int dir) {unsigned int i;
@@ -331,7 +331,7 @@ static int find_nl_seq(u32 seq, const st }/* We don't update if it's older than what we have. */ -static void update_nl_seq (u32 nl_seq,struct ip_ct_ftp_master *info,int dir, +static void update_nl_seq (u32 nl_seq,struct nf_ct_ftp_master *info,int dir,struct sk_buff *skb) {unsigned int i, oldest =NUM_SEQ_TO_REMEMBER ;
@@ -367,7 +367,7 @@ static int help(struct sk_buff **pskb,u32 seq;int dir =CTINFO2DIR (ctinfo);unsigned int matchlen, matchoff; -struct ip_ct_ftp_master *ct_ftp_info = &nfct_help (ct)->help.ct_ftp_info; +struct nf_ct_ftp_master *ct_ftp_info = &nfct_help (ct)->help.ct_ftp_info;struct nf_conntrack_expect *exp;struct nf_conntrack_man cmd = {};unsigned int i;
@@ -523,7 +523,7 @@ static int help(struct sk_buff **pskb,/* Now, NAT might want to mangle the packet, and register the * (possibly changed) expectation itself. */ nf_nat_ftp =rcu_dereference (nf_nat_ftp_hook); -if (nf_nat_ftp) +if (nf_nat_ftp && ct->status &IPS_NAT_MASK ) ret =nf_nat_ftp (pskb, ctinfo, search[dir][i].ftptype, matchoff, matchlen, exp, &seq);else {
PATCH 10/20 : nf_conntrack: add helper function for expectation initialization
In reply to Patrick McHardy[NETFILTER]: nf_conntrack: add helper function for expectation initialization
Expectation address masks need to be differently initialized depending on the address family, create helper function to avoid cluttering up the code too much.
---
commit 3aaeacdbed7ac9ef0fbf569f45c8a9ee4323ab19
tree 3288e7f3bae1c703aac53b7a2063e9adb74745ff
parent c36fe54cbb2515da933901095b4df503d9943bfd
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:07 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:07 +0100
include/net/netfilter/nf_conntrack_expect.h | 4 ++ include/net/netfilter/nf_conntrack_tuple.h | 10 +--- net/netfilter/nf_conntrack_expect.c | 68 +++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 7 deletions(-)
include/net/netfilter/nf_conntrack_expect.h +4 -0
@@ -68,6 +68,10 @@ void nf_conntrack_unexpect_related(struc/* Allocate space for an expectation: this is mandatory before calling nf_conntrack_expect_related. You will have to call put afterwards. */ struct nf_conntrack_expect *nf_conntrack_expect_alloc (struct nf_conn *me); +void nf_conntrack_expect_init (struct nf_conntrack_expect *,int , +union nf_conntrack_address *, +union nf_conntrack_address *, +u_int8_t ,__be16 *,__be16 *);void nf_conntrack_expect_put (struct nf_conntrack_expect *exp);int nf_conntrack_expect_related (struct nf_conntrack_expect *expect);
include/net/netfilter/nf_conntrack_tuple.h +3 -7
@@ -24,7 +24,7 @@ #define NF_CT_TUPLE_L3SIZE 4/* The l3 protocol-specific manipulable parts of the tuple: always in network order! */ -union nf_conntrack_man_l3proto { +union nf_conntrack_address {u_int32_t all[NF_CT_TUPLE_L3SIZE ];__be32 ip;__be32 ip6[4 ];
@@ -54,7 +54,7 @@ union nf_conntrack_man_proto/* The manipulable part of the tuple. */ struct nf_conntrack_man { -union nf_conntrack_man_l3proto u3; +union nf_conntrack_address u3;union nf_conntrack_man_proto u;/* Layer 3 protocol */ u_int16_t l3num;
@@ -67,11 +67,7 @@ struct nf_conntrack_tuple/* These are the parts of the tuple which are fixed. */ struct { -union { -u_int32_t all[NF_CT_TUPLE_L3SIZE ]; -u_int32_t ip; -u_int32_t ip6[4 ]; - } u3; +union nf_conntrack_address u3;union {/* Add other protocols here. */ u_int16_t all;
net/netfilter/nf_conntrack_expect.c +68 -0
74 lines not on this page · raw message
PATCH 11/20 : nf_conntrack/nf_nat: add amanda helper port
In reply to Patrick McHardy[NETFILTER]: nf_conntrack/nf_nat: add amanda helper port
Add IPv4 and IPv6 capable nf_conntrack port of the Amanda conntrack/NAT helper.
---
commit ff0a8e885f158f305e07bddc42071c531930db6f
tree 7cf2ed667a7f3fa43618b2062a9096716f0c4c2f
parent 3aaeacdbed7ac9ef0fbf569f45c8a9ee4323ab19
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:08 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:08 +0100
include/linux/netfilter/nf_conntrack_amanda.h | 10 + net/ipv4/netfilter/Kconfig | 5 + net/ipv4/netfilter/Makefile | 1 net/ipv4/netfilter/nf_nat_amanda.c | 78 ++++++++ net/netfilter/Kconfig | 15 ++ net/netfilter/Makefile | 1 net/netfilter/nf_conntrack_amanda.c | 237 +++++++++++++++++++++++++ 7 files changed, 347 insertions(+), 0 deletions(-)
include/linux/netfilter/nf_conntrack_amanda.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef _NF_CONNTRACK_AMANDA_H +#define _NF_CONNTRACK_AMANDA_H +/* AMANDA tracking. */ + +extern unsigned int (*nf_nat_amanda_hook)(struct sk_buff **pskb, +enum ip_conntrack_info ctinfo, +unsigned int matchoff, +unsigned int matchlen, +struct nf_conntrack_expect *exp); +#endif /* _NF_CONNTRACK_AMANDA_H */
net/ipv4/netfilter/Kconfig +5 -0
@@ -512,6 +512,11 @@ config IP_NF_NAT_AMANDA default IP_NF_NAT if IP_NF_AMANDA=y default m if IP_NF_AMANDA=m +config NF_NAT_AMANDA + tristate + depends on IP_NF_IPTABLES && NF_CONNTRACK && NF_NAT + default NF_NAT && NF_CONNTRACK_AMANDA + config IP_NF_NAT_PPTP tristate depends on IP_NF_NAT!=n && IP_NF_PPTP!=n
net/ipv4/netfilter/Makefile +1 -0
@@ -50,6 +50,7 @@ obj-$(CONFIG_IP_NF_NAT_IRC) += ip_nat_ir obj-$(CONFIG_IP_NF_NAT_SIP) += ip_nat_sip.o # NAT helpers (nf_conntrack) +obj-$(CONFIG_NF_NAT_AMANDA) += nf_nat_amanda.o obj-$(CONFIG_NF_NAT_FTP) += nf_nat_ftp.o # generic IP tables
net/ipv4/netfilter/nf_nat_amanda.c new file +78 -0
78 lines not on this page · raw message
net/netfilter/Kconfig +15 -0
@@ -131,6 +131,21 @@ config NF_CT_PROTO_SCTP If you want to compile it as a module, say M here and read Documentation/modules.txt. If unsure, say `N'. +config NF_CONNTRACK_AMANDA + tristate "Amanda backup protocol support (EXPERIMENTAL)" + depends on EXPERIMENTAL && NF_CONNTRACK + select TEXTSEARCH + select TEXTSEARCH_KMP + help + If you are running the Amanda backup package <http://www.amanda.org/> + on this machine or machines that will be MASQUERADED through this + machine, then you may want to enable this feature. This allows the + connection tracking and natting code to allow the sub-channels that + Amanda requires for communication of the backup data, messages and + index. + + To compile it as a module, choose M here. If unsure, say N. + config NF_CONNTRACK_FTP tristate "FTP support on new connection tracking (EXPERIMENTAL)" depends on EXPERIMENTAL && NF_CONNTRACK
net/netfilter/Makefile +1 -0
@@ -20,6 +20,7 @@ # netlink interface for nf_conntrack obj-$(CONFIG_NF_CT_NETLINK) += nf_conntrack_netlink.o # connection tracking helpers +obj-$(CONFIG_NF_CONNTRACK_AMANDA) += nf_conntrack_amanda.o obj-$(CONFIG_NF_CONNTRACK_FTP) += nf_conntrack_ftp.o # generic X tables
net/netfilter/nf_conntrack_amanda.c new file +237 -0
237 lines not on this page · raw message
PATCH 13/20 : nf_conntrack/nf_nat: add IRC helper port
In reply to Patrick McHardy[NETFILTER]: nf_conntrack/nf_nat: add IRC helper port
Add nf_conntrack port of the IRC conntrack/NAT helper. Since DCC doesn't support IPv6 yet, the helper is still IPv4 only.
---
commit 40f6096353cbb0a314c42355ad927c54a849d092
tree 38e7783febc87a8b53c27c09ebdb28c4d5001b0f
parent b8dfee1057b0a3515ec561fd928e49204bbc4c4a
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:14 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:14 +0100
include/linux/netfilter/nf_conntrack_irc.h | 15 + net/ipv4/netfilter/Kconfig | 5 net/ipv4/netfilter/Makefile | 1 net/ipv4/netfilter/nf_nat_irc.c | 101 ++++++++++ net/netfilter/Kconfig | 15 + net/netfilter/Makefile | 1 net/netfilter/nf_conntrack_irc.c | 281 ++++++++++++++++++++++++++++ 7 files changed, 419 insertions(+), 0 deletions(-)
include/linux/netfilter/nf_conntrack_irc.h new file +15 -0
@@ -0,0 +1,15 @@ +#ifndef _NF_CONNTRACK_IRC_H +#define _NF_CONNTRACK_IRC_H + +#ifdef __KERNEL__ + +#define IRC_PORT 6667 + +extern unsigned int (*nf_nat_irc_hook)(struct sk_buff **pskb, +enum ip_conntrack_info ctinfo, +unsigned int matchoff, +unsigned int matchlen, +struct nf_conntrack_expect *exp); + +#endif /* __KERNEL__ */ +#endif /* _NF_CONNTRACK_IRC_H */
net/ipv4/netfilter/Kconfig +5 -0
@@ -500,6 +500,11 @@ config IP_NF_NAT_IRC default IP_NF_NAT if IP_NF_IRC=y default m if IP_NF_IRC=m +config NF_NAT_IRC + tristate + depends on IP_NF_IPTABLES && NF_CONNTRACK && NF_NAT + default NF_NAT && NF_CONNTRACK_IRC + config IP_NF_NAT_TFTP tristate depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n
net/ipv4/netfilter/Makefile +1 -0
@@ -53,6 +53,7 @@ # NAT helpers (nf_conntrack) obj-$(CONFIG_NF_NAT_AMANDA) += nf_nat_amanda.o obj-$(CONFIG_NF_NAT_FTP) += nf_nat_ftp.o obj-$(CONFIG_NF_NAT_H323) += nf_nat_h323.o +obj-$(CONFIG_NF_NAT_IRC) += nf_nat_irc.o # generic IP tables obj-$(CONFIG_IP_NF_IPTABLES) += ip_tables.o
net/ipv4/netfilter/nf_nat_irc.c new file +101 -0
101 lines not on this page · raw message
net/netfilter/Kconfig +15 -0
@@ -179,6 +179,21 @@ config NF_CONNTRACK_H323 To compile it as a module, choose M here. If unsure, say N. +config NF_CONNTRACK_IRC + tristate "IRC protocol support (EXPERIMENTAL)" + depends on EXPERIMENTAL && NF_CONNTRACK + help + There is a commonly-used extension to IRC called + Direct Client-to-Client Protocol (DCC). This enables users to send + files to each other, and also chat to each other without the need + of a server. DCC Sending is used anywhere you send files over IRC, + and DCC Chat is most commonly used by Eggdrop bots. If you are + using NAT, this extension will enable you to send files and initiate + chats. Note that you do NOT need this extension to get files or + have others initiate chats, or everything else in IRC. + + To compile it as a module, choose M here. If unsure, say N. + config NF_CT_NETLINK tristate 'Connection tracking netlink interface (EXPERIMENTAL)' depends on EXPERIMENTAL && NF_CONNTRACK && NETFILTER_NETLINK
net/netfilter/Makefile +1 -0
@@ -25,6 +25,7 @@ nf_conntrack_h323-objs := nf_conntrack_h obj-$(CONFIG_NF_CONNTRACK_AMANDA) += nf_conntrack_amanda.o obj-$(CONFIG_NF_CONNTRACK_FTP) += nf_conntrack_ftp.o obj-$(CONFIG_NF_CONNTRACK_H323) += nf_conntrack_h323.o +obj-$(CONFIG_NF_CONNTRACK_IRC) += nf_conntrack_irc.o # generic X tables obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
net/netfilter/nf_conntrack_irc.c new file +281 -0
281 lines not on this page · raw message
PATCH 14/20 : nf_conntrack: add NetBIOS name service helper port
In reply to Patrick McHardy[NETFILTER]: nf_conntrack: add NetBIOS name service helper port
Add nf_conntrack port of the NetBIOS name service conntrack helper.
---
commit ce27c390f71686cd741496297293a29a494df3d7
tree a54cffd39866457922150a4c9b9ac49eda693229
parent 40f6096353cbb0a314c42355ad927c54a849d092
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:16 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:16 +0100
net/netfilter/Kconfig | 19 +++++ net/netfilter/Makefile | 1 net/netfilter/nf_conntrack_netbios_ns.c | 125 +++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 0 deletions(-)
net/netfilter/Kconfig +19 -0
@@ -194,6 +194,25 @@ config NF_CONNTRACK_IRC To compile it as a module, choose M here. If unsure, say N. +config NF_CONNTRACK_NETBIOS_NS + tristate "NetBIOS name service protocol support (EXPERIMENTAL)" + depends on EXPERIMENTAL && NF_CONNTRACK + help + NetBIOS name service requests are sent as broadcast messages from an + unprivileged port and responded to with unicast messages to the + same port. This make them hard to firewall properly because connection + tracking doesn't deal with broadcasts. This helper tracks locally + originating NetBIOS name service requests and the corresponding + responses. It relies on correct IP address configuration, specifically + netmask and broadcast address. When properly configured, the output + of "ip address show" should look similar to this: + + $ ip -4 address show eth0 + 4: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000 + inet 172.16.2.252/24 brd 172.16.2.255 scope global eth0 + + To compile it as a module, choose M here. If unsure, say N. + config NF_CT_NETLINK tristate 'Connection tracking netlink interface (EXPERIMENTAL)' depends on EXPERIMENTAL && NF_CONNTRACK && NETFILTER_NETLINK
net/netfilter/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_NF_CONNTRACK_AMANDA) += nf_ obj-$(CONFIG_NF_CONNTRACK_FTP) += nf_conntrack_ftp.o obj-$(CONFIG_NF_CONNTRACK_H323) += nf_conntrack_h323.o obj-$(CONFIG_NF_CONNTRACK_IRC) += nf_conntrack_irc.o +obj-$(CONFIG_NF_CONNTRACK_NETBIOS_NS) += nf_conntrack_netbios_ns.o # generic X tables obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
net/netfilter/nf_conntrack_netbios_ns.c new file +125 -0
125 lines not on this page · raw message
PATCH 15/20 : nf_conntrack/nf_nat: add PPTP helper port
In reply to Patrick McHardy[NETFILTER]: nf_conntrack/nf_nat: add PPTP helper port
Add nf_conntrack port of the PPtP conntrack/NAT helper. Since there seems to be no IPv6-capable PPtP implementation the helper only support IPv4.
---
commit d076bee62093db6576c9c2950be703fc1b74be64
tree d634792f8f1761c94243ff68071afc1770759c10
parent ce27c390f71686cd741496297293a29a494df3d7
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:19 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:19 +0100
include/linux/netfilter/nf_conntrack_pptp.h | 321 ++++++++++++ include/linux/netfilter/nf_conntrack_proto_gre.h | 112 ++++ include/net/netfilter/ipv4/nf_conntrack_ipv4.h | 2 include/net/netfilter/nf_conntrack.h | 4 include/net/netfilter/nf_conntrack_helper.h | 2 include/net/netfilter/nf_conntrack_tuple.h | 6 net/ipv4/netfilter/Kconfig | 10 net/ipv4/netfilter/Makefile | 4 net/ipv4/netfilter/nf_nat_pptp.c | 315 +++++++++++ net/ipv4/netfilter/nf_nat_proto_gre.c | 179 ++++++ net/netfilter/Kconfig | 23 + net/netfilter/Makefile | 2 net/netfilter/nf_conntrack_core.c | 4 net/netfilter/nf_conntrack_pptp.c | 607 ++++++++++++++++++++++ net/netfilter/nf_conntrack_proto_gre.c | 305 +++++++++++ 15 files changed, 1896 insertions(+), 0 deletions(-)
include/linux/netfilter/nf_conntrack_pptp.h new file +321 -0
@@ -0,0 +1,321 @@ +/* PPTP constants and structs */ +#ifndef _NF_CONNTRACK_PPTP_H +#define _NF_CONNTRACK_PPTP_H + +/* state of the control session */ +enum pptp_ctrlsess_state { +PPTP_SESSION_NONE ,/* no session present */ +PPTP_SESSION_ERROR ,/* some session error */ +PPTP_SESSION_STOPREQ ,/* stop_sess request seen */ +PPTP_SESSION_REQUESTED ,/* start_sess request seen */ +PPTP_SESSION_CONFIRMED ,/* session established */ +}; + +/* state of the call inside the control session */ +enum pptp_ctrlcall_state { +PPTP_CALL_NONE , +PPTP_CALL_ERROR , +PPTP_CALL_OUT_REQ , +PPTP_CALL_OUT_CONF , +PPTP_CALL_IN_REQ , +PPTP_CALL_IN_REP , +PPTP_CALL_IN_CONF , +PPTP_CALL_CLEAR_REQ , +}; + +/* conntrack private data */ +struct nf_ct_pptp_master { +enum pptp_ctrlsess_state sstate;/* session state */ +enum pptp_ctrlcall_state cstate;/* call state */ +__be16 pac_call_id;/* call id of PAC */ +__be16 pns_call_id;/* call id of PNS */ + +/* in pre-2.6.11 this used to be per-expect. Now it is per-conntrack +* and therefore imposes a fixed limit on the number of maps */ +struct nf_ct_gre_keymap *keymap[IP_CT_DIR_MAX ]; +}; + +struct nf_nat_pptp { +__be16 pns_call_id;/* NAT'ed PNS call id */ +__be16 pac_call_id;/* NAT'ed PAC call id */ +}; + +#ifdef __KERNEL__ + +#define PPTP_CONTROL_PORT 1723 + +#define PPTP_PACKET_CONTROL 1 +#define PPTP_PACKET_MGMT 2 + +#define PPTP_MAGIC_COOKIE 0x1a2b3c4d + +struct pptp_pkt_hdr { +__u16 packetLength; +__be16 packetType; +__be32 magicCookie; +}; + +/* PptpControlMessageType values */ +#define PPTP_START_SESSION_REQUEST 1 +#define PPTP_START_SESSION_REPLY 2 +#define PPTP_STOP_SESSION_REQUEST 3 +#define PPTP_STOP_SESSION_REPLY 4 +#define PPTP_ECHO_REQUEST 5 +#define PPTP_ECHO_REPLY 6 +#define PPTP_OUT_CALL_REQUEST 7 +#define PPTP_OUT_CALL_REPLY 8 +#define PPTP_IN_CALL_REQUEST 9 +#define PPTP_IN_CALL_REPLY 10 +#define PPTP_IN_CALL_CONNECT 11 +#define PPTP_CALL_CLEAR_REQUEST 12 +#define PPTP_CALL_DISCONNECT_NOTIFY 13 +#define PPTP_WAN_ERROR_NOTIFY 14 +#define PPTP_SET_LINK_INFO 15 + +#define PPTP_MSG_MAX 15 + +/* PptpGeneralError values */ +#define PPTP_ERROR_CODE_NONE 0 +#define PPTP_NOT_CONNECTED 1 +#define PPTP_BAD_FORMAT 2 +#define PPTP_BAD_VALUE 3 +#define PPTP_NO_RESOURCE 4 +#define PPTP_BAD_CALLID 5 +#define PPTP_REMOVE_DEVICE_ERROR 6 + +struct PptpControlHeader { +__be16 messageType; +__u16 reserved; +}; + +/* FramingCapability Bitmap Values */ +#define PPTP_FRAME_CAP_ASYNC 0x1 +#define PPTP_FRAME_CAP_SYNC 0x2 + +/* BearerCapability Bitmap Values */ +#define PPTP_BEARER_CAP_ANALOG 0x1 +#define PPTP_BEARER_CAP_DIGITAL 0x2 + +struct PptpStartSessionRequest { +__be16 protocolVersion; +__u16 reserved1; +__be32 framingCapability; +__be32 bearerCapability; +__be16 maxChannels; +__be16 firmwareRevision; +__u8 hostName[64 ]; +__u8 vendorString[64 ]; +}; + +/* PptpStartSessionResultCode Values */ +#define PPTP_START_OK 1 +#define PPTP_START_GENERAL_ERROR 2 +#define PPTP_START_ALREADY_CONNECTED 3 +#define PPTP_START_NOT_AUTHORIZED 4 +#define PPTP_START_UNKNOWN_PROTOCOL 5 + +struct PptpStartSessionReply { +__be16 protocolVersion; +__u8 resultCode; +__u8 generalErrorCode; +__be32 framingCapability; +__be32 bearerCapability; +__be16 maxChannels; +__be16 firmwareRevision; +__u8 hostName[64 ]; +__u8 vendorString[64 ]; +}; + +/* PptpStopReasons */ +#define PPTP_STOP_NONE 1 +#define PPTP_STOP_PROTOCOL 2 +#define PPTP_STOP_LOCAL_SHUTDOWN 3 + +struct PptpStopSessionRequest { +__u8 reason; +__u8 reserved1; +__u16 reserved2; +}; + +/* PptpStopSessionResultCode */ +#define PPTP_STOP_OK 1 +#define PPTP_STOP_GENERAL_ERROR 2 + +struct PptpStopSessionReply { +__u8 resultCode; +__u8 generalErrorCode; +__u16 reserved1; +}; + +struct PptpEchoRequest { +__be32 identNumber; +}; + +/* PptpEchoReplyResultCode */ +#define PPTP_ECHO_OK 1 +#define PPTP_ECHO_GENERAL_ERROR 2 + +struct PptpEchoReply { +__be32 identNumber; +__u8 resultCode; +__u8 generalErrorCode; +__u16 reserved; +}; + +/* PptpFramingType */ +#define PPTP_ASYNC_FRAMING 1 +#define PPTP_SYNC_FRAMING 2 +#define PPTP_DONT_CARE_FRAMING 3 + +/* PptpCallBearerType */ +#define PPTP_ANALOG_TYPE 1 +#define PPTP_DIGITAL_TYPE 2 +#define PPTP_DONT_CARE_BEARER_TYPE 3 + +struct PptpOutCallRequest { +__be16 callID; +__be16 callSerialNumber; +__be32 minBPS; +__be32 maxBPS; +__be32 bearerType; +__be32 framingType; +__be16 packetWindow; +__be16 packetProcDelay; +__be16 phoneNumberLength; +__u16 reserved1; +__u8 phoneNumber[64 ]; +__u8 subAddress[64 ]; +}; + +/* PptpCallResultCode */ +#define PPTP_OUTCALL_CONNECT 1 +#define PPTP_OUTCALL_GENERAL_ERROR 2 +#define PPTP_OUTCALL_NO_CARRIER 3 +#define PPTP_OUTCALL_BUSY 4 +#define PPTP_OUTCALL_NO_DIAL_TONE 5 +#define PPTP_OUTCALL_TIMEOUT 6 +#define PPTP_OUTCALL_DONT_ACCEPT 7 + +struct PptpOutCallReply { +__be16 callID; +__be16 peersCallID; +__u8 resultCode; +__u8 generalErrorCode; +__be16 causeCode; +__be32 connectSpeed; +__be16 packetWindow; +__be16 packetProcDelay; +__be32 physChannelID; +}; + +struct PptpInCallRequest { +__be16 callID; +__be16 callSerialNumber; +__be32 callBearerType; +__be32 physChannelID; +__be16 dialedNumberLength; +__be16 dialingNumberLength; +__u8 dialedNumber[64 ]; +__u8 dialingNumber[64 ]; +__u8 subAddress[64 ]; +}; + +/* PptpInCallResultCode */ +#define PPTP_INCALL_ACCEPT 1 +#define PPTP_INCALL_GENERAL_ERROR 2 +#define PPTP_INCALL_DONT_ACCEPT 3 + +struct PptpInCallReply { +__be16 callID; +__be16 peersCallID; +__u8 resultCode; +__u8 generalErrorCode; +__be16 packetWindow; +__be16 packetProcDelay; +__u16 reserved; +}; + +struct PptpInCallConnected { +__be16 peersCallID; +__u16 reserved; +__be32 connectSpeed; +__be16 packetWindow; +__be16 packetProcDelay; +__be32 callFramingType; +}; + +struct PptpClearCallRequest { +__be16 callID; +__u16 reserved; +}; + +struct PptpCallDisconnectNotify { +__be16 callID; +__u8 resultCode; +__u8 generalErrorCode; +__be16 causeCode; +__u16 reserved; +__u8 callStatistics[128 ]; +}; + +struct PptpWanErrorNotify { +__be16 peersCallID; +__u16 reserved; +__be32 crcErrors; +__be32 framingErrors; +__be32 hardwareOverRuns; +__be32 bufferOverRuns; +__be32 timeoutErrors; +__be32 alignmentErrors; +}; + +struct PptpSetLinkInfo { +__be16 peersCallID; +__u16 reserved; +__be32 sendAccm; +__be32 recvAccm; +}; + +union pptp_ctrl_union { +struct PptpStartSessionRequest sreq; +struct PptpStartSessionReply srep; +struct PptpStopSessionRequest streq; +struct PptpStopSessionReply strep; +struct PptpOutCallRequest ocreq; +struct PptpOutCallReply ocack; +struct PptpInCallRequest icreq; +struct PptpInCallReply icack; +struct PptpInCallConnected iccon; +struct PptpClearCallRequest clrreq; +struct PptpCallDisconnectNotify disc; +struct PptpWanErrorNotify wanerr; +struct PptpSetLinkInfo setlink; +}; + +/* crap needed for nf_conntrack_compat.h */ +struct nf_conn ; +struct nf_conntrack_expect ; +enum ip_conntrack_info ; + +extern int +(*nf_nat_pptp_hook_outbound)(struct sk_buff **pskb, +struct nf_conn *ct,enum ip_conntrack_info ctinfo, +struct PptpControlHeader *ctlh, +union pptp_ctrl_union *pptpReq); + +extern int +(*nf_nat_pptp_hook_inbound)(struct sk_buff **pskb, +struct nf_conn *ct,enum ip_conntrack_info ctinfo, +struct PptpControlHeader *ctlh, +union pptp_ctrl_union *pptpReq); + +extern void +(*nf_nat_pptp_hook_exp_gre)(struct nf_conntrack_expect *exp_orig, +struct nf_conntrack_expect *exp_reply); + +extern void +(*nf_nat_pptp_hook_expectfn)(struct nf_conn *ct, +struct nf_conntrack_expect *exp); + +#endif /* __KERNEL__ */ +#endif /* _NF_CONNTRACK_PPTP_H */
include/linux/netfilter/nf_conntrack_proto_gre.h new file +112 -0
112 lines not on this page · raw message
include/net/netfilter/ipv4/nf_conntrack_ipv4.h +2 -0
@@ -11,10 +11,12 @@ #define _NF_CONNTRACK_IPV4_H#ifdef CONFIG_NF_NAT_NEEDED #include <net/netfilter/nf_nat.h> +#include <linux/netfilter/nf_conntrack_pptp.h> /* per conntrack: nat application helper private data */ union nf_conntrack_nat_help {/* insert nat helper private data here */ +struct nf_nat_pptp nat_pptp_info; }; struct nf_conn_nat {
include/net/netfilter/nf_conntrack.h +4 -0
@@ -21,6 +21,7 @@ #include <asm/atomic.h>#include <linux/netfilter/nf_conntrack_tcp.h> #include <linux/netfilter/nf_conntrack_sctp.h> +#include <linux/netfilter/nf_conntrack_proto_gre.h> #include <net/netfilter/ipv4/nf_conntrack_icmp.h> #include <net/netfilter/ipv6/nf_conntrack_icmpv6.h>
@@ -33,6 +34,7 @@ union nf_conntrack_proto {struct ip_ct_tcp tcp;struct ip_ct_icmp icmp;struct nf_ct_icmpv6 icmpv6; +struct nf_ct_gre gre; };union nf_conntrack_expect_proto {
@@ -41,12 +43,14 @@ union nf_conntrack_expect_proto {/* Add protocol helper include file here */ #include <linux/netfilter/nf_conntrack_ftp.h> +#include <linux/netfilter/nf_conntrack_pptp.h> #include <linux/netfilter/nf_conntrack_h323.h> /* per conntrack: application helper private data */ union nf_conntrack_help {/* insert conntrack helper private data (master) here */ struct nf_ct_ftp_master ct_ftp_info; +struct nf_ct_pptp_master ct_pptp_info;struct nf_ct_h323_master ct_h323_info; };
include/net/netfilter/nf_conntrack_helper.h +2 -0
@@ -34,6 +34,8 @@ struct nf_conntrack_helperstruct nf_conn *ct, enum ip_conntrack_info conntrackinfo); +void (*destroy)(struct nf_conn *ct); +int (*to_nfattr)(struct sk_buff *skb,const struct nf_conn *ct); };
include/net/netfilter/nf_conntrack_tuple.h +6 -0
@@ -49,6 +49,9 @@ union nf_conntrack_man_protostruct {__be16 port; } sctp; +struct { +__be16 key;/* GRE key is 32bit, PPtP only uses 16bit */ + } gre; };/* The manipulable part of the tuple. */
@@ -84,6 +87,9 @@ struct nf_conntrack_tuplestruct {__be16 port; } sctp; +struct { +__be16 key; + } gre; } u;/* The protocol. */
net/ipv4/netfilter/Kconfig +10 -0
@@ -484,6 +484,10 @@ # # <expr> '&&' <expr> (6) # # (6) Returns the result of min(/expr/, /expr/). +config NF_NAT_PROTO_GRE + tristate + depends on NF_NAT && NF_CT_PROTO_GRE + config IP_NF_NAT_FTP tristate depends on IP_NF_IPTABLES && IP_NF_CONNTRACK && IP_NF_NAT
@@ -528,6 +532,12 @@ config IP_NF_NAT_PPTP default IP_NF_NAT if IP_NF_PPTP=y default m if IP_NF_PPTP=m +config NF_NAT_PPTP + tristate + depends on IP_NF_IPTABLES && NF_CONNTRACK && NF_NAT + default NF_NAT && NF_CONNTRACK_PPTP + select NF_NAT_PROTO_GRE + config IP_NF_NAT_H323 tristate depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n
net/ipv4/netfilter/Makefile +4 -0
@@ -54,6 +54,10 @@ obj-$(CONFIG_NF_NAT_AMANDA) += nf_nat_am obj-$(CONFIG_NF_NAT_FTP) += nf_nat_ftp.o obj-$(CONFIG_NF_NAT_H323) += nf_nat_h323.o obj-$(CONFIG_NF_NAT_IRC) += nf_nat_irc.o +obj-$(CONFIG_NF_NAT_PPTP) += nf_nat_pptp.o + +# NAT protocols (nf_nat) +obj-$(CONFIG_NF_NAT_PROTO_GRE) += nf_nat_proto_gre.o # generic IP tables obj-$(CONFIG_IP_NF_IPTABLES) += ip_tables.o
net/ipv4/netfilter/nf_nat_pptp.c new file +315 -0
315 lines not on this page · raw message
net/ipv4/netfilter/nf_nat_proto_gre.c new file +179 -0
179 lines not on this page · raw message
net/netfilter/Kconfig +23 -0
@@ -120,6 +120,10 @@ config NF_CONNTRACK_EVENTS If unsure, say `N'. +config NF_CT_PROTO_GRE + tristate + depends on EXPERIMENTAL && NF_CONNTRACK + config NF_CT_PROTO_SCTP tristate 'SCTP protocol on new connection tracking support (EXPERIMENTAL)' depends on EXPERIMENTAL && NF_CONNTRACK
@@ -213,6 +217,25 @@ config NF_CONNTRACK_NETBIOS_NS To compile it as a module, choose M here. If unsure, say N. +config NF_CONNTRACK_PPTP + tristate "PPtP protocol support (EXPERIMENTAL)" + depends on EXPERIMENTAL && NF_CONNTRACK + select NF_CT_PROTO_GRE + help + This module adds support for PPTP (Point to Point Tunnelling + Protocol, RFC2637) connection tracking and NAT. + + If you are running PPTP sessions over a stateful firewall or NAT + box, you may want to enable this feature. + + Please note that not all PPTP modes of operation are supported yet. + Specifically these limitations exist: + - Blindy assumes that control connections are always established + in PNS->PAC direction. This is a violation of RFC2637. + - Only supports a single call within each session + + To compile it as a module, choose M here. If unsure, say N. + config NF_CT_NETLINK tristate 'Connection tracking netlink interface (EXPERIMENTAL)' depends on EXPERIMENTAL && NF_CONNTRACK && NETFILTER_NETLINK
net/netfilter/Makefile +2 -0
@@ -14,6 +14,7 @@ # connection tracking obj-$(CONFIG_NF_CONNTRACK) += nf_conntrack.o # SCTP protocol connection tracking +obj-$(CONFIG_NF_CT_PROTO_GRE) += nf_conntrack_proto_gre.o obj-$(CONFIG_NF_CT_PROTO_SCTP) += nf_conntrack_proto_sctp.o # netlink interface for nf_conntrack
@@ -27,6 +28,7 @@ obj-$(CONFIG_NF_CONNTRACK_FTP) += nf_con obj-$(CONFIG_NF_CONNTRACK_H323) += nf_conntrack_h323.o obj-$(CONFIG_NF_CONNTRACK_IRC) += nf_conntrack_irc.o obj-$(CONFIG_NF_CONNTRACK_NETBIOS_NS) += nf_conntrack_netbios_ns.o +obj-$(CONFIG_NF_CONNTRACK_PPTP) += nf_conntrack_pptp.o # generic X tables obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
net/netfilter/nf_conntrack_core.c +4 -0
@@ -300,6 +300,7 @@ static void destroy_conntrack(struct nf_conntrack *nfct) {struct nf_conn *ct = (struct nf_conn *)nfct; +struct nf_conn_help *help =nfct_help (ct);struct nf_conntrack_l3proto *l3proto;struct nf_conntrack_l4proto *l4proto;
@@ -310,6 +311,9 @@ destroy_conntrack(struct nf_conntrack *nnf_conntrack_event (IPCT_DESTROY , ct);set_bit (IPS_DYING_BIT , &ct->status); +if (help && help->helper && help->helper->destroy) + help->helper->destroy (ct); +/* To make sure we don't get any weird locking issues here: * destroy_conntrack() MUST NOT be called with a write lock * to nf_conntrack_lock!!! -HW */
net/netfilter/nf_conntrack_pptp.c new file +607 -0
607 lines not on this page · raw message
net/netfilter/nf_conntrack_proto_gre.c new file +305 -0
305 lines not on this page · raw message
PATCH 16/20 : nf_conntrack/nf_nat: add SIP helper port
In reply to Patrick McHardy[NETFILTER]: nf_conntrack/nf_nat: add SIP helper port
Add IPv4 and IPv6 capable nf_conntrack port of the SIP conntrack/NAT helper.
---
commit b83f09c4c816919e00f9f78ffe12dc4bf81aa2c4
tree 9aeb3063a8f20917aea3c0c1962f8eccd07a393c
parent d076bee62093db6576c9c2950be703fc1b74be64
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:21 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:21 +0100
include/linux/netfilter/nf_conntrack_sip.h | 41 ++ net/ipv4/netfilter/Kconfig | 5 net/ipv4/netfilter/Makefile | 1 net/ipv4/netfilter/nf_nat_sip.c | 283 +++++++++++++++ net/netfilter/Kconfig | 12 + net/netfilter/Makefile | 1 net/netfilter/nf_conntrack_sip.c | 530 ++++++++++++++++++++++++++++ 7 files changed, 873 insertions(+), 0 deletions(-)
include/linux/netfilter/nf_conntrack_sip.h new file +41 -0
@@ -0,0 +1,41 @@ +#ifndef __NF_CONNTRACK_SIP_H__ +#define __NF_CONNTRACK_SIP_H__ +#ifdef __KERNEL__ + +#define SIP_PORT 5060 +#define SIP_TIMEOUT 3600 + +enum sip_header_pos { +POS_REG_REQ_URI , +POS_REQ_URI , +POS_FROM , +POS_TO , +POS_VIA , +POS_CONTACT , +POS_CONTENT , +POS_MEDIA , +POS_OWNER_IP4 , +POS_CONNECTION_IP4 , +POS_OWNER_IP6 , +POS_CONNECTION_IP6 , +POS_SDP_HEADER , +}; + +extern unsigned int (*nf_nat_sip_hook)(struct sk_buff **pskb, +enum ip_conntrack_info ctinfo, +struct nf_conn *ct, +const char **dptr); +extern unsigned int (*nf_nat_sdp_hook)(struct sk_buff **pskb, +enum ip_conntrack_info ctinfo, +struct nf_conntrack_expect *exp, +const char *dptr); + +extern int ct_sip_get_info (struct nf_conn *ct,const char *dptr,size_t dlen, +unsigned int *matchoff,unsigned int *matchlen, +enum sip_header_pos pos); +extern int ct_sip_lnlen (const char *line,const char *limit); +extern const char *ct_sip_search (const char *needle,const char *haystack, +size_t needle_len,size_t haystack_len, +int case_sensitive); +#endif /* __KERNEL__ */ +#endif /* __NF_CONNTRACK_SIP_H__ */
net/ipv4/netfilter/Kconfig +5 -0
@@ -555,6 +555,11 @@ config IP_NF_NAT_SIP default IP_NF_NAT if IP_NF_SIP=y default m if IP_NF_SIP=m +config NF_NAT_SIP + tristate + depends on IP_NF_IPTABLES && NF_CONNTRACK && NF_NAT + default NF_NAT && NF_CONNTRACK_SIP + # mangle + specific targets config IP_NF_MANGLE tristate "Packet mangling"
net/ipv4/netfilter/Makefile +1 -0
@@ -55,6 +55,7 @@ obj-$(CONFIG_NF_NAT_FTP) += nf_nat_ftp.o obj-$(CONFIG_NF_NAT_H323) += nf_nat_h323.o obj-$(CONFIG_NF_NAT_IRC) += nf_nat_irc.o obj-$(CONFIG_NF_NAT_PPTP) += nf_nat_pptp.o +obj-$(CONFIG_NF_NAT_SIP) += nf_nat_sip.o # NAT protocols (nf_nat) obj-$(CONFIG_NF_NAT_PROTO_GRE) += nf_nat_proto_gre.o
net/ipv4/netfilter/nf_nat_sip.c new file +283 -0
283 lines not on this page · raw message
net/netfilter/Kconfig +12 -0
@@ -236,6 +236,18 @@ config NF_CONNTRACK_PPTP To compile it as a module, choose M here. If unsure, say N. +config NF_CONNTRACK_SIP + tristate "SIP protocol support (EXPERIMENTAL)" + depends on EXPERIMENTAL && NF_CONNTRACK + help + SIP is an application-layer control protocol that can establish, + modify, and terminate multimedia sessions (conferences) such as + Internet telephony calls. With the ip_conntrack_sip and + the nf_nat_sip modules you can support the protocol on a connection + tracking/NATing firewall. + + To compile it as a module, choose M here. If unsure, say N. + config NF_CT_NETLINK tristate 'Connection tracking netlink interface (EXPERIMENTAL)' depends on EXPERIMENTAL && NF_CONNTRACK && NETFILTER_NETLINK
net/netfilter/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_NF_CONNTRACK_H323) += nf_co obj-$(CONFIG_NF_CONNTRACK_IRC) += nf_conntrack_irc.o obj-$(CONFIG_NF_CONNTRACK_NETBIOS_NS) += nf_conntrack_netbios_ns.o obj-$(CONFIG_NF_CONNTRACK_PPTP) += nf_conntrack_pptp.o +obj-$(CONFIG_NF_CONNTRACK_SIP) += nf_conntrack_sip.o # generic X tables obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
net/netfilter/nf_conntrack_sip.c new file +530 -0
530 lines not on this page · raw message
PATCH 17/20 : nf_conntrack/nf_nat: add TFTP helper port
In reply to Patrick McHardy[NETFILTER]: nf_conntrack/nf_nat: add TFTP helper port
Add IPv4 and IPv6 capable nf_conntrack port of the TFTP conntrack/NAT helper.
---
commit e95138a41a63f7da0d8969c6a00f6f632b912b28
tree 90fa078d527fdca0c67d40f1de0243c8016c2e4b
parent b83f09c4c816919e00f9f78ffe12dc4bf81aa2c4
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:23 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:23 +0100
include/linux/netfilter/nf_conntrack_tftp.h | 20 +++ net/ipv4/netfilter/Kconfig | 5 + net/ipv4/netfilter/Makefile | 1 net/ipv4/netfilter/nf_nat_tftp.c | 52 +++++++++ net/netfilter/Kconfig | 11 ++ net/netfilter/Makefile | 1 net/netfilter/nf_conntrack_tftp.c | 159 +++++++++++++++++++++++++++ 7 files changed, 249 insertions(+), 0 deletions(-)
include/linux/netfilter/nf_conntrack_tftp.h new file +20 -0
@@ -0,0 +1,20 @@ +#ifndef _NF_CONNTRACK_TFTP_H +#define _NF_CONNTRACK_TFTP_H + +#define TFTP_PORT 69 + +struct tftphdr { +__be16 opcode; +}; + +#define TFTP_OPCODE_READ 1 +#define TFTP_OPCODE_WRITE 2 +#define TFTP_OPCODE_DATA 3 +#define TFTP_OPCODE_ACK 4 +#define TFTP_OPCODE_ERROR 5 + +extern unsigned int (*nf_nat_tftp_hook)(struct sk_buff **pskb, +enum ip_conntrack_info ctinfo, +struct nf_conntrack_expect *exp); + +#endif /* _NF_CONNTRACK_TFTP_H */
net/ipv4/netfilter/Kconfig +5 -0
@@ -515,6 +515,11 @@ config IP_NF_NAT_TFTP default IP_NF_NAT if IP_NF_TFTP=y default m if IP_NF_TFTP=m +config NF_NAT_TFTP + tristate + depends on IP_NF_IPTABLES && NF_CONNTRACK && NF_NAT + default NF_NAT && NF_CONNTRACK_TFTP + config IP_NF_NAT_AMANDA tristate depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n
net/ipv4/netfilter/Makefile +1 -0
@@ -56,6 +56,7 @@ obj-$(CONFIG_NF_NAT_H323) += nf_nat_h323 obj-$(CONFIG_NF_NAT_IRC) += nf_nat_irc.o obj-$(CONFIG_NF_NAT_PPTP) += nf_nat_pptp.o obj-$(CONFIG_NF_NAT_SIP) += nf_nat_sip.o +obj-$(CONFIG_NF_NAT_TFTP) += nf_nat_tftp.o # NAT protocols (nf_nat) obj-$(CONFIG_NF_NAT_PROTO_GRE) += nf_nat_proto_gre.o
net/ipv4/netfilter/nf_nat_tftp.c new file +52 -0
52 lines not on this page · raw message
net/netfilter/Kconfig +11 -0
@@ -248,6 +248,17 @@ config NF_CONNTRACK_SIP To compile it as a module, choose M here. If unsure, say N. +config NF_CONNTRACK_TFTP + tristate "TFTP protocol support (EXPERIMENTAL)" + depends on EXPERIMENTAL && NF_CONNTRACK + help + TFTP connection tracking helper, this is required depending + on how restrictive your ruleset is. + If you are using a tftp client behind -j SNAT or -j MASQUERADING + you will need this. + + To compile it as a module, choose M here. If unsure, say N. + config NF_CT_NETLINK tristate 'Connection tracking netlink interface (EXPERIMENTAL)' depends on EXPERIMENTAL && NF_CONNTRACK && NETFILTER_NETLINK
net/netfilter/Makefile +1 -0
@@ -30,6 +30,7 @@ obj-$(CONFIG_NF_CONNTRACK_IRC) += nf_con obj-$(CONFIG_NF_CONNTRACK_NETBIOS_NS) += nf_conntrack_netbios_ns.o obj-$(CONFIG_NF_CONNTRACK_PPTP) += nf_conntrack_pptp.o obj-$(CONFIG_NF_CONNTRACK_SIP) += nf_conntrack_sip.o +obj-$(CONFIG_NF_CONNTRACK_TFTP) += nf_conntrack_tftp.o # generic X tables obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
net/netfilter/nf_conntrack_tftp.c new file +159 -0
159 lines not on this page · raw message
PATCH 18/20 : nf_nat: add SNMP NAT helper port
In reply to Patrick McHardy[NETFILTER]: nf_nat: add SNMP NAT helper port
Add nf_conntrack port of the SNMP NAT helper.
---
commit 49bfa626948b29f57cc2dc524215abe314926966
tree fcc050507344b1742326e36ba7de25120191dedd
parent e95138a41a63f7da0d8969c6a00f6f632b912b28
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:24 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:24 +0100
net/ipv4/netfilter/Kconfig | 15 net/ipv4/netfilter/Makefile | 1 net/ipv4/netfilter/nf_nat_snmp_basic.c | 1332 ++++++++++++++++++++++++++++++++ 3 files changed, 1348 insertions(+), 0 deletions(-)
net/ipv4/netfilter/Kconfig +15 -0
@@ -477,6 +477,21 @@ config IP_NF_NAT_SNMP_BASIC To compile it as a module, choose M here. If unsure, say N. +config NF_NAT_SNMP_BASIC + tristate "Basic SNMP-ALG support (EXPERIMENTAL)" + depends on EXPERIMENTAL && NF_NAT + ---help--- + + This module implements an Application Layer Gateway (ALG) for + SNMP payloads. In conjunction with NAT, it allows a network + management system to access multiple private networks with + conflicting addresses. It works by modifying IP addresses + inside SNMP payloads to match IP-layer NAT mapping. + + This is the "basic" form of SNMP-ALG, as described in RFC 2962 + + To compile it as a module, choose M here. If unsure, say N. + # If they want FTP, set to $CONFIG_IP_NF_NAT (m or y), # or $CONFIG_IP_NF_FTP (m or y), whichever is weaker. # From kconfig-language.txt:
net/ipv4/netfilter/Makefile +1 -0
@@ -56,6 +56,7 @@ obj-$(CONFIG_NF_NAT_H323) += nf_nat_h323 obj-$(CONFIG_NF_NAT_IRC) += nf_nat_irc.o obj-$(CONFIG_NF_NAT_PPTP) += nf_nat_pptp.o obj-$(CONFIG_NF_NAT_SIP) += nf_nat_sip.o +obj-$(CONFIG_NF_NAT_SNMP_BASIC) += nf_nat_snmp_basic.o obj-$(CONFIG_NF_NAT_TFTP) += nf_nat_tftp.o # NAT protocols (nf_nat)
net/ipv4/netfilter/nf_nat_snmp_basic.c new file +1332 -0
1,332 lines not on this page · raw message
PATCH 19/20 : Mark old IPv4-only connection tracking scheduled for removal
In reply to Patrick McHardy[NETFILTER]: Mark old IPv4-only connection tracking scheduled for removal
Also remove the references to "new connection tracking" from Kconfig. After some short stabilization period of the new connection tracking helpers/NAT code the old one will be removed.
---
commit 02d2bee5dd7717744d3a6cff529d9a71dc99452e
tree 5cae9cd141777f12739e25f8c20219c2f1983c7c
parent 49bfa626948b29f57cc2dc524215abe314926966
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:25 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:25 +0100
Documentation/feature-removal-schedule.txt | 9 +++++++++ net/ipv4/netfilter/Kconfig | 2 +- net/ipv6/netfilter/Kconfig | 2 +- net/netfilter/Kconfig | 6 +++--- 4 files changed, 14 insertions(+), 5 deletions(-)
Documentation/feature-removal-schedule.txt +9 -0
@@ -253,3 +253,12 @@ Why: Orphaned for ages. SMP bugs long u Who: Jeff Garzik <[email protected]> --------------------------- + +What: IPv4 only connection tracking/NAT/helpers +When: 2.6.22 +Why: The new layer 3 independant connection tracking replaces the old + IPv4 only version. After some stabilization of the new code the + old one will be removed. +Who: Patrick McHardy <[email protected]> + +---------------------------
net/ipv4/netfilter/Kconfig +1 -1
@@ -6,7 +6,7 @@ menu "IP: Netfilter Configuration" depends on INET && NETFILTER config NF_CONNTRACK_IPV4 - tristate "IPv4 support for new connection tracking (required for NAT) (EXPERIMENTAL)" + tristate "IPv4 connection tracking support (required for NAT) (EXPERIMENTAL)" depends on EXPERIMENTAL && NF_CONNTRACK ---help--- Connection tracking keeps a record of what packets have passed
net/ipv6/netfilter/Kconfig +1 -1
@@ -6,7 +6,7 @@ menu "IPv6: Netfilter Configuration (EXP depends on INET && IPV6 && NETFILTER && EXPERIMENTAL config NF_CONNTRACK_IPV6 - tristate "IPv6 support for new connection tracking (EXPERIMENTAL)" + tristate "IPv6 connection tracking support (EXPERIMENTAL)" depends on EXPERIMENTAL && NF_CONNTRACK ---help--- Connection tracking keeps a record of what packets have passed
net/netfilter/Kconfig +3 -3
@@ -56,7 +56,7 @@ config NF_CONNTRACK_SUPPORT below). config IP_NF_CONNTRACK_SUPPORT - bool "Layer 3 Dependent Connection tracking" + bool "Layer 3 Dependent Connection tracking (OBSOLETE)" help The old, Layer 3 dependent ip_conntrack subsystem of netfilter.
@@ -125,7 +125,7 @@ config NF_CT_PROTO_GRE depends on EXPERIMENTAL && NF_CONNTRACK config NF_CT_PROTO_SCTP - tristate 'SCTP protocol on new connection tracking support (EXPERIMENTAL)' + tristate 'SCTP protocol connection tracking support (EXPERIMENTAL)' depends on EXPERIMENTAL && NF_CONNTRACK default n help
@@ -151,7 +151,7 @@ config NF_CONNTRACK_AMANDA To compile it as a module, choose M here. If unsure, say N. config NF_CONNTRACK_FTP - tristate "FTP support on new connection tracking (EXPERIMENTAL)" + tristate "FTP protocol support (EXPERIMENTAL)" depends on EXPERIMENTAL && NF_CONNTRACK help Tracking FTP connections is problematic: special helpers are
PATCH 20/20 : nf_conntrack: EXPORT_SYMBOL cleanup
In reply to Patrick McHardy[NETFILTER]: nf_conntrack: EXPORT_SYMBOL cleanup
- move EXPORT_SYMBOL next to exported symbol
- use EXPORT_SYMBOL_GPL since this is what the original code used
---
commit b0f810003e3469a50a8f3b9977731841cc76cdb4
tree 15342b7f30dfbe409bbf0e41bc05523ec27bc73c
parent 02d2bee5dd7717744d3a6cff529d9a71dc99452e
author Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:27 +0100 committer Patrick McHardy <[email protected]> Sat, 02 Dec 2006 15:34:27 +0100
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 7 +- net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 3 - net/netfilter/nf_conntrack_core.c | 32 ++++++++++ net/netfilter/nf_conntrack_ecache.c | 6 ++ net/netfilter/nf_conntrack_expect.c | 10 +++ net/netfilter/nf_conntrack_helper.c | 5 ++ net/netfilter/nf_conntrack_proto.c | 12 ++++ net/netfilter/nf_conntrack_proto_tcp.c | 7 +- net/netfilter/nf_conntrack_proto_udp.c | 5 +- net/netfilter/nf_conntrack_standalone.c | 74 +----------------------- 10 files changed, 75 insertions(+), 86 deletions(-)
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +2 -5
@@ -112,6 +112,8 @@ ipv4_prepare(struct sk_buff **pskb, unsi }int nf_nat_module_is_loaded =0 ; +EXPORT_SYMBOL_GPL (nf_nat_module_is_loaded); +static u_int32_t ipv4_get_features (const struct nf_conntrack_tuple *tuple) {if (nf_nat_module_is_loaded)
@@ -530,8 +532,3 @@ #endifmodule_init (nf_conntrack_l3proto_ipv4_init);module_exit (nf_conntrack_l3proto_ipv4_fini); - -EXPORT_SYMBOL (nf_ct_ipv4_gather_frags); -#ifdef CONFIG_NF_NAT_NEEDED -EXPORT_SYMBOL (nf_nat_module_is_loaded); -#endif
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +1 -2
@@ -380,5 +380,4 @@ #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT#endif #endif }; - -EXPORT_SYMBOL (nf_conntrack_l4proto_icmp); +EXPORT_SYMBOL_GPL (nf_conntrack_l4proto_icmp);
net/netfilter/nf_conntrack_core.c +31 -1
@@ -63,17 +63,27 @@ #define DEBUGP(format, args...)#endif DEFINE_RWLOCK (nf_conntrack_lock); +EXPORT_SYMBOL_GPL (nf_conntrack_lock);/* nf_conntrack_standalone needs this */ atomic_t nf_conntrack_count =ATOMIC_INIT (0 );EXPORT_SYMBOL_GPL (nf_conntrack_count); -void (*nf_conntrack_destroyed)(struct nf_conn *conntrack) =NULL ; +void (*nf_conntrack_destroyed)(struct nf_conn *conntrack); +EXPORT_SYMBOL_GPL (nf_conntrack_destroyed); +unsigned int nf_conntrack_htable_size__read_mostly ; +EXPORT_SYMBOL_GPL (nf_conntrack_htable_size); +int nf_conntrack_max__read_mostly ;EXPORT_SYMBOL_GPL (nf_conntrack_max); +struct list_head *nf_conntrack_hash__read_mostly ; +EXPORT_SYMBOL_GPL (nf_conntrack_hash); +struct nf_conn nf_conntrack_untracked__read_mostly ; +EXPORT_SYMBOL_GPL (nf_conntrack_untracked); +unsigned int nf_ct_log_invalid__read_mostly ;LIST_HEAD (unconfirmed);static int nf_conntrack_vmalloc__read_mostly ;
@@ -210,6 +220,7 @@ out_up_mutex:mutex_unlock (&nf_ct_cache_mutex);return ret; } +EXPORT_SYMBOL_GPL (nf_conntrack_register_cache);/* FIXME: In the current, only nf_conntrack_cleanup() can call this function. */ void nf_conntrack_unregister_cache (u_int32_t features)
@@ -244,6 +255,7 @@ void nf_conntrack_unregister_cache(u_intmutex_unlock (&nf_ct_cache_mutex); } +EXPORT_SYMBOL_GPL (nf_conntrack_unregister_cache); int nf_ct_get_tuple(const struct sk_buff *skb,
@@ -266,6 +278,7 @@ nf_ct_get_tuple(const struct sk_buff *skreturn l4proto->pkt_to_tuple (skb, dataoff, tuple); } +EXPORT_SYMBOL_GPL (nf_ct_get_tuple); int nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
@@ -284,6 +297,7 @@ nf_ct_invert_tuple(struct nf_conntrack_t inverse->dst.protonum = orig->dst.protonum;return l4proto->invert_tuple (inverse, orig); } +EXPORT_SYMBOL_GPL (nf_ct_invert_tuple);static void clean_from_lists (struct nf_conn *ct)
@@ -382,6 +396,7 @@ __nf_conntrack_find(const struct nf_connreturn NULL ; } +EXPORT_SYMBOL_GPL (__nf_conntrack_find);/* Find a connection corresponding to a tuple. */ struct nf_conntrack_tuple_hash *
@@ -398,6 +413,7 @@ nf_conntrack_find_get(const struct nf_coreturn h; } +EXPORT_SYMBOL_GPL (nf_conntrack_find_get); static void __nf_conntrack_hash_insert(struct nf_conn *ct, unsigned int hash,
@@ -421,6 +437,7 @@ void nf_conntrack_hash_insert(struct nf___nf_conntrack_hash_insert (ct, hash, repl_hash);write_unlock_bh (&nf_conntrack_lock); } +EXPORT_SYMBOL_GPL (nf_conntrack_hash_insert);/* Confirm a connection given skb; places it in hash table */ int
@@ -498,6 +515,7 @@ out:write_unlock_bh (&nf_conntrack_lock);return NF_DROP ; } +EXPORT_SYMBOL_GPL (__nf_conntrack_confirm);/* Returns true if a connection correspondings to the tuple (required for NAT). */
@@ -513,6 +531,7 @@ nf_conntrack_tuple_taken(const struct nfreturn h !=NULL ; } +EXPORT_SYMBOL_GPL (nf_conntrack_tuple_taken);/* There's a small race here where we may free a just-assured connection. Too bad: we're in trouble anyway. */
@@ -631,6 +650,7 @@ struct nf_conn *nf_conntrack_alloc(const l3proto =__nf_ct_l3proto_find (orig->src.l3num);return __nf_conntrack_alloc (orig, repl, l3proto,0 ); } +EXPORT_SYMBOL_GPL (nf_conntrack_alloc);void nf_conntrack_free (struct nf_conn *conntrack) {
@@ -641,6 +661,7 @@ void nf_conntrack_free(struct nf_conn *ckmem_cache_free (nf_ct_cache[features].cachep, conntrack);atomic_dec (&nf_conntrack_count); } +EXPORT_SYMBOL_GPL (nf_conntrack_free);/* Allocate a new conntrack: we return -ENOMEM if classification failed due to stress. Otherwise it really is unclassifiable. */
@@ -845,6 +866,7 @@ nf_conntrack_in(int pf, unsigned int hooreturn ret; } +EXPORT_SYMBOL_GPL (nf_conntrack_in);int nf_ct_invert_tuplepr (struct nf_conntrack_tuple *inverse,const struct nf_conntrack_tuple *orig)
@@ -854,6 +876,7 @@ int nf_ct_invert_tuplepr(struct nf_connt__nf_ct_l4proto_find (orig->src.l3num, orig->dst.protonum)); } +EXPORT_SYMBOL_GPL (nf_ct_invert_tuplepr);/* Alter reply tuple (maybe alter helper). This is for NAT, and is implicitly racy: see __nf_conntrack_confirm */
@@ -874,6 +897,7 @@ void nf_conntrack_alter_reply(struct nf_ help->helper =__nf_ct_helper_find (newreply);write_unlock_bh (&nf_conntrack_lock); } +EXPORT_SYMBOL_GPL (nf_conntrack_alter_reply);/* Refresh conntrack for this many jiffies and do accounting if do_acct is 1 */ void __nf_ct_refresh_acct(struct nf_conn *ct,
@@ -931,6 +955,7 @@ #endifif (event)nf_conntrack_event_cache (event, skb); } +EXPORT_SYMBOL_GPL (__nf_ct_refresh_acct);#if defined(CONFIG_NF_CT_NETLINK ) || \ defined(CONFIG_NF_CT_NETLINK_MODULE )
@@ -955,6 +980,7 @@ int nf_ct_port_tuple_to_nfattr(struct sk nfattr_failure:return -1 ; } +EXPORT_SYMBOL_GPL (nf_ct_port_tuple_to_nfattr);static const size_t cta_min_proto[CTA_PROTO_MAX ] = { [CTA_PROTO_SRC_PORT -1 ] =sizeof (u_int16_t),
@@ -975,6 +1001,7 @@ int nf_ct_port_nfattr_to_tuple(struct nf return 0; } +EXPORT_SYMBOL_GPL (nf_ct_port_nfattr_to_tuple);#endif /* Used by ipt_REJECT and ip6t_REJECT. */
@@ -995,6 +1022,7 @@ void __nf_conntrack_attach(struct sk_buf nskb->nfctinfo = ctinfo;nf_conntrack_get (nskb->nfct); } +EXPORT_SYMBOL_GPL (__nf_conntrack_attach); static inline int do_iter(const struct nf_conntrack_tuple_hash *i,
@@ -1048,6 +1076,7 @@ nf_ct_iterate_cleanup(int (*iter)(structnf_ct_put (ct); } } +EXPORT_SYMBOL_GPL (nf_ct_iterate_cleanup);static int kill_all (struct nf_conn *i,void *data) {
@@ -1067,6 +1096,7 @@ void nf_conntrack_flush() {nf_ct_iterate_cleanup (kill_all,NULL ); } +EXPORT_SYMBOL_GPL (nf_conntrack_flush);/* Mishearing the voices in his head, our hero wonders how he's supposed to kill the mall. */
net/netfilter/nf_conntrack_ecache.c +6 -0
@@ -28,9 +28,13 @@ #include <net/netfilter/nf_conntrack_hel#include <net/netfilter/nf_conntrack_core.h> ATOMIC_NOTIFIER_HEAD (nf_conntrack_chain); +EXPORT_SYMBOL_GPL (nf_conntrack_chain); +ATOMIC_NOTIFIER_HEAD (nf_conntrack_expect_chain); +EXPORT_SYMBOL_GPL (nf_conntrack_expect_chain); DEFINE_PER_CPU(struct nf_conntrack_ecache, nf_conntrack_ecache); +EXPORT_PER_CPU_SYMBOL_GPL (nf_conntrack_ecache);/* deliver cached events and clear cache entry - must be called with locally * disabled softirqs */
@@ -59,6 +63,7 @@ void nf_ct_deliver_cached_events(const s__nf_ct_deliver_cached_events (ecache);local_bh_enable (); } +EXPORT_SYMBOL_GPL (nf_ct_deliver_cached_events);/* Deliver cached events for old pending events, if current conntrack != old */ void __nf_ct_event_cache_init (struct nf_conn *ct)
@@ -74,6 +79,7 @@ void __nf_ct_event_cache_init(struct nf_ ecache->ct = ct;nf_conntrack_get (&ct->ct_general); } +EXPORT_SYMBOL_GPL (__nf_ct_event_cache_init);/* flush the event cache - touches other CPU's data and must not be called * while packets are still passing through the code */
net/netfilter/nf_conntrack_expect.c +10 -0
@@ -27,6 +27,8 @@ #include <net/netfilter/nf_conntrack_hel#include <net/netfilter/nf_conntrack_tuple.h> LIST_HEAD (nf_conntrack_expect_list); +EXPORT_SYMBOL_GPL (nf_conntrack_expect_list); +kmem_cache_t *nf_conntrack_expect_cachep__read_mostly ;static unsigned int nf_conntrack_expect_next_id;
@@ -43,6 +45,7 @@ void nf_ct_unlink_expect(struct nf_connt master_help->expecting--;nf_conntrack_expect_put (exp); } +EXPORT_SYMBOL_GPL (nf_ct_unlink_expect);static void expectation_timed_out (unsigned long ul_expect) {
@@ -65,6 +68,7 @@ __nf_conntrack_expect_find(const struct }return NULL ; } +EXPORT_SYMBOL_GPL (__nf_conntrack_expect_find);/* Just find a expectation corresponding to a tuple. */ struct nf_conntrack_expect *
@@ -80,6 +84,7 @@ nf_conntrack_expect_find_get(const strucreturn i; } +EXPORT_SYMBOL_GPL (nf_conntrack_expect_find_get);/* If an expectation for this connection is found, it gets delete from * global list then returned. */
@@ -125,6 +130,7 @@ void nf_ct_remove_expectations(struct nf } } } +EXPORT_SYMBOL_GPL (nf_ct_remove_expectations);/* Would two expected things clash? */ static inline int expect_clash(const struct nf_conntrack_expect *a,
@@ -179,6 +185,7 @@ void nf_conntrack_unexpect_related(struc }write_unlock_bh (&nf_conntrack_lock); } +EXPORT_SYMBOL_GPL (nf_conntrack_unexpect_related);/* We don't increase the master conntrack refcount for non-fulfilled * conntracks. During the conntrack destruction, the expectations are
@@ -195,6 +202,7 @@ struct nf_conntrack_expect *nf_conntrackatomic_set (&new->use,1 );return new; } +EXPORT_SYMBOL_GPL (nf_conntrack_expect_alloc); void nf_conntrack_expect_init(struct nf_conntrack_expect *exp, int family, union nf_conntrack_address *saddr,
@@ -269,6 +277,7 @@ void nf_conntrack_expect_put(struct nf_cif (atomic_dec_and_test (&exp->use))kmem_cache_free (nf_conntrack_expect_cachep, exp); } +EXPORT_SYMBOL_GPL (nf_conntrack_expect_put);static void nf_conntrack_expect_insert (struct nf_conntrack_expect *exp) {
@@ -351,6 +360,7 @@ out:write_unlock_bh (&nf_conntrack_lock);return ret; } +EXPORT_SYMBOL_GPL (nf_conntrack_expect_related);#ifdef CONFIG_PROC_FS static void *exp_seq_start (struct seq_file *s,loff_t *pos)
net/netfilter/nf_conntrack_helper.c +5 -0
@@ -63,11 +63,13 @@ nf_ct_helper_find_get( const struct nf_creturn helper; } +EXPORT_SYMBOL_GPL (nf_ct_helper_find_get);void nf_ct_helper_put (struct nf_conntrack_helper *helper) {module_put (helper->me); } +EXPORT_SYMBOL_GPL (nf_ct_helper_put);struct nf_conntrack_helper *__nf_conntrack_helper_find_byname (const char *name)
@@ -81,6 +83,7 @@ __nf_conntrack_helper_find_byname(constreturn NULL ; } +EXPORT_SYMBOL_GPL (__nf_conntrack_helper_find_byname);static inline int unhelp (struct nf_conntrack_tuple_hash *i,const struct nf_conntrack_helper *me)
@@ -115,6 +118,7 @@ int nf_conntrack_helper_register(structreturn 0 ; } +EXPORT_SYMBOL_GPL (nf_conntrack_helper_register);void nf_conntrack_helper_unregister (struct nf_conntrack_helper *me) {
@@ -148,3 +152,4 @@ void nf_conntrack_helper_unregister(stru/* Someone could be still looking at the helper in a bh. */ synchronize_net (); } +EXPORT_SYMBOL_GPL (nf_conntrack_helper_unregister);
net/netfilter/nf_conntrack_proto.c +12 -0
@@ -30,6 +30,7 @@ #include <net/netfilter/nf_conntrack_corstruct nf_conntrack_l4proto **nf_ct_protos[PF_MAX ]__read_mostly ;struct nf_conntrack_l3proto *nf_ct_l3protos[AF_MAX ]__read_mostly ; +EXPORT_SYMBOL_GPL (nf_ct_l3protos);#ifdef CONFIG_SYSCTL static DEFINE_MUTEX (nf_ct_proto_sysctl_mutex);
@@ -67,6 +68,7 @@ __nf_ct_l4proto_find(u_int16_t l3proto,return nf_ct_protos[l3proto][l4proto]; } +EXPORT_SYMBOL_GPL (__nf_ct_l4proto_find);/* this is guaranteed to always return a valid protocol helper, since * it falls back to generic_protocol */
@@ -83,11 +85,13 @@ nf_ct_l4proto_find_get(u_int16_t l3protoreturn p; } +EXPORT_SYMBOL_GPL (nf_ct_l4proto_find_get);void nf_ct_l4proto_put (struct nf_conntrack_l4proto *p) {module_put (p->me); } +EXPORT_SYMBOL_GPL (nf_ct_l4proto_put);struct nf_conntrack_l3proto *nf_ct_l3proto_find_get (u_int16_t l3proto)
@@ -102,11 +106,13 @@ nf_ct_l3proto_find_get(u_int16_t l3protoreturn p; } +EXPORT_SYMBOL_GPL (nf_ct_l3proto_find_get);void nf_ct_l3proto_put (struct nf_conntrack_l3proto *p) {module_put (p->me); } +EXPORT_SYMBOL_GPL (nf_ct_l3proto_put);int nf_ct_l3proto_try_module_get (unsigned short l3proto)
@@ -125,6 +131,7 @@ retry: p = nf_ct_l3proto_find_get(l3protreturn 0 ; } +EXPORT_SYMBOL_GPL (nf_ct_l3proto_try_module_get);void nf_ct_l3proto_module_put (unsigned short l3proto) {
@@ -136,6 +143,7 @@ void nf_ct_l3proto_module_put(unsigned smodule_put (p->me); } +EXPORT_SYMBOL_GPL (nf_ct_l3proto_module_put);static int kill_l3proto (struct nf_conn *i,void *data) {
@@ -207,6 +215,7 @@ out_unlock: out:return ret; } +EXPORT_SYMBOL_GPL (nf_conntrack_l3proto_register);int nf_conntrack_l3proto_unregister (struct nf_conntrack_l3proto *proto) {
@@ -238,6 +247,7 @@ int nf_conntrack_l3proto_unregister(stru out:return ret; } +EXPORT_SYMBOL_GPL (nf_conntrack_l3proto_unregister);static int nf_ct_l4proto_register_sysctl (struct nf_conntrack_l4proto *l4proto) {
@@ -359,6 +369,7 @@ out_unlock: out:return ret; } +EXPORT_SYMBOL_GPL (nf_conntrack_l4proto_register);int nf_conntrack_l4proto_unregister (struct nf_conntrack_l4proto *l4proto) {
@@ -396,3 +407,4 @@ int nf_conntrack_l4proto_unregister(stru out:return ret; } +EXPORT_SYMBOL_GPL (nf_conntrack_l4proto_unregister);
net/netfilter/nf_conntrack_proto_tcp.c +3 -4
@@ -762,7 +762,7 @@ #endif receiver->td_end, receiver->td_maxend, receiver->td_maxwin, receiver->td_scale); } - +EXPORT_SYMBOL_GPL (nf_conntrack_tcp_update);#endif #define TH_FIN 0x01
@@ -1405,6 +1405,7 @@ #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT#endif #endif }; +EXPORT_SYMBOL_GPL (nf_conntrack_l4proto_tcp4);struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6 = {
@@ -1431,6 +1432,4 @@ #ifdef CONFIG_SYSCTL .ctl_table = tcp_sysctl_table,#endif }; - -EXPORT_SYMBOL (nf_conntrack_l4proto_tcp4); -EXPORT_SYMBOL (nf_conntrack_l4proto_tcp6); +EXPORT_SYMBOL_GPL (nf_conntrack_l4proto_tcp6);
net/netfilter/nf_conntrack_proto_udp.c +2 -3
@@ -223,6 +223,7 @@ #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT#endif #endif }; +EXPORT_SYMBOL_GPL (nf_conntrack_l4proto_udp4);struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6 = {
@@ -247,6 +248,4 @@ #ifdef CONFIG_SYSCTL .ctl_table = udp_sysctl_table,#endif }; - -EXPORT_SYMBOL (nf_conntrack_l4proto_udp4); -EXPORT_SYMBOL (nf_conntrack_l4proto_udp6); +EXPORT_SYMBOL_GPL (nf_conntrack_l4proto_udp6);
net/netfilter/nf_conntrack_standalone.c +3 -71
89 lines not on this page · raw message
Hi, Patrick,
From: Patrick McHardy <[email protected]>
Date: Sat, 2 Dec 2006 15:49:36 +0100 (MET)
Quoted 10 lines
Hi Dave,
following is part two of my netfilter update for 2.6.20, containing NAT support for
nf_conntrackand ports of all conntrack/NAT helpers. With these patchesnf_conntrackis finally a full replacement forip_conntrack, which is now scheduled for removal in 2.6.22 after some stabilization of the new code.You can also pull these patches from
http://people.netfilter.org/~kaber/nf-2.6.20-nat.git
I've tested some kconfig combinations. Some helpers seem to need netfilter.h for NF_{ACCEPT,DROP}, in the case that IPv4 NAT is disabled. And ecache includes some unnecessary headers.
-- Yasuyuki Kozakai
Quoted 1 line
From
0e329162380f9f7342bff139087e1964dcb94bbcMon Sep 17 00:00:00 2001
From: Yasuyuki Kozakai <[email protected]>
Date: Sun, 3 Dec 2006 06:41:20 +0900
Subject: [NETFILTER]: nf_conntrack: fix header inclusions for helpers
--- net/netfilter/nf_conntrack_amanda.c | 1 + net/netfilter/nf_conntrack_ecache.c | 4 ---- net/netfilter/nf_conntrack_netbios_ns.c | 1 + net/netfilter/nf_conntrack_sip.c | 1 + net/netfilter/nf_conntrack_tftp.c | 1 + 5 files changed, 4 insertions(+), 4 deletions(-)
net/netfilter/nf_conntrack_amanda.c +1 -0
@@ -15,6 +15,7 @@#include <linux/skbuff.h> #include <linux/in.h> #include <linux/udp.h> +#include <linux/netfilter.h> #include <net/netfilter/nf_conntrack.h> #include <net/netfilter/nf_conntrack_expect.h>
net/netfilter/nf_conntrack_ecache.c +0 -4
@@ -21,10 +21,6 @@#include <linux/netdevice.h> #include <net/netfilter/nf_conntrack.h> -#include <net/netfilter/nf_conntrack_l3proto.h> -#include <net/netfilter/nf_conntrack_l4proto.h> -#include <net/netfilter/nf_conntrack_expect.h> -#include <net/netfilter/nf_conntrack_helper.h> #include <net/netfilter/nf_conntrack_core.h> ATOMIC_NOTIFIER_HEAD (nf_conntrack_chain);
net/netfilter/nf_conntrack_netbios_ns.c +1 -0
@@ -24,6 +24,7 @@#include <linux/if_addr.h> #include <linux/in.h> #include <linux/ip.h> +#include <linux/netfilter.h> #include <net/route.h> #include <net/netfilter/nf_conntrack.h>
net/netfilter/nf_conntrack_sip.c +1 -0
@@ -14,6 +14,7 @@#include <linux/inet.h> #include <linux/in.h> #include <linux/udp.h> +#include <linux/netfilter.h> #include <net/netfilter/nf_conntrack.h> #include <net/netfilter/nf_conntrack_expect.h>
net/netfilter/nf_conntrack_tftp.c +1 -0
@@ -9,6 +9,7 @@#include <linux/moduleparam.h> #include <linux/in.h> #include <linux/udp.h> +#include <linux/netfilter.h> #include <net/netfilter/nf_conntrack.h> #include <net/netfilter/nf_conntrack_tuple.h>
Signature · 1 line
1.4.4
David Miller
maintainerFrom: Patrick McHardy <[email protected]>
Date: Sat, 2 Dec 2006 15:49:36 +0100 (MET)
Quoted 5 lines
following is part two of my netfilter update for 2.6.20, containing NAT support for
nf_conntrackand ports of all conntrack/NAT helpers. With these patchesnf_conntrackis finally a full replacement forip_conntrack, which is now scheduled for removal in 2.6.22 after some stabilization of the new code.
I've rebased my tree and applied all 20 patches, thanks a lot!
Also, since I wanted to try to push this work to Linus tonight I applied Yasuyuki-san's header include fix as well.
Thanks again. I'm very happy this work got completed in time for 2.6.20