Go to the documentation of this file.
38 #define PFRING_CONF_V1 1
39 #define PFRING_CONF_V2 2
53 "Multi threaded pfring mode. Packets from "
54 "each flow are assigned to a single detect "
55 "thread, unlike \"pfring_auto\" where packets "
56 "from the same flow can be processed by any "
62 "Workers pfring mode, each thread does all"
63 " tasks from acquisition to logging",
69 static void PfringDerefConfig(
void *conf)
93 static void *OldParsePfringConfig(
const char *iface)
95 const char *threadsstr = NULL;
97 const char *tmpclusterid;
98 const char *tmpctype = NULL;
114 pfconf->
ctype = default_ctype;
121 if (
ConfGet(
"pfring.threads", &threadsstr) != 1) {
124 if (threadsstr != NULL) {
127 "pfring.threads: '%s'. Resetting to 1.",
140 if (strncmp(pfconf->
iface,
"zc", 2) == 0) {
141 SCLogInfo(
"ZC interface detected, not setting cluster-id");
143 else if ((pfconf->
threads == 1) && (strncmp(pfconf->
iface,
"dna", 3) == 0)) {
144 SCLogInfo(
"DNA interface detected, not setting cluster-id");
145 }
else if (
ConfGet(
"pfring.cluster-id", &tmpclusterid) != 1) {
146 SCLogError(
"Could not get cluster-id from config");
150 "pfring.cluster_id: '%s'. Resetting to 1.",
158 if (strncmp(pfconf->
iface,
"zc", 2) == 0) {
159 SCLogInfo(
"ZC interface detected, not setting cluster type for PF_RING (iface %s)",
161 }
else if ((pfconf->
threads == 1) && (strncmp(pfconf->
iface,
"dna", 3) == 0)) {
162 SCLogInfo(
"DNA interface detected, not setting cluster type for PF_RING (iface %s)",
164 }
else if (
ConfGet(
"pfring.cluster-type", &tmpctype) != 1) {
165 SCLogError(
"Could not get cluster-type from config");
166 }
else if (strcmp(tmpctype,
"cluster_round_robin") == 0) {
167 SCLogInfo(
"Using round-robin cluster mode for PF_RING (iface %s)",
169 pfconf->
ctype = (cluster_type)tmpctype;
170 }
else if (strcmp(tmpctype,
"cluster_flow") == 0) {
171 SCLogInfo(
"Using flow cluster mode for PF_RING (iface %s)",
173 pfconf->
ctype = (cluster_type)tmpctype;
175 SCLogError(
"invalid cluster-type %s", tmpctype);
196 static void *ParsePfringConfig(
const char *iface)
198 const char *threadsstr = NULL;
203 const char *tmpclusterid;
204 const char *tmpctype = NULL;
207 const char *bpf_filter = NULL;
223 pfconf->
ctype = (cluster_type)default_ctype;
230 if (pf_ring_node == NULL) {
231 SCLogInfo(
"Unable to find pfring config using default value");
239 if (if_root == NULL && if_default == NULL) {
240 SCLogInfo(
"Unable to find pfring config for "
241 "interface %s, using default value or 1.0 "
242 "configuration system. ",
248 if (if_root == NULL) {
249 if_root = if_default;
255 }
else if (threadsstr != NULL) {
256 if (strcmp(threadsstr,
"auto") == 0) {
267 uint16_t threads = 0;
270 "pfring.threads: '%s'. Resetting to 1.",
286 if (
ConfGet(
"pfring.cluster-id", &tmpclusterid) == 1) {
289 "pfring.cluster-id: '%s'. Resetting to 1.",
294 SCLogDebug(
"Going to use command-line provided cluster-id %" PRId32,
298 if (strncmp(pfconf->
iface,
"zc", 2) == 0) {
299 SCLogInfo(
"ZC interface detected, not setting cluster-id for PF_RING (iface %s)",
301 }
else if ((pfconf->
threads == 1) && (strncmp(pfconf->
iface,
"dna", 3) == 0)) {
302 SCLogInfo(
"DNA interface detected, not setting cluster-id for PF_RING (iface %s)",
305 SCLogError(
"Could not get cluster-id from config");
309 "pfring.cluster-id: '%s'. Resetting to 1.",
320 if (
ConfGet(
"bpf-filter", &bpf_filter) == 1) {
321 if (strlen(bpf_filter) > 0) {
324 SCLogError(
"Can't allocate BPF filter string");
326 SCLogDebug(
"Going to use command-line provided bpf filter %s",
332 if (strlen(bpf_filter) > 0) {
335 SCLogError(
"Can't allocate BPF filter string");
344 if (
ConfGet(
"pfring.cluster-type", &tmpctype) == 1) {
345 SCLogDebug(
"Going to use command-line provided cluster-type");
348 if (strncmp(pfconf->
iface,
"zc", 2) == 0) {
349 SCLogInfo(
"ZC interface detected, not setting cluster type for PF_RING (iface %s)",
351 }
else if ((pfconf->
threads == 1) && (strncmp(pfconf->
iface,
"dna", 3) == 0)) {
352 SCLogInfo(
"DNA interface detected, not setting cluster type for PF_RING (iface %s)",
355 SCLogError(
"Could not get cluster-type from config");
362 if (strcmp(tmpctype,
"cluster_round_robin") == 0) {
363 SCLogInfo(
"Using round-robin cluster mode for PF_RING (iface %s)",
366 }
else if (strcmp(tmpctype,
"cluster_flow") == 0) {
367 SCLogInfo(
"Using flow cluster mode for PF_RING (iface %s)",
371 SCLogError(
"invalid cluster-type %s", tmpctype);
377 if (strcmp(tmpctype,
"auto") == 0) {
383 }
else if (strcmp(tmpctype,
"rx-only") == 0) {
392 #ifdef HAVE_PF_RING_FLOW_OFFLOAD
393 SCLogConfig(
"Enabling bypass support in PF_RING for iface %s (if supported by underlying hw)", pfconf->
iface);
396 SCLogError(
"Bypass is not supported by this Pfring version, please upgrade");
405 SCLogWarning(
"Using PF_RING with offloading activated leads to capture problems");
413 static int PfringConfigGetThreadsCount(
void *conf)
419 static int PfringConfLevel(
void)
421 const char *def_dev = NULL;
423 if (
ConfGet(
"pfring.interface", &def_dev) != 1) {
432 ConfGet(
"pfring.live-interface", live_dev);
436 *parser = ParsePfringConfig;
438 SCLogInfo(
"Using 1.0 style configuration for pfring");
439 *parser = OldParsePfringConfig;
441 if (*live_dev == NULL) {
442 if (
ConfGet(
"pfring.interface", live_dev) == 1) {
443 SCLogInfo(
"Using interface %s", *live_dev);
446 SCLogInfo(
"No interface found, problem incoming");
463 const char *live_dev = NULL;
470 ret = GetDevAndParser(&live_dev, &tparser);
472 FatalError(
"Unable to get parser and interface params");
481 SCLogInfo(
"RunModeIdsPfringAutoFp initialised");
494 const char *live_dev = NULL;
501 ret = GetDevAndParser(&live_dev, &tparser);
503 FatalError(
"Unable to get parser and interface params");
507 PfringConfigGetThreadsCount,
515 SCLogInfo(
"RunModeIdsPfringSingle initialised");
528 const char *live_dev = NULL;
535 ret = GetDevAndParser(&live_dev, &tparser);
537 FatalError(
"Unable to get parser and interface params");
546 SCLogInfo(
"RunModeIdsPfringWorkers initialised");
const char * thread_name_workers
int RunModeIdsPfringWorkers(void)
int LiveRegisterDevice(const char *dev)
Add a pcap device for monitoring and create structure.
int RunModeSetLiveCaptureWorkers(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
#define SC_ATOMIC_INIT(name)
wrapper for initializing an atomic variable.
int ConfGetChildValueBoolWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, int *val)
ConfNode * ConfGetNode(const char *name)
Get a ConfNode by name.
#define SC_ATOMIC_ADD(name, val)
add a value to our atomic variable
int StringParseUint16(uint16_t *res, int base, size_t len, const char *str)
void RunModeInitialize(void)
void RunModeIdsPfringRegister(void)
@ CHECKSUM_VALIDATION_RXONLY
const char * thread_name_autofp
void RunModeRegisterNewRunMode(enum RunModes runmode, const char *name, const char *description, int(*RunModeFunc)(void), void(*RunModeIsIPSEnabled)(void))
Registers a new runmode.
@ CHECKSUM_VALIDATION_DISABLE
int StringParseInt32(int32_t *res, int base, size_t len, const char *str)
const char * thread_name_single
int ConfValIsTrue(const char *val)
Check if a value is true.
const char * RunModeIdsPfringGetDefaultMode(void)
size_t strlcpy(char *dst, const char *src, size_t siz)
int RunModeSetLiveCaptureAutoFp(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
@ CHECKSUM_VALIDATION_ENABLE
int ConfGet(const char *name, const char **vptr)
Retrieve the value of a configuration node.
char iface[PFRING_IFACE_NAME_LENGTH]
int RunModeIdsPfringAutoFp(void)
@ CHECKSUM_VALIDATION_AUTO
LiveDevice * LiveGetDevice(const char *name)
Get a pointer to the device at idx.
int GetIfaceRSSQueuesNum(const char *dev)
ConfNode * ConfFindDeviceConfig(ConfNode *node, const char *iface)
Find the configuration node for a specific device.
int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, const char **vptr)
#define SCLogWarning(...)
Macro used to log WARNING messages.
#define SC_ATOMIC_SUB(name, val)
sub a value from our atomic variable
#define PFRING_CONF_FLAGS_CLUSTER
int GetIfaceOffloading(const char *dev, int csum, int other)
output offloading status of the link
int DisableIfaceOffloading(LiveDevice *dev, int csum, int other)
#define PFRING_CONF_FLAGS_BYPASS
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
void TimeModeSetLive(void)
#define CLUSTER_ROUND_ROBIN
void(* DerefFunc)(void *)
#define SC_ATOMIC_RESET(name)
wrapper for reinitializing an atomic variable.
void *(* ConfigIfaceParserFunc)(const char *)
struct SCLogConfig_ SCLogConfig
Holds the config state used by the logging api.
#define SCLogError(...)
Macro used to log ERROR messages.
int ConfValIsFalse(const char *val)
Check if a value is false.
int RunModeSetLiveCaptureSingle(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
uint16_t UtilCpuGetNumProcessorsOnline(void)
Get the number of cpus online in the system.
ChecksumValidationMode checksum_mode
int RunModeIdsPfringSingle(void)