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")
This commit is contained in:
@@ -673,7 +673,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);
|
||||
|
||||
@@ -812,7 +812,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) {
|
||||
@@ -1035,7 +1035,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) {
|
||||
@@ -1322,9 +1322,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);
|
||||
@@ -1422,9 +1419,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);
|
||||
@@ -1590,9 +1584,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);
|
||||
|
||||
Reference in New Issue
Block a user