339#endif 340#define NMUIDHASH(nmp, uid) \ 341 (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ]) 342#define NFSNOHASH(fhsum) \ 343 (&nfsnodehashtbl[(fhsum) & nfsnodehash]) 344 345/* 346 * Network address hash list element 347 */ 348union nethostaddr { 349 u_long had_inetaddr; 350 struct mbuf *had_nam; 351}; 352 353struct nfsuid { 354 TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */ 355 LIST_ENTRY(nfsuid) nu_hash; /* Hash list */ 356 int nu_flag; /* Flags */ 357 union nethostaddr nu_haddr; /* Host addr. for dgram sockets */ 358 struct ucred nu_cr; /* Cred uid mapped to */ 359 int nu_expire; /* Expiry time (sec) */ 360 struct timeval nu_timestamp; /* Kerb. timestamp */ 361 u_long nu_nickname; /* Nickname on server */ 362 NFSKERBKEY_T nu_key; /* and session key */ 363}; 364 365#define nu_inetaddr nu_haddr.had_inetaddr 366#define nu_nam nu_haddr.had_nam 367/* Bits for nu_flag */ 368#define NU_INETADDR 0x1 369#define NU_NAM 0x2 370#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO) 371 372struct nfssvc_sock { 373 TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */ 374 TAILQ_HEAD(, nfsuid) ns_uidlruhead; 375 struct file *ns_fp; 376 struct socket *ns_so; 377 struct mbuf *ns_nam; 378 struct mbuf *ns_raw; 379 struct mbuf *ns_rawend; 380 struct mbuf *ns_rec; 381 struct mbuf *ns_recend; 382 struct mbuf *ns_frag; 383 int ns_flag; 384 int ns_solock; 385 int ns_cc; 386 int ns_reclen; 387 int ns_numuids; 388 u_long ns_sref; 389 LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */ 390 LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ]; 391 LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ]; 392}; 393 394/* Bits for "ns_flag" */ 395#define SLP_VALID 0x01 396#define SLP_DOREC 0x02 397#define SLP_NEEDQ 0x04 398#define SLP_DISCONN 0x08 399#define SLP_GETSTREAM 0x10 400#define SLP_LASTFRAG 0x20 401#define SLP_ALLFLAGS 0xff 402 403extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead; 404extern int nfssvc_sockhead_flag; 405#define SLP_INIT 0x01 406#define SLP_WANTINIT 0x02 407 408/* 409 * One of these structures is allocated for each nfsd. 410 */ 411struct nfsd { 412 TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */ 413 int nfsd_flag; /* NFSD_ flags */ 414 struct nfssvc_sock *nfsd_slp; /* Current socket */ 415 int nfsd_authlen; /* Authenticator len */ 416 u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ 417 int nfsd_verflen; /* and the Verifier */ 418 u_char nfsd_verfstr[RPCVERF_MAXSIZ]; 419 struct proc *nfsd_procp; /* Proc ptr */ 420 struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ 421}; 422 423/* Bits for "nfsd_flag" */ 424#define NFSD_WAITING 0x01 425#define NFSD_REQINPROG 0x02 426#define NFSD_NEEDAUTH 0x04 427#define NFSD_AUTHFAIL 0x08 428 429/* 430 * This structure is used by the server for describing each request. 431 * Some fields are used only when write request gathering is performed. 432 */ 433struct nfsrv_descript { 434 u_quad_t nd_time; /* Write deadline (usec) */ 435 off_t nd_off; /* Start byte offset */ 436 off_t nd_eoff; /* and end byte offset */ 437 LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */ 438 LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */ 439 LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */ 440 struct mbuf *nd_mrep; /* Request mbuf list */ 441 struct mbuf *nd_md; /* Current dissect mbuf */ 442 struct mbuf *nd_mreq; /* Reply mbuf list */ 443 struct mbuf *nd_nam; /* and socket addr */ 444 struct mbuf *nd_nam2; /* return socket addr */ 445 caddr_t nd_dpos; /* Current dissect pos */ 446 int nd_procnum; /* RPC # */ 447 int nd_stable; /* storage type */ 448 int nd_flag; /* nd_flag */ 449 int nd_len; /* Length of this write */ 450 int nd_repstat; /* Reply status */ 451 u_long nd_retxid; /* Reply xid */ 452 u_long nd_duration; /* Lease duration */ 453 struct timeval nd_starttime; /* Time RPC initiated */ 454 fhandle_t nd_fh; /* File handle */ 455 struct ucred nd_cr; /* Credentials */ 456}; 457 458/* Bits for "nd_flag" */ 459#define ND_READ LEASE_READ 460#define ND_WRITE LEASE_WRITE 461#define ND_CHECK 0x04 462#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK) 463#define ND_NFSV3 0x08 464#define ND_NQNFS 0x10 465#define ND_KERBNICK 0x20 466#define ND_KERBFULL 0x40 467#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL) 468 469extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head; 470extern int nfsd_head_flag; 471#define NFSD_CHECKSLP 0x01 472 473/* 474 * These macros compare nfsrv_descript structures. 475 */ 476#define NFSW_CONTIG(o, n) \ 477 ((o)->nd_eoff >= (n)->nd_off && \ 478 !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH)) 479 480#define NFSW_SAMECRED(o, n) \ 481 (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \ 482 !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \ 483 sizeof (struct ucred))) 484 485int nfs_reply __P((struct nfsreq *)); 486int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int)); 487int nfs_send __P((struct socket *,struct mbuf *,struct mbuf *,struct nfsreq *)); 488int nfs_rephead __P((int,struct nfsrv_descript *,struct nfssvc_sock *,int,int,u_quad_t *,struct mbuf **,struct mbuf **,caddr_t *)); 489int nfs_sndlock __P((int *,struct nfsreq *)); 490void nfs_sndunlock __P((int *flagp)); 491int nfs_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); 492int nfs_vinvalbuf __P((struct vnode *,int,struct ucred *,struct proc *,int)); 493int nfs_readrpc __P((struct vnode *,struct uio *,struct ucred *)); 494int nfs_writerpc __P((struct vnode *,struct uio *,struct ucred *,int *,int *)); 495int nfs_readdirrpc __P((register struct vnode *,struct uio *,struct ucred *)); 496int nfs_asyncio __P((struct buf *,struct ucred *)); 497int nfs_doio __P((struct buf *,struct ucred *,struct proc *)); 498int nfs_readlinkrpc __P((struct vnode *,struct uio *,struct ucred *)); 499int nfs_sigintr __P((struct nfsmount *,struct nfsreq *r,struct proc *)); 500int nfs_readdirplusrpc __P((struct vnode *,register struct uio *,struct ucred *)); 501int nfsm_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); 502void nfsm_srvfattr __P((struct nfsrv_descript *,struct vattr *,struct nfs_fattr *)); 503void nfsm_srvwcc __P((struct nfsrv_descript *,int,struct vattr *,int,struct vattr *,struct mbuf **,char **)); 504void nfsm_srvpostopattr __P((struct nfsrv_descript *,int,struct vattr *,struct mbuf **,char **)); 505int netaddr_match __P((int,union nethostaddr *,struct mbuf *)); 506int nfs_request __P((struct vnode *,struct mbuf *,int,struct proc *,struct ucred *,struct mbuf **,struct mbuf **,caddr_t *)); 507int nfs_loadattrcache __P((struct vnode **,struct mbuf **,caddr_t *,struct vattr *)); 508int nfs_namei __P((struct nameidata *,fhandle_t *,int,struct nfssvc_sock *,struct mbuf *,struct mbuf **,caddr_t *,struct vnode **,struct proc *,int)); 509void nfsm_adj __P((struct mbuf *,int,int)); 510int nfsm_mbuftouio __P((struct mbuf **,struct uio *,int,caddr_t *)); 511void nfsrv_initcache __P((void)); 512int nfs_getauth __P((struct nfsmount *,struct nfsreq *,struct ucred *,char **,int *,char *,int *,NFSKERBKEY_T)); 513int nfs_getnickauth __P((struct nfsmount *,struct ucred *,char **,int *,char *,int)); 514int nfs_savenickauth __P((struct nfsmount *,struct ucred *,int,NFSKERBKEY_T,struct mbuf **,char **,struct mbuf *)); 515int nfs_adv __P((struct mbuf **,caddr_t *,int,int)); 516void nfs_nhinit __P((void)); 517void nfs_timer __P((void*)); 518u_long nfs_hash __P((nfsfh_t *,int)); 519void nfsrv_slpderef __P((struct nfssvc_sock *slp)); 520int nfsrv_dorec __P((struct nfssvc_sock *,struct nfsd *,struct nfsrv_descript **)); 521void nfsrv_cleancache __P((void)); 522int nfsrv_getcache __P((struct nfsrv_descript *,struct nfssvc_sock *,struct mbuf **)); 523int nfs_init __P((void)); 524void nfsrv_updatecache __P((struct nfsrv_descript *,int,struct mbuf *)); 525int nfs_connect __P((struct nfsmount *,struct nfsreq *)); 526void nfs_disconnect __P((struct nfsmount *nmp)); 527int nfs_getattrcache __P((struct vnode *,struct vattr *)); 528int nfsm_strtmbuf __P((struct mbuf **,char **,char *,long)); 529int nfs_bioread __P((struct vnode *,struct uio *,int,struct ucred *)); 530int nfsm_uiotombuf __P((struct uio *,struct mbuf **,int,caddr_t *)); 531void nfsrv_init __P((int)); 532void nfs_clearcommit __P((struct mount *)); 533int nfsrv_errmap __P((struct nfsrv_descript *, int)); 534void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag)); 535void nfsrvw_sort __P((gid_t [],int)); 536void nfsrv_setcred __P((struct ucred *,struct ucred *)); 537int nfs_writebp __P((struct buf *,int)); 538int nfsrv_object_create __P(( struct vnode * )); 539void nfsrv_wakenfsd __P((struct nfssvc_sock *slp)); 540int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *, 541 struct proc *, struct mbuf **)); 542int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, 543 struct proc *p)); 544 545int nfsrv3_access __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 546 struct proc *procp, struct mbuf **mrq)); 547int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 548 struct proc *procp, struct mbuf **mrq)); 549int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 550 struct proc *procp, struct mbuf **mrq)); 551int nfsrv_fhtovp __P((fhandle_t *,int,struct vnode **, 552 struct ucred *,struct nfssvc_sock *,struct mbuf *, 553 int *,int)); 554int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 555 struct proc *procp, struct mbuf **mrq)); 556int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 557 struct proc *procp, struct mbuf **mrq)); 558int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 559 struct proc *procp, struct mbuf **mrq)); 560int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 561 struct proc *procp, struct mbuf **mrq)); 562int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 563 struct proc *procp, struct mbuf **mrq)); 564int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 565 struct proc *procp, struct mbuf **mrq)); 566int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 567 struct proc *procp, struct mbuf **mrq)); 568int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 569 struct proc *procp, struct mbuf **mrq)); 570int nfsrv_pathconf __P((struct nfsrv_descript *nfsd, 571 struct nfssvc_sock *slp, struct proc *procp, 572 struct mbuf **mrq)); 573int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 574 struct proc *procp, struct mbuf **mrq)); 575int nfsrv_readdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 576 struct proc *procp, struct mbuf **mrq)); 577int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd, 578 struct nfssvc_sock *slp, struct proc *procp, 579 struct mbuf **mrq)); 580int nfsrv_readlink __P((struct nfsrv_descript *nfsd, 581 struct nfssvc_sock *slp, struct proc *procp, 582 struct mbuf **mrq)); 583int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 584 struct proc *procp, struct mbuf **mrq)); 585int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 586 struct proc *procp, struct mbuf **mrq)); 587int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 588 struct proc *procp, struct mbuf **mrq)); 589int nfsrv_setattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 590 struct proc *procp, struct mbuf **mrq)); 591int nfsrv_statfs __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 592 struct proc *procp, struct mbuf **mrq)); 593int nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 594 struct proc *procp, struct mbuf **mrq)); 595int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 596 struct proc *procp, struct mbuf **mrq)); 597 598 599#endif /* KERNEL */ 600 601#endif
|