packet: optimize json context cleaning

We don't need to recycle the full alert array. This is going to
optimize packet recycle time.
pull/13432/head
Eric Leblond 1 year ago committed by Victor Julien
parent 1deca14331
commit a297fd029a

@ -145,11 +145,12 @@ PacketAlert *PacketAlertCreate(void)
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;

@ -294,7 +294,7 @@ typedef struct PacketAlerts_ {
} PacketAlerts;
PacketAlert *PacketAlertCreate(void);
void PacketAlertRecycle(PacketAlert *pa_array);
void PacketAlertRecycle(PacketAlert *pa_array, uint16_t cnt);
void PacketAlertFree(PacketAlert *pa);

@ -123,11 +123,12 @@ void PacketReinit(Packet *p)
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;

Loading…
Cancel
Save