summaryrefslogtreecommitdiffstats
path: root/sunrpc/sunrpc.stp
blob: 689577c149a94b4842d920a9ed282281ba44955d (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
%{
#include <linux/sunrpc/sched.h>
#include <linux/sunrpc/clnt.h>
%}
function rpcprocnum:long(_msg:long)
%{
	struct rpc_message *msg = (struct rpc_message *)(long) kread(&(THIS->_msg));
	struct rpc_procinfo *rpc_proc = 
		(struct rpc_procinfo *)(long) kread(&(msg->rpc_proc));

	THIS->__retvalue = rpc_proc->p_proc;

	CATCH_DEREF_FAULT();
%}
function rpcprocname:string(_msg:long)
%{
	struct rpc_message *msg = (struct rpc_message *)(long) kread(&(THIS->_msg));
	struct rpc_procinfo *rpc_proc = 
		(struct rpc_procinfo *)(long) kread(&(msg->rpc_proc));
	char *p_name = kread(&(rpc_proc->p_name));
	char buf[MAXSTRINGLEN];

	snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s(%d)",
		p_name ? p_name : "NULL" , rpc_proc->p_proc);

	CATCH_DEREF_FAULT();
%}
function rpcprogname:string(_clnt:long)
%{
	struct rpc_clnt *clnt = (struct rpc_clnt *)(long) kread(&(THIS->_clnt));
	char *cl_server = kread(&(clnt->cl_server));
	char *cl_protname = kread(&(clnt->cl_protname));
	char buf[MAXSTRINGLEN];

	snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s:%s",
		cl_server ? cl_server : "NULL" ,
		cl_protname ? cl_protname : "NULL" );

	CATCH_DEREF_FAULT();
%}
global syn_clnt, syn_msg, syn_flags
global asyn_clnt, asyn_msg, asyn_flags
global show_all

probe module("sunrpc").function("rpc_call_sync")
{
	if (show_all) {
		printf("%s(%d): rpc_call_sync:%s:%s: flags 0x%x\n",
				execname(), pid(), rpcprocname($msg), 
				rpcprogname($clnt), $flags);
	}
	syn_clnt = $clnt;
	syn_msg = $msg;
	syn_flags = $flags;
}
probe module("sunrpc").function("rpc_call_sync").return
{
	if ($return) {
		if (rpcprocnum(syn_msg) != 2 && $return != -2) {
			printf("%s(%d): rpc_call_sync:%s:%s: return %d (%s)\n", 
				execname(), pid(), rpcprocname(syn_msg), rpcprogname(syn_clnt),
				$return, errno_str($return));
		}
	}
}
probe module("sunrpc").function("rpc_call_async")
{
	if (show_all) {
		printf("%s(%d): rpc_call_sync:%s:%s:flags 0x%x\n",
				execname(), pid(), rpcprocname($msg), 
				rpcprogname($clnt), $flags);
	}
	asyn_clnt = $clnt;
	asyn_msg = $msg;
	asyn_flags = $flags;
}
probe module("sunrpc").function("rpc_call_async").return
{
	if ($return) {
		if (rpcprocnum(asyn_msg) != 2 && $return != -2) {
			printf("%s(%d): rpc_call_sync:%s:%s: return %d (%s)\n", 
				execname(), pid(), rpcprocname(syn_msg), rpcprogname(syn_clnt),
				$return, errno_str($return));
		}
	}
}
probe begin 
{ 
	show_all = 0;
	if (argc > 0) {
		if (isinstr(argv[1], "--show_all")) {
			show_all = 1
		} else {
			error("Usage: sunrpc -- --show_all");
		}
	}
	log("starting sunrpc probe")
}
probe end { log("ending sunrpc probe") }