From 48d950c6c672553f11f353b3dd76c7e13dcd16cd Mon Sep 17 00:00:00 2001
From: sapanb <sapanb@8c455092-636d-4788-adf5-e71def0336e8>
Date: Sun, 14 Sep 2008 21:01:39 +0000
Subject: [PATCH] Codemux-attribution-related bugfix. Codemux marks connections
 late in their lifetime. We need to react to these changes and update the
 corresponding flows.

git-svn-id: http://svn.planet-lab.org/svn/fprobe-ulog/trunk@10489 8c455092-636d-4788-adf5-e71def0336e8
---
 src/fprobe-ulog.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/fprobe-ulog.c b/src/fprobe-ulog.c
index 1e42e27..c744c01 100644
--- a/src/fprobe-ulog.c
+++ b/src/fprobe-ulog.c
@@ -583,6 +583,15 @@ done:
 		flown->tcp_flags |= flow->tcp_flags;
 		flown->size += flow->size;
 		flown->pkts += flow->pkts;
+
+		/* The xid of the first xid of a flow is misleading. Reset the xid of the flow
+		 * if a better value comes along. A good example of this is that by the time CoDemux sets the
+		 * peercred of a flow, it has already been accounted for here and attributed to root. */
+
+		if (flown->xid<1)
+				flown->xid = flow->xid;
+
+
 		if (flow->flags & FLOW_FRAG) {
 			/* Fragmented flow require some additional work */
 			if (flow->flags & FLOW_TL) {
@@ -647,7 +656,7 @@ void *fill(int fields, uint16_t *format, struct Flow *flow, void *p)
 
 			case NETFLOW_IPV4_DST_ADDR:
 				((struct in_addr *) p)->s_addr = flow->dip.s_addr;
-				if ((flow->dip.s_addr == inet_addr("64.34.177.39"))) {
+				if ((flow->dip.s_addr == inet_addr("10.0.0.8"))) {
 					my_log(LOG_INFO, "Created records for test flow. No. of packets=%d",flow->pkts);
 				}
 				p += NETFLOW_IPV4_DST_ADDR_SIZE;
@@ -1158,7 +1167,7 @@ void *cap_thread()
 				flow->xid = ulog_msg->mark;
 
 
-			if ((flow->dip.s_addr == inet_addr("64.34.177.39")) || (flow->sip.s_addr == inet_addr("64.34.177.39"))) {
+			if ((flow->dip.s_addr == inet_addr("10.0.0.8")) || (flow->sip.s_addr == inet_addr("10.0.0.8"))) {
 				my_log(LOG_INFO, "Received test flow to corewars.org from slice %d ",flow->xid);
 			}
 			flow->iif = snmp_index(ulog_msg->indev_name);
-- 
2.47.0