1 /* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Rick Macklem at The University of Guelph. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of the University nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95 33 * $FreeBSD: src/sys/nfs/nfs_syscalls.c,v 1.58.2.1 2000/11/26 02:30:06 dillon Exp $ 34 */ 35 36 #include <sys/param.h> 37 #include <sys/systm.h> 38 #include <sys/sysproto.h> 39 #include <sys/kernel.h> 40 #include <sys/sysctl.h> 41 #include <sys/file.h> 42 #include <sys/filedesc.h> 43 #include <sys/vnode.h> 44 #include <sys/malloc.h> 45 #include <sys/mount.h> 46 #include <sys/proc.h> 47 #include <sys/priv.h> 48 #include <sys/buf.h> 49 #include <sys/mbuf.h> 50 #include <sys/resourcevar.h> 51 #include <sys/socket.h> 52 #include <sys/socketvar.h> 53 #include <sys/domain.h> 54 #include <sys/protosw.h> 55 #include <sys/nlookup.h> 56 57 #include <sys/mutex2.h> 58 #include <sys/thread2.h> 59 60 #include <netinet/in.h> 61 #include <netinet/tcp.h> 62 #include "xdr_subs.h" 63 #include "rpcv2.h" 64 #include "nfsproto.h" 65 #include "nfs.h" 66 #include "nfsm_subs.h" 67 #include "nfsrvcache.h" 68 #include "nfsmount.h" 69 #include "nfsnode.h" 70 #include "nfsrtt.h" 71 72 static MALLOC_DEFINE(M_NFSSVC, "NFS srvsock", "Nfs server structure"); 73 74 static int nuidhash_max = NFS_MAXUIDHASH; 75 76 #ifndef NFS_NOSERVER 77 static void nfsrv_zapsock (struct nfssvc_sock *slp); 78 #endif 79 80 #define TRUE 1 81 #define FALSE 0 82 83 SYSCTL_DECL(_vfs_nfs); 84 85 #ifndef NFS_NOSERVER 86 int nfsd_waiting = 0; 87 static struct nfsdrt nfsdrt; 88 static int nfs_numnfsd = 0; 89 static void nfsd_rt (int sotype, struct nfsrv_descript *nd, 90 int cacherep); 91 static int nfssvc_addsock (struct file *, struct sockaddr *, 92 struct thread *); 93 static int nfssvc_nfsd (struct nfsd_srvargs *,caddr_t,struct thread *); 94 95 static int nfs_privport = 0; 96 SYSCTL_INT(_vfs_nfs, NFS_NFSPRIVPORT, nfs_privport, CTLFLAG_RW, &nfs_privport, 97 0, "Enable privileged source port checks"); 98 SYSCTL_INT(_vfs_nfs, OID_AUTO, gatherdelay, CTLFLAG_RW, &nfsrvw_procrastinate, 0, 99 "Enable NFS request procrastination"); 100 SYSCTL_INT(_vfs_nfs, OID_AUTO, gatherdelay_v3, CTLFLAG_RW, &nfsrvw_procrastinate_v3, 0, 101 "Enable NFSv3 request procrastination"); 102 int nfs_soreserve = NFS_MAXPACKET * NFS_MAXASYNCBIO; 103 SYSCTL_INT(_vfs_nfs, OID_AUTO, soreserve, CTLFLAG_RW, &nfs_soreserve, 0, 104 "Minimum NFS socket buffer size reservation"); 105 106 /* 107 * NFS server system calls 108 */ 109 110 #endif /* NFS_NOSERVER */ 111 /* 112 * nfssvc_args(int flag, caddr_t argp) 113 * 114 * Nfs server psuedo system call for the nfsd's 115 * Based on the flag value it either: 116 * - adds a socket to the selection list 117 * - remains in the kernel as an nfsd 118 * - remains in the kernel as an nfsiod 119 * 120 * MPALMOSTSAFE 121 */ 122 int 123 sys_nfssvc(struct nfssvc_args *uap) 124 { 125 #ifndef NFS_NOSERVER 126 struct nlookupdata nd; 127 struct file *fp; 128 struct sockaddr *nam; 129 struct nfsd_args nfsdarg; 130 struct nfsd_srvargs nfsd_srvargs, *nsd = &nfsd_srvargs; 131 struct nfsd_cargs ncd; 132 struct nfsd *nfsd; 133 struct nfssvc_sock *slp; 134 struct nfsuid *nuidp; 135 struct nfsmount *nmp; 136 struct vnode *vp; 137 #endif /* NFS_NOSERVER */ 138 int error; 139 struct thread *td = curthread; 140 141 /* 142 * Must be super user 143 */ 144 error = priv_check(td, PRIV_ROOT); 145 if (error) 146 return (error); 147 148 lwkt_gettoken(&nfs_token); 149 150 while (nfssvc_sockhead_flag & SLP_INIT) { 151 nfssvc_sockhead_flag |= SLP_WANTINIT; 152 tsleep((caddr_t)&nfssvc_sockhead, 0, "nfsd init", 0); 153 } 154 if (uap->flag & NFSSVC_BIOD) 155 error = ENXIO; /* no longer need nfsiod's */ 156 #ifdef NFS_NOSERVER 157 else 158 error = ENXIO; 159 #else /* !NFS_NOSERVER */ 160 else if (uap->flag & NFSSVC_MNTD) { 161 error = copyin(uap->argp, (caddr_t)&ncd, sizeof (ncd)); 162 if (error) 163 goto done; 164 vp = NULL; 165 error = nlookup_init(&nd, ncd.ncd_dirp, UIO_USERSPACE, 166 NLC_FOLLOW); 167 if (error == 0) 168 error = nlookup(&nd); 169 if (error == 0) 170 error = cache_vget(&nd.nl_nch, nd.nl_cred, LK_EXCLUSIVE, &vp); 171 nlookup_done(&nd); 172 if (error) 173 goto done; 174 175 if ((vp->v_flag & VROOT) == 0) 176 error = EINVAL; 177 nmp = VFSTONFS(vp->v_mount); 178 vput(vp); 179 if (error) 180 goto done; 181 if ((nmp->nm_state & NFSSTA_MNTD) && 182 (uap->flag & NFSSVC_GOTAUTH) == 0) { 183 error = 0; 184 goto done; 185 } 186 nmp->nm_state |= NFSSTA_MNTD; 187 error = nfs_clientd(nmp, td->td_ucred, &ncd, uap->flag, 188 uap->argp, td); 189 } else if (uap->flag & NFSSVC_ADDSOCK) { 190 error = copyin(uap->argp, (caddr_t)&nfsdarg, sizeof(nfsdarg)); 191 if (error) 192 goto done; 193 error = holdsock(td->td_proc->p_fd, nfsdarg.sock, &fp); 194 if (error) 195 goto done; 196 /* 197 * Get the client address for connected sockets. 198 */ 199 if (nfsdarg.name == NULL || nfsdarg.namelen == 0) 200 nam = NULL; 201 else { 202 error = getsockaddr(&nam, nfsdarg.name, 203 nfsdarg.namelen); 204 if (error) { 205 fdrop(fp); 206 goto done; 207 } 208 } 209 error = nfssvc_addsock(fp, nam, td); 210 fdrop(fp); 211 } else { 212 error = copyin(uap->argp, (caddr_t)nsd, sizeof (*nsd)); 213 if (error) 214 goto done; 215 if ((uap->flag & NFSSVC_AUTHIN) && 216 ((nfsd = nsd->nsd_nfsd)) != NULL && 217 (nfsd->nfsd_slp->ns_flag & SLP_VALID)) { 218 slp = nfsd->nfsd_slp; 219 220 /* 221 * First check to see if another nfsd has already 222 * added this credential. 223 */ 224 for (nuidp = NUIDHASH(slp,nsd->nsd_cr.cr_uid)->lh_first; 225 nuidp != 0; nuidp = nuidp->nu_hash.le_next) { 226 if (nuidp->nu_cr.cr_uid == nsd->nsd_cr.cr_uid && 227 (!nfsd->nfsd_nd->nd_nam2 || 228 netaddr_match(NU_NETFAM(nuidp), 229 &nuidp->nu_haddr, nfsd->nfsd_nd->nd_nam2))) 230 break; 231 } 232 if (nuidp) { 233 nfsrv_setcred(&nuidp->nu_cr,&nfsd->nfsd_nd->nd_cr); 234 nfsd->nfsd_nd->nd_flag |= ND_KERBFULL; 235 } else { 236 /* 237 * Nope, so we will. 238 */ 239 if (slp->ns_numuids < nuidhash_max) { 240 slp->ns_numuids++; 241 nuidp = (struct nfsuid *) 242 kmalloc(sizeof (struct nfsuid), M_NFSUID, 243 M_WAITOK); 244 } else 245 nuidp = NULL; 246 if ((slp->ns_flag & SLP_VALID) == 0) { 247 if (nuidp) 248 kfree((caddr_t)nuidp, M_NFSUID); 249 } else { 250 if (nuidp == NULL) { 251 nuidp = TAILQ_FIRST(&slp->ns_uidlruhead); 252 LIST_REMOVE(nuidp, nu_hash); 253 TAILQ_REMOVE(&slp->ns_uidlruhead, nuidp, 254 nu_lru); 255 if (nuidp->nu_flag & NU_NAM) 256 kfree(nuidp->nu_nam, M_SONAME); 257 } 258 nuidp->nu_flag = 0; 259 nuidp->nu_cr = nsd->nsd_cr; 260 if (nuidp->nu_cr.cr_ngroups > NGROUPS) 261 nuidp->nu_cr.cr_ngroups = NGROUPS; 262 nuidp->nu_cr.cr_ref = 1; 263 nuidp->nu_timestamp = nsd->nsd_timestamp; 264 nuidp->nu_expire = time_uptime + nsd->nsd_ttl; 265 /* 266 * and save the session key in nu_key. 267 */ 268 bcopy(nsd->nsd_key, nuidp->nu_key, 269 sizeof (nsd->nsd_key)); 270 if (nfsd->nfsd_nd->nd_nam2) { 271 struct sockaddr_in *saddr; 272 273 saddr = (struct sockaddr_in *) 274 nfsd->nfsd_nd->nd_nam2; 275 switch (saddr->sin_family) { 276 case AF_INET: 277 nuidp->nu_flag |= NU_INETADDR; 278 nuidp->nu_inetaddr = 279 saddr->sin_addr.s_addr; 280 break; 281 case AF_ISO: 282 default: 283 nuidp->nu_flag |= NU_NAM; 284 nuidp->nu_nam = 285 dup_sockaddr(nfsd->nfsd_nd->nd_nam2); 286 break; 287 }; 288 } 289 TAILQ_INSERT_TAIL(&slp->ns_uidlruhead, nuidp, 290 nu_lru); 291 LIST_INSERT_HEAD(NUIDHASH(slp, nsd->nsd_uid), 292 nuidp, nu_hash); 293 nfsrv_setcred(&nuidp->nu_cr, 294 &nfsd->nfsd_nd->nd_cr); 295 nfsd->nfsd_nd->nd_flag |= ND_KERBFULL; 296 } 297 } 298 } 299 if ((uap->flag & NFSSVC_AUTHINFAIL) && (nfsd = nsd->nsd_nfsd)) 300 nfsd->nfsd_flag |= NFSD_AUTHFAIL; 301 error = nfssvc_nfsd(nsd, uap->argp, td); 302 } 303 #endif /* NFS_NOSERVER */ 304 if (error == EINTR || error == ERESTART) 305 error = 0; 306 done: 307 lwkt_reltoken(&nfs_token); 308 return (error); 309 } 310 311 #ifndef NFS_NOSERVER 312 /* 313 * Adds a socket to the list for servicing by nfsds. 314 */ 315 static int 316 nfssvc_addsock(struct file *fp, struct sockaddr *mynam, struct thread *td) 317 { 318 int siz; 319 struct nfssvc_sock *slp; 320 struct socket *so; 321 int error; 322 323 so = (struct socket *)fp->f_data; 324 #if 0 325 tslp = NULL; 326 /* 327 * Add it to the list, as required. 328 */ 329 if (so->so_proto->pr_protocol == IPPROTO_UDP) { 330 tslp = nfs_udpsock; 331 if (tslp->ns_flag & SLP_VALID) { 332 if (mynam != NULL) 333 kfree(mynam, M_SONAME); 334 return (EPERM); 335 } 336 } 337 #endif 338 /* 339 * Reserve buffer space in the socket. Note that due to bugs in 340 * Linux's delayed-ack code, serious performance degredation may 341 * occur with linux hosts if the minimum is used. 342 * 343 * NFS sockets are not limited to the standard sb_max or by 344 * resource limits. 345 */ 346 if (so->so_type == SOCK_STREAM) 347 siz = NFS_MAXPACKET + sizeof (u_long); 348 else 349 siz = NFS_MAXPACKET; 350 if (siz < nfs_soreserve) 351 siz = nfs_soreserve; 352 353 error = soreserve(so, siz, siz, NULL); 354 if (error) { 355 if (mynam != NULL) 356 kfree(mynam, M_SONAME); 357 return (error); 358 } 359 360 /* 361 * Set protocol specific options { for now TCP only } and 362 * reserve some space. For datagram sockets, this can get called 363 * repeatedly for the same socket, but that isn't harmful. 364 */ 365 if (so->so_type == SOCK_STREAM) { 366 struct sockopt sopt; 367 int val; 368 369 bzero(&sopt, sizeof sopt); 370 sopt.sopt_level = SOL_SOCKET; 371 sopt.sopt_name = SO_KEEPALIVE; 372 sopt.sopt_val = &val; 373 sopt.sopt_valsize = sizeof val; 374 val = 1; 375 sosetopt(so, &sopt); 376 } 377 if (so->so_proto->pr_domain->dom_family == AF_INET && 378 so->so_proto->pr_protocol == IPPROTO_TCP) { 379 struct sockopt sopt; 380 int val; 381 382 bzero(&sopt, sizeof sopt); 383 sopt.sopt_level = IPPROTO_TCP; 384 sopt.sopt_name = TCP_NODELAY; 385 sopt.sopt_val = &val; 386 sopt.sopt_valsize = sizeof val; 387 val = 1; 388 sosetopt(so, &sopt); 389 390 bzero(&sopt, sizeof sopt); 391 sopt.sopt_level = IPPROTO_TCP; 392 sopt.sopt_name = TCP_FASTKEEP; 393 sopt.sopt_val = &val; 394 sopt.sopt_valsize = sizeof val; 395 val = 1; 396 sosetopt(so, &sopt); 397 } 398 atomic_clear_int(&so->so_rcv.ssb_flags, SSB_NOINTR); 399 so->so_rcv.ssb_timeo = 0; 400 atomic_clear_int(&so->so_snd.ssb_flags, SSB_NOINTR); 401 so->so_snd.ssb_timeo = 0; 402 403 /* 404 * Clear AUTOSIZE, otherwise the socket buffer could be reduced 405 * to the point where rpc's cannot be queued using the mbuf 406 * interface. 407 */ 408 atomic_clear_int(&so->so_rcv.ssb_flags, SSB_AUTOSIZE); 409 atomic_clear_int(&so->so_snd.ssb_flags, SSB_AUTOSIZE); 410 411 slp = kmalloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK | M_ZERO); 412 mtx_init(&slp->ns_solock, "nfsvc"); 413 STAILQ_INIT(&slp->ns_rec); 414 TAILQ_INIT(&slp->ns_uidlruhead); 415 lwkt_token_init(&slp->ns_token, "nfssrv_token"); 416 417 lwkt_gettoken(&nfs_token); 418 nfsrv_slpref(slp); 419 TAILQ_INSERT_TAIL(&nfssvc_sockhead, slp, ns_chain); 420 lwkt_gettoken(&slp->ns_token); 421 422 slp->ns_so = so; 423 slp->ns_nam = mynam; 424 fp->f_count++; 425 slp->ns_fp = fp; 426 427 so->so_upcallarg = (caddr_t)slp; 428 so->so_upcall = nfsrv_rcv_upcall; 429 atomic_set_int(&so->so_rcv.ssb_flags, SSB_UPCALL); 430 slp->ns_flag = (SLP_VALID | SLP_NEEDQ); 431 nfsrv_wakenfsd(slp, 1); 432 433 lwkt_reltoken(&slp->ns_token); 434 lwkt_reltoken(&nfs_token); 435 436 return (0); 437 } 438 439 /* 440 * Called by nfssvc() for nfsds. Just loops around servicing rpc requests 441 * until it is killed by a signal. 442 */ 443 static int 444 nfssvc_nfsd(struct nfsd_srvargs *nsd, caddr_t argp, struct thread *td) 445 { 446 int siz; 447 struct nfssvc_sock *slp; 448 struct nfsd *nfsd = nsd->nsd_nfsd; 449 struct nfsrv_descript *nd = NULL; 450 struct mbuf *m, *mreq; 451 int error, cacherep, sotype, writes_todo; 452 int procrastinate; 453 int slplocked; 454 u_quad_t cur_usec; 455 456 #ifndef nolint 457 cacherep = RC_DOIT; 458 writes_todo = 0; 459 #endif 460 lwkt_gettoken(&nfs_token); 461 462 if (nfsd == NULL) { 463 nsd->nsd_nfsd = nfsd = (struct nfsd *) 464 kmalloc(sizeof (struct nfsd), M_NFSD, M_WAITOK|M_ZERO); 465 nfsd->nfsd_td = td; 466 TAILQ_INSERT_TAIL(&nfsd_head, nfsd, nfsd_chain); 467 nfs_numnfsd++; 468 } 469 470 /* 471 * Loop getting rpc requests until SIGKILL. 472 */ 473 for (;;) { 474 if ((nfsd->nfsd_flag & NFSD_REQINPROG) == 0) { 475 while (nfsd->nfsd_slp == NULL && 476 (nfsd_head_flag & NFSD_CHECKSLP) == 0) { 477 nfsd->nfsd_flag |= NFSD_WAITING; 478 nfsd_waiting++; 479 error = tsleep(nfsd, PCATCH, "nfsd", 0); 480 nfsd_waiting--; 481 if (error && nfsd->nfsd_slp == NULL) 482 goto done; 483 } 484 if (nfsd->nfsd_slp == NULL && 485 (nfsd_head_flag & NFSD_CHECKSLP)) { 486 TAILQ_FOREACH(slp, &nfssvc_sockhead, ns_chain) { 487 if ((slp->ns_flag & SLP_ACTION_MASK) || 488 slp->ns_needq_upcall) { 489 nfsrv_slpref(slp); 490 nfsd->nfsd_slp = slp; 491 break; 492 } 493 } 494 if (slp == NULL) 495 nfsd_head_flag &= ~NFSD_CHECKSLP; 496 } 497 if ((slp = nfsd->nfsd_slp) == NULL) 498 continue; 499 500 lwkt_reltoken(&nfs_token); 501 lwkt_gettoken(&slp->ns_token); 502 503 if (slp->ns_needq_upcall) { 504 slp->ns_needq_upcall = 0; 505 slp->ns_flag |= SLP_NEEDQ; 506 } 507 508 if (slp->ns_flag & SLP_VALID) { 509 /* 510 * We can both process additional received 511 * data into new records and process existing 512 * records. This keeps the pipeline hot by 513 * allowing the tcp socket to continue to 514 * drain while we are processing records. 515 */ 516 while (slp->ns_flag & (SLP_DISCONN|SLP_NEEDQ)) { 517 if (slp->ns_flag & SLP_DISCONN) { 518 nfsrv_zapsock(slp); 519 break; 520 } 521 if (slp->ns_flag & SLP_NEEDQ) { 522 nfs_slplock(slp, 1); 523 if ((slp->ns_flag & 524 SLP_NEEDQ) == 0) { 525 nfs_slpunlock(slp); 526 continue; 527 } 528 nfsrv_rcv(slp->ns_so, 529 (caddr_t)slp, 530 M_WAITOK); 531 nfs_slpunlock(slp); 532 break; 533 } 534 } 535 error = nfsrv_dorec(slp, nfsd, &nd); 536 cur_usec = nfs_curusec(); 537 if (error && slp->ns_tq.lh_first && 538 slp->ns_tq.lh_first->nd_time <= cur_usec) { 539 error = 0; 540 cacherep = RC_DOIT; 541 writes_todo = 1; 542 } else { 543 writes_todo = 0; 544 } 545 nfsd->nfsd_flag |= NFSD_REQINPROG; 546 } else { 547 slp->ns_flag &= ~SLP_ACTION_MASK; 548 error = 0; 549 } 550 } else { 551 error = 0; 552 slp = nfsd->nfsd_slp; 553 554 lwkt_reltoken(&nfs_token); 555 lwkt_gettoken(&slp->ns_token); 556 557 if (slp->ns_needq_upcall) { 558 slp->ns_needq_upcall = 0; 559 slp->ns_flag |= SLP_NEEDQ; 560 } 561 if (NFSRV_RECLIMIT(slp) == 0 && 562 (slp->ns_flag & SLP_NEEDQ)) { 563 nfs_slplock(slp, 1); 564 if (NFSRV_RECLIMIT(slp) == 0 && 565 (slp->ns_flag & SLP_NEEDQ)) { 566 nfsrv_rcv(slp->ns_so, (caddr_t)slp, 567 M_WAITOK); 568 } 569 nfs_slpunlock(slp); 570 } 571 } 572 573 /* 574 * nfs_token not held here. slp token is held. 575 */ 576 if (error || (slp->ns_flag & SLP_VALID) == 0) { 577 if (nd) { 578 kfree((caddr_t)nd, M_NFSRVDESC); 579 nd = NULL; 580 } 581 nfsd->nfsd_flag &= ~NFSD_REQINPROG; 582 if (slp->ns_flag & SLP_ACTION_MASK) { 583 lwkt_reltoken(&slp->ns_token); 584 lwkt_gettoken(&nfs_token); 585 } else { 586 nfsd->nfsd_slp = NULL; 587 lwkt_reltoken(&slp->ns_token); 588 lwkt_gettoken(&nfs_token); 589 nfsrv_slpderef(slp); 590 } 591 continue; 592 } 593 sotype = slp->ns_so->so_type; 594 595 /* 596 * Execute the NFS request - handle the server side cache 597 * 598 * nfs_token not held here. slp token is held. 599 */ 600 if (nd) { 601 getmicrotime(&nd->nd_starttime); 602 if (nd->nd_nam2) 603 nd->nd_nam = nd->nd_nam2; 604 else 605 nd->nd_nam = slp->ns_nam; 606 607 /* 608 * Check to see if authorization is needed. 609 */ 610 if (nfsd->nfsd_flag & NFSD_NEEDAUTH) { 611 nfsd->nfsd_flag &= ~NFSD_NEEDAUTH; 612 nsd->nsd_haddr = 613 ((struct sockaddr_in *) 614 nd->nd_nam)->sin_addr.s_addr; 615 nsd->nsd_authlen = nfsd->nfsd_authlen; 616 nsd->nsd_verflen = nfsd->nfsd_verflen; 617 if (!copyout(nfsd->nfsd_authstr,nsd->nsd_authstr, 618 nfsd->nfsd_authlen) && 619 !copyout(nfsd->nfsd_verfstr, nsd->nsd_verfstr, 620 nfsd->nfsd_verflen) && 621 !copyout((caddr_t)nsd, argp, sizeof (*nsd))) 622 { 623 lwkt_reltoken(&slp->ns_token); 624 return (ENEEDAUTH); 625 } 626 cacherep = RC_DROPIT; 627 } else { 628 cacherep = nfsrv_getcache(nd, slp, &mreq); 629 } 630 631 if (nfsd->nfsd_flag & NFSD_AUTHFAIL) { 632 nfsd->nfsd_flag &= ~NFSD_AUTHFAIL; 633 nd->nd_procnum = NFSPROC_NOOP; 634 nd->nd_repstat = (NFSERR_AUTHERR | AUTH_TOOWEAK); 635 cacherep = RC_DOIT; 636 } else if (nfs_privport) { 637 /* Check if source port is privileged */ 638 u_short port; 639 struct sockaddr *nam = nd->nd_nam; 640 struct sockaddr_in *sin; 641 642 sin = (struct sockaddr_in *)nam; 643 port = ntohs(sin->sin_port); 644 if (port >= IPPORT_RESERVED && 645 nd->nd_procnum != NFSPROC_NULL) { 646 nd->nd_procnum = NFSPROC_NOOP; 647 nd->nd_repstat = (NFSERR_AUTHERR | AUTH_TOOWEAK); 648 cacherep = RC_DOIT; 649 kprintf("NFS request from unprivileged port (%s:%d)\n", 650 inet_ntoa(sin->sin_addr), port); 651 } 652 } 653 } 654 655 /* 656 * Execute the NFS request - direct execution 657 * 658 * Loop to get all the write rpc replies that have been 659 * gathered together. 660 * 661 * nfs_token not held here. slp token is held. 662 */ 663 do { 664 switch (cacherep) { 665 case RC_DOIT: 666 if (nd && (nd->nd_flag & ND_NFSV3)) 667 procrastinate = nfsrvw_procrastinate_v3; 668 else 669 procrastinate = nfsrvw_procrastinate; 670 if (writes_todo || (nd->nd_procnum == NFSPROC_WRITE && 671 procrastinate > 0) 672 ) { 673 error = nfsrv_writegather(&nd, slp, 674 nfsd->nfsd_td, &mreq); 675 } else { 676 /* NOT YET lwkt_reltoken(&slp->ns_token); */ 677 error = (*(nfsrv3_procs[nd->nd_procnum]))(nd, 678 slp, nfsd->nfsd_td, &mreq); 679 /* NOT YET lwkt_gettoken(&slp->ns_token); */ 680 lwpkthreaddeferred(); /* vnlru issues */ 681 } 682 if (mreq == NULL) 683 break; 684 if (error != 0 && error != NFSERR_RETVOID) { 685 if (nd->nd_procnum != NQNFSPROC_VACATED) 686 nfsstats.srv_errs++; 687 nfsrv_updatecache(nd, FALSE, mreq); 688 if (nd->nd_nam2) 689 kfree(nd->nd_nam2, M_SONAME); 690 break; 691 } 692 nfsstats.srvrpccnt[nd->nd_procnum]++; 693 nfsrv_updatecache(nd, TRUE, mreq); 694 nd->nd_mrep = NULL; 695 /* FALL THROUGH */ 696 case RC_REPLY: 697 m = mreq; 698 siz = 0; 699 while (m) { 700 siz += m->m_len; 701 m = m->m_next; 702 } 703 if (siz <= 0 || siz > NFS_MAXPACKET) { 704 kprintf("mbuf siz=%d\n",siz); 705 panic("Bad nfs svc reply"); 706 } 707 m = mreq; 708 m->m_pkthdr.len = siz; 709 m->m_pkthdr.rcvif = NULL; 710 /* 711 * For stream protocols, prepend a Sun RPC 712 * Record Mark. 713 */ 714 if (sotype == SOCK_STREAM) { 715 M_PREPEND(m, NFSX_UNSIGNED, M_WAITOK); 716 if (m == NULL) { 717 error = ENOBUFS; 718 slplocked = 0; 719 goto skip; 720 } 721 *mtod(m, u_int32_t *) = htonl(0x80000000 | siz); 722 } 723 if ((slp->ns_flag & SLP_VALID) && 724 (slp->ns_so->so_proto->pr_flags & PR_CONNREQUIRED)){ 725 nfs_slplock(slp, 1); 726 slplocked = 1; 727 } else { 728 slplocked = 0; 729 } 730 if (slp->ns_flag & SLP_VALID) { 731 error = nfs_send(slp->ns_so, nd->nd_nam2, m, NULL); 732 } else { 733 error = EPIPE; 734 m_freem(m); 735 } 736 skip: 737 if (nfsrtton) 738 nfsd_rt(sotype, nd, cacherep); 739 if (nd->nd_nam2) 740 kfree(nd->nd_nam2, M_SONAME); 741 if (nd->nd_mrep) 742 m_freem(nd->nd_mrep); 743 if (error == EPIPE || error == ENOBUFS) 744 nfsrv_zapsock(slp); 745 if (slplocked) 746 nfs_slpunlock(slp); 747 if (error == EINTR || error == ERESTART) { 748 kfree((caddr_t)nd, M_NFSRVDESC); 749 lwkt_reltoken(&slp->ns_token); 750 lwkt_gettoken(&nfs_token); 751 nfsd->nfsd_slp = NULL; 752 nfsrv_slpderef(slp); 753 goto done; 754 } 755 break; 756 case RC_DROPIT: 757 if (nfsrtton) 758 nfsd_rt(sotype, nd, cacherep); 759 m_freem(nd->nd_mrep); 760 if (nd->nd_nam2) 761 kfree(nd->nd_nam2, M_SONAME); 762 break; 763 } 764 if (nd) { 765 kfree((caddr_t)nd, M_NFSRVDESC); 766 nd = NULL; 767 } 768 769 /* 770 * Check to see if there are outstanding writes that 771 * need to be serviced. 772 */ 773 cur_usec = nfs_curusec(); 774 if (slp->ns_tq.lh_first && 775 slp->ns_tq.lh_first->nd_time <= cur_usec) { 776 cacherep = RC_DOIT; 777 writes_todo = 1; 778 } else { 779 writes_todo = 0; 780 } 781 } while (writes_todo); 782 783 /* 784 * nfs_token not held here. slp token is held. 785 */ 786 if (nfsrv_dorec(slp, nfsd, &nd)) { 787 nfsd->nfsd_flag &= ~NFSD_REQINPROG; 788 if (slp->ns_flag & SLP_ACTION_MASK) { 789 lwkt_reltoken(&slp->ns_token); 790 lwkt_gettoken(&nfs_token); 791 } else { 792 nfsd->nfsd_slp = NULL; 793 lwkt_reltoken(&slp->ns_token); 794 lwkt_gettoken(&nfs_token); 795 nfsrv_slpderef(slp); 796 } 797 } else { 798 lwkt_reltoken(&slp->ns_token); 799 lwkt_gettoken(&nfs_token); 800 } 801 } 802 done: 803 TAILQ_REMOVE(&nfsd_head, nfsd, nfsd_chain); 804 kfree((caddr_t)nfsd, M_NFSD); 805 nsd->nsd_nfsd = NULL; 806 if (--nfs_numnfsd == 0) 807 nfsrv_init(TRUE); /* Reinitialize everything */ 808 809 lwkt_reltoken(&nfs_token); 810 return (error); 811 } 812 813 /* 814 * Shut down a socket associated with an nfssvc_sock structure. 815 * Should be called with the send lock set, if required. 816 * 817 * The trick here is to increment the sref at the start, so that the nfsds 818 * will stop using it and clear ns_flag at the end so that it will not be 819 * reassigned during cleanup. 820 * 821 * That said, while we shutdown() the socket here, we don't actually destroy 822 * it until the final deref as there might be other code in the middle of 823 * using it. 824 */ 825 static void 826 nfsrv_zapsock(struct nfssvc_sock *slp) 827 { 828 struct nfsuid *nuidp, *nnuidp; 829 struct nfsrv_descript *nwp, *nnwp; 830 struct socket *so; 831 struct nfsrv_rec *rec; 832 int wasvalid; 833 834 wasvalid = slp->ns_flag & SLP_VALID; 835 slp->ns_flag &= ~SLP_ALLFLAGS; 836 if (wasvalid && slp->ns_fp) { 837 so = slp->ns_so; 838 atomic_clear_int(&so->so_rcv.ssb_flags, SSB_UPCALL); 839 so->so_upcall = NULL; 840 so->so_upcallarg = NULL; 841 soshutdown(so, SHUT_RDWR); 842 if (slp->ns_nam) { 843 kfree(slp->ns_nam, M_SONAME); 844 slp->ns_nam = NULL; 845 } 846 847 m_freem(slp->ns_raw); 848 slp->ns_raw = NULL; 849 850 while ((rec = STAILQ_FIRST(&slp->ns_rec)) != NULL) { 851 --slp->ns_numrec; 852 STAILQ_REMOVE_HEAD(&slp->ns_rec, nr_link); 853 if (rec->nr_address) 854 kfree(rec->nr_address, M_SONAME); 855 m_freem(rec->nr_packet); 856 kfree(rec, M_NFSRVDESC); 857 } 858 KKASSERT(slp->ns_numrec == 0); 859 860 TAILQ_FOREACH_MUTABLE(nuidp, &slp->ns_uidlruhead, nu_lru, 861 nnuidp) { 862 LIST_REMOVE(nuidp, nu_hash); 863 TAILQ_REMOVE(&slp->ns_uidlruhead, nuidp, nu_lru); 864 if (nuidp->nu_flag & NU_NAM) 865 kfree(nuidp->nu_nam, M_SONAME); 866 kfree((caddr_t)nuidp, M_NFSUID); 867 } 868 crit_enter(); /* XXX doesn't do anything any more */ 869 for (nwp = slp->ns_tq.lh_first; nwp; nwp = nnwp) { 870 nnwp = nwp->nd_tq.le_next; 871 LIST_REMOVE(nwp, nd_tq); 872 kfree((caddr_t)nwp, M_NFSRVDESC); 873 } 874 LIST_INIT(&slp->ns_tq); 875 crit_exit(); 876 877 nfsrv_slpderef(slp); 878 } 879 } 880 881 /* 882 * Derefence a server socket structure. If it has no more references and 883 * is no longer valid, you can throw it away. 884 * 885 * Must be holding nfs_token! 886 */ 887 void 888 nfsrv_slpderef(struct nfssvc_sock *slp) 889 { 890 struct file *fp; 891 892 ASSERT_LWKT_TOKEN_HELD(&nfs_token); 893 if (slp->ns_sref == 1) { 894 KKASSERT((slp->ns_flag & SLP_VALID) == 0); 895 TAILQ_REMOVE(&nfssvc_sockhead, slp, ns_chain); 896 slp->ns_sref = 0; 897 fp = slp->ns_fp; 898 slp->ns_fp = NULL; 899 slp->ns_so = NULL; 900 if (fp) 901 closef(fp, NULL); 902 kfree((caddr_t)slp, M_NFSSVC); 903 } else { 904 --slp->ns_sref; 905 } 906 } 907 908 void 909 nfsrv_slpref(struct nfssvc_sock *slp) 910 { 911 ASSERT_LWKT_TOKEN_HELD(&nfs_token); 912 ++slp->ns_sref; 913 } 914 915 /* 916 * Lock a socket against others. 917 * 918 * Returns 0 on failure, 1 on success. 919 */ 920 int 921 nfs_slplock(struct nfssvc_sock *slp, int wait) 922 { 923 mtx_t *mtx = &slp->ns_solock; 924 925 if (wait) { 926 mtx_lock_ex(mtx, 0, 0); 927 return(1); 928 } else if (mtx_lock_ex_try(mtx) == 0) { 929 return(1); 930 } else { 931 return(0); 932 } 933 } 934 935 /* 936 * Unlock the stream socket for others. 937 */ 938 void 939 nfs_slpunlock(struct nfssvc_sock *slp) 940 { 941 mtx_t *mtx = &slp->ns_solock; 942 943 mtx_unlock(mtx); 944 } 945 946 /* 947 * Initialize the data structures for the server. 948 * Handshake with any new nfsds starting up to avoid any chance of 949 * corruption. 950 */ 951 void 952 nfsrv_init(int terminating) 953 { 954 struct nfssvc_sock *slp, *nslp; 955 956 lwkt_gettoken(&nfs_token); 957 if (nfssvc_sockhead_flag & SLP_INIT) 958 panic("nfsd init"); 959 nfssvc_sockhead_flag |= SLP_INIT; 960 961 if (terminating) { 962 TAILQ_FOREACH_MUTABLE(slp, &nfssvc_sockhead, ns_chain, nslp) { 963 nfsrv_slpref(slp); 964 lwkt_gettoken(&slp->ns_token); 965 if (slp->ns_flag & SLP_VALID) 966 nfsrv_zapsock(slp); 967 lwkt_reltoken(&slp->ns_token); 968 nfsrv_slpderef(slp); 969 } 970 nfsrv_cleancache(); /* And clear out server cache */ 971 } else { 972 nfs_pub.np_valid = 0; 973 } 974 975 TAILQ_INIT(&nfssvc_sockhead); 976 nfssvc_sockhead_flag &= ~SLP_INIT; 977 if (nfssvc_sockhead_flag & SLP_WANTINIT) { 978 nfssvc_sockhead_flag &= ~SLP_WANTINIT; 979 wakeup((caddr_t)&nfssvc_sockhead); 980 } 981 982 TAILQ_INIT(&nfsd_head); 983 nfsd_head_flag &= ~NFSD_CHECKSLP; 984 985 lwkt_reltoken(&nfs_token); 986 987 #if 0 988 nfs_udpsock = (struct nfssvc_sock *) 989 kmalloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK | M_ZERO); 990 mtx_init(&nfs_udpsock->ns_solock); 991 STAILQ_INIT(&nfs_udpsock->ns_rec); 992 TAILQ_INIT(&nfs_udpsock->ns_uidlruhead); 993 TAILQ_INSERT_HEAD(&nfssvc_sockhead, nfs_udpsock, ns_chain); 994 995 nfs_cltpsock = (struct nfssvc_sock *) 996 kmalloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK | M_ZERO); 997 mtx_init(&nfs_cltpsock->ns_solock); 998 STAILQ_INIT(&nfs_cltpsock->ns_rec); 999 TAILQ_INIT(&nfs_cltpsock->ns_uidlruhead); 1000 TAILQ_INSERT_TAIL(&nfssvc_sockhead, nfs_cltpsock, ns_chain); 1001 #endif 1002 } 1003 1004 /* 1005 * Add entries to the server monitor log. 1006 */ 1007 static void 1008 nfsd_rt(int sotype, struct nfsrv_descript *nd, int cacherep) 1009 { 1010 struct drt *rt; 1011 1012 rt = &nfsdrt.drt[nfsdrt.pos]; 1013 if (cacherep == RC_DOIT) 1014 rt->flag = 0; 1015 else if (cacherep == RC_REPLY) 1016 rt->flag = DRT_CACHEREPLY; 1017 else 1018 rt->flag = DRT_CACHEDROP; 1019 if (sotype == SOCK_STREAM) 1020 rt->flag |= DRT_TCP; 1021 if (nd->nd_flag & ND_NFSV3) 1022 rt->flag |= DRT_NFSV3; 1023 rt->proc = nd->nd_procnum; 1024 if (nd->nd_nam->sa_family == AF_INET) 1025 rt->ipadr = ((struct sockaddr_in *)nd->nd_nam)->sin_addr.s_addr; 1026 else 1027 rt->ipadr = INADDR_ANY; 1028 rt->resptime = nfs_curusec() - (nd->nd_starttime.tv_sec * 1000000 + nd->nd_starttime.tv_usec); 1029 getmicrotime(&rt->tstamp); 1030 nfsdrt.pos = (nfsdrt.pos + 1) % NFSRTTLOGSIZ; 1031 } 1032 #endif /* NFS_NOSERVER */ 1033 1034 /* 1035 * Get an authorization string for the uid by having the mount_nfs sitting 1036 * on this mount point porpous out of the kernel and do it. 1037 */ 1038 int 1039 nfs_getauth(struct nfsmount *nmp, struct nfsreq *rep, 1040 struct ucred *cred, char **auth_str, int *auth_len, char *verf_str, 1041 int *verf_len, NFSKERBKEY_T key /* return session key */) 1042 { 1043 int error = 0; 1044 1045 while ((nmp->nm_state & NFSSTA_WAITAUTH) == 0) { 1046 nmp->nm_state |= NFSSTA_WANTAUTH; 1047 (void) tsleep((caddr_t)&nmp->nm_authtype, 0, 1048 "nfsauth1", 2 * hz); 1049 error = nfs_sigintr(nmp, rep, rep->r_td); 1050 if (error) { 1051 nmp->nm_state &= ~NFSSTA_WANTAUTH; 1052 return (error); 1053 } 1054 } 1055 nmp->nm_state &= ~(NFSSTA_WAITAUTH | NFSSTA_WANTAUTH); 1056 nmp->nm_authstr = *auth_str = (char *)kmalloc(RPCAUTH_MAXSIZ, M_TEMP, M_WAITOK); 1057 nmp->nm_authlen = RPCAUTH_MAXSIZ; 1058 nmp->nm_verfstr = verf_str; 1059 nmp->nm_verflen = *verf_len; 1060 nmp->nm_authuid = cred->cr_uid; 1061 wakeup((caddr_t)&nmp->nm_authstr); 1062 1063 /* 1064 * And wait for mount_nfs to do its stuff. 1065 */ 1066 while ((nmp->nm_state & NFSSTA_HASAUTH) == 0 && error == 0) { 1067 (void) tsleep((caddr_t)&nmp->nm_authlen, 0, 1068 "nfsauth2", 2 * hz); 1069 error = nfs_sigintr(nmp, rep, rep->r_td); 1070 } 1071 if (nmp->nm_state & NFSSTA_AUTHERR) { 1072 nmp->nm_state &= ~NFSSTA_AUTHERR; 1073 error = EAUTH; 1074 } 1075 if (error) 1076 kfree((caddr_t)*auth_str, M_TEMP); 1077 else { 1078 *auth_len = nmp->nm_authlen; 1079 *verf_len = nmp->nm_verflen; 1080 bcopy((caddr_t)nmp->nm_key, (caddr_t)key, sizeof (NFSKERBKEY_T)); 1081 } 1082 nmp->nm_state &= ~NFSSTA_HASAUTH; 1083 nmp->nm_state |= NFSSTA_WAITAUTH; 1084 if (nmp->nm_state & NFSSTA_WANTAUTH) { 1085 nmp->nm_state &= ~NFSSTA_WANTAUTH; 1086 wakeup((caddr_t)&nmp->nm_authtype); 1087 } 1088 return (error); 1089 } 1090 1091 /* 1092 * Get a nickname authenticator and verifier. 1093 */ 1094 int 1095 nfs_getnickauth(struct nfsmount *nmp, struct ucred *cred, char **auth_str, 1096 int *auth_len, char *verf_str, int verf_len) 1097 { 1098 struct nfsuid *nuidp; 1099 u_int32_t *nickp, *verfp; 1100 struct timeval ktvout; 1101 1102 #ifdef DIAGNOSTIC 1103 if (verf_len < (4 * NFSX_UNSIGNED)) 1104 panic("nfs_getnickauth verf too small"); 1105 #endif 1106 for (nuidp = NMUIDHASH(nmp, cred->cr_uid)->lh_first; 1107 nuidp != NULL; nuidp = nuidp->nu_hash.le_next) { 1108 if (nuidp->nu_cr.cr_uid == cred->cr_uid) 1109 break; 1110 } 1111 if (!nuidp || nuidp->nu_expire < time_uptime) 1112 return (EACCES); 1113 1114 /* 1115 * Move to the end of the lru list (end of lru == most recently used). 1116 */ 1117 TAILQ_REMOVE(&nmp->nm_uidlruhead, nuidp, nu_lru); 1118 TAILQ_INSERT_TAIL(&nmp->nm_uidlruhead, nuidp, nu_lru); 1119 1120 nickp = (u_int32_t *)kmalloc(2 * NFSX_UNSIGNED, M_TEMP, M_WAITOK); 1121 *nickp++ = txdr_unsigned(RPCAKN_NICKNAME); 1122 *nickp = txdr_unsigned(nuidp->nu_nickname); 1123 *auth_str = (char *)nickp; 1124 *auth_len = 2 * NFSX_UNSIGNED; 1125 1126 /* 1127 * Now we must encrypt the verifier and package it up. 1128 */ 1129 verfp = (u_int32_t *)verf_str; 1130 *verfp++ = txdr_unsigned(RPCAKN_NICKNAME); 1131 if (time_second != nuidp->nu_timestamp.tv_sec || 1132 (time_second == nuidp->nu_timestamp.tv_sec && 1133 time_second > nuidp->nu_timestamp.tv_usec)) /* XXX */ 1134 getmicrotime(&nuidp->nu_timestamp); 1135 else 1136 nuidp->nu_timestamp.tv_usec++; 1137 1138 /* 1139 * Now encrypt the timestamp verifier in ecb mode using the session 1140 * key. 1141 */ 1142 #ifdef NFSKERB 1143 XXX 1144 #else 1145 ktvout.tv_sec = 0; 1146 ktvout.tv_usec = 0; 1147 #endif 1148 1149 *verfp++ = ktvout.tv_sec; 1150 *verfp++ = ktvout.tv_usec; 1151 *verfp = 0; 1152 return (0); 1153 } 1154 1155 /* 1156 * Save the current nickname in a hash list entry on the mount point. 1157 */ 1158 int 1159 nfs_savenickauth(struct nfsmount *nmp, struct ucred *cred, int len, 1160 NFSKERBKEY_T key, struct mbuf **mdp, char **dposp, 1161 struct mbuf *mrep) 1162 { 1163 struct nfsuid *nuidp; 1164 u_int32_t *tl; 1165 struct timeval ktvin, ktvout; 1166 u_int32_t nick; 1167 int deltasec, error = 0; 1168 struct nfsm_info info; 1169 1170 info.md = *mdp; 1171 info.dpos = *dposp; 1172 info.mrep = mrep; 1173 1174 if (len == (3 * NFSX_UNSIGNED)) { 1175 NULLOUT(tl = nfsm_dissect(&info, 3 * NFSX_UNSIGNED)); 1176 ktvin.tv_sec = *tl++; 1177 ktvin.tv_usec = *tl++; 1178 nick = fxdr_unsigned(u_int32_t, *tl); 1179 1180 /* 1181 * Decrypt the timestamp in ecb mode. 1182 */ 1183 #ifdef NFSKERB 1184 XXX 1185 #else 1186 ktvout.tv_sec = 0; 1187 ktvout.tv_usec = 0; 1188 #endif 1189 ktvout.tv_sec = fxdr_unsigned(long, ktvout.tv_sec); 1190 ktvout.tv_usec = fxdr_unsigned(long, ktvout.tv_usec); 1191 deltasec = time_second - ktvout.tv_sec; 1192 if (deltasec < 0) 1193 deltasec = -deltasec; 1194 /* 1195 * If ok, add it to the hash list for the mount point. 1196 */ 1197 if (deltasec <= NFS_KERBCLOCKSKEW) { 1198 if (nmp->nm_numuids < nuidhash_max) { 1199 nmp->nm_numuids++; 1200 nuidp = (struct nfsuid *) 1201 kmalloc(sizeof (struct nfsuid), M_NFSUID, 1202 M_WAITOK); 1203 } else { 1204 nuidp = TAILQ_FIRST(&nmp->nm_uidlruhead); 1205 LIST_REMOVE(nuidp, nu_hash); 1206 TAILQ_REMOVE(&nmp->nm_uidlruhead, nuidp, 1207 nu_lru); 1208 } 1209 nuidp->nu_flag = 0; 1210 nuidp->nu_cr.cr_uid = cred->cr_uid; 1211 nuidp->nu_expire = time_uptime + NFS_KERBTTL; 1212 nuidp->nu_timestamp = ktvout; 1213 nuidp->nu_nickname = nick; 1214 bcopy(key, nuidp->nu_key, sizeof (NFSKERBKEY_T)); 1215 TAILQ_INSERT_TAIL(&nmp->nm_uidlruhead, nuidp, 1216 nu_lru); 1217 LIST_INSERT_HEAD(NMUIDHASH(nmp, cred->cr_uid), 1218 nuidp, nu_hash); 1219 } 1220 } else { 1221 ERROROUT(nfsm_adv(&info, nfsm_rndup(len))); 1222 } 1223 nfsmout: 1224 *mdp = info.md; 1225 *dposp = info.dpos; 1226 return (error); 1227 } 1228