From: Eric Leblond Date: Tue, 18 Sep 2012 15:12:31 +0000 (+0200) Subject: af-packet: little code cleaning X-Git-Tag: suricata-1.4beta2~62 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5f12b23469fc7ab4c6c30cfc43dbce92488dfb12;p=thirdparty%2Fsuricata.git af-packet: little code cleaning This patch cleans the code were two almost identical treatment on the packet we're made. It may be linked by a merge error I've done or to a simple mistake on my side. --- diff --git a/src/source-af-packet.c b/src/source-af-packet.c index d924c86eeb..f86617fc26 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -722,18 +722,6 @@ int AFPReadFromRing(AFPThreadVars *ptv) * function. */ h.h2->tp_status |= TP_STATUS_USER_BUSY; - p->afp_v.relptr = h.raw; - p->ReleaseData = AFPReleaseDataFromRing; - p->afp_v.mpeer = ptv->mpeer; - AFPRefSocket(ptv->mpeer); - - p->afp_v.copy_mode = ptv->copy_mode; - if (p->afp_v.copy_mode != AFP_COPY_MODE_NONE) { - p->afp_v.peer = ptv->mpeer->peer; - } else { - p->afp_v.peer = NULL; - } - from = (void *)h.raw + TPACKET_ALIGN(ptv->tp_hdrlen); ptv->pkts++; @@ -759,6 +747,9 @@ int AFPReadFromRing(AFPThreadVars *ptv) SCReturnInt(AFP_FAILURE); } else { p->afp_v.relptr = h.raw; + p->ReleaseData = AFPReleaseDataFromRing; + p->afp_v.mpeer = ptv->mpeer; + AFPRefSocket(ptv->mpeer); p->afp_v.copy_mode = ptv->copy_mode; if (p->afp_v.copy_mode != AFP_COPY_MODE_NONE) { @@ -766,7 +757,6 @@ int AFPReadFromRing(AFPThreadVars *ptv) } else { p->afp_v.peer = NULL; } - p->ReleaseData = AFPReleaseDataFromRing; } } else { if (PacketCopyData(p, (unsigned char*)h.raw + h.h2->tp_mac, h.h2->tp_snaplen) == -1) { @@ -802,6 +792,11 @@ int AFPReadFromRing(AFPThreadVars *ptv) AFPDumpCounters(ptv, 1); } + /* release frame if not in zero copy mode */ + if (!(ptv->flags & AFP_ZERO_COPY)) { + h.h2->tp_status = TP_STATUS_KERNEL; + } + if (TmThreadsSlotProcessPkt(ptv->tv, ptv->slot, p) != TM_ECODE_OK) { h.h2->tp_status = TP_STATUS_KERNEL; if (++ptv->frame_offset >= ptv->req.tp_frame_nr) { @@ -811,10 +806,6 @@ int AFPReadFromRing(AFPThreadVars *ptv) SCReturnInt(AFP_FAILURE); } - /* release frame if not in zero copy mode */ - if (!(ptv->flags & AFP_ZERO_COPY)) { - h.h2->tp_status = TP_STATUS_KERNEL; - } next_frame: if (++ptv->frame_offset >= ptv->req.tp_frame_nr) { ptv->frame_offset = 0;