summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@kernel.org>2017-12-28 21:47:20 -0500
committerDavid S. Miller <davem@davemloft.net>2018-01-02 14:27:29 -0500
commitfa4475f79251a0539e64c08b8b039be23d107dc9 (patch)
treeadd16f1f91696c942f8af9271863e5a7566c07ee
parent103d750c88fe6b42dbe7abc4d204027f343ee125 (diff)
net: sctp: Remove debug SCTP probe module
Remove SCTP probe module since jprobe has been deprecated. That function is now replaced by sctp/sctp_probe and sctp/sctp_probe_path trace-events. You can use it via ftrace or perftools. Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/sctp/Kconfig12
-rw-r--r--net/sctp/Makefile3
-rw-r--r--net/sctp/probe.c244
3 files changed, 0 insertions, 259 deletions
diff --git a/net/sctp/Kconfig b/net/sctp/Kconfig
index d9c04dc1b3f3..c740b189d4ba 100644
--- a/net/sctp/Kconfig
+++ b/net/sctp/Kconfig
@@ -37,18 +37,6 @@ menuconfig IP_SCTP
37 37
38if IP_SCTP 38if IP_SCTP
39 39
40config NET_SCTPPROBE
41 tristate "SCTP: Association probing"
42 depends on PROC_FS && KPROBES
43 ---help---
44 This module allows for capturing the changes to SCTP association
45 state in response to incoming packets. It is used for debugging
46 SCTP congestion control algorithms. If you don't understand
47 what was just said, you don't need it: say N.
48
49 To compile this code as a module, choose M here: the
50 module will be called sctp_probe.
51
52config SCTP_DBG_OBJCNT 40config SCTP_DBG_OBJCNT
53 bool "SCTP: Debug object counts" 41 bool "SCTP: Debug object counts"
54 depends on PROC_FS 42 depends on PROC_FS
diff --git a/net/sctp/Makefile b/net/sctp/Makefile
index 54bd9c1a8aa1..6776582ec449 100644
--- a/net/sctp/Makefile
+++ b/net/sctp/Makefile
@@ -4,7 +4,6 @@
4# 4#
5 5
6obj-$(CONFIG_IP_SCTP) += sctp.o 6obj-$(CONFIG_IP_SCTP) += sctp.o
7obj-$(CONFIG_NET_SCTPPROBE) += sctp_probe.o
8obj-$(CONFIG_INET_SCTP_DIAG) += sctp_diag.o 7obj-$(CONFIG_INET_SCTP_DIAG) += sctp_diag.o
9 8
10sctp-y := sm_statetable.o sm_statefuns.o sm_sideeffect.o \ 9sctp-y := sm_statetable.o sm_statefuns.o sm_sideeffect.o \
@@ -16,8 +15,6 @@ sctp-y := sm_statetable.o sm_statefuns.o sm_sideeffect.o \
16 offload.o stream_sched.o stream_sched_prio.o \ 15 offload.o stream_sched.o stream_sched_prio.o \
17 stream_sched_rr.o stream_interleave.o 16 stream_sched_rr.o stream_interleave.o
18 17
19sctp_probe-y := probe.o
20
21sctp-$(CONFIG_SCTP_DBG_OBJCNT) += objcnt.o 18sctp-$(CONFIG_SCTP_DBG_OBJCNT) += objcnt.o
22sctp-$(CONFIG_PROC_FS) += proc.o 19sctp-$(CONFIG_PROC_FS) += proc.o
23sctp-$(CONFIG_SYSCTL) += sysctl.o 20sctp-$(CONFIG_SYSCTL) += sysctl.o
diff --git a/net/sctp/probe.c b/net/sctp/probe.c
deleted file mode 100644
index 1280f85a598d..000000000000
--- a/net/sctp/probe.c
+++ /dev/null
@@ -1,244 +0,0 @@
1/*
2 * sctp_probe - Observe the SCTP flow with kprobes.
3 *
4 * The idea for this came from Werner Almesberger's umlsim
5 * Copyright (C) 2004, Stephen Hemminger <shemminger@osdl.org>
6 *
7 * Modified for SCTP from Stephen Hemminger's code
8 * Copyright (C) 2010, Wei Yongjun <yjwei@cn.fujitsu.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
26
27#include <linux/kernel.h>
28#include <linux/kprobes.h>
29#include <linux/socket.h>
30#include <linux/sctp.h>
31#include <linux/proc_fs.h>
32#include <linux/vmalloc.h>
33#include <linux/module.h>
34#include <linux/kfifo.h>
35#include <linux/time.h>
36#include <net/net_namespace.h>
37
38#include <net/sctp/sctp.h>
39#include <net/sctp/sm.h>
40
41MODULE_SOFTDEP("pre: sctp");
42MODULE_AUTHOR("Wei Yongjun <yjwei@cn.fujitsu.com>");
43MODULE_DESCRIPTION("SCTP snooper");
44MODULE_LICENSE("GPL");
45
46static int port __read_mostly = 0;
47MODULE_PARM_DESC(port, "Port to match (0=all)");
48module_param(port, int, 0);
49
50static unsigned int fwmark __read_mostly = 0;
51MODULE_PARM_DESC(fwmark, "skb mark to match (0=no mark)");
52module_param(fwmark, uint, 0);
53
54static int bufsize __read_mostly = 64 * 1024;
55MODULE_PARM_DESC(bufsize, "Log buffer size (default 64k)");
56module_param(bufsize, int, 0);
57
58static int full __read_mostly = 1;
59MODULE_PARM_DESC(full, "Full log (1=every ack packet received, 0=only cwnd changes)");
60module_param(full, int, 0);
61
62static const char procname[] = "sctpprobe";
63
64static struct {
65 struct kfifo fifo;
66 spinlock_t lock;
67 wait_queue_head_t wait;
68 struct timespec64 tstart;
69} sctpw;
70
71static __printf(1, 2) void printl(const char *fmt, ...)
72{
73 va_list args;
74 int len;
75 char tbuf[256];
76
77 va_start(args, fmt);
78 len = vscnprintf(tbuf, sizeof(tbuf), fmt, args);
79 va_end(args);
80
81 kfifo_in_locked(&sctpw.fifo, tbuf, len, &sctpw.lock);
82 wake_up(&sctpw.wait);
83}
84
85static int sctpprobe_open(struct inode *inode, struct file *file)
86{
87 kfifo_reset(&sctpw.fifo);
88 ktime_get_ts64(&sctpw.tstart);
89
90 return 0;
91}
92
93static ssize_t sctpprobe_read(struct file *file, char __user *buf,
94 size_t len, loff_t *ppos)
95{
96 int error = 0, cnt = 0;
97 unsigned char *tbuf;
98
99 if (!buf)
100 return -EINVAL;
101
102 if (len == 0)
103 return 0;
104
105 tbuf = vmalloc(len);
106 if (!tbuf)
107 return -ENOMEM;
108
109 error = wait_event_interruptible(sctpw.wait,
110 kfifo_len(&sctpw.fifo) != 0);
111 if (error)
112 goto out_free;
113
114 cnt = kfifo_out_locked(&sctpw.fifo, tbuf, len, &sctpw.lock);
115 error = copy_to_user(buf, tbuf, cnt) ? -EFAULT : 0;
116
117out_free:
118 vfree(tbuf);
119
120 return error ? error : cnt;
121}
122
123static const struct file_operations sctpprobe_fops = {
124 .owner = THIS_MODULE,
125 .open = sctpprobe_open,
126 .read = sctpprobe_read,
127 .llseek = noop_llseek,
128};
129
130static enum sctp_disposition jsctp_sf_eat_sack(
131 struct net *net,
132 const struct sctp_endpoint *ep,
133 const struct sctp_association *asoc,
134 const union sctp_subtype type,
135 void *arg,
136 struct sctp_cmd_seq *commands)
137{
138 struct sctp_chunk *chunk = arg;
139 struct sk_buff *skb = chunk->skb;
140 struct sctp_transport *sp;
141 static __u32 lcwnd = 0;
142 struct timespec64 now;
143
144 sp = asoc->peer.primary_path;
145
146 if (((port == 0 && fwmark == 0) ||
147 asoc->peer.port == port ||
148 ep->base.bind_addr.port == port ||
149 (fwmark > 0 && skb->mark == fwmark)) &&
150 (full || sp->cwnd != lcwnd)) {
151 lcwnd = sp->cwnd;
152
153 ktime_get_ts64(&now);
154 now = timespec64_sub(now, sctpw.tstart);
155
156 printl("%lu.%06lu ", (unsigned long) now.tv_sec,
157 (unsigned long) now.tv_nsec / NSEC_PER_USEC);
158
159 printl("%p %5d %5d %5d %8d %5d ", asoc,
160 ep->base.bind_addr.port, asoc->peer.port,
161 asoc->pathmtu, asoc->peer.rwnd, asoc->unack_data);
162
163 list_for_each_entry(sp, &asoc->peer.transport_addr_list,
164 transports) {
165 if (sp == asoc->peer.primary_path)
166 printl("*");
167
168 printl("%pISc %2u %8u %8u %8u %8u %8u ",
169 &sp->ipaddr, sp->state, sp->cwnd, sp->ssthresh,
170 sp->flight_size, sp->partial_bytes_acked,
171 sp->pathmtu);
172 }
173 printl("\n");
174 }
175
176 jprobe_return();
177 return 0;
178}
179
180static struct jprobe sctp_recv_probe = {
181 .kp = {
182 .symbol_name = "sctp_sf_eat_sack_6_2",
183 },
184 .entry = jsctp_sf_eat_sack,
185};
186
187static __init int sctp_setup_jprobe(void)
188{
189 int ret = register_jprobe(&sctp_recv_probe);
190
191 if (ret) {
192 if (request_module("sctp"))
193 goto out;
194 ret = register_jprobe(&sctp_recv_probe);
195 }
196
197out:
198 return ret;
199}
200
201static __init int sctpprobe_init(void)
202{
203 int ret = -ENOMEM;
204
205 /* Warning: if the function signature of sctp_sf_eat_sack_6_2,
206 * has been changed, you also have to change the signature of
207 * jsctp_sf_eat_sack, otherwise you end up right here!
208 */
209 BUILD_BUG_ON(__same_type(sctp_sf_eat_sack_6_2,
210 jsctp_sf_eat_sack) == 0);
211
212 init_waitqueue_head(&sctpw.wait);
213 spin_lock_init(&sctpw.lock);
214 if (kfifo_alloc(&sctpw.fifo, bufsize, GFP_KERNEL))
215 return ret;
216
217 if (!proc_create(procname, S_IRUSR, init_net.proc_net,
218 &sctpprobe_fops))
219 goto free_kfifo;
220
221 ret = sctp_setup_jprobe();
222 if (ret)
223 goto remove_proc;
224
225 pr_info("probe registered (port=%d/fwmark=%u) bufsize=%u\n",
226 port, fwmark, bufsize);
227 return 0;
228
229remove_proc:
230 remove_proc_entry(procname, init_net.proc_net);
231free_kfifo:
232 kfifo_free(&sctpw.fifo);
233 return ret;
234}
235
236static __exit void sctpprobe_exit(void)
237{
238 kfifo_free(&sctpw.fifo);
239 remove_proc_entry(procname, init_net.proc_net);
240 unregister_jprobe(&sctp_recv_probe);
241}
242
243module_init(sctpprobe_init);
244module_exit(sctpprobe_exit);