suricata
source-nfq.c File Reference
#include "suricata-common.h"
#include "suricata.h"
#include "packet.h"
#include "decode.h"
#include "packet-queue.h"
#include "threads.h"
#include "threadvars.h"
#include "tm-threads.h"
#include "tm-queuehandlers.h"
#include "tmqh-packetpool.h"
#include "conf.h"
#include "conf-yaml-loader.h"
#include "source-nfq-prototypes.h"
#include "action-globals.h"
#include "util-datalink.h"
#include "util-debug.h"
#include "util-error.h"
#include "util-byte.h"
#include "util-cpu.h"
#include "util-privs.h"
#include "util-device.h"
#include "runmodes.h"
#include "source-nfq.h"
Include dependency graph for source-nfq.c:

Go to the source code of this file.

Data Structures

struct  NFQThreadVars_
 
struct  NFQCnf_
 

Macros

#define MAX_ALREADY_TREATED   5
 
#define NFQ_VERDICT_RETRY_COUNT   3
 
#define NFQ_BURST_FACTOR   4
 
#define SOL_NETLINK   270
 
#define NFQ_FLAG_FAIL_OPEN   (1 << 0)
 
#define NFQMutexLock(nq)
 
#define NFQMutexUnlock(nq)
 
#define T_DATA_SIZE   70000
 

Typedefs

typedef struct NFQThreadVars_ NFQThreadVars
 
typedef enum NFQMode_ NFQMode
 
typedef struct NFQCnf_ NFQCnf
 

Enumerations

enum  NFQMode_ { NFQ_ACCEPT_MODE, NFQ_REPEAT_MODE, NFQ_ROUTE_MODE }
 

Functions

void TmModuleReceiveNFQRegister (void)
 
void TmModuleVerdictNFQRegister (void)
 
void TmModuleDecodeNFQRegister (void)
 
void NFQInitConfig (bool quiet)
 To initialize the NFQ global configuration data. More...
 
int NFQRegisterQueue (const uint16_t number)
 Add a single Netfilter queue. More...
 
int NFQParseAndRegisterQueues (const char *queues)
 Parses and adds Netfilter queue(s). More...
 
void * NFQGetQueue (int number)
 Get a pointer to the NFQ queue at index. More...
 
void * NFQGetThread (int number)
 Get a pointer to the NFQ thread at index. More...
 
void NFQContextsClean (void)
 Clean global contexts. Must be called on exit. More...
 

Variables

uint32_t max_pending_packets
 
NFQCnf nfq_config
 

Detailed Description

Author
Victor Julien victo.nosp@m.r@in.nosp@m.linia.nosp@m.c.ne.nosp@m.t
Eric Leblond eric@.nosp@m.regi.nosp@m.t.org

Netfilter's netfilter_queue support for reading packets from the kernel and setting verdicts back to it (inline mode).

Definition in file source-nfq.c.

Macro Definition Documentation

◆ MAX_ALREADY_TREATED

#define MAX_ALREADY_TREATED   5

Definition at line 103 of file source-nfq.c.

◆ NFQ_BURST_FACTOR

#define NFQ_BURST_FACTOR   4

Definition at line 108 of file source-nfq.c.

◆ NFQ_FLAG_FAIL_OPEN

#define NFQ_FLAG_FAIL_OPEN   (1 << 0)

Definition at line 155 of file source-nfq.c.

◆ NFQ_VERDICT_RETRY_COUNT

#define NFQ_VERDICT_RETRY_COUNT   3

Definition at line 104 of file source-nfq.c.

◆ NFQMutexLock

#define NFQMutexLock (   nq)
Value:
do { \
if ((nq)->use_mutex) \
SCMutexLock(&(nq)->mutex_qh); \
} while (0)

Definition at line 387 of file source-nfq.c.

◆ NFQMutexUnlock

#define NFQMutexUnlock (   nq)
Value:
do { \
if ((nq)->use_mutex) \
SCMutexUnlock(&(nq)->mutex_qh); \
} while (0)

Definition at line 392 of file source-nfq.c.

◆ SOL_NETLINK

#define SOL_NETLINK   270

Definition at line 111 of file source-nfq.c.

◆ T_DATA_SIZE

#define T_DATA_SIZE   70000

Typedef Documentation

◆ NFQCnf

typedef struct NFQCnf_ NFQCnf

◆ NFQMode

typedef enum NFQMode_ NFQMode

◆ NFQThreadVars

typedef struct NFQThreadVars_ NFQThreadVars

Enumeration Type Documentation

◆ NFQMode_

enum NFQMode_
Enumerator
NFQ_ACCEPT_MODE 
NFQ_REPEAT_MODE 
NFQ_ROUTE_MODE 

Definition at line 148 of file source-nfq.c.

Function Documentation

◆ NFQContextsClean()

void NFQContextsClean ( void  )

Clean global contexts. Must be called on exit.

Definition at line 1300 of file source-nfq.c.

Referenced by GlobalsDestroy().

Here is the caller graph for this function:

◆ NFQGetQueue()

void* NFQGetQueue ( int  number)

Get a pointer to the NFQ queue at index.

Parameters
numberidx of the queue in our array
Return values
ptrpointer to the NFQThreadVars at index
NULLon error

Definition at line 944 of file source-nfq.c.

References unlikely.

◆ NFQGetThread()

void* NFQGetThread ( int  number)

Get a pointer to the NFQ thread at index.

This function is temporary used as configuration parser.

Parameters
numberidx of the queue in our array
Return values
ptrpointer to the NFQThreadVars at index
NULLon error

Definition at line 962 of file source-nfq.c.

References unlikely.

Referenced by RunModeIpsNFQAutoFp(), and RunModeIpsNFQWorker().

Here is the caller graph for this function:

◆ NFQInitConfig()

void NFQInitConfig ( bool  quiet)

To initialize the NFQ global configuration data.

Parameters
quietIt tells the mode of operation, if it is TRUE nothing will be get printed.

Definition at line 206 of file source-nfq.c.

References NFQCnf_::batchcount, NFQCnf_::bypass_mark, NFQCnf_::bypass_mask, ConfGet(), ConfGetBool(), ConfGetInt(), FatalError, NFQCnf_::flags, NFQCnf_::mark, NFQCnf_::mask, NFQCnf_::mode, NFQCnf_::next_queue, NFQ_ACCEPT_MODE, nfq_config, NFQ_FLAG_FAIL_OPEN, NFQ_REPEAT_MODE, NFQ_ROUTE_MODE, SCLogDebug, SCLogError, SCLogInfo, and SCLogWarning.

Here is the call graph for this function:

◆ NFQParseAndRegisterQueues()

int NFQParseAndRegisterQueues ( const char *  queues)

Parses and adds Netfilter queue(s).

Parameters
stringwith the queue number or range
Return values
0on success.
-1on failure.

Definition at line 879 of file source-nfq.c.

References SCLogError, and SCRealloc.

◆ NFQRegisterQueue()

int NFQRegisterQueue ( const uint16_t  number)

Add a single Netfilter queue.

Parameters
stringwith the queue number
Return values
0on success.
-1on failure.

Definition at line 823 of file source-nfq.c.

References UtilCpuGetNumProcessorsOnline().

Here is the call graph for this function:

◆ TmModuleDecodeNFQRegister()

void TmModuleDecodeNFQRegister ( void  )

Definition at line 192 of file source-nfq.c.

References TmModule_::name, TmModule_::ThreadInit, TMM_DECODENFQ, and tmm_modules.

Referenced by RegisterAllModules().

Here is the caller graph for this function:

◆ TmModuleReceiveNFQRegister()

void TmModuleReceiveNFQRegister ( void  )

Definition at line 169 of file source-nfq.c.

Referenced by RegisterAllModules().

Here is the caller graph for this function:

◆ TmModuleVerdictNFQRegister()

void TmModuleVerdictNFQRegister ( void  )

Definition at line 184 of file source-nfq.c.

References TmModule_::name, TmModule_::ThreadInit, tmm_modules, and TMM_VERDICTNFQ.

Referenced by RegisterAllModules().

Here is the caller graph for this function:

Variable Documentation

◆ nfq_config

NFQCnf nfq_config

Definition at line 167 of file source-nfq.c.

Referenced by NFQInitConfig().