af-packet: add variable to disable offloading detection

This flag adds variable to disable offloading detection. The effect
of the flag is to avoid to transmit auxiliary data at each packet.
This could result in a potential performance gain.
remotes/origin/master-1.2.x
Eric Leblond 14 years ago committed by Victor Julien
parent f6ddaf3341
commit 67f791e891

@ -108,7 +108,7 @@ void *ParseAFPConfig(const char *iface)
char *tmpclusterid; char *tmpclusterid;
char *tmpctype; char *tmpctype;
intmax_t value; intmax_t value;
int dispromisc; int boolval;
if (iface == NULL) { if (iface == NULL) {
return NULL; return NULL;
@ -125,6 +125,7 @@ void *ParseAFPConfig(const char *iface)
aconf->cluster_id = 1; aconf->cluster_id = 1;
aconf->cluster_type = PACKET_FANOUT_HASH; aconf->cluster_type = PACKET_FANOUT_HASH;
aconf->promisc = 1; aconf->promisc = 1;
aconf->detect_offload = 1;
aconf->DerefFunc = AFPDerefConfig; aconf->DerefFunc = AFPDerefConfig;
/* Find initial node */ /* Find initial node */
@ -197,12 +198,20 @@ void *ParseAFPConfig(const char *iface)
aconf->buffer_size = 0; aconf->buffer_size = 0;
} }
ConfGetChildValueBool(if_root, "disable-promisc", (int *)&dispromisc); ConfGetChildValueBool(if_root, "disable-promisc", (int *)&boolval);
if (dispromisc) { if (boolval) {
SCLogInfo("Disabling promiscuous mode on iface %s", SCLogInfo("Disabling promiscuous mode on iface %s",
aconf->iface); aconf->iface);
aconf->promisc = 0; aconf->promisc = 0;
} }
ConfGetChildValueBool(if_root, "detect-offload", (int *)&boolval);
if (! boolval) {
SCLogInfo("Disabling checksum offloading detection for %s",
aconf->iface);
aconf->detect_offload = 0;
}
return aconf; return aconf;
} }

@ -160,6 +160,7 @@ typedef struct AFPThreadVars_
/* socket buffer size */ /* socket buffer size */
int buffer_size; int buffer_size;
int promisc; int promisc;
int detect_offload;
int cluster_id; int cluster_id;
int cluster_type; int cluster_type;
@ -522,13 +523,18 @@ static int AFPCreateSocket(AFPThreadVars *ptv, char *devname, int verbose)
} }
} }
{ int val = 1; if (ptv->detect_offload) {
if (setsockopt(ptv->socket, SOL_PACKET, PACKET_AUXDATA, &val, int val = 1;
sizeof(val)) == -1 && errno != ENOPROTOOPT) { if (setsockopt(ptv->socket, SOL_PACKET, PACKET_AUXDATA, &val,
/* FIXME */ sizeof(val)) == -1 && errno != ENOPROTOOPT) {
return -1; SCLogError(SC_ERR_AFP_CREATE,
"Couldn't active auxdata on iface %s, error %s",
devname,
strerror(errno));
close(ptv->socket);
return -1;
}
} }
}
/* set socket recv buffer size */ /* set socket recv buffer size */
if (ptv->buffer_size != 0) { if (ptv->buffer_size != 0) {
@ -607,6 +613,7 @@ TmEcode ReceiveAFPThreadInit(ThreadVars *tv, void *initdata, void **data) {
ptv->buffer_size = afpconfig->buffer_size; ptv->buffer_size = afpconfig->buffer_size;
ptv->promisc = afpconfig->promisc; ptv->promisc = afpconfig->promisc;
ptv->detect_offload = afpconfig->detect_offload;
ptv->threads = 1; ptv->threads = 1;
#ifdef HAVE_PACKET_FANOUT #ifdef HAVE_PACKET_FANOUT

@ -53,6 +53,8 @@ typedef struct AFPIfaceConfig_
int cluster_type; int cluster_type;
/* promisc mode */ /* promisc mode */
int promisc; int promisc;
/* no local packet */
int detect_offload;
SC_ATOMIC_DECLARE(unsigned int, ref); SC_ATOMIC_DECLARE(unsigned int, ref);
void (*DerefFunc)(void *); void (*DerefFunc)(void *);
} AFPIfaceConfig; } AFPIfaceConfig;

@ -204,6 +204,9 @@ af-packet:
# buffer-size: 32768 # buffer-size: 32768
# Set to yes to disable promiscuous mode # Set to yes to disable promiscuous mode
# disable-promisc: no # disable-promisc: no
# If your IDS do not treat any transmitted packets, you can set
# the following variable to no.
# detect-offload: yes
- interface: eth1 - interface: eth1
threads: 1 threads: 1
cluster-id: 98 cluster-id: 98

Loading…
Cancel
Save