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.c75
1 files changed, 48 insertions, 27 deletions
diff --git a/net/dccp/probe.c b/net/dccp/probe.c
index eaa59d82ab0f..81368a7f5379 100644
--- a/net/dccp/probe.c
+++ b/net/dccp/probe.c
@@ -46,54 +46,75 @@ static struct {
46 struct kfifo *fifo; 46 struct kfifo *fifo;
47 spinlock_t lock; 47 spinlock_t lock;
48 wait_queue_head_t wait; 48 wait_queue_head_t wait;
49 ktime_t start; 49 struct timespec tstart;
50} dccpw; 50} dccpw;
51 51
52static void jdccp_write_xmit(struct sock *sk) 52static void printl(const char *fmt, ...)
53{ 53{
54 const struct inet_sock *inet = inet_sk(sk); 54 va_list args;
55 struct ccid3_hc_tx_sock *hctx = NULL; 55 int len;
56 struct timespec tv; 56 struct timespec now;
57 char buf[256]; 57 char tbuf[256];
58 int len, ccid = ccid_get_current_tx_ccid(dccp_sk(sk));
59 58
60 if (ccid == DCCPC_CCID3) 59 va_start(args, fmt);
61 hctx = ccid3_hc_tx_sk(sk); 60 getnstimeofday(&now);
62 61
63 if (!port || ntohs(inet->dport) == port || ntohs(inet->sport) == port) { 62 now = timespec_sub(now, dccpw.tstart);
64 63
65 tv = ktime_to_timespec(ktime_sub(ktime_get(), dccpw.start)); 64 len = sprintf(tbuf, "%lu.%06lu ",
66 len = sprintf(buf, "%lu.%09lu %d.%d.%d.%d:%u %d.%d.%d.%d:%u %d", 65 (unsigned long) now.tv_sec,
67 (unsigned long)tv.tv_sec, 66 (unsigned long) now.tv_nsec / NSEC_PER_USEC);
68 (unsigned long)tv.tv_nsec, 67 len += vscnprintf(tbuf+len, sizeof(tbuf)-len, fmt, args);
69 NIPQUAD(inet->saddr), ntohs(inet->sport), 68 va_end(args);
70 NIPQUAD(inet->daddr), ntohs(inet->dport), ccid);
71 69
70 kfifo_put(dccpw.fifo, tbuf, len);
71 wake_up(&dccpw.wait);
72}
73
74static int jdccp_sendmsg(struct kiocb *iocb, struct sock *sk,
75 struct msghdr *msg, size_t size)
76{
77 const struct dccp_minisock *dmsk = dccp_msk(sk);
78 const struct inet_sock *inet = inet_sk(sk);
79 const struct ccid3_hc_tx_sock *hctx;
80
81 if (dmsk->dccpms_tx_ccid == DCCPC_CCID3)
82 hctx = ccid3_hc_tx_sk(sk);
83 else
84 hctx = NULL;
85
86 if (port == 0 || ntohs(inet->dport) == port ||
87 ntohs(inet->sport) == port) {
72 if (hctx) 88 if (hctx)
73 len += sprintf(buf + len, " %d %d %d %u %u %u %d", 89 printl("%d.%d.%d.%d:%u %d.%d.%d.%d:%u %d %d %d %d %u "
74 hctx->s, hctx->rtt, hctx->p, hctx->x_calc, 90 "%llu %llu %d\n",
75 (unsigned)(hctx->x_recv >> 6), 91 NIPQUAD(inet->saddr), ntohs(inet->sport),
76 (unsigned)(hctx->x >> 6), hctx->t_ipi); 92 NIPQUAD(inet->daddr), ntohs(inet->dport), size,
77 93 hctx->ccid3hctx_s, hctx->ccid3hctx_rtt,
78 len += sprintf(buf + len, "\n"); 94 hctx->ccid3hctx_p, hctx->ccid3hctx_x_calc,
79 kfifo_put(dccpw.fifo, buf, len); 95 hctx->ccid3hctx_x_recv >> 6,
80 wake_up(&dccpw.wait); 96 hctx->ccid3hctx_x >> 6, hctx->ccid3hctx_t_ipi);
97 else
98 printl("%d.%d.%d.%d:%u %d.%d.%d.%d:%u %d\n",
99 NIPQUAD(inet->saddr), ntohs(inet->sport),
100 NIPQUAD(inet->daddr), ntohs(inet->dport), size);
81 } 101 }
82 102
83 jprobe_return(); 103 jprobe_return();
104 return 0;
84} 105}
85 106
86static struct jprobe dccp_send_probe = { 107static struct jprobe dccp_send_probe = {
87 .kp = { 108 .kp = {
88 .symbol_name = "dccp_write_xmit", 109 .symbol_name = "dccp_sendmsg",
89 }, 110 },
90 .entry = jdccp_write_xmit, 111 .entry = jdccp_sendmsg,
91}; 112};
92 113
93static int dccpprobe_open(struct inode *inode, struct file *file) 114static int dccpprobe_open(struct inode *inode, struct file *file)
94{ 115{
95 kfifo_reset(dccpw.fifo); 116 kfifo_reset(dccpw.fifo);
96 dccpw.start = ktime_get(); 117 getnstimeofday(&dccpw.tstart);
97 return 0; 118 return 0;
98} 119}
99 120