aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/probe.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/dccp/probe.c')
-rw-r--r--net/dccp/probe.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/net/dccp/probe.c b/net/dccp/probe.c
index 37731da41481..078e48d442fd 100644
--- a/net/dccp/probe.c
+++ b/net/dccp/probe.c
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/kfifo.h> 31#include <linux/kfifo.h>
32#include <linux/vmalloc.h> 32#include <linux/vmalloc.h>
33#include <linux/gfp.h>
33#include <net/net_namespace.h> 34#include <net/net_namespace.h>
34 35
35#include "dccp.h" 36#include "dccp.h"
@@ -43,7 +44,7 @@ static int bufsize = 64 * 1024;
43static const char procname[] = "dccpprobe"; 44static const char procname[] = "dccpprobe";
44 45
45static struct { 46static struct {
46 struct kfifo *fifo; 47 struct kfifo fifo;
47 spinlock_t lock; 48 spinlock_t lock;
48 wait_queue_head_t wait; 49 wait_queue_head_t wait;
49 struct timespec tstart; 50 struct timespec tstart;
@@ -67,7 +68,7 @@ static void printl(const char *fmt, ...)
67 len += vscnprintf(tbuf+len, sizeof(tbuf)-len, fmt, args); 68 len += vscnprintf(tbuf+len, sizeof(tbuf)-len, fmt, args);
68 va_end(args); 69 va_end(args);
69 70
70 kfifo_put(dccpw.fifo, tbuf, len); 71 kfifo_in_locked(&dccpw.fifo, tbuf, len, &dccpw.lock);
71 wake_up(&dccpw.wait); 72 wake_up(&dccpw.wait);
72} 73}
73 74
@@ -75,26 +76,25 @@ static int jdccp_sendmsg(struct kiocb *iocb, struct sock *sk,
75 struct msghdr *msg, size_t size) 76 struct msghdr *msg, size_t size)
76{ 77{
77 const struct inet_sock *inet = inet_sk(sk); 78 const struct inet_sock *inet = inet_sk(sk);
78 struct ccid3_hc_tx_sock *hctx = NULL; 79 struct ccid3_hc_tx_sock *hc = NULL;
79 80
80 if (ccid_get_current_tx_ccid(dccp_sk(sk)) == DCCPC_CCID3) 81 if (ccid_get_current_tx_ccid(dccp_sk(sk)) == DCCPC_CCID3)
81 hctx = ccid3_hc_tx_sk(sk); 82 hc = ccid3_hc_tx_sk(sk);
82 83
83 if (port == 0 || ntohs(inet->dport) == port || 84 if (port == 0 || ntohs(inet->inet_dport) == port ||
84 ntohs(inet->sport) == port) { 85 ntohs(inet->inet_sport) == port) {
85 if (hctx) 86 if (hc)
86 printl("%pI4:%u %pI4:%u %d %d %d %d %u " 87 printl("%pI4:%u %pI4:%u %d %d %d %d %u %llu %llu %d\n",
87 "%llu %llu %d\n", 88 &inet->inet_saddr, ntohs(inet->inet_sport),
88 &inet->saddr, ntohs(inet->sport), 89 &inet->inet_daddr, ntohs(inet->inet_dport), size,
89 &inet->daddr, ntohs(inet->dport), size, 90 hc->tx_s, hc->tx_rtt, hc->tx_p,
90 hctx->ccid3hctx_s, hctx->ccid3hctx_rtt, 91 hc->tx_x_calc, hc->tx_x_recv >> 6,
91 hctx->ccid3hctx_p, hctx->ccid3hctx_x_calc, 92 hc->tx_x >> 6, hc->tx_t_ipi);
92 hctx->ccid3hctx_x_recv >> 6,
93 hctx->ccid3hctx_x >> 6, hctx->ccid3hctx_t_ipi);
94 else 93 else
95 printl("%pI4:%u %pI4:%u %d\n", 94 printl("%pI4:%u %pI4:%u %d\n",
96 &inet->saddr, ntohs(inet->sport), 95 &inet->inet_saddr, ntohs(inet->inet_sport),
97 &inet->daddr, ntohs(inet->dport), size); 96 &inet->inet_daddr, ntohs(inet->inet_dport),
97 size);
98 } 98 }
99 99
100 jprobe_return(); 100 jprobe_return();
@@ -110,7 +110,7 @@ static struct jprobe dccp_send_probe = {
110 110
111static int dccpprobe_open(struct inode *inode, struct file *file) 111static int dccpprobe_open(struct inode *inode, struct file *file)
112{ 112{
113 kfifo_reset(dccpw.fifo); 113 kfifo_reset(&dccpw.fifo);
114 getnstimeofday(&dccpw.tstart); 114 getnstimeofday(&dccpw.tstart);
115 return 0; 115 return 0;
116} 116}
@@ -132,11 +132,11 @@ static ssize_t dccpprobe_read(struct file *file, char __user *buf,
132 return -ENOMEM; 132 return -ENOMEM;
133 133
134 error = wait_event_interruptible(dccpw.wait, 134 error = wait_event_interruptible(dccpw.wait,
135 __kfifo_len(dccpw.fifo) != 0); 135 kfifo_len(&dccpw.fifo) != 0);
136 if (error) 136 if (error)
137 goto out_free; 137 goto out_free;
138 138
139 cnt = kfifo_get(dccpw.fifo, tbuf, len); 139 cnt = kfifo_out_locked(&dccpw.fifo, tbuf, len, &dccpw.lock);
140 error = copy_to_user(buf, tbuf, cnt) ? -EFAULT : 0; 140 error = copy_to_user(buf, tbuf, cnt) ? -EFAULT : 0;
141 141
142out_free: 142out_free:
@@ -157,14 +157,13 @@ static __init int dccpprobe_init(void)
157 157
158 init_waitqueue_head(&dccpw.wait); 158 init_waitqueue_head(&dccpw.wait);
159 spin_lock_init(&dccpw.lock); 159 spin_lock_init(&dccpw.lock);
160 dccpw.fifo = kfifo_alloc(bufsize, GFP_KERNEL, &dccpw.lock); 160 if (kfifo_alloc(&dccpw.fifo, bufsize, GFP_KERNEL))
161 if (IS_ERR(dccpw.fifo)) 161 return ret;
162 return PTR_ERR(dccpw.fifo);
163
164 if (!proc_net_fops_create(&init_net, procname, S_IRUSR, &dccpprobe_fops)) 162 if (!proc_net_fops_create(&init_net, procname, S_IRUSR, &dccpprobe_fops))
165 goto err0; 163 goto err0;
166 164
167 ret = register_jprobe(&dccp_send_probe); 165 try_then_request_module((ret = register_jprobe(&dccp_send_probe)) == 0,
166 "dccp");
168 if (ret) 167 if (ret)
169 goto err1; 168 goto err1;
170 169
@@ -173,14 +172,14 @@ static __init int dccpprobe_init(void)
173err1: 172err1:
174 proc_net_remove(&init_net, procname); 173 proc_net_remove(&init_net, procname);
175err0: 174err0:
176 kfifo_free(dccpw.fifo); 175 kfifo_free(&dccpw.fifo);
177 return ret; 176 return ret;
178} 177}
179module_init(dccpprobe_init); 178module_init(dccpprobe_init);
180 179
181static __exit void dccpprobe_exit(void) 180static __exit void dccpprobe_exit(void)
182{ 181{
183 kfifo_free(dccpw.fifo); 182 kfifo_free(&dccpw.fifo);
184 proc_net_remove(&init_net, procname); 183 proc_net_remove(&init_net, procname);
185 unregister_jprobe(&dccp_send_probe); 184 unregister_jprobe(&dccp_send_probe);
186 185