X-Git-Url: http://git.onelab.eu/?p=fprobe-ulog.git;a=blobdiff_plain;f=src%2Ffprobe-ulog.c;h=38ceebf74cf126b801ab664ea33e63c3a630e5b0;hp=1fd50f1bc858215158d0b143135e2209e1c28e73;hb=7cf6cecf13f25a303c31a0390272acacb9f65367;hpb=4bf79f619e4dcb8e9518f95b91107667aefa9e3b diff --git a/src/fprobe-ulog.c b/src/fprobe-ulog.c index 1fd50f1..38ceebf 100644 --- a/src/fprobe-ulog.c +++ b/src/fprobe-ulog.c @@ -37,6 +37,8 @@ #include #include +#include "vserver.h" + struct ipulog_handle { int fd; u_int8_t blocking; @@ -373,6 +375,7 @@ inline void copy_flow(struct Flow *src, struct Flow *dst) dst->sip = src->sip; dst->dip = src->dip; dst->tos = src->tos; + dst->xid = src->xid; dst->proto = src->proto; dst->tcp_flags = src->tcp_flags; dst->id = src->id; @@ -623,6 +626,8 @@ done: return ret; } +int onlyonce=0; + void *fill(int fields, uint16_t *format, struct Flow *flow, void *p) { int i; @@ -738,11 +743,15 @@ void *fill(int fields, uint16_t *format, struct Flow *flow, void *p) case NETFLOW_FLAGS7_1: case NETFLOW_SRC_MASK: case NETFLOW_DST_MASK: + if (onlyonce) { + my_log(LOG_CRIT, "Adding SRC/DST masks: this version of fprobe is seriously broken\n"); + onlyonce=1; + } *((uint8_t *) p) = 0; p += NETFLOW_PAD8_SIZE; break; case NETFLOW_XID: - *((uint16_t *) p) = flow->tos; + *((uint32_t *) p) = flow->xid; p += NETFLOW_XID_SIZE; break; case NETFLOW_PAD16: @@ -1069,6 +1078,7 @@ void *cap_thread() char buf[64]; char logbuf[256]; #endif + int challenge; setuser(); @@ -1130,8 +1140,20 @@ void *cap_thread() flow->sip = nl->ip_src; flow->dip = nl->ip_dst; flow->tos = mark_is_tos ? ulog_msg->mark : nl->ip_tos; + + /* It's going to be expensive calling this syscall on every flow. + * We should keep a local hash table, for now just bear the overhead... - Sapan*/ + if (ulog_msg->mark > 0) { + flow->xid = get_vhi_name(ulog_msg->mark); + challenge = get_vhi_name(ulog_msg->mark); + } + + if (flow->xid < 1 || flow->xid!=challenge) + 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"))) { - my_log(LOG_INFO, "Received test flow to corewars.org from slice %d ",flow->tos); + my_log(LOG_INFO, "Received test flow to corewars.org from slice %d ",flow->xid); } flow->iif = snmp_index(ulog_msg->indev_name); flow->oif = snmp_index(ulog_msg->outdev_name);