]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - net/netfilter/nf_conntrack_proto_generic.c
netfilter: nf_conntrack: pass timeout array to l4->new and l4->packet
[mirror_ubuntu-artful-kernel.git] / net / netfilter / nf_conntrack_proto_generic.c
CommitLineData
9fb9cbb1
YK
1/* (C) 1999-2001 Paul `Rusty' Russell
2 * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
9fb9cbb1
YK
7 */
8
9#include <linux/types.h>
cd354f1a 10#include <linux/jiffies.h>
9fb9cbb1
YK
11#include <linux/timer.h>
12#include <linux/netfilter.h>
605dcad6 13#include <net/netfilter/nf_conntrack_l4proto.h>
9fb9cbb1 14
933a41e7 15static unsigned int nf_ct_generic_timeout __read_mostly = 600*HZ;
9fb9cbb1 16
09f263cd
JE
17static bool generic_pkt_to_tuple(const struct sk_buff *skb,
18 unsigned int dataoff,
19 struct nf_conntrack_tuple *tuple)
9fb9cbb1
YK
20{
21 tuple->src.u.all = 0;
22 tuple->dst.u.all = 0;
23
09f263cd 24 return true;
9fb9cbb1
YK
25}
26
09f263cd
JE
27static bool generic_invert_tuple(struct nf_conntrack_tuple *tuple,
28 const struct nf_conntrack_tuple *orig)
9fb9cbb1
YK
29{
30 tuple->src.u.all = 0;
31 tuple->dst.u.all = 0;
32
09f263cd 33 return true;
9fb9cbb1
YK
34}
35
36/* Print out the per-protocol part of the tuple. */
37static int generic_print_tuple(struct seq_file *s,
38 const struct nf_conntrack_tuple *tuple)
39{
40 return 0;
41}
42
2c8503f5
PNA
43static unsigned int *generic_get_timeouts(struct net *net)
44{
45 return &nf_ct_generic_timeout;
46}
47
9fb9cbb1 48/* Returns verdict for packet, or -1 for invalid. */
2c8503f5
PNA
49static int generic_packet(struct nf_conn *ct,
50 const struct sk_buff *skb,
51 unsigned int dataoff,
52 enum ip_conntrack_info ctinfo,
53 u_int8_t pf,
54 unsigned int hooknum,
55 unsigned int *timeout)
9fb9cbb1 56{
2c8503f5 57 nf_ct_refresh_acct(ct, ctinfo, skb, *timeout);
9fb9cbb1
YK
58 return NF_ACCEPT;
59}
60
61/* Called when a new connection for this protocol found. */
2c8503f5
PNA
62static bool generic_new(struct nf_conn *ct, const struct sk_buff *skb,
63 unsigned int dataoff, unsigned int *timeouts)
9fb9cbb1 64{
09f263cd 65 return true;
9fb9cbb1
YK
66}
67
933a41e7
PM
68#ifdef CONFIG_SYSCTL
69static struct ctl_table_header *generic_sysctl_header;
70static struct ctl_table generic_sysctl_table[] = {
71 {
933a41e7
PM
72 .procname = "nf_conntrack_generic_timeout",
73 .data = &nf_ct_generic_timeout,
74 .maxlen = sizeof(unsigned int),
75 .mode = 0644,
6d9f239a 76 .proc_handler = proc_dointvec_jiffies,
933a41e7 77 },
f8572d8f 78 { }
933a41e7 79};
a999e683
PM
80#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
81static struct ctl_table generic_compat_sysctl_table[] = {
82 {
a999e683
PM
83 .procname = "ip_conntrack_generic_timeout",
84 .data = &nf_ct_generic_timeout,
85 .maxlen = sizeof(unsigned int),
86 .mode = 0644,
6d9f239a 87 .proc_handler = proc_dointvec_jiffies,
a999e683 88 },
f8572d8f 89 { }
a999e683
PM
90};
91#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
933a41e7
PM
92#endif /* CONFIG_SYSCTL */
93
61075af5 94struct nf_conntrack_l4proto nf_conntrack_l4proto_generic __read_mostly =
9fb9cbb1
YK
95{
96 .l3proto = PF_UNSPEC,
fe2a7ce4 97 .l4proto = 255,
9fb9cbb1
YK
98 .name = "unknown",
99 .pkt_to_tuple = generic_pkt_to_tuple,
100 .invert_tuple = generic_invert_tuple,
101 .print_tuple = generic_print_tuple,
2c8503f5
PNA
102 .packet = generic_packet,
103 .get_timeouts = generic_get_timeouts,
104 .new = generic_new,
933a41e7
PM
105#ifdef CONFIG_SYSCTL
106 .ctl_table_header = &generic_sysctl_header,
107 .ctl_table = generic_sysctl_table,
a999e683
PM
108#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
109 .ctl_compat_table = generic_compat_sysctl_table,
110#endif
933a41e7 111#endif
9fb9cbb1 112};