Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit message #748

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/source-af-packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ static inline void AFPDumpCounters(AFPThreadVars *ptv)
SCPerfCounterAddUI64(ptv->capture_kernel_packets, ptv->tv->sc_perf_pca, kstats.tp_packets);
SCPerfCounterAddUI64(ptv->capture_kernel_drops, ptv->tv->sc_perf_pca, kstats.tp_drops);
(void) SC_ATOMIC_ADD(ptv->livedev->drop, kstats.tp_drops);
(void) SC_ATOMIC_ADD(ptv->livedev->pkts, kstats.tp_packets);
}
#endif
}
Expand Down Expand Up @@ -561,7 +562,6 @@ int AFPRead(AFPThreadVars *ptv)

ptv->pkts++;
ptv->bytes += caplen + offset;
(void) SC_ATOMIC_ADD(ptv->livedev->pkts, 1);
p->livedev = ptv->livedev;

/* add forged header */
Expand Down
2 changes: 1 addition & 1 deletion src/source-ipfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ void ReceiveIPFWThreadExitStats(ThreadVars *tv, void *data)

SCEnter();

SCLogInfo("(%s) Packets %" PRIu32 ", bytes %" PRIu64 "", tv->name, ptv->pkts, ptv->bytes);
SCLogNotice("(%s) Packets %" PRIu32 ", bytes %" PRIu64 "", tv->name, ptv->pkts, ptv->bytes);

SCReturn;
}
Expand Down
2 changes: 1 addition & 1 deletion src/source-napatech.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ void NapatechStreamThreadExitStats(ThreadVars *tv, void *data)
if (ntv->drops > 0)
percent = (((double) ntv->drops) / (ntv->pkts+ntv->drops)) * 100;

SCLogInfo("Stream: %lu; Packets: %"PRIu64"; Drops: %"PRIu64" (%5.2f%%); Bytes: %"PRIu64, ntv->stream_id, ntv->pkts, ntv->drops, percent, ntv->bytes);
SCLogNotice("Stream: %lu; Packets: %"PRIu64"; Drops: %"PRIu64" (%5.2f%%); Bytes: %"PRIu64, ntv->stream_id, ntv->pkts, ntv->drops, percent, ntv->bytes);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/source-nfq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1000,9 +1000,9 @@ void ReceiveNFQThreadExitStats(ThreadVars *tv, void *data) {
NFQThreadVars *ntv = (NFQThreadVars *)data;
NFQQueueVars *nq = NFQGetQueue(ntv->nfq_index);
#ifdef COUNTERS
SCLogInfo("(%s) Pkts %" PRIu32 ", Bytes %" PRIu64 ", Errors %" PRIu32 "",
SCLogNotice("(%s) Pkts %" PRIu32 ", Bytes %" PRIu64 ", Errors %" PRIu32 "",
tv->name, nq->pkts, nq->bytes, nq->errs);
SCLogInfo("Pkts accepted %"PRIu32", dropped %"PRIu32", replaced %"PRIu32,
SCLogNotice("Pkts accepted %"PRIu32", dropped %"PRIu32", replaced %"PRIu32,
nq->accepted, nq->dropped, nq->replaced);
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion src/source-pcap-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ void ReceivePcapFileThreadExitStats(ThreadVars *tv, void *data) {
SCLogInfo("1/%" PRIu64 "th of packets have an invalid checksum",
chrate);
}
SCLogInfo("Pcap-file module read %" PRIu32 " packets, %" PRIu64 " bytes", ptv->pkts, ptv->bytes);
SCLogNotice("Pcap-file module read %" PRIu32 " packets, %" PRIu64 " bytes", ptv->pkts, ptv->bytes);
return;
}

Expand Down
12 changes: 10 additions & 2 deletions src/source-pfring.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,18 @@ static inline void PfringDumpCounters(PfringThreadVars *ptv)
{
pfring_stat pfring_s;
if (likely((pfring_stats(ptv->pd, &pfring_s) >= 0))) {
/* pfring counter is per socket and is not cleared after read.
* So to get the number of packet on the interface we can add
* the newly seen packets and drops for this thread and add it
* to the interface counter */
uint64_t th_pkts = SCPerfGetLocalCounterValue(ptv->capture_kernel_packets,
ptv->tv->sc_perf_pca);
uint64_t th_drops = SCPerfGetLocalCounterValue(ptv->capture_kernel_drops,
ptv->tv->sc_perf_pca);
SC_ATOMIC_ADD(ptv->livedev->pkts, pfring_s.recv - th_pkts);
SC_ATOMIC_ADD(ptv->livedev->drop, pfring_s.drop - th_drops);
SCPerfCounterSetUI64(ptv->capture_kernel_packets, ptv->tv->sc_perf_pca, pfring_s.recv);
SCPerfCounterSetUI64(ptv->capture_kernel_drops, ptv->tv->sc_perf_pca, pfring_s.drop);
SC_ATOMIC_SET(ptv->livedev->drop, pfring_s.drop);
}
}

Expand All @@ -211,7 +220,6 @@ static inline void PfringProcessPacket(void *user, struct pfring_pkthdr *h, Pack

ptv->bytes += h->caplen;
ptv->pkts++;
(void) SC_ATOMIC_ADD(ptv->livedev->pkts, 1);
p->livedev = ptv->livedev;

/* PF_RING may fail to set timestamp */
Expand Down
1 change: 1 addition & 0 deletions src/suricata.c
Original file line number Diff line number Diff line change
Expand Up @@ -2296,6 +2296,7 @@ int main(int argc, char **argv)

TagDestroyCtx();

LiveDeviceListClean();
RunModeShutDown();
OutputDeregisterAll();
TimeDeinit();
Expand Down
23 changes: 23 additions & 0 deletions src/util-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,29 @@ int LiveBuildDeviceList(char * runmode)
return i;
}

int LiveDeviceListClean()
{
SCEnter();
LiveDevice *pd;

TAILQ_FOREACH(pd, &live_devices, next) {
SCLogNotice("Stats for '%s': pkts: %u, drop: %u (%.2f%%), invalid chksum: %u",
pd->dev,
SC_ATOMIC_GET(pd->pkts),
SC_ATOMIC_GET(pd->drop),
100 * (SC_ATOMIC_GET(pd->drop) * 1.0) / SC_ATOMIC_GET(pd->pkts),
SC_ATOMIC_GET(pd->invalid_checksums));
if (pd->dev)
SCFree(pd->dev);
SC_ATOMIC_DESTROY(pd->pkts);
SC_ATOMIC_DESTROY(pd->drop);
SC_ATOMIC_DESTROY(pd->invalid_checksums);
SCFree(pd);
}

SCReturnInt(TM_ECODE_OK);
}

#ifdef BUILD_UNIX_SOCKET
TmEcode LiveDeviceIfaceStat(json_t *cmd, json_t *answer, void *data)
{
Expand Down
1 change: 1 addition & 0 deletions src/util-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ int LiveGetDeviceCount(void);
char *LiveGetDeviceName(int number);
LiveDevice *LiveGetDevice(char *dev);
int LiveBuildDeviceList(char * base);
int LiveDeviceListClean(void);

#ifdef BUILD_UNIX_SOCKET
TmEcode LiveDeviceIfaceStat(json_t *cmd, json_t *server_msg, void *data);
Expand Down