clnt.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295
  1. /*
  2. * linux/net/sunrpc/clnt.c
  3. *
  4. * This file contains the high-level RPC interface.
  5. * It is modeled as a finite state machine to support both synchronous
  6. * and asynchronous requests.
  7. *
  8. * - RPC header generation and argument serialization.
  9. * - Credential refresh.
  10. * - TCP connect handling.
  11. * - Retry of operation when it is suspected the operation failed because
  12. * of uid squashing on the server, or when the credentials were stale
  13. * and need to be refreshed, or when a packet was damaged in transit.
  14. * This may be have to be moved to the VFS layer.
  15. *
  16. * NB: BSD uses a more intelligent approach to guessing when a request
  17. * or reply has been lost by keeping the RTO estimate for each procedure.
  18. * We currently make do with a constant timeout value.
  19. *
  20. * Copyright (C) 1992,1993 Rick Sladkey <jrs@world.std.com>
  21. * Copyright (C) 1995,1996 Olaf Kirch <okir@monad.swb.de>
  22. */
  23. #include <asm/system.h>
  24. #include <linux/module.h>
  25. #include <linux/types.h>
  26. #include <linux/mm.h>
  27. #include <linux/slab.h>
  28. #include <linux/utsname.h>
  29. #include <linux/sunrpc/clnt.h>
  30. #include <linux/workqueue.h>
  31. #include <linux/sunrpc/rpc_pipe_fs.h>
  32. #include <linux/nfs.h>
  33. #define RPC_SLACK_SPACE (1024) /* total overkill */
  34. #ifdef RPC_DEBUG
  35. # define RPCDBG_FACILITY RPCDBG_CALL
  36. #endif
  37. static DECLARE_WAIT_QUEUE_HEAD(destroy_wait);
  38. static void call_start(struct rpc_task *task);
  39. static void call_reserve(struct rpc_task *task);
  40. static void call_reserveresult(struct rpc_task *task);
  41. static void call_allocate(struct rpc_task *task);
  42. static void call_encode(struct rpc_task *task);
  43. static void call_decode(struct rpc_task *task);
  44. static void call_bind(struct rpc_task *task);
  45. static void call_bind_status(struct rpc_task *task);
  46. static void call_transmit(struct rpc_task *task);
  47. static void call_status(struct rpc_task *task);
  48. static void call_transmit_status(struct rpc_task *task);
  49. static void call_refresh(struct rpc_task *task);
  50. static void call_refreshresult(struct rpc_task *task);
  51. static void call_timeout(struct rpc_task *task);
  52. static void call_connect(struct rpc_task *task);
  53. static void call_connect_status(struct rpc_task *task);
  54. static u32 * call_header(struct rpc_task *task);
  55. static u32 * call_verify(struct rpc_task *task);
  56. static int
  57. rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
  58. {
  59. static uint32_t clntid;
  60. int error;
  61. if (dir_name == NULL)
  62. return 0;
  63. for (;;) {
  64. snprintf(clnt->cl_pathname, sizeof(clnt->cl_pathname),
  65. "%s/clnt%x", dir_name,
  66. (unsigned int)clntid++);
  67. clnt->cl_pathname[sizeof(clnt->cl_pathname) - 1] = '\0';
  68. clnt->cl_dentry = rpc_mkdir(clnt->cl_pathname, clnt);
  69. if (!IS_ERR(clnt->cl_dentry))
  70. return 0;
  71. error = PTR_ERR(clnt->cl_dentry);
  72. if (error != -EEXIST) {
  73. printk(KERN_INFO "RPC: Couldn't create pipefs entry %s, error %d\n",
  74. clnt->cl_pathname, error);
  75. return error;
  76. }
  77. }
  78. }
  79. /*
  80. * Create an RPC client
  81. * FIXME: This should also take a flags argument (as in task->tk_flags).
  82. * It's called (among others) from pmap_create_client, which may in
  83. * turn be called by an async task. In this case, rpciod should not be
  84. * made to sleep too long.
  85. */
  86. struct rpc_clnt *
  87. rpc_new_client(struct rpc_xprt *xprt, char *servname,
  88. struct rpc_program *program, u32 vers,
  89. rpc_authflavor_t flavor)
  90. {
  91. struct rpc_version *version;
  92. struct rpc_clnt *clnt = NULL;
  93. struct rpc_auth *auth;
  94. int err;
  95. int len;
  96. dprintk("RPC: creating %s client for %s (xprt %p)\n",
  97. program->name, servname, xprt);
  98. err = -EINVAL;
  99. if (!xprt)
  100. goto out_no_xprt;
  101. if (vers >= program->nrvers || !(version = program->version[vers]))
  102. goto out_err;
  103. err = -ENOMEM;
  104. clnt = kmalloc(sizeof(*clnt), GFP_KERNEL);
  105. if (!clnt)
  106. goto out_err;
  107. memset(clnt, 0, sizeof(*clnt));
  108. atomic_set(&clnt->cl_users, 0);
  109. atomic_set(&clnt->cl_count, 1);
  110. clnt->cl_parent = clnt;
  111. clnt->cl_server = clnt->cl_inline_name;
  112. len = strlen(servname) + 1;
  113. if (len > sizeof(clnt->cl_inline_name)) {
  114. char *buf = kmalloc(len, GFP_KERNEL);
  115. if (buf != 0)
  116. clnt->cl_server = buf;
  117. else
  118. len = sizeof(clnt->cl_inline_name);
  119. }
  120. strlcpy(clnt->cl_server, servname, len);
  121. clnt->cl_xprt = xprt;
  122. clnt->cl_procinfo = version->procs;
  123. clnt->cl_maxproc = version->nrprocs;
  124. clnt->cl_protname = program->name;
  125. clnt->cl_pmap = &clnt->cl_pmap_default;
  126. clnt->cl_port = xprt->addr.sin_port;
  127. clnt->cl_prog = program->number;
  128. clnt->cl_vers = version->number;
  129. clnt->cl_prot = xprt->prot;
  130. clnt->cl_stats = program->stats;
  131. rpc_init_wait_queue(&clnt->cl_pmap_default.pm_bindwait, "bindwait");
  132. if (!clnt->cl_port)
  133. clnt->cl_autobind = 1;
  134. clnt->cl_rtt = &clnt->cl_rtt_default;
  135. rpc_init_rtt(&clnt->cl_rtt_default, xprt->timeout.to_initval);
  136. err = rpc_setup_pipedir(clnt, program->pipe_dir_name);
  137. if (err < 0)
  138. goto out_no_path;
  139. auth = rpcauth_create(flavor, clnt);
  140. if (IS_ERR(auth)) {
  141. printk(KERN_INFO "RPC: Couldn't create auth handle (flavor %u)\n",
  142. flavor);
  143. err = PTR_ERR(auth);
  144. goto out_no_auth;
  145. }
  146. /* save the nodename */
  147. clnt->cl_nodelen = strlen(system_utsname.nodename);
  148. if (clnt->cl_nodelen > UNX_MAXNODENAME)
  149. clnt->cl_nodelen = UNX_MAXNODENAME;
  150. memcpy(clnt->cl_nodename, system_utsname.nodename, clnt->cl_nodelen);
  151. return clnt;
  152. out_no_auth:
  153. rpc_rmdir(clnt->cl_pathname);
  154. out_no_path:
  155. if (clnt->cl_server != clnt->cl_inline_name)
  156. kfree(clnt->cl_server);
  157. kfree(clnt);
  158. out_err:
  159. xprt_destroy(xprt);
  160. out_no_xprt:
  161. return ERR_PTR(err);
  162. }
  163. /**
  164. * Create an RPC client
  165. * @xprt - pointer to xprt struct
  166. * @servname - name of server
  167. * @info - rpc_program
  168. * @version - rpc_program version
  169. * @authflavor - rpc_auth flavour to use
  170. *
  171. * Creates an RPC client structure, then pings the server in order to
  172. * determine if it is up, and if it supports this program and version.
  173. *
  174. * This function should never be called by asynchronous tasks such as
  175. * the portmapper.
  176. */
  177. struct rpc_clnt *rpc_create_client(struct rpc_xprt *xprt, char *servname,
  178. struct rpc_program *info, u32 version, rpc_authflavor_t authflavor)
  179. {
  180. struct rpc_clnt *clnt;
  181. int err;
  182. clnt = rpc_new_client(xprt, servname, info, version, authflavor);
  183. if (IS_ERR(clnt))
  184. return clnt;
  185. err = rpc_ping(clnt, RPC_TASK_SOFT|RPC_TASK_NOINTR);
  186. if (err == 0)
  187. return clnt;
  188. rpc_shutdown_client(clnt);
  189. return ERR_PTR(err);
  190. }
  191. /*
  192. * This function clones the RPC client structure. It allows us to share the
  193. * same transport while varying parameters such as the authentication
  194. * flavour.
  195. */
  196. struct rpc_clnt *
  197. rpc_clone_client(struct rpc_clnt *clnt)
  198. {
  199. struct rpc_clnt *new;
  200. new = kmalloc(sizeof(*new), GFP_KERNEL);
  201. if (!new)
  202. goto out_no_clnt;
  203. memcpy(new, clnt, sizeof(*new));
  204. atomic_set(&new->cl_count, 1);
  205. atomic_set(&new->cl_users, 0);
  206. new->cl_parent = clnt;
  207. atomic_inc(&clnt->cl_count);
  208. /* Duplicate portmapper */
  209. rpc_init_wait_queue(&new->cl_pmap_default.pm_bindwait, "bindwait");
  210. /* Turn off autobind on clones */
  211. new->cl_autobind = 0;
  212. new->cl_oneshot = 0;
  213. new->cl_dead = 0;
  214. dget(new->cl_dentry);
  215. rpc_init_rtt(&new->cl_rtt_default, clnt->cl_xprt->timeout.to_initval);
  216. if (new->cl_auth)
  217. atomic_inc(&new->cl_auth->au_count);
  218. new->cl_pmap = &new->cl_pmap_default;
  219. rpc_init_wait_queue(&new->cl_pmap_default.pm_bindwait, "bindwait");
  220. return new;
  221. out_no_clnt:
  222. printk(KERN_INFO "RPC: out of memory in %s\n", __FUNCTION__);
  223. return ERR_PTR(-ENOMEM);
  224. }
  225. /*
  226. * Properly shut down an RPC client, terminating all outstanding
  227. * requests. Note that we must be certain that cl_oneshot and
  228. * cl_dead are cleared, or else the client would be destroyed
  229. * when the last task releases it.
  230. */
  231. int
  232. rpc_shutdown_client(struct rpc_clnt *clnt)
  233. {
  234. dprintk("RPC: shutting down %s client for %s, tasks=%d\n",
  235. clnt->cl_protname, clnt->cl_server,
  236. atomic_read(&clnt->cl_users));
  237. while (atomic_read(&clnt->cl_users) > 0) {
  238. /* Don't let rpc_release_client destroy us */
  239. clnt->cl_oneshot = 0;
  240. clnt->cl_dead = 0;
  241. rpc_killall_tasks(clnt);
  242. wait_event_timeout(destroy_wait,
  243. !atomic_read(&clnt->cl_users), 1*HZ);
  244. }
  245. if (atomic_read(&clnt->cl_users) < 0) {
  246. printk(KERN_ERR "RPC: rpc_shutdown_client clnt %p tasks=%d\n",
  247. clnt, atomic_read(&clnt->cl_users));
  248. #ifdef RPC_DEBUG
  249. rpc_show_tasks();
  250. #endif
  251. BUG();
  252. }
  253. return rpc_destroy_client(clnt);
  254. }
  255. /*
  256. * Delete an RPC client
  257. */
  258. int
  259. rpc_destroy_client(struct rpc_clnt *clnt)
  260. {
  261. if (!atomic_dec_and_test(&clnt->cl_count))
  262. return 1;
  263. BUG_ON(atomic_read(&clnt->cl_users) != 0);
  264. dprintk("RPC: destroying %s client for %s\n",
  265. clnt->cl_protname, clnt->cl_server);
  266. if (clnt->cl_auth) {
  267. rpcauth_destroy(clnt->cl_auth);
  268. clnt->cl_auth = NULL;
  269. }
  270. if (clnt->cl_parent != clnt) {
  271. rpc_destroy_client(clnt->cl_parent);
  272. goto out_free;
  273. }
  274. if (clnt->cl_pathname[0])
  275. rpc_rmdir(clnt->cl_pathname);
  276. if (clnt->cl_xprt) {
  277. xprt_destroy(clnt->cl_xprt);
  278. clnt->cl_xprt = NULL;
  279. }
  280. if (clnt->cl_server != clnt->cl_inline_name)
  281. kfree(clnt->cl_server);
  282. out_free:
  283. if (clnt->cl_dentry)
  284. dput(clnt->cl_dentry);
  285. kfree(clnt);
  286. return 0;
  287. }
  288. /*
  289. * Release an RPC client
  290. */
  291. void
  292. rpc_release_client(struct rpc_clnt *clnt)
  293. {
  294. dprintk("RPC: rpc_release_client(%p, %d)\n",
  295. clnt, atomic_read(&clnt->cl_users));
  296. if (!atomic_dec_and_test(&clnt->cl_users))
  297. return;
  298. wake_up(&destroy_wait);
  299. if (clnt->cl_oneshot || clnt->cl_dead)
  300. rpc_destroy_client(clnt);
  301. }
  302. /**
  303. * rpc_bind_new_program - bind a new RPC program to an existing client
  304. * @old - old rpc_client
  305. * @program - rpc program to set
  306. * @vers - rpc program version
  307. *
  308. * Clones the rpc client and sets up a new RPC program. This is mainly
  309. * of use for enabling different RPC programs to share the same transport.
  310. * The Sun NFSv2/v3 ACL protocol can do this.
  311. */
  312. struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *old,
  313. struct rpc_program *program,
  314. int vers)
  315. {
  316. struct rpc_clnt *clnt;
  317. struct rpc_version *version;
  318. int err;
  319. BUG_ON(vers >= program->nrvers || !program->version[vers]);
  320. version = program->version[vers];
  321. clnt = rpc_clone_client(old);
  322. if (IS_ERR(clnt))
  323. goto out;
  324. clnt->cl_procinfo = version->procs;
  325. clnt->cl_maxproc = version->nrprocs;
  326. clnt->cl_protname = program->name;
  327. clnt->cl_prog = program->number;
  328. clnt->cl_vers = version->number;
  329. clnt->cl_stats = program->stats;
  330. err = rpc_ping(clnt, RPC_TASK_SOFT|RPC_TASK_NOINTR);
  331. if (err != 0) {
  332. rpc_shutdown_client(clnt);
  333. clnt = ERR_PTR(err);
  334. }
  335. out:
  336. return clnt;
  337. }
  338. /*
  339. * Default callback for async RPC calls
  340. */
  341. static void
  342. rpc_default_callback(struct rpc_task *task, void *data)
  343. {
  344. }
  345. static const struct rpc_call_ops rpc_default_ops = {
  346. .rpc_call_done = rpc_default_callback,
  347. };
  348. /*
  349. * Export the signal mask handling for synchronous code that
  350. * sleeps on RPC calls
  351. */
  352. #define RPC_INTR_SIGNALS (sigmask(SIGHUP) | sigmask(SIGINT) | sigmask(SIGQUIT) | sigmask(SIGTERM))
  353. static void rpc_save_sigmask(sigset_t *oldset, int intr)
  354. {
  355. unsigned long sigallow = sigmask(SIGKILL);
  356. sigset_t sigmask;
  357. /* Block all signals except those listed in sigallow */
  358. if (intr)
  359. sigallow |= RPC_INTR_SIGNALS;
  360. siginitsetinv(&sigmask, sigallow);
  361. sigprocmask(SIG_BLOCK, &sigmask, oldset);
  362. }
  363. static inline void rpc_task_sigmask(struct rpc_task *task, sigset_t *oldset)
  364. {
  365. rpc_save_sigmask(oldset, !RPC_TASK_UNINTERRUPTIBLE(task));
  366. }
  367. static inline void rpc_restore_sigmask(sigset_t *oldset)
  368. {
  369. sigprocmask(SIG_SETMASK, oldset, NULL);
  370. }
  371. void rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset)
  372. {
  373. rpc_save_sigmask(oldset, clnt->cl_intr);
  374. }
  375. void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset)
  376. {
  377. rpc_restore_sigmask(oldset);
  378. }
  379. /*
  380. * New rpc_call implementation
  381. */
  382. int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
  383. {
  384. struct rpc_task *task;
  385. sigset_t oldset;
  386. int status;
  387. /* If this client is slain all further I/O fails */
  388. if (clnt->cl_dead)
  389. return -EIO;
  390. BUG_ON(flags & RPC_TASK_ASYNC);
  391. status = -ENOMEM;
  392. task = rpc_new_task(clnt, flags, &rpc_default_ops, NULL);
  393. if (task == NULL)
  394. goto out;
  395. /* Mask signals on RPC calls _and_ GSS_AUTH upcalls */
  396. rpc_task_sigmask(task, &oldset);
  397. rpc_call_setup(task, msg, 0);
  398. /* Set up the call info struct and execute the task */
  399. status = task->tk_status;
  400. if (status == 0) {
  401. atomic_inc(&task->tk_count);
  402. status = rpc_execute(task);
  403. if (status == 0)
  404. status = task->tk_status;
  405. }
  406. rpc_restore_sigmask(&oldset);
  407. rpc_release_task(task);
  408. out:
  409. return status;
  410. }
  411. /*
  412. * New rpc_call implementation
  413. */
  414. int
  415. rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags,
  416. const struct rpc_call_ops *tk_ops, void *data)
  417. {
  418. struct rpc_task *task;
  419. sigset_t oldset;
  420. int status;
  421. /* If this client is slain all further I/O fails */
  422. if (clnt->cl_dead)
  423. return -EIO;
  424. flags |= RPC_TASK_ASYNC;
  425. /* Create/initialize a new RPC task */
  426. status = -ENOMEM;
  427. if (!(task = rpc_new_task(clnt, flags, tk_ops, data)))
  428. goto out;
  429. /* Mask signals on GSS_AUTH upcalls */
  430. rpc_task_sigmask(task, &oldset);
  431. rpc_call_setup(task, msg, 0);
  432. /* Set up the call info struct and execute the task */
  433. status = task->tk_status;
  434. if (status == 0)
  435. rpc_execute(task);
  436. else
  437. rpc_release_task(task);
  438. rpc_restore_sigmask(&oldset);
  439. out:
  440. return status;
  441. }
  442. void
  443. rpc_call_setup(struct rpc_task *task, struct rpc_message *msg, int flags)
  444. {
  445. task->tk_msg = *msg;
  446. task->tk_flags |= flags;
  447. /* Bind the user cred */
  448. if (task->tk_msg.rpc_cred != NULL)
  449. rpcauth_holdcred(task);
  450. else
  451. rpcauth_bindcred(task);
  452. if (task->tk_status == 0)
  453. task->tk_action = call_start;
  454. else
  455. task->tk_action = rpc_exit_task;
  456. }
  457. void
  458. rpc_setbufsize(struct rpc_clnt *clnt, unsigned int sndsize, unsigned int rcvsize)
  459. {
  460. struct rpc_xprt *xprt = clnt->cl_xprt;
  461. if (xprt->ops->set_buffer_size)
  462. xprt->ops->set_buffer_size(xprt, sndsize, rcvsize);
  463. }
  464. /*
  465. * Return size of largest payload RPC client can support, in bytes
  466. *
  467. * For stream transports, this is one RPC record fragment (see RFC
  468. * 1831), as we don't support multi-record requests yet. For datagram
  469. * transports, this is the size of an IP packet minus the IP, UDP, and
  470. * RPC header sizes.
  471. */
  472. size_t rpc_max_payload(struct rpc_clnt *clnt)
  473. {
  474. return clnt->cl_xprt->max_payload;
  475. }
  476. EXPORT_SYMBOL(rpc_max_payload);
  477. /**
  478. * rpc_force_rebind - force transport to check that remote port is unchanged
  479. * @clnt: client to rebind
  480. *
  481. */
  482. void rpc_force_rebind(struct rpc_clnt *clnt)
  483. {
  484. if (clnt->cl_autobind)
  485. clnt->cl_port = 0;
  486. }
  487. EXPORT_SYMBOL(rpc_force_rebind);
  488. /*
  489. * Restart an (async) RPC call. Usually called from within the
  490. * exit handler.
  491. */
  492. void
  493. rpc_restart_call(struct rpc_task *task)
  494. {
  495. if (RPC_ASSASSINATED(task))
  496. return;
  497. task->tk_action = call_start;
  498. }
  499. /*
  500. * 0. Initial state
  501. *
  502. * Other FSM states can be visited zero or more times, but
  503. * this state is visited exactly once for each RPC.
  504. */
  505. static void
  506. call_start(struct rpc_task *task)
  507. {
  508. struct rpc_clnt *clnt = task->tk_client;
  509. dprintk("RPC: %4d call_start %s%d proc %d (%s)\n", task->tk_pid,
  510. clnt->cl_protname, clnt->cl_vers, task->tk_msg.rpc_proc->p_proc,
  511. (RPC_IS_ASYNC(task) ? "async" : "sync"));
  512. /* Increment call count */
  513. task->tk_msg.rpc_proc->p_count++;
  514. clnt->cl_stats->rpccnt++;
  515. task->tk_action = call_reserve;
  516. }
  517. /*
  518. * 1. Reserve an RPC call slot
  519. */
  520. static void
  521. call_reserve(struct rpc_task *task)
  522. {
  523. dprintk("RPC: %4d call_reserve\n", task->tk_pid);
  524. if (!rpcauth_uptodatecred(task)) {
  525. task->tk_action = call_refresh;
  526. return;
  527. }
  528. task->tk_status = 0;
  529. task->tk_action = call_reserveresult;
  530. xprt_reserve(task);
  531. }
  532. /*
  533. * 1b. Grok the result of xprt_reserve()
  534. */
  535. static void
  536. call_reserveresult(struct rpc_task *task)
  537. {
  538. int status = task->tk_status;
  539. dprintk("RPC: %4d call_reserveresult (status %d)\n",
  540. task->tk_pid, task->tk_status);
  541. /*
  542. * After a call to xprt_reserve(), we must have either
  543. * a request slot or else an error status.
  544. */
  545. task->tk_status = 0;
  546. if (status >= 0) {
  547. if (task->tk_rqstp) {
  548. task->tk_action = call_allocate;
  549. return;
  550. }
  551. printk(KERN_ERR "%s: status=%d, but no request slot, exiting\n",
  552. __FUNCTION__, status);
  553. rpc_exit(task, -EIO);
  554. return;
  555. }
  556. /*
  557. * Even though there was an error, we may have acquired
  558. * a request slot somehow. Make sure not to leak it.
  559. */
  560. if (task->tk_rqstp) {
  561. printk(KERN_ERR "%s: status=%d, request allocated anyway\n",
  562. __FUNCTION__, status);
  563. xprt_release(task);
  564. }
  565. switch (status) {
  566. case -EAGAIN: /* woken up; retry */
  567. task->tk_action = call_reserve;
  568. return;
  569. case -EIO: /* probably a shutdown */
  570. break;
  571. default:
  572. printk(KERN_ERR "%s: unrecognized error %d, exiting\n",
  573. __FUNCTION__, status);
  574. break;
  575. }
  576. rpc_exit(task, status);
  577. }
  578. /*
  579. * 2. Allocate the buffer. For details, see sched.c:rpc_malloc.
  580. * (Note: buffer memory is freed in xprt_release).
  581. */
  582. static void
  583. call_allocate(struct rpc_task *task)
  584. {
  585. struct rpc_rqst *req = task->tk_rqstp;
  586. struct rpc_xprt *xprt = task->tk_xprt;
  587. unsigned int bufsiz;
  588. dprintk("RPC: %4d call_allocate (status %d)\n",
  589. task->tk_pid, task->tk_status);
  590. task->tk_action = call_bind;
  591. if (req->rq_buffer)
  592. return;
  593. /* FIXME: compute buffer requirements more exactly using
  594. * auth->au_wslack */
  595. bufsiz = task->tk_msg.rpc_proc->p_bufsiz + RPC_SLACK_SPACE;
  596. if (xprt->ops->buf_alloc(task, bufsiz << 1) != NULL)
  597. return;
  598. printk(KERN_INFO "RPC: buffer allocation failed for task %p\n", task);
  599. if (RPC_IS_ASYNC(task) || !signalled()) {
  600. xprt_release(task);
  601. task->tk_action = call_reserve;
  602. rpc_delay(task, HZ>>4);
  603. return;
  604. }
  605. rpc_exit(task, -ERESTARTSYS);
  606. }
  607. static inline int
  608. rpc_task_need_encode(struct rpc_task *task)
  609. {
  610. return task->tk_rqstp->rq_snd_buf.len == 0;
  611. }
  612. static inline void
  613. rpc_task_force_reencode(struct rpc_task *task)
  614. {
  615. task->tk_rqstp->rq_snd_buf.len = 0;
  616. }
  617. /*
  618. * 3. Encode arguments of an RPC call
  619. */
  620. static void
  621. call_encode(struct rpc_task *task)
  622. {
  623. struct rpc_rqst *req = task->tk_rqstp;
  624. struct xdr_buf *sndbuf = &req->rq_snd_buf;
  625. struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
  626. unsigned int bufsiz;
  627. kxdrproc_t encode;
  628. u32 *p;
  629. dprintk("RPC: %4d call_encode (status %d)\n",
  630. task->tk_pid, task->tk_status);
  631. /* Default buffer setup */
  632. bufsiz = req->rq_bufsize >> 1;
  633. sndbuf->head[0].iov_base = (void *)req->rq_buffer;
  634. sndbuf->head[0].iov_len = bufsiz;
  635. sndbuf->tail[0].iov_len = 0;
  636. sndbuf->page_len = 0;
  637. sndbuf->len = 0;
  638. sndbuf->buflen = bufsiz;
  639. rcvbuf->head[0].iov_base = (void *)((char *)req->rq_buffer + bufsiz);
  640. rcvbuf->head[0].iov_len = bufsiz;
  641. rcvbuf->tail[0].iov_len = 0;
  642. rcvbuf->page_len = 0;
  643. rcvbuf->len = 0;
  644. rcvbuf->buflen = bufsiz;
  645. /* Encode header and provided arguments */
  646. encode = task->tk_msg.rpc_proc->p_encode;
  647. if (!(p = call_header(task))) {
  648. printk(KERN_INFO "RPC: call_header failed, exit EIO\n");
  649. rpc_exit(task, -EIO);
  650. return;
  651. }
  652. if (encode == NULL)
  653. return;
  654. task->tk_status = rpcauth_wrap_req(task, encode, req, p,
  655. task->tk_msg.rpc_argp);
  656. if (task->tk_status == -ENOMEM) {
  657. /* XXX: Is this sane? */
  658. rpc_delay(task, 3*HZ);
  659. task->tk_status = -EAGAIN;
  660. }
  661. }
  662. /*
  663. * 4. Get the server port number if not yet set
  664. */
  665. static void
  666. call_bind(struct rpc_task *task)
  667. {
  668. struct rpc_clnt *clnt = task->tk_client;
  669. dprintk("RPC: %4d call_bind (status %d)\n",
  670. task->tk_pid, task->tk_status);
  671. task->tk_action = call_connect;
  672. if (!clnt->cl_port) {
  673. task->tk_action = call_bind_status;
  674. task->tk_timeout = task->tk_xprt->bind_timeout;
  675. rpc_getport(task, clnt);
  676. }
  677. }
  678. /*
  679. * 4a. Sort out bind result
  680. */
  681. static void
  682. call_bind_status(struct rpc_task *task)
  683. {
  684. int status = -EACCES;
  685. if (task->tk_status >= 0) {
  686. dprintk("RPC: %4d call_bind_status (status %d)\n",
  687. task->tk_pid, task->tk_status);
  688. task->tk_status = 0;
  689. task->tk_action = call_connect;
  690. return;
  691. }
  692. switch (task->tk_status) {
  693. case -EACCES:
  694. dprintk("RPC: %4d remote rpcbind: RPC program/version unavailable\n",
  695. task->tk_pid);
  696. rpc_delay(task, 3*HZ);
  697. goto retry_bind;
  698. case -ETIMEDOUT:
  699. dprintk("RPC: %4d rpcbind request timed out\n",
  700. task->tk_pid);
  701. if (RPC_IS_SOFT(task)) {
  702. status = -EIO;
  703. break;
  704. }
  705. goto retry_bind;
  706. case -EPFNOSUPPORT:
  707. dprintk("RPC: %4d remote rpcbind service unavailable\n",
  708. task->tk_pid);
  709. break;
  710. case -EPROTONOSUPPORT:
  711. dprintk("RPC: %4d remote rpcbind version 2 unavailable\n",
  712. task->tk_pid);
  713. break;
  714. default:
  715. dprintk("RPC: %4d unrecognized rpcbind error (%d)\n",
  716. task->tk_pid, -task->tk_status);
  717. status = -EIO;
  718. break;
  719. }
  720. rpc_exit(task, status);
  721. return;
  722. retry_bind:
  723. task->tk_status = 0;
  724. task->tk_action = call_bind;
  725. return;
  726. }
  727. /*
  728. * 4b. Connect to the RPC server
  729. */
  730. static void
  731. call_connect(struct rpc_task *task)
  732. {
  733. struct rpc_xprt *xprt = task->tk_xprt;
  734. dprintk("RPC: %4d call_connect xprt %p %s connected\n",
  735. task->tk_pid, xprt,
  736. (xprt_connected(xprt) ? "is" : "is not"));
  737. task->tk_action = call_transmit;
  738. if (!xprt_connected(xprt)) {
  739. task->tk_action = call_connect_status;
  740. if (task->tk_status < 0)
  741. return;
  742. xprt_connect(task);
  743. }
  744. }
  745. /*
  746. * 4c. Sort out connect result
  747. */
  748. static void
  749. call_connect_status(struct rpc_task *task)
  750. {
  751. struct rpc_clnt *clnt = task->tk_client;
  752. int status = task->tk_status;
  753. dprintk("RPC: %5u call_connect_status (status %d)\n",
  754. task->tk_pid, task->tk_status);
  755. task->tk_status = 0;
  756. if (status >= 0) {
  757. clnt->cl_stats->netreconn++;
  758. task->tk_action = call_transmit;
  759. return;
  760. }
  761. /* Something failed: remote service port may have changed */
  762. rpc_force_rebind(clnt);
  763. switch (status) {
  764. case -ENOTCONN:
  765. case -ETIMEDOUT:
  766. case -EAGAIN:
  767. task->tk_action = call_bind;
  768. break;
  769. default:
  770. rpc_exit(task, -EIO);
  771. break;
  772. }
  773. }
  774. /*
  775. * 5. Transmit the RPC request, and wait for reply
  776. */
  777. static void
  778. call_transmit(struct rpc_task *task)
  779. {
  780. dprintk("RPC: %4d call_transmit (status %d)\n",
  781. task->tk_pid, task->tk_status);
  782. task->tk_action = call_status;
  783. if (task->tk_status < 0)
  784. return;
  785. task->tk_status = xprt_prepare_transmit(task);
  786. if (task->tk_status != 0)
  787. return;
  788. /* Encode here so that rpcsec_gss can use correct sequence number. */
  789. if (rpc_task_need_encode(task)) {
  790. task->tk_rqstp->rq_bytes_sent = 0;
  791. call_encode(task);
  792. /* Did the encode result in an error condition? */
  793. if (task->tk_status != 0)
  794. goto out_nosend;
  795. }
  796. task->tk_action = call_transmit_status;
  797. xprt_transmit(task);
  798. if (task->tk_status < 0)
  799. return;
  800. if (!task->tk_msg.rpc_proc->p_decode) {
  801. task->tk_action = rpc_exit_task;
  802. rpc_wake_up_task(task);
  803. }
  804. return;
  805. out_nosend:
  806. /* release socket write lock before attempting to handle error */
  807. xprt_abort_transmit(task);
  808. rpc_task_force_reencode(task);
  809. }
  810. /*
  811. * 6. Sort out the RPC call status
  812. */
  813. static void
  814. call_status(struct rpc_task *task)
  815. {
  816. struct rpc_clnt *clnt = task->tk_client;
  817. struct rpc_rqst *req = task->tk_rqstp;
  818. int status;
  819. if (req->rq_received > 0 && !req->rq_bytes_sent)
  820. task->tk_status = req->rq_received;
  821. dprintk("RPC: %4d call_status (status %d)\n",
  822. task->tk_pid, task->tk_status);
  823. status = task->tk_status;
  824. if (status >= 0) {
  825. task->tk_action = call_decode;
  826. return;
  827. }
  828. task->tk_status = 0;
  829. switch(status) {
  830. case -ETIMEDOUT:
  831. task->tk_action = call_timeout;
  832. break;
  833. case -ECONNREFUSED:
  834. case -ENOTCONN:
  835. rpc_force_rebind(clnt);
  836. task->tk_action = call_bind;
  837. break;
  838. case -EAGAIN:
  839. task->tk_action = call_transmit;
  840. break;
  841. case -EIO:
  842. /* shutdown or soft timeout */
  843. rpc_exit(task, status);
  844. break;
  845. default:
  846. printk("%s: RPC call returned error %d\n",
  847. clnt->cl_protname, -status);
  848. rpc_exit(task, status);
  849. break;
  850. }
  851. }
  852. /*
  853. * 6a. Handle transmission errors.
  854. */
  855. static void
  856. call_transmit_status(struct rpc_task *task)
  857. {
  858. if (task->tk_status != -EAGAIN)
  859. rpc_task_force_reencode(task);
  860. call_status(task);
  861. }
  862. /*
  863. * 6b. Handle RPC timeout
  864. * We do not release the request slot, so we keep using the
  865. * same XID for all retransmits.
  866. */
  867. static void
  868. call_timeout(struct rpc_task *task)
  869. {
  870. struct rpc_clnt *clnt = task->tk_client;
  871. if (xprt_adjust_timeout(task->tk_rqstp) == 0) {
  872. dprintk("RPC: %4d call_timeout (minor)\n", task->tk_pid);
  873. goto retry;
  874. }
  875. dprintk("RPC: %4d call_timeout (major)\n", task->tk_pid);
  876. if (RPC_IS_SOFT(task)) {
  877. printk(KERN_NOTICE "%s: server %s not responding, timed out\n",
  878. clnt->cl_protname, clnt->cl_server);
  879. rpc_exit(task, -EIO);
  880. return;
  881. }
  882. if (!(task->tk_flags & RPC_CALL_MAJORSEEN)) {
  883. task->tk_flags |= RPC_CALL_MAJORSEEN;
  884. printk(KERN_NOTICE "%s: server %s not responding, still trying\n",
  885. clnt->cl_protname, clnt->cl_server);
  886. }
  887. rpc_force_rebind(clnt);
  888. retry:
  889. clnt->cl_stats->rpcretrans++;
  890. task->tk_action = call_bind;
  891. task->tk_status = 0;
  892. }
  893. /*
  894. * 7. Decode the RPC reply
  895. */
  896. static void
  897. call_decode(struct rpc_task *task)
  898. {
  899. struct rpc_clnt *clnt = task->tk_client;
  900. struct rpc_rqst *req = task->tk_rqstp;
  901. kxdrproc_t decode = task->tk_msg.rpc_proc->p_decode;
  902. u32 *p;
  903. dprintk("RPC: %4d call_decode (status %d)\n",
  904. task->tk_pid, task->tk_status);
  905. if (task->tk_flags & RPC_CALL_MAJORSEEN) {
  906. printk(KERN_NOTICE "%s: server %s OK\n",
  907. clnt->cl_protname, clnt->cl_server);
  908. task->tk_flags &= ~RPC_CALL_MAJORSEEN;
  909. }
  910. if (task->tk_status < 12) {
  911. if (!RPC_IS_SOFT(task)) {
  912. task->tk_action = call_bind;
  913. clnt->cl_stats->rpcretrans++;
  914. goto out_retry;
  915. }
  916. printk(KERN_WARNING "%s: too small RPC reply size (%d bytes)\n",
  917. clnt->cl_protname, task->tk_status);
  918. rpc_exit(task, -EIO);
  919. return;
  920. }
  921. req->rq_rcv_buf.len = req->rq_private_buf.len;
  922. /* Check that the softirq receive buffer is valid */
  923. WARN_ON(memcmp(&req->rq_rcv_buf, &req->rq_private_buf,
  924. sizeof(req->rq_rcv_buf)) != 0);
  925. /* Verify the RPC header */
  926. p = call_verify(task);
  927. if (IS_ERR(p)) {
  928. if (p == ERR_PTR(-EAGAIN))
  929. goto out_retry;
  930. return;
  931. }
  932. task->tk_action = rpc_exit_task;
  933. if (decode)
  934. task->tk_status = rpcauth_unwrap_resp(task, decode, req, p,
  935. task->tk_msg.rpc_resp);
  936. dprintk("RPC: %4d call_decode result %d\n", task->tk_pid,
  937. task->tk_status);
  938. return;
  939. out_retry:
  940. req->rq_received = req->rq_private_buf.len = 0;
  941. task->tk_status = 0;
  942. }
  943. /*
  944. * 8. Refresh the credentials if rejected by the server
  945. */
  946. static void
  947. call_refresh(struct rpc_task *task)
  948. {
  949. dprintk("RPC: %4d call_refresh\n", task->tk_pid);
  950. xprt_release(task); /* Must do to obtain new XID */
  951. task->tk_action = call_refreshresult;
  952. task->tk_status = 0;
  953. task->tk_client->cl_stats->rpcauthrefresh++;
  954. rpcauth_refreshcred(task);
  955. }
  956. /*
  957. * 8a. Process the results of a credential refresh
  958. */
  959. static void
  960. call_refreshresult(struct rpc_task *task)
  961. {
  962. int status = task->tk_status;
  963. dprintk("RPC: %4d call_refreshresult (status %d)\n",
  964. task->tk_pid, task->tk_status);
  965. task->tk_status = 0;
  966. task->tk_action = call_reserve;
  967. if (status >= 0 && rpcauth_uptodatecred(task))
  968. return;
  969. if (status == -EACCES) {
  970. rpc_exit(task, -EACCES);
  971. return;
  972. }
  973. task->tk_action = call_refresh;
  974. if (status != -ETIMEDOUT)
  975. rpc_delay(task, 3*HZ);
  976. return;
  977. }
  978. /*
  979. * Call header serialization
  980. */
  981. static u32 *
  982. call_header(struct rpc_task *task)
  983. {
  984. struct rpc_clnt *clnt = task->tk_client;
  985. struct rpc_rqst *req = task->tk_rqstp;
  986. u32 *p = req->rq_svec[0].iov_base;
  987. /* FIXME: check buffer size? */
  988. p = xprt_skip_transport_header(task->tk_xprt, p);
  989. *p++ = req->rq_xid; /* XID */
  990. *p++ = htonl(RPC_CALL); /* CALL */
  991. *p++ = htonl(RPC_VERSION); /* RPC version */
  992. *p++ = htonl(clnt->cl_prog); /* program number */
  993. *p++ = htonl(clnt->cl_vers); /* program version */
  994. *p++ = htonl(task->tk_msg.rpc_proc->p_proc); /* procedure */
  995. p = rpcauth_marshcred(task, p);
  996. req->rq_slen = xdr_adjust_iovec(&req->rq_svec[0], p);
  997. return p;
  998. }
  999. /*
  1000. * Reply header verification
  1001. */
  1002. static u32 *
  1003. call_verify(struct rpc_task *task)
  1004. {
  1005. struct kvec *iov = &task->tk_rqstp->rq_rcv_buf.head[0];
  1006. int len = task->tk_rqstp->rq_rcv_buf.len >> 2;
  1007. u32 *p = iov->iov_base, n;
  1008. int error = -EACCES;
  1009. if ((len -= 3) < 0)
  1010. goto out_overflow;
  1011. p += 1; /* skip XID */
  1012. if ((n = ntohl(*p++)) != RPC_REPLY) {
  1013. printk(KERN_WARNING "call_verify: not an RPC reply: %x\n", n);
  1014. goto out_garbage;
  1015. }
  1016. if ((n = ntohl(*p++)) != RPC_MSG_ACCEPTED) {
  1017. if (--len < 0)
  1018. goto out_overflow;
  1019. switch ((n = ntohl(*p++))) {
  1020. case RPC_AUTH_ERROR:
  1021. break;
  1022. case RPC_MISMATCH:
  1023. dprintk("%s: RPC call version mismatch!\n", __FUNCTION__);
  1024. error = -EPROTONOSUPPORT;
  1025. goto out_err;
  1026. default:
  1027. dprintk("%s: RPC call rejected, unknown error: %x\n", __FUNCTION__, n);
  1028. goto out_eio;
  1029. }
  1030. if (--len < 0)
  1031. goto out_overflow;
  1032. switch ((n = ntohl(*p++))) {
  1033. case RPC_AUTH_REJECTEDCRED:
  1034. case RPC_AUTH_REJECTEDVERF:
  1035. case RPCSEC_GSS_CREDPROBLEM:
  1036. case RPCSEC_GSS_CTXPROBLEM:
  1037. if (!task->tk_cred_retry)
  1038. break;
  1039. task->tk_cred_retry--;
  1040. dprintk("RPC: %4d call_verify: retry stale creds\n",
  1041. task->tk_pid);
  1042. rpcauth_invalcred(task);
  1043. task->tk_action = call_refresh;
  1044. goto out_retry;
  1045. case RPC_AUTH_BADCRED:
  1046. case RPC_AUTH_BADVERF:
  1047. /* possibly garbled cred/verf? */
  1048. if (!task->tk_garb_retry)
  1049. break;
  1050. task->tk_garb_retry--;
  1051. dprintk("RPC: %4d call_verify: retry garbled creds\n",
  1052. task->tk_pid);
  1053. task->tk_action = call_bind;
  1054. goto out_retry;
  1055. case RPC_AUTH_TOOWEAK:
  1056. printk(KERN_NOTICE "call_verify: server %s requires stronger "
  1057. "authentication.\n", task->tk_client->cl_server);
  1058. break;
  1059. default:
  1060. printk(KERN_WARNING "call_verify: unknown auth error: %x\n", n);
  1061. error = -EIO;
  1062. }
  1063. dprintk("RPC: %4d call_verify: call rejected %d\n",
  1064. task->tk_pid, n);
  1065. goto out_err;
  1066. }
  1067. if (!(p = rpcauth_checkverf(task, p))) {
  1068. printk(KERN_WARNING "call_verify: auth check failed\n");
  1069. goto out_garbage; /* bad verifier, retry */
  1070. }
  1071. len = p - (u32 *)iov->iov_base - 1;
  1072. if (len < 0)
  1073. goto out_overflow;
  1074. switch ((n = ntohl(*p++))) {
  1075. case RPC_SUCCESS:
  1076. return p;
  1077. case RPC_PROG_UNAVAIL:
  1078. dprintk("RPC: call_verify: program %u is unsupported by server %s\n",
  1079. (unsigned int)task->tk_client->cl_prog,
  1080. task->tk_client->cl_server);
  1081. error = -EPFNOSUPPORT;
  1082. goto out_err;
  1083. case RPC_PROG_MISMATCH:
  1084. dprintk("RPC: call_verify: program %u, version %u unsupported by server %s\n",
  1085. (unsigned int)task->tk_client->cl_prog,
  1086. (unsigned int)task->tk_client->cl_vers,
  1087. task->tk_client->cl_server);
  1088. error = -EPROTONOSUPPORT;
  1089. goto out_err;
  1090. case RPC_PROC_UNAVAIL:
  1091. dprintk("RPC: call_verify: proc %p unsupported by program %u, version %u on server %s\n",
  1092. task->tk_msg.rpc_proc,
  1093. task->tk_client->cl_prog,
  1094. task->tk_client->cl_vers,
  1095. task->tk_client->cl_server);
  1096. error = -EOPNOTSUPP;
  1097. goto out_err;
  1098. case RPC_GARBAGE_ARGS:
  1099. dprintk("RPC: %4d %s: server saw garbage\n", task->tk_pid, __FUNCTION__);
  1100. break; /* retry */
  1101. default:
  1102. printk(KERN_WARNING "call_verify: server accept status: %x\n", n);
  1103. /* Also retry */
  1104. }
  1105. out_garbage:
  1106. task->tk_client->cl_stats->rpcgarbage++;
  1107. if (task->tk_garb_retry) {
  1108. task->tk_garb_retry--;
  1109. dprintk("RPC %s: retrying %4d\n", __FUNCTION__, task->tk_pid);
  1110. task->tk_action = call_bind;
  1111. out_retry:
  1112. return ERR_PTR(-EAGAIN);
  1113. }
  1114. printk(KERN_WARNING "RPC %s: retry failed, exit EIO\n", __FUNCTION__);
  1115. out_eio:
  1116. error = -EIO;
  1117. out_err:
  1118. rpc_exit(task, error);
  1119. return ERR_PTR(error);
  1120. out_overflow:
  1121. printk(KERN_WARNING "RPC %s: server reply was truncated.\n", __FUNCTION__);
  1122. goto out_garbage;
  1123. }
  1124. static int rpcproc_encode_null(void *rqstp, u32 *data, void *obj)
  1125. {
  1126. return 0;
  1127. }
  1128. static int rpcproc_decode_null(void *rqstp, u32 *data, void *obj)
  1129. {
  1130. return 0;
  1131. }
  1132. static struct rpc_procinfo rpcproc_null = {
  1133. .p_encode = rpcproc_encode_null,
  1134. .p_decode = rpcproc_decode_null,
  1135. };
  1136. int rpc_ping(struct rpc_clnt *clnt, int flags)
  1137. {
  1138. struct rpc_message msg = {
  1139. .rpc_proc = &rpcproc_null,
  1140. };
  1141. int err;
  1142. msg.rpc_cred = authnull_ops.lookup_cred(NULL, NULL, 0);
  1143. err = rpc_call_sync(clnt, &msg, flags);
  1144. put_rpccred(msg.rpc_cred);
  1145. return err;
  1146. }