|
|
|
|
@ -353,7 +353,12 @@ typedef struct AFPThreadVars_
|
|
|
|
|
int ebpf_filter_fd;
|
|
|
|
|
struct ebpf_timeout_config ebpf_t_config;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef AFPACKET_TEST_REPLAY
|
|
|
|
|
/* Test-replay stop condition: ReceiveAFPLoop exits after this many
|
|
|
|
|
* packets. Set from AFPIfaceConfig::max_packets at thread init. A
|
|
|
|
|
* value of 0 disables the cap (loop runs until normal stop). */
|
|
|
|
|
uint32_t max_packets;
|
|
|
|
|
#endif
|
|
|
|
|
} AFPThreadVars;
|
|
|
|
|
|
|
|
|
|
static TmEcode ReceiveAFPThreadInit(ThreadVars *, const void *, void **);
|
|
|
|
|
@ -1428,6 +1433,16 @@ TmEcode ReceiveAFPLoop(ThreadVars *tv, void *data, void *slot)
|
|
|
|
|
} else if (r > 0) {
|
|
|
|
|
StatsCounterIncr(&ptv->tv->stats, ptv->capture_afp_poll_data);
|
|
|
|
|
r = AFPReadFunc(ptv);
|
|
|
|
|
#ifdef AFPACKET_TEST_REPLAY
|
|
|
|
|
/* Test-replay stop condition: signal Suricata to stop after the
|
|
|
|
|
* configured number of packets so suricata-verify live tests
|
|
|
|
|
* driven by tcpreplay terminate deterministically. ptv->pkts is
|
|
|
|
|
* uint64_t; widen max_packets so the comparison is unsigned and
|
|
|
|
|
* same-width. */
|
|
|
|
|
if (ptv->max_packets > 0 && ptv->pkts >= (uint64_t)ptv->max_packets) {
|
|
|
|
|
suricata_ctl_flags |= SURICATA_STOP;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
switch (r) {
|
|
|
|
|
case AFP_READ_OK:
|
|
|
|
|
/* Trigger one dump of stats every second */
|
|
|
|
|
@ -2246,8 +2261,8 @@ static int AFPSetFlowStorage(Packet *p, int map_fd, void *key0, void* key1,
|
|
|
|
|
#define FlowKeyIpFill(k, p) \
|
|
|
|
|
{ \
|
|
|
|
|
(k)->ip_proto = ((p)->proto == IPPROTO_TCP) ? 1 : 0; \
|
|
|
|
|
(k)->vlan0 = (p)->vlan_id[0]; \
|
|
|
|
|
(k)->vlan1 = (p)->vlan_id[1]; \
|
|
|
|
|
(k)->vlan0 = (p)->vlan_id[0] & g_vlan_mask; \
|
|
|
|
|
(k)->vlan1 = (p)->vlan_id[1] & g_vlan_mask; \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -2566,6 +2581,9 @@ TmEcode ReceiveAFPThreadInit(ThreadVars *tv, const void *initdata, void **data)
|
|
|
|
|
ptv->promisc = afpconfig->promisc;
|
|
|
|
|
ptv->checksum_mode = afpconfig->checksum_mode;
|
|
|
|
|
ptv->bpf_filter = NULL;
|
|
|
|
|
#ifdef AFPACKET_TEST_REPLAY
|
|
|
|
|
ptv->max_packets = afpconfig->max_packets;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
ptv->threads = 1;
|
|
|
|
|
#ifdef HAVE_PACKET_FANOUT
|
|
|
|
|
|