svc_udp.c 16 KB

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