9 #include <linux/types.h>
10 #include <linux/netfilter.h>
11 #include <linux/slab.h>
12 #include <linux/module.h>
17 #include <linux/netdevice.h>
21 #include <linux/sysctl.h>
37 #ifdef CONFIG_NF_CONNTRACK_PROCFS
55 struct net *
net = seq_file_net(seq);
60 st->
bucket < net->ct.htable_size;
72 struct net *net = seq_file_net(seq);
76 while (is_a_nulls(head)) {
78 if (++st->
bucket >= net->ct.htable_size)
82 hlist_nulls_first_rcu(
83 &net->ct.hash[st->
bucket]));
93 while (pos && (head = ct_get_next(seq, head)))
98 static void *ct_seq_start(
struct seq_file *seq, loff_t *pos)
105 return ct_get_idx(seq, *pos);
108 static void *ct_seq_next(
struct seq_file *s,
void *
v, loff_t *pos)
111 return ct_get_next(s, v);
114 static void ct_seq_stop(
struct seq_file *s,
void *
v)
120 #ifdef CONFIG_NF_CONNTRACK_SECMARK
137 static inline int ct_show_secctx(
struct seq_file *s,
const struct nf_conn *ct)
143 #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
144 static int ct_show_delta_time(
struct seq_file *s,
const struct nf_conn *ct)
150 tstamp = nf_conn_tstamp_find(ct);
152 delta_time = st->time_now - tstamp->
start;
159 (
unsigned long long)delta_time);
172 static int ct_seq_show(
struct seq_file *s,
void *
v)
175 struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(hash);
188 l3proto = __nf_ct_l3proto_find(nf_ct_l3num(ct));
195 l3proto->
name, nf_ct_l3num(ct),
196 l4proto->
name, nf_ct_protonum(ct),
198 ? (
long)(ct->
timeout.expires - jiffies)/
HZ : 0) != 0)
226 #if defined(CONFIG_NF_CONNTRACK_MARK)
231 if (ct_show_secctx(s, ct))
234 #ifdef CONFIG_NF_CONNTRACK_ZONES
235 if (
seq_printf(s,
"zone=%u ", nf_ct_zone(ct)))
239 if (ct_show_delta_time(s, ct))
252 .
start = ct_seq_start,
272 static void *ct_cpu_seq_start(
struct seq_file *seq, loff_t *pos)
274 struct net *net = seq_file_net(seq);
290 static void *ct_cpu_seq_next(
struct seq_file *seq,
void *v, loff_t *pos)
292 struct net *net = seq_file_net(seq);
295 for (cpu = *pos; cpu < nr_cpu_ids; ++
cpu) {
305 static void ct_cpu_seq_stop(
struct seq_file *seq,
void *v)
309 static int ct_cpu_seq_show(
struct seq_file *seq,
void *v)
311 struct net *net = seq_file_net(seq);
316 seq_printf(seq,
"entries searched found new invalid ignore delete delete_list insert insert_failed drop early_drop icmp_error expect_new expect_create expect_delete search_restart\n");
320 seq_printf(seq,
"%08x %08x %08x %08x %08x %08x %08x %08x "
321 "%08x %08x %08x %08x %08x %08x %08x %08x %08x\n",
345 .
start = ct_cpu_seq_start,
346 .next = ct_cpu_seq_next,
347 .stop = ct_cpu_seq_stop,
348 .show = ct_cpu_seq_show,
351 static int ct_cpu_seq_open(
struct inode *inode,
struct file *file)
359 .open = ct_cpu_seq_open,
365 static int nf_conntrack_standalone_init_proc(
struct net *net)
371 goto out_nf_conntrack;
376 goto out_stat_nf_conntrack;
379 out_stat_nf_conntrack:
385 static void nf_conntrack_standalone_fini_proc(
struct net *net)
391 static int nf_conntrack_standalone_init_proc(
struct net *net)
396 static void nf_conntrack_standalone_fini_proc(
struct net *net)
405 static int log_invalid_proto_min = 0;
406 static int log_invalid_proto_max = 255;
410 static ctl_table nf_ct_sysctl_table[] = {
414 .maxlen =
sizeof(
int),
419 .procname =
"nf_conntrack_count",
421 .maxlen =
sizeof(
int),
426 .procname =
"nf_conntrack_buckets",
428 .maxlen =
sizeof(
unsigned int),
433 .procname =
"nf_conntrack_checksum",
434 .data = &
init_net.ct.sysctl_checksum,
435 .maxlen =
sizeof(
unsigned int),
440 .procname =
"nf_conntrack_log_invalid",
441 .data = &
init_net.ct.sysctl_log_invalid,
442 .maxlen =
sizeof(
unsigned int),
445 .extra1 = &log_invalid_proto_min,
446 .extra2 = &log_invalid_proto_max,
449 .procname =
"nf_conntrack_expect_max",
451 .maxlen =
sizeof(
int),
458 #define NET_NF_CONNTRACK_MAX 2089
460 static ctl_table nf_ct_netfilter_table[] = {
464 .maxlen =
sizeof(
int),
471 static int nf_conntrack_standalone_init_sysctl(
struct net *net)
476 nf_ct_netfilter_header =
478 if (!nf_ct_netfilter_header)
482 table =
kmemdup(nf_ct_sysctl_table,
sizeof(nf_ct_sysctl_table),
488 table[2].
data = &net->ct.htable_size;
489 table[3].
data = &net->ct.sysctl_checksum;
490 table[4].
data = &net->ct.sysctl_log_invalid;
493 if (!net->ct.sysctl_header)
494 goto out_unregister_netfilter;
498 out_unregister_netfilter:
508 static void nf_conntrack_standalone_fini_sysctl(
struct net *net)
514 table = net->ct.sysctl_header->ctl_table_arg;
519 static int nf_conntrack_standalone_init_sysctl(
struct net *net)
524 static void nf_conntrack_standalone_fini_sysctl(
struct net *net)
529 static int nf_conntrack_net_init(
struct net *net)
536 ret = nf_conntrack_standalone_init_proc(net);
539 net->ct.sysctl_checksum = 1;
540 net->ct.sysctl_log_invalid = 0;
541 ret = nf_conntrack_standalone_init_sysctl(net);
547 nf_conntrack_standalone_fini_proc(net);
554 static void nf_conntrack_net_exit(
struct net *net)
556 nf_conntrack_standalone_fini_sysctl(net);
557 nf_conntrack_standalone_fini_proc(net);
562 .init = nf_conntrack_net_init,
563 .exit = nf_conntrack_net_exit,
566 static int __init nf_conntrack_standalone_init(
void)
571 static void __exit nf_conntrack_standalone_fini(
void)