Commit 34fe32c6 authored by Håvard Moås's avatar Håvard Moås
Browse files

Update IPFIXLIB to update congestion control logic, havard.mork@gmail.com

git-svn-id: file:///home/svn/mapi/branches/haavardm-mapi@72 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent aef3ed93
......@@ -616,7 +616,7 @@ void addPktToHash(np_ctxt_t *npctxt,
if((bkt->proto == proto)
&& ((cmpIpAddress(bkt->src, src) && cmpIpAddress(bkt->dst, dst) && (bkt->sport == sport) && (bkt->dport == dport))
|| (cmpIpAddress(bkt->src, dst) && cmpIpAddress(bkt->dst, src) && (bkt->sport == dport) && (bkt->dport == sport)))) {
unsigned long ts_sec, ts_usec; // Distance from lasat packet
unsigned long ts_sec=0, ts_usec=0; // Distance from lasat packet
/*
......
......@@ -257,6 +257,7 @@ typedef struct {
FILE *flowFd; /* Not used with mapi */
u_int32_t exportBucketsLen;
HashBucket *exportQueue;
HashBucket *exportQueueEnd;
NetFlow5Record v5Flow;
IPFIXFlowHeader ipfixHeader;
V9FlowHeader v9Header;
......
......@@ -128,7 +128,8 @@ exportBucket(np_ctxt_t *npctxt, HashBucket *myBucket)
void queueBucketToExport(np_ctxt_t *npctxt, HashBucket *myBucket) {
pthread_mutex_lock(&exportMutex);
addToList(myBucket, &npctxt->exportQueue);
// addToList(myBucket, &npctxt->exportQueue);
addToListEnd(myBucket, &npctxt->exportQueue, &npctxt->exportQueueEnd);
myBucket->time_exported = time(NULL);
npctxt->exportBucketsLen++;
pthread_mutex_unlock(&exportMutex);
......@@ -159,6 +160,8 @@ dequeueBucketToExport(void* ctxt)
/* Remove bucket from list */
pthread_mutex_lock(&exportMutex);
myBucket = getListHead(&npctxt->exportQueue);
if(npctxt->exportQueue==NULL)
npctxt->exportQueueEnd = NULL;
npctxt->exportBucketsLen--;
pthread_mutex_unlock(&exportMutex);
......@@ -168,11 +171,11 @@ dequeueBucketToExport(void* ctxt)
exportBucket(npctxt, myBucket);
} else {
if(myBucket->pktRcvd > 0)
npctxt->notsent_flows = npctxt->notsent_flows + 2;
npctxt->notsent_flows = npctxt->notsent_flows + 2ull;
else
npctxt->notsent_flows = npctxt->notsent_flows + 1;
npctxt->notsent_pkts = npctxt->notsent_pkts + myBucket->pktSent + myBucket->pktRcvd;
npctxt->notsent_octets = npctxt->notsent_octets+myBucket->bytesSent+myBucket->bytesRcvd;
npctxt->notsent_flows = npctxt->notsent_flows + 1ull;
npctxt->notsent_pkts = npctxt->notsent_pkts + (u_int64_t)myBucket->pktSent + (u_int64_t)myBucket->pktRcvd;
npctxt->notsent_octets = npctxt->notsent_octets+(u_int64_t)myBucket->bytesSent+(u_int64_t)myBucket->bytesRcvd;
}
/* Recycle bucket */
......@@ -1116,6 +1119,7 @@ npInitContext(void)
npctxt->npBuffer = NULL;
npctxt->flowFd = NULL;
npctxt->exportQueue = NULL;
npctxt->exportQueueEnd = NULL;
npctxt->exportBucketsLen = 0;
npctxt->lastMaxBucketSearch = 5; /* Don't bother with values < 5 */
......
......@@ -1791,7 +1791,6 @@ unsigned int ntop_sleep(unsigned int secs) {
HashBucket* getListHead(HashBucket **list) {
HashBucket *bkt = *list;
(*list) = bkt->next;
return(bkt);
......@@ -1803,3 +1802,13 @@ void addToList(HashBucket *bkt, HashBucket **list) {
bkt->next = *list;
(*list) = bkt;
}
void addToListEnd(HashBucket *bkt, HashBucket **list, HashBucket **listend) {
bkt->next = NULL;
if(*listend==NULL) {
*list = *listend = bkt;
return;
}
(*listend)->next = bkt;
*listend = bkt;
}
......@@ -30,6 +30,8 @@ extern short isWinNT();
int nprobe_sleep(int secs);
#endif
extern unsigned long long htonll(unsigned long long n);
extern void traceEvent(np_ctxt_t *npctxt, int eventTraceLevel, char* file, int line, char * format, ...);
extern int snprintf(char *string, size_t maxlen, const char *format, ...);
extern void checkHostFingerprint(char *fingerprint, char *osName, int osNameLen);
......@@ -48,3 +50,4 @@ extern u_int32_t nsTimeDiff(unsigned long long end, unsigned long long begin);
extern unsigned int ntop_sleep(unsigned int secs);
extern HashBucket* getListHead(HashBucket **list);
extern void addToList(HashBucket *bkt, HashBucket **list);
extern void addToListEnd(HashBucket *bkt, HashBucket **list, HashBucket **listend);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment