1 // SPDX-License-Identifier: GPL-2.0-only
2 #include <linux/kernel.h>
3 #include <linux/proc_fs.h>
4 #include <net/netfilter/nf_flow_table.h>
6 static void *nf_flow_table_cpu_seq_start(struct seq_file *seq, loff_t *pos)
8 struct net *net = seq_file_net(seq);
12 return SEQ_START_TOKEN;
14 for (cpu = *pos - 1; cpu < nr_cpu_ids; ++cpu) {
15 if (!cpu_possible(cpu))
18 return per_cpu_ptr(net->ft.stat, cpu);
24 static void *nf_flow_table_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos)
26 struct net *net = seq_file_net(seq);
29 for (cpu = *pos; cpu < nr_cpu_ids; ++cpu) {
30 if (!cpu_possible(cpu))
33 return per_cpu_ptr(net->ft.stat, cpu);
39 static void nf_flow_table_cpu_seq_stop(struct seq_file *seq, void *v)
43 static int nf_flow_table_cpu_seq_show(struct seq_file *seq, void *v)
45 const struct nf_flow_table_stat *st = v;
47 if (v == SEQ_START_TOKEN) {
48 seq_puts(seq, "wq_add wq_del wq_stats\n");
52 seq_printf(seq, "%8d %8d %8d\n",
60 static const struct seq_operations nf_flow_table_cpu_seq_ops = {
61 .start = nf_flow_table_cpu_seq_start,
62 .next = nf_flow_table_cpu_seq_next,
63 .stop = nf_flow_table_cpu_seq_stop,
64 .show = nf_flow_table_cpu_seq_show,
67 int nf_flow_table_init_proc(struct net *net)
69 struct proc_dir_entry *pde;
71 pde = proc_create_net("nf_flowtable", 0444, net->proc_net_stat,
72 &nf_flow_table_cpu_seq_ops,
73 sizeof(struct seq_net_private));
74 return pde ? 0 : -ENOMEM;
77 void nf_flow_table_fini_proc(struct net *net)
79 remove_proc_entry("nf_flowtable", net->proc_net_stat);