The branch stable/14 has been updated by kp:

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

commit e0d4064bcae396d06c08a24c9670c1e68afb03d3
Author:     Kristof Provost <[email protected]>
AuthorDate: 2025-12-17 13:22:05 +0000
Commit:     Kristof Provost <[email protected]>
CommitDate: 2026-05-26 08:53:20 +0000

    snmp_pf: fix refresh
    
    Some refresh functions had two layers of 'do we need to refresh now?'
    checks, leading to inconsistent refreshes.
    Consolidate them.
    
    PR:             291725
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    
    (cherry picked from commit a862e4b5a27c356e2584ee74fd9e211c18b1b125)
---
 usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c 
b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c
index a5786007d3f4..c6f288d0a608 100644
--- a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c
+++ b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c
@@ -675,7 +675,7 @@ pf_tables(struct snmp_context __unused *ctx, struct 
snmp_value *val,
                return (SNMP_ERR_NOT_WRITEABLE);
 
        if (op == SNMP_OP_GET) {
-               if ((time(NULL) - pft_table_age) > PFT_TABLE_MAXAGE)
+               if (! started || (time(NULL) - pft_table_age) > 
PFT_TABLE_MAXAGE)
                        if (pft_refresh() == -1)
                            return (SNMP_ERR_GENERR);
 
@@ -814,7 +814,7 @@ pf_tbladdr(struct snmp_context __unused *ctx, struct 
snmp_value __unused *val,
        asn_subid_t     which = val->var.subs[sub - 1];
        struct pfa_entry *e = NULL;
 
-       if ((time(NULL) - pfa_table_age) > PFA_TABLE_MAXAGE)
+       if (! started || (time(NULL) - pfa_table_age) > PFA_TABLE_MAXAGE)
                pfa_refresh();
 
        switch (op) {
@@ -1037,7 +1037,7 @@ pf_lbltable(struct snmp_context __unused *ctx, struct 
snmp_value *val,
        asn_subid_t     which = val->var.subs[sub - 1];
        struct pfl_entry *e = NULL;
 
-       if ((time(NULL) - pfl_table_age) > PFL_TABLE_MAXAGE)
+       if (! started || (time(NULL) - pfl_table_age) > PFL_TABLE_MAXAGE)
                pfl_refresh();
 
        switch (op) {
@@ -1307,9 +1307,6 @@ pft_refresh(void)
        struct pft_entry *e;
        int i, numtbls = 1;
 
-       if (started && this_tick <= pf_tick)
-               return (0);
-
        while (!TAILQ_EMPTY(&pft_table)) {
                e = TAILQ_FIRST(&pft_table);
                TAILQ_REMOVE(&pft_table, e, link);
@@ -1441,9 +1438,6 @@ pfa_refresh(void)
        struct pfa_entry *e;
        int i, numtbls = 1, cidx, naddrs;
 
-       if (started && this_tick <= pf_tick)
-               return (0);
-
        while (!TAILQ_EMPTY(&pfa_table)) {
                e = TAILQ_FIRST(&pfa_table);
                TAILQ_REMOVE(&pfa_table, e, link);
@@ -1612,9 +1606,6 @@ pfl_refresh(void)
 {
        struct pfl_entry *e;
 
-       if (started && this_tick <= pf_tick)
-               return (0);
-
        while (!TAILQ_EMPTY(&pfl_table)) {
                e = TAILQ_FIRST(&pfl_table);
                TAILQ_REMOVE(&pfl_table, e, link);

Reply via email to