afpacket: move zero copy setup to config parsing

This way it's run and logged per device, instead of per thread.
pull/1784/head
Victor Julien 10 years ago
parent 9d882116e2
commit bed1867830

@ -372,6 +372,22 @@ void *ParseAFPConfig(const char *iface)
"Using AF_PACKET with GRO or LRO activated can lead to capture problems"); "Using AF_PACKET with GRO or LRO activated can lead to capture problems");
} }
char *active_runmode = RunmodeGetActive();
if (active_runmode && !strcmp("workers", active_runmode)) {
aconf->flags |= AFP_ZERO_COPY;
SCLogInfo("%s: enabling zero copy mode", iface);
} else {
/* If we are using copy mode we need a lock */
aconf->flags |= AFP_SOCK_PROTECT;
}
/* If we are in RING mode, then we can use ZERO copy
* by using the data release mechanism */
if (aconf->flags & AFP_RING_MODE) {
aconf->flags |= AFP_ZERO_COPY;
SCLogInfo("%s: enabling zero copy mode by using data release call", iface);
}
return aconf; return aconf;
} }

@ -1720,23 +1720,6 @@ TmEcode ReceiveAFPThreadInit(ThreadVars *tv, void *initdata, void **data)
ptv->tv); ptv->tv);
#endif #endif
char *active_runmode = RunmodeGetActive();
if (active_runmode && !strcmp("workers", active_runmode)) {
ptv->flags |= AFP_ZERO_COPY;
SCLogInfo("Enabling zero copy mode");
} else {
/* If we are using copy mode we need a lock */
ptv->flags |= AFP_SOCK_PROTECT;
}
/* If we are in RING mode, then we can use ZERO copy
* by using the data release mechanism */
if (ptv->flags & AFP_RING_MODE) {
ptv->flags |= AFP_ZERO_COPY;
SCLogInfo("Enabling zero copy mode by using data release call");
}
ptv->copy_mode = afpconfig->copy_mode; ptv->copy_mode = afpconfig->copy_mode;
if (ptv->copy_mode != AFP_COPY_MODE_NONE) { if (ptv->copy_mode != AFP_COPY_MODE_NONE) {
strlcpy(ptv->out_iface, afpconfig->out_iface, AFP_IFACE_NAME_LENGTH); strlcpy(ptv->out_iface, afpconfig->out_iface, AFP_IFACE_NAME_LENGTH);

Loading…
Cancel
Save