We don't need to recycle the full alert array. This is going to
optimize packet recycle time.
return pa_array;
}
-void PacketAlertRecycle(PacketAlert *pa_array)
+void PacketAlertRecycle(PacketAlert *pa_array, uint16_t cnt)
{
if (pa_array == NULL)
return;
- for (int i = 0; i < packet_alert_max; i++) {
+ /* Clean json content for alerts attached to the packet */
+ for (int i = 0; i < cnt; i++) {
struct PacketContextData *current_json = pa_array[i].json_info;
while (current_json) {
struct PacketContextData *next_json = current_json->next;
} PacketAlerts;
PacketAlert *PacketAlertCreate(void);
-void PacketAlertRecycle(PacketAlert *pa_array);
+void PacketAlertRecycle(PacketAlert *pa_array, uint16_t cnt);
void PacketAlertFree(PacketAlert *pa);
p->BypassPacketsFlow = NULL;
#define RESET_PKT_LEN(p) ((p)->pktlen = 0)
RESET_PKT_LEN(p);
- p->alerts.cnt = 0;
p->alerts.discarded = 0;
p->alerts.suppressed = 0;
p->alerts.drop.action = 0;
- PacketAlertRecycle(p->alerts.alerts);
+ if (p->alerts.cnt > 0)
+ PacketAlertRecycle(p->alerts.alerts, p->alerts.cnt);
+ p->alerts.cnt = 0;
p->pcap_cnt = 0;
p->tunnel_rtv_cnt = 0;
p->tunnel_tpr_cnt = 0;