#define PACKET_TEST_ACTION_DO(p, a) (p)->action &(a)
-static inline void PacketDrop(Packet *p, enum PacketDropReason r)
+#define PACKET_UPDATE_ACTION(p, a) (p)->action |= (a)
+static inline void PacketUpdateAction(Packet *p, const uint8_t a)
+{
+ if (likely(p->root == NULL)) {
+ PACKET_UPDATE_ACTION(p, a);
+ } else {
+ PACKET_UPDATE_ACTION(p->root, a);
+ }
+}
+
+static inline void PacketDrop(Packet *p, const uint8_t action, enum PacketDropReason r)
{
if (p->drop_reason == PKT_DROP_REASON_NOT_SET)
p->drop_reason = (uint8_t)r;
- PACKET_SET_ACTION(p, ACTION_DROP);
+ PACKET_UPDATE_ACTION(p, action);
}
#define PACKET_DROP(p) PacketDrop((p), PKT_DROP_REASON_NOT_SET)
}
#define PACKET_TEST_ACTION(p, a) PacketTestAction((p), (a))
-#define PACKET_UPDATE_ACTION(p, a) do { \
- ((p)->root ? \
- ((p)->root->action |= a) : \
- ((p)->action |= a)); \
-} while (0)
-
#define TUNNEL_INCR_PKT_RTV_NOLOCK(p) do { \
((p)->root ? (p)->root->tunnel_rtv_cnt++ : (p)->tunnel_rtv_cnt++); \
} while (0)
s->action, alert_flags);
if (s->action & ACTION_DROP) {
- PacketDrop(p, PKT_DROP_REASON_RULES);
+ PacketDrop(p, s->action, PKT_DROP_REASON_RULES);
if (p->alerts.drop.action == 0) {
p->alerts.drop.num = s->num;
pa->flags |= PACKET_ALERT_RATE_FILTER_MODIFIED;
break;
case TH_ACTION_DROP:
- PacketDrop(p, PKT_DROP_REASON_RULES_THRESHOLD);
+ PacketDrop(p, new_action, PKT_DROP_REASON_RULES_THRESHOLD);
pa->flags |= PACKET_ALERT_RATE_FILTER_MODIFIED;
break;
case TH_ACTION_REJECT:
/* if flow is set to drop, we enforce that here */
if (p->flow->flags & FLOW_ACTION_DROP) {
- PacketDrop(p, PKT_DROP_REASON_FLOW_DROP);
+ PacketDrop(p, ACTION_DROP, PKT_DROP_REASON_FLOW_DROP);
SCReturn;
}
FlowSetNoPacketInspectionFlag(p->flow);
DecodeSetNoPacketInspectionFlag(p);
StreamTcpDisableAppLayer(p->flow);
- PacketDrop(p, PKT_DROP_REASON_FLOW_DROP);
+ PacketDrop(p, ACTION_DROP, PKT_DROP_REASON_FLOW_DROP);
/* return the segments to the pool */
StreamTcpSessionPktFree(p);
SCReturnInt(0);
* anyway. Doesn't disable all detection, so we can still
* match on the stream event that was set. */
DecodeSetNoPayloadInspectionFlag(p);
- PacketDrop(p, PKT_DROP_REASON_STREAM_ERROR);
+ PacketDrop(p, ACTION_DROP, PKT_DROP_REASON_STREAM_ERROR);
}
SCReturnInt(-1);
}
SCLogDebug("EXCEPTION_POLICY_DROP_PACKET");
DecodeSetNoPayloadInspectionFlag(p);
DecodeSetNoPacketInspectionFlag(p);
- PacketDrop(p, drop_reason);
+ PacketDrop(p, ACTION_DROP, drop_reason);
break;
case EXCEPTION_POLICY_BYPASS_FLOW:
PacketBypassCallback(p);