nfs_nfsiod.c (33181) | nfs_nfsiod.c (34961) |
---|---|
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 --- 20 unchanged lines hidden (view full) --- 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95 | 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 --- 20 unchanged lines hidden (view full) --- 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95 |
37 * $Id: nfs_syscalls.c,v 1.35 1998/02/06 12:13:57 eivind Exp $ | 37 * $Id: nfs_syscalls.c,v 1.36 1998/02/09 06:10:37 eivind Exp $ |
38 */ 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/sysproto.h> 43#include <sys/kernel.h> 44#include <sys/sysctl.h> 45#include <sys/file.h> --- 249 unchanged lines hidden (view full) --- 295 FREE(nuidp->nu_nam, M_SONAME); 296 } 297 nuidp->nu_flag = 0; 298 nuidp->nu_cr = nsd->nsd_cr; 299 if (nuidp->nu_cr.cr_ngroups > NGROUPS) 300 nuidp->nu_cr.cr_ngroups = NGROUPS; 301 nuidp->nu_cr.cr_ref = 1; 302 nuidp->nu_timestamp = nsd->nsd_timestamp; | 38 */ 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/sysproto.h> 43#include <sys/kernel.h> 44#include <sys/sysctl.h> 45#include <sys/file.h> --- 249 unchanged lines hidden (view full) --- 295 FREE(nuidp->nu_nam, M_SONAME); 296 } 297 nuidp->nu_flag = 0; 298 nuidp->nu_cr = nsd->nsd_cr; 299 if (nuidp->nu_cr.cr_ngroups > NGROUPS) 300 nuidp->nu_cr.cr_ngroups = NGROUPS; 301 nuidp->nu_cr.cr_ref = 1; 302 nuidp->nu_timestamp = nsd->nsd_timestamp; |
303 nuidp->nu_expire = time.tv_sec + nsd->nsd_ttl; | 303 nuidp->nu_expire = time_second + nsd->nsd_ttl; |
304 /* 305 * and save the session key in nu_key. 306 */ 307 bcopy(nsd->nsd_key, nuidp->nu_key, 308 sizeof (nsd->nsd_key)); 309 if (nfsd->nfsd_nd->nd_nam2) { 310 struct sockaddr_in *saddr; 311 --- 203 unchanged lines hidden (view full) --- 515 slp->ns_flag &= ~SLP_NEEDQ; 516 (void) nfs_sndlock(&slp->ns_solock, 517 (struct nfsreq *)0); 518 nfsrv_rcv(slp->ns_so, (caddr_t)slp, 519 M_WAIT); 520 nfs_sndunlock(&slp->ns_solock); 521 } 522 error = nfsrv_dorec(slp, nfsd, &nd); | 304 /* 305 * and save the session key in nu_key. 306 */ 307 bcopy(nsd->nsd_key, nuidp->nu_key, 308 sizeof (nsd->nsd_key)); 309 if (nfsd->nfsd_nd->nd_nam2) { 310 struct sockaddr_in *saddr; 311 --- 203 unchanged lines hidden (view full) --- 515 slp->ns_flag &= ~SLP_NEEDQ; 516 (void) nfs_sndlock(&slp->ns_solock, 517 (struct nfsreq *)0); 518 nfsrv_rcv(slp->ns_so, (caddr_t)slp, 519 M_WAIT); 520 nfs_sndunlock(&slp->ns_solock); 521 } 522 error = nfsrv_dorec(slp, nfsd, &nd); |
523 cur_usec = (u_quad_t)time.tv_sec * 1000000 + 524 (u_quad_t)time.tv_usec; | 523 cur_usec = nfs_curusec(); |
525 if (error && slp->ns_tq.lh_first && 526 slp->ns_tq.lh_first->nd_time <= cur_usec) { 527 error = 0; 528 cacherep = RC_DOIT; 529 writes_todo = 1; 530 } else 531 writes_todo = 0; 532 nfsd->nfsd_flag |= NFSD_REQINPROG; --- 15 unchanged lines hidden (view full) --- 548 splx(s); 549 so = slp->ns_so; 550 sotype = so->so_type; 551 if (so->so_proto->pr_flags & PR_CONNREQUIRED) 552 solockp = &slp->ns_solock; 553 else 554 solockp = (int *)0; 555 if (nd) { | 524 if (error && slp->ns_tq.lh_first && 525 slp->ns_tq.lh_first->nd_time <= cur_usec) { 526 error = 0; 527 cacherep = RC_DOIT; 528 writes_todo = 1; 529 } else 530 writes_todo = 0; 531 nfsd->nfsd_flag |= NFSD_REQINPROG; --- 15 unchanged lines hidden (view full) --- 547 splx(s); 548 so = slp->ns_so; 549 sotype = so->so_type; 550 if (so->so_proto->pr_flags & PR_CONNREQUIRED) 551 solockp = &slp->ns_solock; 552 else 553 solockp = (int *)0; 554 if (nd) { |
556 gettime(&nd->nd_starttime); | 555 getmicrotime(&nd->nd_starttime); |
557 if (nd->nd_nam2) 558 nd->nd_nam = nd->nd_nam2; 559 else 560 nd->nd_nam = slp->ns_nam; 561 562 /* 563 * Check to see if authorization is needed. 564 */ --- 13 unchanged lines hidden (view full) --- 578 cacherep = RC_DROPIT; 579 } else 580 cacherep = nfsrv_getcache(nd, slp, &mreq); 581 582 /* 583 * Check for just starting up for NQNFS and send 584 * fake "try again later" replies to the NQNFS clients. 585 */ | 556 if (nd->nd_nam2) 557 nd->nd_nam = nd->nd_nam2; 558 else 559 nd->nd_nam = slp->ns_nam; 560 561 /* 562 * Check to see if authorization is needed. 563 */ --- 13 unchanged lines hidden (view full) --- 577 cacherep = RC_DROPIT; 578 } else 579 cacherep = nfsrv_getcache(nd, slp, &mreq); 580 581 /* 582 * Check for just starting up for NQNFS and send 583 * fake "try again later" replies to the NQNFS clients. 584 */ |
586 if (notstarted && nqnfsstarttime <= time.tv_sec) { | 585 if (notstarted && nqnfsstarttime <= time_second) { |
587 if (modify_flag) { | 586 if (modify_flag) { |
588 nqnfsstarttime = time.tv_sec + nqsrv_writeslack; | 587 nqnfsstarttime = time_second + nqsrv_writeslack; |
589 modify_flag = 0; 590 } else 591 notstarted = 0; 592 } 593 if (notstarted) { 594 if ((nd->nd_flag & ND_NQNFS) == 0) 595 cacherep = RC_DROPIT; 596 else if (nd->nd_procnum != NFSPROC_WRITE) { --- 116 unchanged lines hidden (view full) --- 713 FREE((caddr_t)nd, M_NFSRVDESC); 714 nd = NULL; 715 } 716 717 /* 718 * Check to see if there are outstanding writes that 719 * need to be serviced. 720 */ | 588 modify_flag = 0; 589 } else 590 notstarted = 0; 591 } 592 if (notstarted) { 593 if ((nd->nd_flag & ND_NQNFS) == 0) 594 cacherep = RC_DROPIT; 595 else if (nd->nd_procnum != NFSPROC_WRITE) { --- 116 unchanged lines hidden (view full) --- 712 FREE((caddr_t)nd, M_NFSRVDESC); 713 nd = NULL; 714 } 715 716 /* 717 * Check to see if there are outstanding writes that 718 * need to be serviced. 719 */ |
721 cur_usec = (u_quad_t)time.tv_sec * 1000000 + 722 (u_quad_t)time.tv_usec; | 720 cur_usec = nfs_curusec(); |
723 s = splsoftclock(); 724 if (slp->ns_tq.lh_first && 725 slp->ns_tq.lh_first->nd_time <= cur_usec) { 726 cacherep = RC_DOIT; 727 writes_todo = 1; 728 } else 729 writes_todo = 0; 730 splx(s); --- 236 unchanged lines hidden (view full) --- 967 if (verf_len < (4 * NFSX_UNSIGNED)) 968 panic("nfs_getnickauth verf too small"); 969#endif 970 for (nuidp = NMUIDHASH(nmp, cred->cr_uid)->lh_first; 971 nuidp != 0; nuidp = nuidp->nu_hash.le_next) { 972 if (nuidp->nu_cr.cr_uid == cred->cr_uid) 973 break; 974 } | 721 s = splsoftclock(); 722 if (slp->ns_tq.lh_first && 723 slp->ns_tq.lh_first->nd_time <= cur_usec) { 724 cacherep = RC_DOIT; 725 writes_todo = 1; 726 } else 727 writes_todo = 0; 728 splx(s); --- 236 unchanged lines hidden (view full) --- 965 if (verf_len < (4 * NFSX_UNSIGNED)) 966 panic("nfs_getnickauth verf too small"); 967#endif 968 for (nuidp = NMUIDHASH(nmp, cred->cr_uid)->lh_first; 969 nuidp != 0; nuidp = nuidp->nu_hash.le_next) { 970 if (nuidp->nu_cr.cr_uid == cred->cr_uid) 971 break; 972 } |
975 if (!nuidp || nuidp->nu_expire < time.tv_sec) | 973 if (!nuidp || nuidp->nu_expire < time_second) |
976 return (EACCES); 977 978 /* 979 * Move to the end of the lru list (end of lru == most recently used). 980 */ 981 TAILQ_REMOVE(&nmp->nm_uidlruhead, nuidp, nu_lru); 982 TAILQ_INSERT_TAIL(&nmp->nm_uidlruhead, nuidp, nu_lru); 983 984 nickp = (u_long *)malloc(2 * NFSX_UNSIGNED, M_TEMP, M_WAITOK); 985 *nickp++ = txdr_unsigned(RPCAKN_NICKNAME); 986 *nickp = txdr_unsigned(nuidp->nu_nickname); 987 *auth_str = (char *)nickp; 988 *auth_len = 2 * NFSX_UNSIGNED; 989 990 /* 991 * Now we must encrypt the verifier and package it up. 992 */ 993 verfp = (u_long *)verf_str; 994 *verfp++ = txdr_unsigned(RPCAKN_NICKNAME); | 974 return (EACCES); 975 976 /* 977 * Move to the end of the lru list (end of lru == most recently used). 978 */ 979 TAILQ_REMOVE(&nmp->nm_uidlruhead, nuidp, nu_lru); 980 TAILQ_INSERT_TAIL(&nmp->nm_uidlruhead, nuidp, nu_lru); 981 982 nickp = (u_long *)malloc(2 * NFSX_UNSIGNED, M_TEMP, M_WAITOK); 983 *nickp++ = txdr_unsigned(RPCAKN_NICKNAME); 984 *nickp = txdr_unsigned(nuidp->nu_nickname); 985 *auth_str = (char *)nickp; 986 *auth_len = 2 * NFSX_UNSIGNED; 987 988 /* 989 * Now we must encrypt the verifier and package it up. 990 */ 991 verfp = (u_long *)verf_str; 992 *verfp++ = txdr_unsigned(RPCAKN_NICKNAME); |
995 if (time.tv_sec > nuidp->nu_timestamp.tv_sec || 996 (time.tv_sec == nuidp->nu_timestamp.tv_sec && 997 time.tv_usec > nuidp->nu_timestamp.tv_usec)) 998 gettime(&nuidp->nu_timestamp); | 993 if (time_second > nuidp->nu_timestamp.tv_sec || 994 (time_second == nuidp->nu_timestamp.tv_sec && 995 time_second > nuidp->nu_timestamp.tv_usec)) 996 getmicrotime(&nuidp->nu_timestamp); |
999 else 1000 nuidp->nu_timestamp.tv_usec++; 1001 ktvin.tv_sec = txdr_unsigned(nuidp->nu_timestamp.tv_sec); 1002 ktvin.tv_usec = txdr_unsigned(nuidp->nu_timestamp.tv_usec); 1003 1004 /* 1005 * Now encrypt the timestamp verifier in ecb mode using the session 1006 * key. --- 39 unchanged lines hidden (view full) --- 1046 /* 1047 * Decrypt the timestamp in ecb mode. 1048 */ 1049#ifdef NFSKERB 1050 XXX 1051#endif 1052 ktvout.tv_sec = fxdr_unsigned(long, ktvout.tv_sec); 1053 ktvout.tv_usec = fxdr_unsigned(long, ktvout.tv_usec); | 997 else 998 nuidp->nu_timestamp.tv_usec++; 999 ktvin.tv_sec = txdr_unsigned(nuidp->nu_timestamp.tv_sec); 1000 ktvin.tv_usec = txdr_unsigned(nuidp->nu_timestamp.tv_usec); 1001 1002 /* 1003 * Now encrypt the timestamp verifier in ecb mode using the session 1004 * key. --- 39 unchanged lines hidden (view full) --- 1044 /* 1045 * Decrypt the timestamp in ecb mode. 1046 */ 1047#ifdef NFSKERB 1048 XXX 1049#endif 1050 ktvout.tv_sec = fxdr_unsigned(long, ktvout.tv_sec); 1051 ktvout.tv_usec = fxdr_unsigned(long, ktvout.tv_usec); |
1054 deltasec = time.tv_sec - ktvout.tv_sec; | 1052 deltasec = time_second - ktvout.tv_sec; |
1055 if (deltasec < 0) 1056 deltasec = -deltasec; 1057 /* 1058 * If ok, add it to the hash list for the mount point. 1059 */ 1060 if (deltasec <= NFS_KERBCLOCKSKEW) { 1061 if (nmp->nm_numuids < nuidhash_max) { 1062 nmp->nm_numuids++; 1063 nuidp = (struct nfsuid *) 1064 malloc(sizeof (struct nfsuid), M_NFSUID, 1065 M_WAITOK); 1066 } else { 1067 nuidp = nmp->nm_uidlruhead.tqh_first; 1068 LIST_REMOVE(nuidp, nu_hash); 1069 TAILQ_REMOVE(&nmp->nm_uidlruhead, nuidp, 1070 nu_lru); 1071 } 1072 nuidp->nu_flag = 0; 1073 nuidp->nu_cr.cr_uid = cred->cr_uid; | 1053 if (deltasec < 0) 1054 deltasec = -deltasec; 1055 /* 1056 * If ok, add it to the hash list for the mount point. 1057 */ 1058 if (deltasec <= NFS_KERBCLOCKSKEW) { 1059 if (nmp->nm_numuids < nuidhash_max) { 1060 nmp->nm_numuids++; 1061 nuidp = (struct nfsuid *) 1062 malloc(sizeof (struct nfsuid), M_NFSUID, 1063 M_WAITOK); 1064 } else { 1065 nuidp = nmp->nm_uidlruhead.tqh_first; 1066 LIST_REMOVE(nuidp, nu_hash); 1067 TAILQ_REMOVE(&nmp->nm_uidlruhead, nuidp, 1068 nu_lru); 1069 } 1070 nuidp->nu_flag = 0; 1071 nuidp->nu_cr.cr_uid = cred->cr_uid; |
1074 nuidp->nu_expire = time.tv_sec + NFS_KERBTTL; | 1072 nuidp->nu_expire = time_second + NFS_KERBTTL; |
1075 nuidp->nu_timestamp = ktvout; 1076 nuidp->nu_nickname = nick; 1077 bcopy(key, nuidp->nu_key, sizeof (key)); 1078 TAILQ_INSERT_TAIL(&nmp->nm_uidlruhead, nuidp, 1079 nu_lru); 1080 LIST_INSERT_HEAD(NMUIDHASH(nmp, cred->cr_uid), 1081 nuidp, nu_hash); 1082 } --- 96 unchanged lines hidden (view full) --- 1179 rt->flag |= DRT_NQNFS; 1180 else if (nd->nd_flag & ND_NFSV3) 1181 rt->flag |= DRT_NFSV3; 1182 rt->proc = nd->nd_procnum; 1183 if (nd->nd_nam->sa_family == AF_INET) 1184 rt->ipadr = ((struct sockaddr_in *)nd->nd_nam)->sin_addr.s_addr; 1185 else 1186 rt->ipadr = INADDR_ANY; | 1073 nuidp->nu_timestamp = ktvout; 1074 nuidp->nu_nickname = nick; 1075 bcopy(key, nuidp->nu_key, sizeof (key)); 1076 TAILQ_INSERT_TAIL(&nmp->nm_uidlruhead, nuidp, 1077 nu_lru); 1078 LIST_INSERT_HEAD(NMUIDHASH(nmp, cred->cr_uid), 1079 nuidp, nu_hash); 1080 } --- 96 unchanged lines hidden (view full) --- 1177 rt->flag |= DRT_NQNFS; 1178 else if (nd->nd_flag & ND_NFSV3) 1179 rt->flag |= DRT_NFSV3; 1180 rt->proc = nd->nd_procnum; 1181 if (nd->nd_nam->sa_family == AF_INET) 1182 rt->ipadr = ((struct sockaddr_in *)nd->nd_nam)->sin_addr.s_addr; 1183 else 1184 rt->ipadr = INADDR_ANY; |
1187 rt->resptime = ((time.tv_sec - nd->nd_starttime.tv_sec) * 1000000) + 1188 (time.tv_usec - nd->nd_starttime.tv_usec); 1189 gettime(&rt->tstamp); | 1185 rt->resptime = nfs_curusec() - (nd->nd_starttime.tv_sec * 1000000 + nd->nd_starttime.tv_usec); 1186 getmicrotime(&rt->tstamp); |
1190 nfsdrt.pos = (nfsdrt.pos + 1) % NFSRTTLOGSIZ; 1191} 1192#endif /* NFS_NOSERVER */ | 1187 nfsdrt.pos = (nfsdrt.pos + 1) % NFSRTTLOGSIZ; 1188} 1189#endif /* NFS_NOSERVER */ |