Bugzilla – Attachment 1953 Details for
Bug 1836
"undesired" behavior when using the -r flag
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Patch to fix -r 'behavior'
softflowd-1836.patch (text/plain), 2.79 KB, created by
Daan van der Sanden
on 2010-11-09 21:59:53 AEDT
(
hide
)
Description:
Patch to fix -r 'behavior'
Filename:
MIME Type:
Creator:
Daan van der Sanden
Created:
2010-11-09 21:59:53 AEDT
Size:
2.79 KB
patch
obsolete
>diff -u softflowd-0.9.8/softflowd.c softflowd-0.9.8-patched/softflowd.c >--- softflowd-0.9.8/softflowd.c 2006-11-02 07:23:29.000000000 +0100 >+++ softflowd-0.9.8-patched/softflowd.c 2010-11-09 11:34:26.000000000 +0100 >@@ -608,6 +608,36 @@ > return (PP_OK); > } > >+/* Subtract the `struct timeval' values X and Y, >+ * storing the result in RESULT. >+ * Return 1 if the difference is negative, otherwise 0. >+ */ >+ >+int >+timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y) >+{ >+ /* Perform the carry for the later subtraction by updating y. */ >+ if (x->tv_usec < y->tv_usec) { >+ int nsec = (y->tv_usec - x->tv_usec) / 1000000L + 1; >+ y->tv_usec -= 1000000L * nsec; >+ y->tv_sec += nsec; >+ } >+ if (x->tv_usec - y->tv_usec > 1000000L) { >+ int nsec = (x->tv_usec - y->tv_usec) / 1000000L; >+ y->tv_usec += 1000000L * nsec; >+ y->tv_sec -= nsec; >+ } >+ >+ /* Compute the time remaining to wait. >+ tv_usec is certainly positive. */ >+ result->tv_sec = x->tv_sec - y->tv_sec; >+ result->tv_usec = x->tv_usec - y->tv_usec; >+ >+ /* Return 1 if result is negative. */ >+ return x->tv_sec < y->tv_sec; >+} >+ >+ > /* > * Subtract two timevals. Returns (t1 - t2) in milliseconds. > */ >@@ -1642,7 +1672,10 @@ > struct NETFLOW_TARGET target; > struct CB_CTXT cb_ctxt; > struct pollfd pl[2]; >- >+ struct timeval now, usec_counter; >+ usec_counter.tv_sec = 4276800L; >+ usec_counter.tv_usec = 0L; >+ > closefrom(STDERR_FILENO + 1); > > init_flowtrack(&flowtrack); >@@ -1763,7 +1796,7 @@ > usage(); > exit(1); > } >- >+ > /* join remaining arguments (if any) into bpf program */ > bpf_prog = argv_join(argc - optind, argv + optind); > >@@ -1818,7 +1851,17 @@ > } > > /* Main processing loop */ >- gettimeofday(&flowtrack.system_boot_time, NULL); >+ >+ /* set correct time to read flows from the past when read from a pcap file */ >+ if ( capfile != NULL ) { >+ gettimeofday(&now, NULL); >+ if ( timeval_subtract (&flowtrack.system_boot_time,&now,&usec_counter) == 1) { >+ fprintf(stderr,"This should not have happened unless today is before 19 february 1970.\n"); >+ exit(1); >+ } >+ } else { >+ gettimeofday(&flowtrack.system_boot_time, NULL); >+ } > stop_collection_flag = 0; > memset(&cb_ctxt, '\0', sizeof(cb_ctxt)); > cb_ctxt.ft = &flowtrack; >diff -u softflowd-0.9.8/softflowd.h softflowd-0.9.8-patched/softflowd.h >--- softflowd-0.9.8/softflowd.h 2006-03-16 09:23:13.000000000 +0100 >+++ softflowd-0.9.8-patched/softflowd.h 2010-11-09 10:43:57.000000000 +0100 >@@ -192,6 +192,7 @@ > > /* Prototype for functions shared from softflowd.c */ > u_int32_t timeval_sub_ms(const struct timeval *t1, const struct timeval *t2); >+int timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y); > > /* Prototypes for functions to send NetFlow packets, from netflow*.c */ > int send_netflow_v1(struct FLOW **flows, int num_flows, int nfsock,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1836
: 1953 |
2070