summaryrefslogtreecommitdiffstats
path: root/sunrpc/sunrpc-svc.stp
blob: b566ae1160828669dc12ff84378eb0359af4204f (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
function svcprog:string(_prog:long) 
%{
	static struct {
		int	prog;
		char *string;
	} svc_progtbl[] = {
		{100000, "rpcbind"},
		{100024, "statd"},
		{100011, "rquotad"},
		{100003, "nfsd"},
		{100021, "nlockmgr"},
		{100005, "mountd"},
		{100227, "nfs_acl"},
	};
	int	i;
	int tabsz = (sizeof(svc_progtbl)/sizeof(svc_progtbl[0]));

	for (i = 0; i < tabsz; i++) {
		if (svc_progtbl[i].prog == THIS->_prog) {
			break;
		}
	}
	if (i == tabsz)
		snprintf(THIS->__retvalue, MAXSTRINGLEN, "%lld", THIS->_prog);
	else
		snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", svc_progtbl[i].string);

%}
function svcerror:string(err:long) 
%{
	static struct {
		int	svcerr;
		char *string;
	} svc_errtbl[] = {
		{1, "SVC_GARBAGE" },
		{2, "SVC_SYSERR" },
		{3, "SVC_VALID" },
		{4, "SVC_NEGATIVE" },
		{5, "SVC_OK" },
		{6, "SVC_DROP" },
		{7, "SVC_DENIED" },
		{8, "SVC_PENDING" },
		{9, "SVC_COMPLETE" },
	};
	int	i;
	int tabsz = (sizeof(svc_errtbl)/sizeof(svc_errtbl[0]));

	for (i = 0; i < tabsz; i++) {
		if (svc_errtbl[i].svcerr == THIS->err) {
			break;
		}
	}
	if (i == tabsz)
		snprintf(THIS->__retvalue, MAXSTRINGLEN, "svcerr %lld", THIS->err);
	else
		snprintf(THIS->__retvalue, MAXSTRINGLEN, 
			"svcderr %d(%s)", svc_errtbl[i].svcerr, svc_errtbl[i].string);

%}
global rq_prog, rq_vers, rq_proc, rq_prot
global show_all

probe module("sunrpc").function("svc_process")
{
	rq_prot = $rqstp->rq_prot
	rq_proc = $rqstp->rq_proc
	rq_vers = $rqstp->rq_vers
	rq_prog = $rqstp->rq_prog
}
probe module("sunrpc").function("svc_process").return
{
	if ($return == 0) {
		printf("%s(%d): %s[%d]:%d: return %d (%s)\n", 
			execname(), pid(), svcprog(rq_prog), rq_vers, rq_proc,
			$return, errno_str($return));
	} else if (show_all && $return != 0) {
		if (rq_vers == 4) {
			printf("%s(%d): %s[%d]:%d: bytes %d\n", 
				execname(), pid(), svcprog(rq_prog), rq_vers, 
				rq_proc, $return);
		} else {
			printf("%s(%d): %s[%d]:%d: bytes %d\n", 
				execname(), pid(), svcprog(rq_prog), rq_vers, 
				rq_proc, $return);
		}
	}
}
probe module("sunrpc").function("svc_authenticate")
{
	if (show_all) {
		printf("svc_authenticate: rqstp %p authp %p\n", $rqstp, $authp);
	}
}
probe module("sunrpc").function("svc_authenticate").return
{
	if (show_all) {
		printf("svc_authenticate: return %s\n", svcerror($return));
	} else if ($return != 5) {
		printf("svc_authenticate: return %s\n", svcerror($return));
	}
}
probe module("sunrpc").function("svc_recv")
{
	if (show_all) {
		printf("svc_recv: rqstp %p timeout %d\n", $rqstp, $timeout);
	}
}
probe module("sunrpc").function("svc_recv").return
{
	if (show_all) {
		if ($return >=  0) {
			printf("svc_recv: bytes %d\n", $return);
		} else {
			printf("svc_recv: return %d (%s)\n", $return, errno_str($return));
		}
	} else if ($return < 0 && $return != -11) {
			printf("svc_recv: return %d (%s)\n", $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-svc probe") 
}
probe end { log("ending sunrpc-svc probe") }