@ -443,7 +443,7 @@ Packet *TmqhInputPacketpool(ThreadVars *tv)
void TmqhOutputPacketpool ( ThreadVars * t , Packet * p )
void TmqhOutputPacketpool ( ThreadVars * t , Packet * p )
{
{
int proot = 0 ;
bool proot = false ;
SCEnter ( ) ;
SCEnter ( ) ;
SCLogDebug ( " Packet %p, p->root %p, alloced %s " , p , p - > root , p - > flags & PKT_ALLOC ? " true " : " false " ) ;
SCLogDebug ( " Packet %p, p->root %p, alloced %s " , p , p - > root , p - > flags & PKT_ALLOC ? " true " : " false " ) ;
@ -458,17 +458,19 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
if ( IS_TUNNEL_ROOT_PKT ( p ) ) {
if ( IS_TUNNEL_ROOT_PKT ( p ) ) {
SCLogDebug ( " IS_TUNNEL_ROOT_PKT == TRUE " ) ;
SCLogDebug ( " IS_TUNNEL_ROOT_PKT == TRUE " ) ;
if ( TUNNEL_PKT_TPR ( p ) = = 0 ) {
const uint16_t outstanding = TUNNEL_PKT_TPR ( p ) - TUNNEL_PKT_RTV ( p ) ;
SCLogDebug ( " TUNNEL_PKT_TPR(p) == 0, no more tunnel packet "
SCLogDebug ( " root pkt: outstanding %u " , outstanding ) ;
" depending on this root " ) ;
if ( outstanding = = 0 ) {
SCLogDebug ( " no tunnel packets outstanding, no more tunnel "
" packet(s) depending on this root " ) ;
/* if this packet is the root and there are no
/* if this packet is the root and there are no
* more tunnel packets , return it to the pool */
* more tunnel packets to consider
*
/* fall through */
* return it to the pool */
} else {
} else {
SCLogDebug ( " tunnel root Packet %p: TUNNEL_PKT_TPR(p) > 0, so "
SCLogDebug ( " tunnel root Packet %p: outstanding > 0, so "
" packets are still depending on this root, setting "
" packets are still depending on this root, setting "
" p->tunnel_verdicted == 1 " , p ) ;
" SET_TUNNEL_PKT_VERDICTED " , p ) ;
/* if this is the root and there are more tunnel
/* if this is the root and there are more tunnel
* packets , return this to the pool . It ' s still referenced
* packets , return this to the pool . It ' s still referenced
* by the tunnel packets , and we will return it
* by the tunnel packets , and we will return it
@ -482,34 +484,34 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
} else {
} else {
SCLogDebug ( " NOT IS_TUNNEL_ROOT_PKT, so tunnel pkt " ) ;
SCLogDebug ( " NOT IS_TUNNEL_ROOT_PKT, so tunnel pkt " ) ;
/* the p->root != NULL here seems unnecessary: IS_TUNNEL_PKT checks
TUNNEL_INCR_PKT_RTV_NOLOCK ( p ) ;
* that p - > tunnel_pkt = = 1 , IS_TUNNEL_ROOT_PKT checks that +
const uint16_t outstanding = TUNNEL_PKT_TPR ( p ) - TUNNEL_PKT_RTV ( p ) ;
* p - > root = = NULL . So when we are here p - > root can only be
SCLogDebug ( " tunnel pkt: outstanding %u " , outstanding ) ;
* non - NULL , right ? CLANG thinks differently . May be a FP , but
/* all tunnel packets are processed except us. Root already
* better safe than sorry . VJ */
* processed . So return tunnel pkt and root packet to the
if ( p - > root ! = NULL & & IS_TUNNEL_PKT_VERDICTED ( p - > root ) & &
* pool . */
TUNNEL_PKT_TPR ( p ) = = 1 )
if ( outstanding = = 0 & &
p - > root & & IS_TUNNEL_PKT_VERDICTED ( p - > root ) )
{
{
SCLogDebug ( " p->root->tunnel_verdicted == 1 && TUNNEL_PKT_TPR(p) == 1 " ) ;
SCLogDebug ( " root verdicted == true && no outstanding " ) ;
/* the root is ready and we are the last tunnel packet,
* lets enqueue them both . */
TUNNEL_DECR_PKT_TPR_NOLOCK ( p ) ;
/* handle the root */
/* handle freeing the root as well*/
SCLogDebug ( " setting proot = 1 for root pkt, p->root %p "
SCLogDebug ( " setting proot = 1 for root pkt, p->root %p "
" (tunnel packet %p) " , p - > root , p ) ;
" (tunnel packet %p) " , p - > root , p ) ;
proot = 1 ;
proot = true ;
/* fall through */
/* fall through */
} else {
/* root not ready yet, so get rid of the tunnel pkt only */
SCLogDebug ( " NOT p->root->tunnel_verdicted == 1 && "
} else {
" TUNNEL_PKT_TPR(p) == 1 (% " PRIu32 " ) " , TUNNEL_PKT_TPR ( p ) ) ;
/* root not ready yet, or not the last tunnel packet,
* so get rid of the tunnel pkt only */
TUNNEL_DECR_PKT_TPR_NOLOCK ( p ) ;
SCLogDebug ( " NOT IS_TUNNEL_PKT_VERDICTED (%s) || "
" outstanding > 0 (%u) " ,
( p - > root & & IS_TUNNEL_PKT_VERDICTED ( p - > root ) ) ? " true " : " false " ,
outstanding ) ;
/* fall through */
/* fall through */
}
}
}
}
SCMutexUnlock ( m ) ;
SCMutexUnlock ( m ) ;
@ -520,7 +522,7 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
FlowDeReference ( & p - > flow ) ;
FlowDeReference ( & p - > flow ) ;
/* we're done with the tunnel root now as well */
/* we're done with the tunnel root now as well */
if ( proot = = 1 ) {
if ( proot = = true ) {
SCLogDebug ( " getting rid of root pkt... alloc'd %s " , p - > root - > flags & PKT_ALLOC ? " true " : " false " ) ;
SCLogDebug ( " getting rid of root pkt... alloc'd %s " , p - > root - > flags & PKT_ALLOC ? " true " : " false " ) ;
FlowDeReference ( & p - > root - > flow ) ;
FlowDeReference ( & p - > root - > flow ) ;