summaryrefslogtreecommitdiffstats
path: root/sunrpc/bz680329.stp
blob: b4644936f082fc647d54c26609fd1d85c1f70951 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/usr/bin/stap -vg

%{
#include <linux/sunrpc/xprt.h>
%}

function xprt_connected:long(xprt:long) %{
	struct rpc_xprt *_xprt = (struct rpc_xprt *)(long)THIS->xprt;
	THIS->__retvalue = (long)xprt_connected(_xprt);
%}

function xprt_connecting:long(xprt:long) %{
	struct rpc_xprt *_xprt = (struct rpc_xprt *)(long)THIS->xprt;
	THIS->__retvalue = (long)xprt_connecting(_xprt);
%}

function sk_state:string(sk:long) {
	state = @cast(sk, "sock_common")->skc_state
	if (state == 1) {
		return "ESTABLISHED"
	} else if (state == 2) {
		return "SYN_SENT"
	} else if (state == 3) {
		return "SYN_RECV"
	} else if (state == 4) {
		return "FIN_WAIT1"
	} else if (state == 5) {
		return "FIN_WAIT2"
	} else if (state == 6) {
		return "TIME_WAIT"
	} else if (state == 7) {
		return "CLOSE"
	} else if (state == 8) {
		return "CLOSE_WAIT"
	} else if (state == 9) {
		return "LAST_ACK"
	} else if (state == 10) {
		return "LISTEN"
	} else if (state == 11) {
		return "CLOSING"
	}
	return sprintf("%d", state)
}

function strerr:string(e:long) {
	if (e == -99) {
		return "-EADDRNOTAVAILE"
	} else if (e == -111) {
		return "-ECONNREFUSED"
	} else if (e == -104) {
		return "-ECONNRESET"
	} else if (e == -101) {
		return "-ENETUNREACH"
	} else if (e == -115) {
		return "-EINPROGRESS"
	} else if (e == -114) {
		return "-EALREADY"
	} else if (e == -22) {
		return "-EINVAL"
	}
	return sprintf("%d", e)
}

function addrfam:string(f:long) {
	if (f == 0) {
		return "AF_UNSPEC"
	} else if (f == 2) {
		return "AF_INET"
	}
	return sprintf("%u", f)
}

probe begin {
	printf("%s Trace start\n", ctime(gettimeofday_s()))
}

probe module("sunrpc").function("xprt_connect") {
	if ($task->tk_client->cl_xprt->prot == 6) {
		printf("%s --> %s() tk_pid=%u xprt=%p (%s)\n",
			ctime(gettimeofday_s()), probefunc(), 
			$task->tk_pid, $task->tk_client->cl_xprt,
			xprt_connected($task->tk_client->cl_xprt) ? 
				"connected" : "not connected")
	}
}

probe module("sunrpc").function("xprt_connect").return {
	if ($task->tk_client->cl_xprt->prot == 6) {
		printf("%s <-- %s() tk_pid=%u\n\n", 
			ctime(gettimeofday_s()), probefunc(), 
			$task->tk_pid)
	}
}

probe module("sunrpc").function("xs_connect") {
	if ($task->tk_client->cl_xprt->prot == 6) {
		connecting = xprt_connecting($task->tk_client->cl_xprt)
		if (connecting) {
			printf("%s  --> %s() tk_pid=%u socket=%p (connecting, do nothing)\n", 
				ctime(gettimeofday_s()), probefunc(), 
				$task->tk_pid, $task->tk_client->cl_xprt->sock)
		}
		else if ($task->tk_client->cl_xprt->sock == 0) {
			printf("%s  --> %s() tk_pid=%u socket=%p (not connecting, queue work)\n", 
				ctime(gettimeofday_s()), probefunc(), 
				$task->tk_pid, $task->tk_client->cl_xprt->sock)
		}
		else {
			printf("%s  --> %s() tk_pid=%u socket=%p (not connecting, queue delayed work) reestablish_timeout=%d\n", 
				ctime(gettimeofday_s()), probefunc(), 
				$task->tk_pid, $task->tk_client->cl_xprt->sock,
				$task->tk_client->cl_xprt->reestablish_timeout)
		}
	}
}

probe module("sunrpc").function("xs_connect").return {
	if ($task->tk_client->cl_xprt->prot == 6) {
		printf("%s  <-- %s() tk_pid=%u\n", 
			ctime(gettimeofday_s()), probefunc(), 
			$task->tk_pid)
	}
}

probe module("sunrpc").function("xs_tcp_connect_worker") {
	if (@cast($args, "rpc_xprt")->sock == 0) {
		printf("%s --> %s() xprt=%p socket=%p\n", 
			ctime(gettimeofday_s()), probefunc(),
			$args, @cast($args, "rpc_xprt")->sock)
	}
	else {
		printf("%s --> %s() xprt=%p socket=%p sk_state=%s\n", 
			ctime(gettimeofday_s()), probefunc(),
			$args, @cast($args, "rpc_xprt")->sock,
			sk_state(@cast($args, "rpc_xprt")->sock->sk))
	}
}

probe module("sunrpc").function("xs_tcp_connect_worker").return {
	printf("%s <-- %s()\n\n", 
		ctime(gettimeofday_s()), probefunc())
}

probe module("sunrpc").function("xs_tcp_reuse_connection") {
	printf("%s  --> %s()\n", 
		ctime(gettimeofday_s()), probefunc())
}

probe kernel.function("kernel_connect") {
	printf("%s   --> %s() socket=%p sock=%p family=%s\n", 
		ctime(gettimeofday_s()), probefunc(),
		$sock, $sock->sk, addrfam($addr->sa_family))
}

probe kernel.function("kernel_connect").return {
	printf("%s   <-- %s() return=%s\n", 
		ctime(gettimeofday_s()), probefunc(),
		strerr($return))
}

probe module("sunrpc").function("xs_tcp_state_change") {
	printf("%s --> %s() sock=%p sk_state=%s\n", 
		ctime(gettimeofday_s()), probefunc(),
		$sk, sk_state($sk))
}

probe module("sunrpc").function("xs_tcp_state_change").return {
	printf("%s <-- %s()\n\n", 
		ctime(gettimeofday_s()), probefunc())
}

probe module("sunrpc").function("__rpc_default_timer") {
	printf("%s --> %s(): tk_pid=%u Timed out\n",
		ctime(gettimeofday_s()), probefunc(),
		$task->tk_pid)
}

probe module("sunrpc").function("__rpc_default_timer").return {
	printf("%s <-- %s()\n\n",
		ctime(gettimeofday_s()), probefunc())
}