svc_udp.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. /* @(#)svc_udp.c 2.2 88/07/29 4.0 RPCSRC */
  2. /*
  3. * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  4. * unrestricted use provided that this legend is included on all tape
  5. * media and as a part of the software program in whole or part. Users
  6. * may copy or modify Sun RPC without charge, but are not authorized
  7. * to license or distribute it to anyone else except as part of a product or
  8. * program developed by the user.
  9. *
  10. * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  11. * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  12. * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  13. *
  14. * Sun RPC is provided with no support and without any obligation on the
  15. * part of Sun Microsystems, Inc. to assist in its use, correction,
  16. * modification or enhancement.
  17. *
  18. * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  19. * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  20. * OR ANY PART THEREOF.
  21. *
  22. * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  23. * or profits or other special, indirect and consequential damages, even if
  24. * Sun has been advised of the possibility of such damages.
  25. *
  26. * Sun Microsystems, Inc.
  27. * 2550 Garcia Avenue
  28. * Mountain View, California 94043
  29. */
  30. #if 0
  31. static char sccsid[] = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro";
  32. #endif
  33. /*
  34. * svc_udp.c,
  35. * Server side for UDP/IP based RPC. (Does some caching in the hopes of
  36. * achieving execute-at-most-once semantics.)
  37. *
  38. * Copyright (C) 1984, Sun Microsystems, Inc.
  39. */
  40. #define xprt_register __xprt_register
  41. #define xprt_unregister __xprt_unregister
  42. #define xdrmem_create __xdrmem_create
  43. #define xdr_callmsg __xdr_callmsg
  44. #define xdr_replymsg __xdr_replymsg
  45. #define getsockname __getsockname
  46. #define setsockopt __setsockopt
  47. #define bind __bind
  48. #define bindresvport __bindresvport
  49. #define recvfrom __recvfrom
  50. #define sendto __sendto
  51. #define recvmsg __recvmsg
  52. #define sendmsg __sendmsg
  53. #define __FORCE_GLIBC
  54. #define _GNU_SOURCE
  55. #include <features.h>
  56. #include <stdio.h>
  57. #include <unistd.h>
  58. #include <string.h>
  59. #include <rpc/rpc.h>
  60. #include <sys/socket.h>
  61. #include <errno.h>
  62. #ifdef IP_PKTINFO
  63. #include <sys/uio.h>
  64. #endif
  65. #ifdef USE_IN_LIBIO
  66. # include <wchar.h>
  67. # include <libio/iolibio.h>
  68. # define fputs(s, f) _IO_fputs (s, f)
  69. #endif
  70. #define rpc_buffer(xprt) ((xprt)->xp_p1)
  71. #ifndef MAX
  72. #define MAX(a, b) ((a > b) ? a : b)
  73. #endif
  74. static bool_t svcudp_recv (SVCXPRT *, struct rpc_msg *);
  75. static bool_t svcudp_reply (SVCXPRT *, struct rpc_msg *);
  76. static enum xprt_stat svcudp_stat (SVCXPRT *);
  77. static bool_t svcudp_getargs (SVCXPRT *, xdrproc_t, caddr_t);
  78. static bool_t svcudp_freeargs (SVCXPRT *, xdrproc_t, caddr_t);
  79. static void svcudp_destroy (SVCXPRT *);
  80. static const struct xp_ops svcudp_op =
  81. {
  82. svcudp_recv,
  83. svcudp_stat,
  84. svcudp_getargs,
  85. svcudp_reply,
  86. svcudp_freeargs,
  87. svcudp_destroy
  88. };
  89. static int cache_get (SVCXPRT *, struct rpc_msg *, char **replyp,
  90. u_long *replylenp);
  91. static void cache_set (SVCXPRT *xprt, u_long replylen);
  92. /*
  93. * kept in xprt->xp_p2
  94. */
  95. struct svcudp_data
  96. {
  97. u_int su_iosz; /* byte size of send.recv buffer */
  98. u_long su_xid; /* transaction id */
  99. XDR su_xdrs; /* XDR handle */
  100. char su_verfbody[MAX_AUTH_BYTES]; /* verifier body */
  101. char *su_cache; /* cached data, NULL if no cache */
  102. };
  103. #define su_data(xprt) ((struct svcudp_data *)(xprt->xp_p2))
  104. /*
  105. * Usage:
  106. * xprt = svcudp_create(sock);
  107. *
  108. * If sock<0 then a socket is created, else sock is used.
  109. * If the socket, sock is not bound to a port then svcudp_create
  110. * binds it to an arbitrary port. In any (successful) case,
  111. * xprt->xp_sock is the registered socket number and xprt->xp_port is the
  112. * associated port number.
  113. * Once *xprt is initialized, it is registered as a transporter;
  114. * see (svc.h, xprt_register).
  115. * The routines returns NULL if a problem occurred.
  116. */
  117. SVCXPRT attribute_hidden *
  118. __svcudp_bufcreate (int sock, u_int sendsz, u_int recvsz)
  119. {
  120. bool_t madesock = FALSE;
  121. SVCXPRT *xprt;
  122. struct svcudp_data *su;
  123. struct sockaddr_in addr;
  124. socklen_t len = sizeof (struct sockaddr_in);
  125. int pad;
  126. void *buf;
  127. if (sock == RPC_ANYSOCK)
  128. {
  129. if ((sock = __socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
  130. {
  131. __perror (_("svcudp_create: socket creation problem"));
  132. return (SVCXPRT *) NULL;
  133. }
  134. madesock = TRUE;
  135. }
  136. __memset ((char *) &addr, 0, sizeof (addr));
  137. addr.sin_family = AF_INET;
  138. if (bindresvport (sock, &addr))
  139. {
  140. addr.sin_port = 0;
  141. (void) bind (sock, (struct sockaddr *) &addr, len);
  142. }
  143. if (getsockname (sock, (struct sockaddr *) &addr, &len) != 0)
  144. {
  145. __perror (_("svcudp_create - cannot getsockname"));
  146. if (madesock)
  147. (void) __close (sock);
  148. return (SVCXPRT *) NULL;
  149. }
  150. xprt = (SVCXPRT *) mem_alloc (sizeof (SVCXPRT));
  151. su = (struct svcudp_data *) mem_alloc (sizeof (*su));
  152. buf = mem_alloc (((MAX (sendsz, recvsz) + 3) / 4) * 4);
  153. if (xprt == NULL || su == NULL || buf == NULL)
  154. {
  155. #ifdef USE_IN_LIBIO
  156. if (_IO_fwide (stderr, 0) > 0)
  157. (void) __fwprintf (stderr, L"%s", _("svcudp_create: out of memory\n"));
  158. else
  159. #endif
  160. (void) fputs (_("svcudp_create: out of memory\n"), stderr);
  161. mem_free (xprt, sizeof (SVCXPRT));
  162. mem_free (su, sizeof (*su));
  163. mem_free (buf, ((MAX (sendsz, recvsz) + 3) / 4) * 4);
  164. return NULL;
  165. }
  166. su->su_iosz = ((MAX (sendsz, recvsz) + 3) / 4) * 4;
  167. rpc_buffer (xprt) = buf;
  168. xdrmem_create (&(su->su_xdrs), rpc_buffer (xprt), su->su_iosz, XDR_DECODE);
  169. su->su_cache = NULL;
  170. xprt->xp_p2 = (caddr_t) su;
  171. xprt->xp_verf.oa_base = su->su_verfbody;
  172. xprt->xp_ops = &svcudp_op;
  173. xprt->xp_port = ntohs (addr.sin_port);
  174. xprt->xp_sock = sock;
  175. #ifdef IP_PKTINFO
  176. if ((sizeof (struct iovec) + sizeof (struct msghdr)
  177. + sizeof(struct cmsghdr) + sizeof (struct in_pktinfo))
  178. > sizeof (xprt->xp_pad))
  179. {
  180. # ifdef USE_IN_LIBIO
  181. if (_IO_fwide (stderr, 0) > 0)
  182. (void) __fwprintf (stderr, L"%s",
  183. _("svcudp_create: xp_pad is too small for IP_PKTINFO\n"));
  184. else
  185. # endif
  186. (void) fputs (_("svcudp_create: xp_pad is too small for IP_PKTINFO\n"),
  187. stderr);
  188. return NULL;
  189. }
  190. pad = 1;
  191. if (setsockopt (sock, SOL_IP, IP_PKTINFO, (void *) &pad,
  192. sizeof (pad)) == 0)
  193. /* Set the padding to all 1s. */
  194. pad = 0xff;
  195. else
  196. #endif
  197. /* Clear the padding. */
  198. pad = 0;
  199. __memset (&xprt->xp_pad [0], pad, sizeof (xprt->xp_pad));
  200. xprt_register (xprt);
  201. return xprt;
  202. }
  203. strong_alias(__svcudp_bufcreate,svcudp_bufcreate)
  204. SVCXPRT attribute_hidden *
  205. __svcudp_create (int sock)
  206. {
  207. return __svcudp_bufcreate (sock, UDPMSGSIZE, UDPMSGSIZE);
  208. }
  209. strong_alias(__svcudp_create,svcudp_create)
  210. static enum xprt_stat
  211. svcudp_stat (xprt)
  212. SVCXPRT *xprt;
  213. {
  214. return XPRT_IDLE;
  215. }
  216. static bool_t
  217. svcudp_recv (xprt, msg)
  218. SVCXPRT *xprt;
  219. struct rpc_msg *msg;
  220. {
  221. struct svcudp_data *su = su_data (xprt);
  222. XDR *xdrs = &(su->su_xdrs);
  223. int rlen;
  224. char *reply;
  225. u_long replylen;
  226. socklen_t len;
  227. /* It is very tricky when you have IP aliases. We want to make sure
  228. that we are sending the packet from the IP address where the
  229. incoming packet is addressed to. H.J. */
  230. #ifdef IP_PKTINFO
  231. struct iovec *iovp;
  232. struct msghdr *mesgp;
  233. #endif
  234. again:
  235. /* FIXME -- should xp_addrlen be a size_t? */
  236. len = (socklen_t) sizeof(struct sockaddr_in);
  237. #ifdef IP_PKTINFO
  238. iovp = (struct iovec *) &xprt->xp_pad [0];
  239. mesgp = (struct msghdr *) &xprt->xp_pad [sizeof (struct iovec)];
  240. if (mesgp->msg_iovlen)
  241. {
  242. iovp->iov_base = rpc_buffer (xprt);
  243. iovp->iov_len = su->su_iosz;
  244. mesgp->msg_iov = iovp;
  245. mesgp->msg_iovlen = 1;
  246. mesgp->msg_name = &(xprt->xp_raddr);
  247. mesgp->msg_namelen = len;
  248. mesgp->msg_control = &xprt->xp_pad [sizeof (struct iovec)
  249. + sizeof (struct msghdr)];
  250. mesgp->msg_controllen = sizeof(xprt->xp_pad)
  251. - sizeof (struct iovec) - sizeof (struct msghdr);
  252. rlen = recvmsg (xprt->xp_sock, mesgp, 0);
  253. if (rlen >= 0)
  254. len = mesgp->msg_namelen;
  255. }
  256. else
  257. #endif
  258. rlen = recvfrom (xprt->xp_sock, rpc_buffer (xprt),
  259. (int) su->su_iosz, 0,
  260. (struct sockaddr *) &(xprt->xp_raddr), &len);
  261. xprt->xp_addrlen = len;
  262. if (rlen == -1 && errno == EINTR)
  263. goto again;
  264. if (rlen < 16) /* < 4 32-bit ints? */
  265. return FALSE;
  266. xdrs->x_op = XDR_DECODE;
  267. XDR_SETPOS (xdrs, 0);
  268. if (!xdr_callmsg (xdrs, msg))
  269. return FALSE;
  270. su->su_xid = msg->rm_xid;
  271. if (su->su_cache != NULL)
  272. {
  273. if (cache_get (xprt, msg, &reply, &replylen))
  274. {
  275. #ifdef IP_PKTINFO
  276. if (mesgp->msg_iovlen)
  277. {
  278. iovp->iov_base = reply;
  279. iovp->iov_len = replylen;
  280. (void) sendmsg (xprt->xp_sock, mesgp, 0);
  281. }
  282. else
  283. #endif
  284. (void) sendto (xprt->xp_sock, reply, (int) replylen, 0,
  285. (struct sockaddr *) &xprt->xp_raddr, len);
  286. return TRUE;
  287. }
  288. }
  289. return TRUE;
  290. }
  291. static bool_t
  292. svcudp_reply (xprt, msg)
  293. SVCXPRT *xprt;
  294. struct rpc_msg *msg;
  295. {
  296. struct svcudp_data *su = su_data (xprt);
  297. XDR *xdrs = &(su->su_xdrs);
  298. int slen, sent;
  299. bool_t stat = FALSE;
  300. #ifdef IP_PKTINFO
  301. struct iovec *iovp;
  302. struct msghdr *mesgp;
  303. #endif
  304. xdrs->x_op = XDR_ENCODE;
  305. XDR_SETPOS (xdrs, 0);
  306. msg->rm_xid = su->su_xid;
  307. if (xdr_replymsg (xdrs, msg))
  308. {
  309. slen = (int) XDR_GETPOS (xdrs);
  310. #ifdef IP_PKTINFO
  311. mesgp = (struct msghdr *) &xprt->xp_pad [sizeof (struct iovec)];
  312. if (mesgp->msg_iovlen)
  313. {
  314. iovp = (struct iovec *) &xprt->xp_pad [0];
  315. iovp->iov_base = rpc_buffer (xprt);
  316. iovp->iov_len = slen;
  317. sent = sendmsg (xprt->xp_sock, mesgp, 0);
  318. }
  319. else
  320. #endif
  321. sent = sendto (xprt->xp_sock, rpc_buffer (xprt), slen, 0,
  322. (struct sockaddr *) &(xprt->xp_raddr),
  323. xprt->xp_addrlen);
  324. if (sent == slen)
  325. {
  326. stat = TRUE;
  327. if (su->su_cache && slen >= 0)
  328. {
  329. cache_set (xprt, (u_long) slen);
  330. }
  331. }
  332. }
  333. return stat;
  334. }
  335. static bool_t
  336. svcudp_getargs (xprt, xdr_args, args_ptr)
  337. SVCXPRT *xprt;
  338. xdrproc_t xdr_args;
  339. caddr_t args_ptr;
  340. {
  341. return (*xdr_args) (&(su_data (xprt)->su_xdrs), args_ptr);
  342. }
  343. static bool_t
  344. svcudp_freeargs (xprt, xdr_args, args_ptr)
  345. SVCXPRT *xprt;
  346. xdrproc_t xdr_args;
  347. caddr_t args_ptr;
  348. {
  349. XDR *xdrs = &(su_data (xprt)->su_xdrs);
  350. xdrs->x_op = XDR_FREE;
  351. return (*xdr_args) (xdrs, args_ptr);
  352. }
  353. static void
  354. svcudp_destroy (xprt)
  355. SVCXPRT *xprt;
  356. {
  357. struct svcudp_data *su = su_data (xprt);
  358. xprt_unregister (xprt);
  359. (void) __close (xprt->xp_sock);
  360. XDR_DESTROY (&(su->su_xdrs));
  361. mem_free (rpc_buffer (xprt), su->su_iosz);
  362. mem_free ((caddr_t) su, sizeof (struct svcudp_data));
  363. mem_free ((caddr_t) xprt, sizeof (SVCXPRT));
  364. }
  365. /***********this could be a separate file*********************/
  366. /*
  367. * Fifo cache for udp server
  368. * Copies pointers to reply buffers into fifo cache
  369. * Buffers are sent again if retransmissions are detected.
  370. */
  371. #define SPARSENESS 4 /* 75% sparse */
  372. #ifdef USE_IN_LIBIO
  373. # define CACHE_PERROR(msg) \
  374. if (_IO_fwide (stderr, 0) > 0) \
  375. (void) __fwprintf(stderr, L"%s\n", msg); \
  376. else \
  377. (void) fprintf(stderr, "%s\n", msg)
  378. #else
  379. # define CACHE_PERROR(msg) \
  380. (void) fprintf(stderr,"%s\n", msg)
  381. #endif
  382. #define ALLOC(type, size) \
  383. (type *) mem_alloc((unsigned) (sizeof(type) * (size)))
  384. #define BZERO(addr, type, size) \
  385. __memset((char *) addr, 0, sizeof(type) * (int) (size))
  386. /*
  387. * An entry in the cache
  388. */
  389. typedef struct cache_node *cache_ptr;
  390. struct cache_node
  391. {
  392. /*
  393. * Index into cache is xid, proc, vers, prog and address
  394. */
  395. u_long cache_xid;
  396. u_long cache_proc;
  397. u_long cache_vers;
  398. u_long cache_prog;
  399. struct sockaddr_in cache_addr;
  400. /*
  401. * The cached reply and length
  402. */
  403. char *cache_reply;
  404. u_long cache_replylen;
  405. /*
  406. * Next node on the list, if there is a collision
  407. */
  408. cache_ptr cache_next;
  409. };
  410. /*
  411. * The entire cache
  412. */
  413. struct udp_cache
  414. {
  415. u_long uc_size; /* size of cache */
  416. cache_ptr *uc_entries; /* hash table of entries in cache */
  417. cache_ptr *uc_fifo; /* fifo list of entries in cache */
  418. u_long uc_nextvictim; /* points to next victim in fifo list */
  419. u_long uc_prog; /* saved program number */
  420. u_long uc_vers; /* saved version number */
  421. u_long uc_proc; /* saved procedure number */
  422. struct sockaddr_in uc_addr; /* saved caller's address */
  423. };
  424. /*
  425. * the hashing function
  426. */
  427. #define CACHE_LOC(transp, xid) \
  428. (xid % (SPARSENESS*((struct udp_cache *) su_data(transp)->su_cache)->uc_size))
  429. /*
  430. * Enable use of the cache.
  431. * Note: there is no disable.
  432. */
  433. int
  434. svcudp_enablecache (SVCXPRT *transp, u_long size)
  435. {
  436. struct svcudp_data *su = su_data (transp);
  437. struct udp_cache *uc;
  438. if (su->su_cache != NULL)
  439. {
  440. CACHE_PERROR (_("enablecache: cache already enabled"));
  441. return 0;
  442. }
  443. uc = ALLOC (struct udp_cache, 1);
  444. if (uc == NULL)
  445. {
  446. CACHE_PERROR (_("enablecache: could not allocate cache"));
  447. return 0;
  448. }
  449. uc->uc_size = size;
  450. uc->uc_nextvictim = 0;
  451. uc->uc_entries = ALLOC (cache_ptr, size * SPARSENESS);
  452. if (uc->uc_entries == NULL)
  453. {
  454. CACHE_PERROR (_("enablecache: could not allocate cache data"));
  455. return 0;
  456. }
  457. BZERO (uc->uc_entries, cache_ptr, size * SPARSENESS);
  458. uc->uc_fifo = ALLOC (cache_ptr, size);
  459. if (uc->uc_fifo == NULL)
  460. {
  461. CACHE_PERROR (_("enablecache: could not allocate cache fifo"));
  462. return 0;
  463. }
  464. BZERO (uc->uc_fifo, cache_ptr, size);
  465. su->su_cache = (char *) uc;
  466. return 1;
  467. }
  468. /*
  469. * Set an entry in the cache
  470. */
  471. static void
  472. cache_set (SVCXPRT *xprt, u_long replylen)
  473. {
  474. cache_ptr victim;
  475. cache_ptr *vicp;
  476. struct svcudp_data *su = su_data (xprt);
  477. struct udp_cache *uc = (struct udp_cache *) su->su_cache;
  478. u_int loc;
  479. char *newbuf;
  480. /*
  481. * Find space for the new entry, either by
  482. * reusing an old entry, or by mallocing a new one
  483. */
  484. victim = uc->uc_fifo[uc->uc_nextvictim];
  485. if (victim != NULL)
  486. {
  487. loc = CACHE_LOC (xprt, victim->cache_xid);
  488. for (vicp = &uc->uc_entries[loc];
  489. *vicp != NULL && *vicp != victim;
  490. vicp = &(*vicp)->cache_next)
  491. ;
  492. if (*vicp == NULL)
  493. {
  494. CACHE_PERROR (_("cache_set: victim not found"));
  495. return;
  496. }
  497. *vicp = victim->cache_next; /* remote from cache */
  498. newbuf = victim->cache_reply;
  499. }
  500. else
  501. {
  502. victim = ALLOC (struct cache_node, 1);
  503. if (victim == NULL)
  504. {
  505. CACHE_PERROR (_("cache_set: victim alloc failed"));
  506. return;
  507. }
  508. newbuf = mem_alloc (su->su_iosz);
  509. if (newbuf == NULL)
  510. {
  511. CACHE_PERROR (_("cache_set: could not allocate new rpc_buffer"));
  512. return;
  513. }
  514. }
  515. /*
  516. * Store it away
  517. */
  518. victim->cache_replylen = replylen;
  519. victim->cache_reply = rpc_buffer (xprt);
  520. rpc_buffer (xprt) = newbuf;
  521. xdrmem_create (&(su->su_xdrs), rpc_buffer (xprt), su->su_iosz, XDR_ENCODE);
  522. victim->cache_xid = su->su_xid;
  523. victim->cache_proc = uc->uc_proc;
  524. victim->cache_vers = uc->uc_vers;
  525. victim->cache_prog = uc->uc_prog;
  526. victim->cache_addr = uc->uc_addr;
  527. loc = CACHE_LOC (xprt, victim->cache_xid);
  528. victim->cache_next = uc->uc_entries[loc];
  529. uc->uc_entries[loc] = victim;
  530. uc->uc_fifo[uc->uc_nextvictim++] = victim;
  531. uc->uc_nextvictim %= uc->uc_size;
  532. }
  533. /*
  534. * Try to get an entry from the cache
  535. * return 1 if found, 0 if not found
  536. */
  537. static int
  538. cache_get (xprt, msg, replyp, replylenp)
  539. SVCXPRT *xprt;
  540. struct rpc_msg *msg;
  541. char **replyp;
  542. u_long *replylenp;
  543. {
  544. u_int loc;
  545. cache_ptr ent;
  546. struct svcudp_data *su = su_data (xprt);
  547. struct udp_cache *uc = (struct udp_cache *) su->su_cache;
  548. #define EQADDR(a1, a2) (__memcmp((char*)&a1, (char*)&a2, sizeof(a1)) == 0)
  549. loc = CACHE_LOC (xprt, su->su_xid);
  550. for (ent = uc->uc_entries[loc]; ent != NULL; ent = ent->cache_next)
  551. {
  552. if (ent->cache_xid == su->su_xid &&
  553. ent->cache_proc == uc->uc_proc &&
  554. ent->cache_vers == uc->uc_vers &&
  555. ent->cache_prog == uc->uc_prog &&
  556. EQADDR (ent->cache_addr, uc->uc_addr))
  557. {
  558. *replyp = ent->cache_reply;
  559. *replylenp = ent->cache_replylen;
  560. return 1;
  561. }
  562. }
  563. /*
  564. * Failed to find entry
  565. * Remember a few things so we can do a set later
  566. */
  567. uc->uc_proc = msg->rm_call.cb_proc;
  568. uc->uc_vers = msg->rm_call.cb_vers;
  569. uc->uc_prog = msg->rm_call.cb_prog;
  570. __memcpy (&uc->uc_addr, &xprt->xp_raddr, sizeof (uc->uc_addr));
  571. return 0;
  572. }