Feature #415 ยป 0001-capture-add-data-release-mechanism.patch
src/decode.h | ||
---|---|---|
/* IPS action to take */
|
||
uint8_t action;
|
||
/** The release function for packet data */
|
||
TmEcode (*ReleaseData)(struct Packet_ *);
|
||
void *relptr;
|
||
/* pkt vars */
|
||
PktVar *pktvar;
|
||
src/source-af-packet.c | ||
---|---|---|
SCReturnInt(AFP_READ_OK);
|
||
}
|
||
TmEcode AFPReleaseDataFromRing(Packet *p)
|
||
{
|
||
if (p->relptr) {
|
||
union thdr h;
|
||
h.raw = p->relptr;
|
||
h.h2->tp_status = TP_STATUS_KERNEL;
|
||
return TM_ECODE_OK;
|
||
}
|
||
return TM_ECODE_FAILED;
|
||
}
|
||
/**
|
||
* \brief AF packet read function for ring
|
||
*
|
||
... | ... | |
if (PacketSetData(p, (unsigned char*)h.raw + h.h2->tp_mac, h.h2->tp_snaplen) == -1) {
|
||
TmqhOutputPacketpool(ptv->tv, p);
|
||
SCReturnInt(AFP_FAILURE);
|
||
} else {
|
||
if (ptv->flags & AFP_RING_MODE) {
|
||
p->relptr = h.raw;
|
||
p->ReleaseData = AFPReleaseDataFromRing;
|
||
}
|
||
}
|
||
} else {
|
||
if (PacketCopyData(p, (unsigned char*)h.raw + h.h2->tp_mac, h.h2->tp_snaplen) == -1) {
|
||
... | ... | |
SCLogInfo("Enabling zero copy mode");
|
||
}
|
||
/* 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");
|
||
}
|
||
r = AFPCreateSocket(ptv, ptv->iface, 1);
|
||
if (r < 0) {
|
||
SCLogError(SC_ERR_AFP_CREATE, "Couldn't init AF_PACKET socket");
|
src/tmqh-packetpool.c | ||
---|---|---|
p->ext_pkt = NULL;
|
||
}
|
||
if (p->relptr && p->ReleaseData) {
|
||
if (p->ReleaseData(p) == TM_ECODE_FAILED) {
|
||
SCLogWarning(SC_ERR_INVALID_ACTION, "Unable to release packet data");
|
||
}
|
||
}
|
||
PACKET_PROFILING_END(p);
|
||
SCLogDebug("getting rid of tunnel pkt... alloc'd %s (root %p)", p->flags & PKT_ALLOC ? "true" : "false", p->root);
|