The branch, v3-6-test has been updated via bb61529 s3/vfs_time_audit: use monotonic clock for time deltas from cc2d13f Add test that detects problems in the SMB signing code when run through cli_write() (which doesn't use the new async methods).
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test - Log ----------------------------------------------------------------- commit bb61529e58e44d62da44fec35cdb16c1feeb696d Author: Björn Jacke <b...@sernet.de> Date: Wed Nov 10 00:40:29 2010 +0100 s3/vfs_time_audit: use monotonic clock for time deltas ----------------------------------------------------------------------- Summary of changes: source3/modules/vfs_time_audit.c | 777 ++++++++++++++++++++++---------------- 1 files changed, 444 insertions(+), 333 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c index b510edb..84e4175 100644 --- a/source3/modules/vfs_time_audit.c +++ b/source3/modules/vfs_time_audit.c @@ -44,16 +44,17 @@ static int smb_time_audit_connect(vfs_handle_struct *handle, const char *svc, const char *user) { int result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; if (!handle) { return -1; } - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_CONNECT(handle, svc, user); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("connect", timediff); } @@ -62,12 +63,13 @@ static int smb_time_audit_connect(vfs_handle_struct *handle, static void smb_time_audit_disconnect(vfs_handle_struct *handle) { - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); SMB_VFS_NEXT_DISCONNECT(handle); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("disconnect", timediff); @@ -82,13 +84,14 @@ static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle, uint64_t *dfree, uint64_t *dsize) { uint64_t result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize, dfree, dsize); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; /* Don't have a reasonable notion of failure here */ if (timediff > audit_timeout) { @@ -103,12 +106,13 @@ static int smb_time_audit_get_quota(struct vfs_handle_struct *handle, SMB_DISK_QUOTA *qt) { int result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("get_quota", timediff); @@ -121,12 +125,13 @@ static int smb_time_audit_set_quota(struct vfs_handle_struct *handle, SMB_DISK_QUOTA *qt) { int result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("set_quota", timediff); @@ -141,13 +146,14 @@ static int smb_time_audit_get_shadow_copy_data(struct vfs_handle_struct *handle, bool labels) { int result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("get_shadow_copy_data", timediff); @@ -161,12 +167,13 @@ static int smb_time_audit_statvfs(struct vfs_handle_struct *handle, struct vfs_statvfs_struct *statbuf) { int result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("statvfs", timediff); @@ -179,12 +186,13 @@ static uint32_t smb_time_audit_fs_capabilities(struct vfs_handle_struct *handle, enum timestamp_set_resolution *p_ts_res) { uint32_t result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("fs_capabilities", timediff); @@ -198,12 +206,13 @@ static SMB_STRUCT_DIR *smb_time_audit_opendir(vfs_handle_struct *handle, const char *mask, uint32 attr) { SMB_STRUCT_DIR *result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("opendir", timediff); @@ -217,12 +226,13 @@ static SMB_STRUCT_DIRENT *smb_time_audit_readdir(vfs_handle_struct *handle, SMB_STRUCT_STAT *sbuf) { SMB_STRUCT_DIRENT *result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("readdir", timediff); @@ -234,12 +244,13 @@ static SMB_STRUCT_DIRENT *smb_time_audit_readdir(vfs_handle_struct *handle, static void smb_time_audit_seekdir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp, long offset) { - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("seekdir", timediff); @@ -252,12 +263,13 @@ static long smb_time_audit_telldir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp) { long result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_TELLDIR(handle, dirp); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("telldir", timediff); @@ -269,12 +281,13 @@ static long smb_time_audit_telldir(vfs_handle_struct *handle, static void smb_time_audit_rewinddir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp) { - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); SMB_VFS_NEXT_REWINDDIR(handle, dirp); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("rewinddir", timediff); @@ -287,12 +300,13 @@ static int smb_time_audit_mkdir(vfs_handle_struct *handle, const char *path, mode_t mode) { int result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_MKDIR(handle, path, mode); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("mkdir", timediff); @@ -305,12 +319,13 @@ static int smb_time_audit_rmdir(vfs_handle_struct *handle, const char *path) { int result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_RMDIR(handle, path); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("rmdir", timediff); @@ -323,12 +338,13 @@ static int smb_time_audit_closedir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp) { int result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("closedir", timediff); @@ -340,12 +356,13 @@ static int smb_time_audit_closedir(vfs_handle_struct *handle, static void smb_time_audit_init_search_op(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp) { - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("init_search_op", timediff); @@ -359,12 +376,13 @@ static int smb_time_audit_open(vfs_handle_struct *handle, int flags, mode_t mode) { int result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("open", timediff); @@ -391,10 +409,10 @@ static NTSTATUS smb_time_audit_create_file(vfs_handle_struct *handle, int *pinfo) { NTSTATUS result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_CREATE_FILE( handle, /* handle */ req, /* req */ @@ -412,7 +430,8 @@ static NTSTATUS smb_time_audit_create_file(vfs_handle_struct *handle, ea_list, /* ea_list */ result_fsp, /* result */ pinfo); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("create_file", timediff); @@ -424,12 +443,13 @@ static NTSTATUS smb_time_audit_create_file(vfs_handle_struct *handle, static int smb_time_audit_close(vfs_handle_struct *handle, files_struct *fsp) { int result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_CLOSE(handle, fsp); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("close", timediff); @@ -442,12 +462,13 @@ static ssize_t smb_time_audit_read(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n) { ssize_t result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_READ(handle, fsp, data, n); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("read", timediff); @@ -461,12 +482,13 @@ static ssize_t smb_time_audit_pread(vfs_handle_struct *handle, void *data, size_t n, SMB_OFF_T offset) { ssize_t result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("pread", timediff); @@ -480,12 +502,13 @@ static ssize_t smb_time_audit_write(vfs_handle_struct *handle, const void *data, size_t n) { ssize_t result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("write", timediff); @@ -500,12 +523,13 @@ static ssize_t smb_time_audit_pwrite(vfs_handle_struct *handle, SMB_OFF_T offset) { ssize_t result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("pwrite", timediff); @@ -519,12 +543,13 @@ static SMB_OFF_T smb_time_audit_lseek(vfs_handle_struct *handle, SMB_OFF_T offset, int whence) { ssize_t result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("lseek", timediff); @@ -539,12 +564,13 @@ static ssize_t smb_time_audit_sendfile(vfs_handle_struct *handle, int tofd, size_t n) { ssize_t result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("sendfile", timediff); @@ -559,12 +585,13 @@ static ssize_t smb_time_audit_recvfile(vfs_handle_struct *handle, int fromfd, size_t n) { ssize_t result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("recvfile", timediff); @@ -578,12 +605,13 @@ static int smb_time_audit_rename(vfs_handle_struct *handle, const struct smb_filename *newname) { int result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; - GetTimeOfDay(&tv); + clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_RENAME(handle, oldname, newname); - timediff = timeval_elapsed(&tv); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log("rename", timediff); @@ -595,12 +623,13 @@ static int smb_time_audit_rename(vfs_handle_struct *handle, static int smb_time_audit_fsync(vfs_handle_struct *handle, files_struct *fsp) { int result; - struct timeval tv; + struct timespec ts1,ts2; double timediff; -- Samba Shared Repository