12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14 #include <linux/module.h>
16 #include <linux/socket.h>
17 #include <linux/hash.h>
18 #include <linux/l2tp.h>
37 static struct dentry *rootdir;
38 static struct dentry *tunnels;
61 l2tp_dfs_next_tunnel(pd);
66 static void *l2tp_dfs_seq_start(
struct seq_file *
m, loff_t *
offs)
78 l2tp_dfs_next_tunnel(pd);
80 l2tp_dfs_next_session(pd);
91 static void *l2tp_dfs_seq_next(
struct seq_file *m,
void *
v, loff_t *pos)
97 static void l2tp_dfs_seq_stop(
struct seq_file *
p,
void *
v)
102 static void l2tp_dfs_seq_tunnel_show(
struct seq_file *m,
void *
v)
105 int session_count = 0;
128 #if IS_ENABLED(CONFIG_IPV6)
138 seq_printf(m,
" source port %hu, dest port %hu\n",
145 seq_printf(m,
" %d sessions, refcnt %d/%d\n", session_count,
149 seq_printf(m,
" %08x rx %llu/%llu/%llu rx %llu/%llu/%llu\n",
151 (
unsigned long long)tunnel->
stats.tx_packets,
152 (
unsigned long long)tunnel->
stats.tx_bytes,
153 (
unsigned long long)tunnel->
stats.tx_errors,
154 (
unsigned long long)tunnel->
stats.rx_packets,
155 (
unsigned long long)tunnel->
stats.rx_bytes,
156 (
unsigned long long)tunnel->
stats.rx_errors);
158 if (tunnel->show !=
NULL)
159 tunnel->show(m, tunnel);
162 static void l2tp_dfs_seq_session_show(
struct seq_file *m,
void *v)
174 seq_printf(m,
" config %d/%d/%c/%c/%s/%s %08x %u\n",
175 session->
mtu, session->
mru,
179 session->
data_seq == 2 ?
"DATASEQ" :
"-",
183 seq_printf(m,
" offset %hu l2specific %hu/%hu\n",
196 seq_printf(m,
" peer cookie %02x%02x%02x%02x",
206 seq_printf(m,
" %hu/%hu tx %llu/%llu/%llu rx %llu/%llu/%llu\n",
207 session->
nr, session->
ns,
208 (
unsigned long long)session->
stats.tx_packets,
209 (
unsigned long long)session->
stats.tx_bytes,
210 (
unsigned long long)session->
stats.tx_errors,
211 (
unsigned long long)session->
stats.rx_packets,
212 (
unsigned long long)session->
stats.rx_bytes,
213 (
unsigned long long)session->
stats.rx_errors);
215 if (session->show !=
NULL)
216 session->show(m, session);
219 static int l2tp_dfs_seq_show(
struct seq_file *m,
void *v)
225 seq_puts(m,
"TUNNEL ID, peer ID from IP to IP\n");
226 seq_puts(m,
" L2TPv2/L2TPv3, UDP/IP\n");
227 seq_puts(m,
" sessions session-count, refcnt refcnt/sk->refcnt\n");
228 seq_puts(m,
" debug tx-pkts/bytes/errs rx-pkts/bytes/errs\n");
229 seq_puts(m,
" SESSION ID, peer ID, PWTYPE\n");
231 seq_puts(m,
" offset OFFSET l2specific TYPE/LEN\n");
234 seq_puts(m,
" config mtu/mru/rcvseq/sendseq/dataseq/lns debug reorderto\n");
235 seq_puts(m,
" nr/ns tx-pkts/bytes/errs rx-pkts/bytes/errs\n");
241 l2tp_dfs_seq_tunnel_show(m, pd->
tunnel);
243 l2tp_dfs_seq_session_show(m, pd->
session);
250 .start = l2tp_dfs_seq_start,
251 .next = l2tp_dfs_seq_next,
252 .stop = l2tp_dfs_seq_stop,
253 .show = l2tp_dfs_seq_show,
270 if (IS_ERR(pd->
net)) {
271 rc = PTR_ERR(pd->
net);
275 rc =
seq_open(file, &l2tp_dfs_seq_ops);
292 static int l2tp_dfs_seq_release(
struct inode *inode,
struct file *file)
309 .open = l2tp_dfs_seq_open,
312 .release = l2tp_dfs_seq_release,
315 static int __init l2tp_debugfs_init(
void)
320 if (IS_ERR(rootdir)) {
321 rc = PTR_ERR(rootdir);
330 pr_info(
"L2TP debugfs support\n");
339 static void __exit l2tp_debugfs_exit(
void)