The branch main has been updated by cc:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7a52b570e758a5f607c4071e260065633632c868

commit 7a52b570e758a5f607c4071e260065633632c868
Author:     Cheng Cui <[email protected]>
AuthorDate: 2023-05-30 11:02:45 +0000
Commit:     Cheng Cui <[email protected]>
CommitDate: 2023-05-30 12:23:36 +0000

    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
---
 sys/netinet/siftr.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

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);

Reply via email to