dpdk: fix timestamp issues

Each thread had its own version of the `machine_start_time`, which
lead to slight time differences. This became apparent mostly in IPS,
where 2 threads each process a side of the flow.

This patch makes the `machine_start_time` global.
pull/8042/head
Victor Julien 4 years ago
parent cd2a5ec84f
commit f1068bbb08

@ -291,6 +291,7 @@ static void InitEal()
FatalError( FatalError(
SC_ERR_DPDK_EAL_INIT, "DPDK EAL initialization error: %s", rte_strerror(-retval)); SC_ERR_DPDK_EAL_INIT, "DPDK EAL initialization error: %s", rte_strerror(-retval));
} }
DPDKSetTimevalOfMachineStart();
} }
static void DPDKDerefConfig(void *conf) static void DPDKDerefConfig(void *conf)

@ -90,6 +90,7 @@ TmEcode NoDPDKSupportExit(ThreadVars *tv, const void *initdata, void **data)
#include <numa.h> #include <numa.h>
#define BURST_SIZE 32 #define BURST_SIZE 32
static struct timeval machine_start_time = { 0, 0 };
/** /**
* \brief Structure to hold thread specific variables. * \brief Structure to hold thread specific variables.
@ -122,7 +123,6 @@ typedef struct DPDKThreadVars_ {
uint16_t queue_id; uint16_t queue_id;
struct rte_mempool *pkt_mempool; struct rte_mempool *pkt_mempool;
struct rte_mbuf *received_mbufs[BURST_SIZE]; struct rte_mbuf *received_mbufs[BURST_SIZE];
struct timeval machine_start_time;
} DPDKThreadVars; } DPDKThreadVars;
static TmEcode ReceiveDPDKThreadInit(ThreadVars *, const void *, void **); static TmEcode ReceiveDPDKThreadInit(ThreadVars *, const void *, void **);
@ -166,10 +166,10 @@ static void CyclesAddToTimeval(
new_tv->tv_usec = (usec % 1000000); new_tv->tv_usec = (usec % 1000000);
} }
static void DPDKSetTimevalOfMachineStart(struct timeval *tv) void DPDKSetTimevalOfMachineStart(void)
{ {
gettimeofday(tv, NULL); gettimeofday(&machine_start_time, NULL);
tv->tv_sec -= DPDKGetSeconds(); machine_start_time.tv_sec -= DPDKGetSeconds();
} }
/** /**
@ -374,7 +374,7 @@ static TmEcode ReceiveDPDKLoop(ThreadVars *tv, void *data, void *slot)
p->flags |= PKT_IGNORE_CHECKSUM; p->flags |= PKT_IGNORE_CHECKSUM;
} }
DPDKSetTimevalReal(&ptv->machine_start_time, &p->ts); DPDKSetTimevalReal(&machine_start_time, &p->ts);
p->dpdk_v.mbuf = ptv->received_mbufs[i]; p->dpdk_v.mbuf = ptv->received_mbufs[i];
p->ReleasePacket = DPDKReleasePacket; p->ReleasePacket = DPDKReleasePacket;
p->dpdk_v.copy_mode = ptv->copy_mode; p->dpdk_v.copy_mode = ptv->copy_mode;
@ -432,7 +432,6 @@ static TmEcode ReceiveDPDKThreadInit(ThreadVars *tv, const void *initdata, void
ptv->pkts = 0; ptv->pkts = 0;
ptv->bytes = 0; ptv->bytes = 0;
ptv->livedev = LiveGetDevice(dpdk_config->iface); ptv->livedev = LiveGetDevice(dpdk_config->iface);
DPDKSetTimevalOfMachineStart(&ptv->machine_start_time);
ptv->capture_dpdk_packets = StatsRegisterCounter("capture.packets", ptv->tv); ptv->capture_dpdk_packets = StatsRegisterCounter("capture.packets", ptv->tv);
ptv->capture_dpdk_rx_errs = StatsRegisterCounter("capture.rx_errors", ptv->tv); ptv->capture_dpdk_rx_errs = StatsRegisterCounter("capture.rx_errors", ptv->tv);

@ -41,6 +41,7 @@ typedef enum { DPDK_COPY_MODE_NONE, DPDK_COPY_MODE_TAP, DPDK_COPY_MODE_IPS } Dpd
// Offloads // Offloads
#define DPDK_RX_CHECKSUM_OFFLOAD (1 << 4) /**< Enable chsum offload */ #define DPDK_RX_CHECKSUM_OFFLOAD (1 << 4) /**< Enable chsum offload */
void DPDKSetTimevalOfMachineStart(void);
typedef struct DPDKIfaceConfig_ { typedef struct DPDKIfaceConfig_ {
#ifdef HAVE_DPDK #ifdef HAVE_DPDK
char iface[RTE_ETH_NAME_MAX_LEN]; char iface[RTE_ETH_NAME_MAX_LEN];

Loading…
Cancel
Save