mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
Refactored patch (removed options, less ambiguous name)
This commit is contained in:
parent
54437c128f
commit
ba4c816b0e
6 changed files with 28 additions and 52 deletions
|
@ -3710,28 +3710,20 @@ export {
|
||||||
## external harness and shouldn't output anything to the console.
|
## external harness and shouldn't output anything to the console.
|
||||||
const errors_to_stderr = T &redef;
|
const errors_to_stderr = T &redef;
|
||||||
}
|
}
|
||||||
|
module GLOBAL;
|
||||||
|
|
||||||
module Fanout;
|
module PacketFanout;
|
||||||
|
|
||||||
type Method: enum {
|
|
||||||
METHOD_HASH = 0,
|
|
||||||
METHOD_LB = 1,
|
|
||||||
METHOD_CPU = 2,
|
|
||||||
METHOD_ROLLOVER = 3
|
|
||||||
};
|
|
||||||
|
|
||||||
type Flag: enum {
|
|
||||||
FLAG_NONE = 0,
|
|
||||||
FLAG_DEFRAG = 0x8000,
|
|
||||||
FLAG_ROLLOVER = 0x1000
|
|
||||||
};
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
## Toggle whether to do packet fanout.
|
||||||
const enable = F &redef;
|
const enable = F &redef;
|
||||||
|
|
||||||
|
## The packet fanout id should be shared amongst worker processes operating
|
||||||
|
## the same socket.
|
||||||
const id = 0 &redef;
|
const id = 0 &redef;
|
||||||
const method = METHOD_HASH &redef;
|
|
||||||
const flag = FLAG_NONE &redef;
|
## If true, causes packets to be defragmented before fanout is applied.
|
||||||
}
|
const flag_defrag = T &redef;
|
||||||
|
} # end export
|
||||||
module GLOBAL;
|
module GLOBAL;
|
||||||
|
|
||||||
## Number of bytes per packet to capture from live interfaces.
|
## Number of bytes per packet to capture from live interfaces.
|
||||||
|
|
|
@ -9,8 +9,8 @@ const detect_filtered_trace: bool;
|
||||||
const report_gaps_for_partial: bool;
|
const report_gaps_for_partial: bool;
|
||||||
const exit_only_after_terminate: bool;
|
const exit_only_after_terminate: bool;
|
||||||
|
|
||||||
const Fanout::enable: bool;
|
const PacketFanout::enable: bool;
|
||||||
const Fanout::id: count;
|
const PacketFanout::id: count;
|
||||||
|
|
||||||
const NFS3::return_data: bool;
|
const NFS3::return_data: bool;
|
||||||
const NFS3::return_data_max: count;
|
const NFS3::return_data_max: count;
|
||||||
|
|
|
@ -5,25 +5,8 @@
|
||||||
|
|
||||||
#ifdef HAVE_PACKET_FANOUT
|
#ifdef HAVE_PACKET_FANOUT
|
||||||
#include <linux/if_packet.h>
|
#include <linux/if_packet.h>
|
||||||
#ifndef PACKET_FANOUT
|
|
||||||
#define PACKET_FANOUT 18
|
|
||||||
#define PACKET_FANOUT_HASH 0
|
|
||||||
#define PACKET_FANOUT_LB 1
|
|
||||||
#define PACKET_FANOUT_CPU 2
|
|
||||||
#define PACKET_FANOUT_FLAG_DEFRAG 0x8000
|
|
||||||
|
|
||||||
#ifndef PACKET_FANOUT_ROLLOVER
|
|
||||||
#define PACKET_FANOUT_ROLLOVER 3
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PACKET_FANOUT_FLAG_ROLLOVER
|
|
||||||
#define PACKET_FANOUT_FLAG_ROLLOVER 0x1000
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PACKET_FANOUT_FLAG_NONE -1
|
|
||||||
#endif /* PACKET_FANOUT */
|
|
||||||
#endif /* HAVE_PACKET_FANOUT */
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <pcap.h>
|
#include <pcap.h>
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,10 +161,14 @@ void PcapSource::OpenLive()
|
||||||
|
|
||||||
#ifdef HAVE_PACKET_FANOUT
|
#ifdef HAVE_PACKET_FANOUT
|
||||||
/* Turn on cluster mode for the device. */
|
/* Turn on cluster mode for the device. */
|
||||||
if ( fanout_enable )
|
if ( packet_fanout_enable )
|
||||||
{
|
{
|
||||||
uint32_t fanout_arg = (fanout_method << 16) | (fanout_id & 0xffff);
|
uint32_t packet_fanout_arg = (PACKET_FANOUT_HASH << 16) | (packet_fanout_id & 0xffff);
|
||||||
if (setsockopt(props.selectable_fd, SOL_PACKET, PACKET_FANOUT, &fanout_arg, sizeof(fanout_arg)) == -1)
|
|
||||||
|
if ( packet_fanout_flag_defrag )
|
||||||
|
packet_fanout_arg |= (PACKET_FANOUT_FLAG_DEFRAG << 16);
|
||||||
|
|
||||||
|
if (setsockopt(props.selectable_fd, SOL_PACKET, PACKET_FANOUT, &packet_fanout_arg, sizeof(packet_fanout_arg)) == -1)
|
||||||
{
|
{
|
||||||
Error(fmt("%s: setsockopt: %s", __FUNCTION__, strerror(errno)));
|
Error(fmt("%s: setsockopt: %s", __FUNCTION__, strerror(errno)));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -6,10 +6,9 @@
|
||||||
#include "../PktSrc.h"
|
#include "../PktSrc.h"
|
||||||
|
|
||||||
#ifdef HAVE_PACKET_FANOUT
|
#ifdef HAVE_PACKET_FANOUT
|
||||||
extern bool fanout_enable;
|
extern bool packet_fanout_enable;
|
||||||
extern int fanout_id;
|
extern int packet_fanout_id;
|
||||||
extern int fanout_method;
|
extern bool packet_fanout_flag_defrag;
|
||||||
extern int fanout_flag;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace iosource {
|
namespace iosource {
|
||||||
|
|
14
src/main.cc
14
src/main.cc
|
@ -125,10 +125,9 @@ int snaplen = 0; // this gets set from the scripting-layer's value
|
||||||
int bufsize = 0;
|
int bufsize = 0;
|
||||||
|
|
||||||
#ifdef HAVE_PACKET_FANOUT
|
#ifdef HAVE_PACKET_FANOUT
|
||||||
bool fanout_enable = false;
|
bool packet_fanout_enable = false;
|
||||||
int fanout_id = 0;
|
int packet_fanout_id = 0;
|
||||||
int fanout_method = PACKET_FANOUT_HASH;
|
bool packet_fanout_flag_defrag = false;
|
||||||
int fanout_flag = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OpaqueType* md5_type = 0;
|
OpaqueType* md5_type = 0;
|
||||||
|
@ -1001,10 +1000,9 @@ int main(int argc, char** argv)
|
||||||
bufsize = internal_val("bufsize")->AsCount() * 1024 * 1024;
|
bufsize = internal_val("bufsize")->AsCount() * 1024 * 1024;
|
||||||
|
|
||||||
#ifdef HAVE_PACKET_FANOUT
|
#ifdef HAVE_PACKET_FANOUT
|
||||||
fanout_enable = internal_val("Fanout::enable")->AsBool();
|
packet_fanout_enable = internal_val("PacketFanout::enable")->AsBool();
|
||||||
fanout_id = internal_val("Fanout::id")->AsCount();
|
packet_fanout_id = internal_val("PacketFanout::id")->AsCount();
|
||||||
fanout_method = internal_val("Fanout::method")->AsEnum();
|
packet_fanout_flag_defrag = internal_val("PacketFanout::flag_defrag")->AsBool();
|
||||||
fanout_flag = internal_val("Fanout::flag")->AsEnum();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( dns_type != DNS_PRIME )
|
if ( dns_type != DNS_PRIME )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue