%{ #include #include #include #include #include %} function task_dump:string(_task:long) %{ struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task)); char buf[64]; int cc=0; if (task <= 0) { sprintf(buf+cc, "task NULL"); } else { sprintf(buf+cc, ": task 0x%p tk_pid %d tk_status %d", task, task->tk_pid, task->tk_status); cc = strlen(buf); } snprintf(THIS->__retvalue, 64, "%s", buf); CATCH_DEREF_FAULT(); %} function xprt_dump:string(_task:long) %{ struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task)); struct rpc_rqst *req; struct rpc_xprt *xprt; char buf[64]; int cc=0; if (task <= 0) { sprintf(buf+cc, "task NULL"); goto leave; } req = (struct rpc_rqst *)(long) kread(&(task->tk_rqstp)); if (req <= 0) { sprintf(buf+cc, "req is NULL"); goto leave; } xprt = (struct rpc_xprt *)(long) kread(&(req->rq_xprt)); if (xprt <= 0) { sprintf(buf+cc, "xprt is NULL"); goto leave; } sprintf(buf+cc, ": xprt 0x%p state 0x%lx", xprt, xprt->state); cc = strlen(buf); leave: snprintf(THIS->__retvalue, 64, "%s", buf); CATCH_DEREF_FAULT(); %} function task_status:long(_task:long) %{ struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task)); THIS->__retvalue = task->tk_status; CATCH_DEREF_FAULT(); %} function task_flags:string(_task:long) %{ struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task)); char buf[64]; int cc=0; if (task->tk_flags & RPC_TASK_ASYNC) { snprintf(buf+cc, 64, "ASYNC"); cc = strlen(buf); } snprintf(THIS->__retvalue, 64, "%s", buf); CATCH_DEREF_FAULT(); %} function cl_prognum:long(_task:long) %{ struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task)); struct rpc_clnt *clnt = (struct rpc_clnt *)(long) kread(&(task->tk_client)); THIS->__retvalue = clnt->cl_prog; CATCH_DEREF_FAULT(); %} function cl_vers:long(_task:long) %{ struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task)); struct rpc_clnt *clnt = (struct rpc_clnt *)(long) kread(&(task->tk_client)); THIS->__retvalue = clnt->cl_vers; CATCH_DEREF_FAULT(); %} function cl_protname:string(_task:long) %{ struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task)); struct rpc_clnt *clnt; char *protname = NULL; if (task) { clnt = (struct rpc_clnt *)(long) kread(&(task->tk_client)); if (clnt) protname = (char *)(long) kread(&(clnt->cl_protname)); } snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", protname); CATCH_DEREF_FAULT(); %} function cl_prog:string(_task:long) %{ struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task)); struct rpc_clnt *clnt; struct rpc_procinfo *proc; char *p_name; char buf[64]; static struct { int prog; char *string; } prog_progtbl[] = { {100000, "rpcbind"}, {100024, "statd"}, {100011, "rquotad"}, {100003, "nfs"}, {100021, "nlockmgr"}, {100005, "mountd"}, {100227, "nfs_acl"}, }; int i; int tabsz = (sizeof(prog_progtbl)/sizeof(prog_progtbl[0])); if (task <= 0) { sprintf(buf, "task NULL"); goto leave; } clnt = (struct rpc_clnt *)(long) kread(&(task->tk_client)); if (clnt == NULL) { sprintf(buf, "tk_client NULL"); goto leave; } proc = (struct rpc_procinfo *)(long) kread(&(clnt->cl_procinfo)); if (proc == NULL) { sprintf(buf, "cl_procinfo NULL"); goto leave; } p_name = kread(&(proc->p_name)); for (i = 0; i < tabsz; i++) { if (prog_progtbl[i].prog == clnt->cl_prog) { break; } } if (i == tabsz) snprintf(buf, 64, "0x%x[%d]:%d", clnt->cl_prog, clnt->cl_vers, proc->p_proc); else snprintf(buf, 64, "%s[%d]:%d", prog_progtbl[i].string, clnt->cl_vers, proc->p_proc); leave: snprintf(THIS->__retvalue, 64, "%s", buf); CATCH_DEREF_FAULT(); %} function cl_server:string(_task:long) %{ struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task)); struct rpc_clnt *clnt; char *cl_server = NULL; if (task) { clnt = (struct rpc_clnt *)(long) kread(&(task->tk_client)); if (clnt) cl_server = kread(&(clnt->cl_server)); } snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", cl_server); CATCH_DEREF_FAULT(); %} function rpc_rtt:long(_task:long) %{ struct rpc_task *task = (struct rpc_task *)(long) kread(&(THIS->_task)); struct rpc_rqst *req; long rtt = 0; if (task) rtt = ktime_to_ms(ktime_sub(ktime_get(), task->tk_start)); THIS->__retvalue = rtt; CATCH_DEREF_FAULT(); %} /* 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(); %} */