diff options
author | Cheng Cui <cc@FreeBSD.org> | 2023-05-30 11:02:45 +0000 |
---|---|---|
committer | Cheng Cui <cc@FreeBSD.org> | 2023-05-30 12:23:36 +0000 |
commit | 7a52b570e758a5f607c4071e260065633632c868 (patch) | |
tree | 7d3e1fe5f5799d75307dae234272266e1e2a9a7a | |
parent | 84ffbd7782d2e98e440782b453f4e64cd1026d33 (diff) | |
download | src-7a52b570e758a5f607c4071e260065633632c868.tar.gz src-7a52b570e758a5f607c4071e260065633632c868.zip |
siftr: bring back the siftr_pkts_per_log feature
Summary: this missing feature is introduced by commit aa61cff4249c
Test Plan: verified in Emulab.net
Reviewers: rscheff, tuexen
Approved by: tuexen (mentor)
Subscribers: imp, melifaro, glebius
Differential Revision: https://reviews.freebsd.org/D40336
-rw-r--r-- | sys/netinet/siftr.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/netinet/siftr.c b/sys/netinet/siftr.c index 2c02130bbcca..cbcd2b2ead42 100644 --- a/sys/netinet/siftr.c +++ b/sys/netinet/siftr.c @@ -379,6 +379,22 @@ siftr_process_pkt(struct pkt_node * pkt_node) if (hash_node == NULL) { return; + } else if (siftr_pkts_per_log > 1) { + /* + * Taking the remainder of the counter divided + * by the current value of siftr_pkts_per_log + * and storing that in counter provides a neat + * way to modulate the frequency of log + * messages being written to the log file. + */ + hash_node->counter = (hash_node->counter + 1) % + siftr_pkts_per_log; + /* + * If we have not seen enough packets since the last time + * we wrote a log message for this connection, return. + */ + if (hash_node->counter > 0) + return; } log_buf = alq_getn(siftr_alq, MAX_LOG_MSG_LEN, ALQ_WAITOK); |