From 9315567023ca83f33b91554be940134825cf63e7 Mon Sep 17 00:00:00 2001 From: Shteryana Shopova Date: Fri, 19 Mar 2010 09:53:25 +0000 Subject: [PATCH] Make sure the snmp_pf module will first refresh its entires if necessary, then find a specific entry, and get the requested value. So far, it found the specific entry, refreshed the entry list if necessary, and got the requested value from the found entry. The problem is that refreshing nukes all old entries and replaces them with new ones and the obtained entry pointer was no longer valid after the refresh. Reviewed by: bz, philip MFC after: 1 week --- usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c | 24 +++++++++++------------ 1 file changed, 12 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 56c2cdaafd3c..4e915f427eea 100644 --- a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c +++ b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c @@ -534,6 +534,9 @@ pf_iftable(struct snmp_context __unused *ctx, struct snmp_value *val, asn_subid_t which = val->var.subs[sub - 1]; struct pfi_entry *e = NULL; + if ((time(NULL) - pfi_table_age) > PFI_TABLE_MAXAGE) + pfi_refresh(); + switch (op) { case SNMP_OP_SET: return (SNMP_ERR_NOT_WRITEABLE); @@ -557,9 +560,6 @@ pf_iftable(struct snmp_context __unused *ctx, struct snmp_value *val, abort(); } - if ((time(NULL) - pfi_table_age) > PFI_TABLE_MAXAGE) - pfi_refresh(); - switch (which) { case LEAF_pfInterfacesIfDescr: return (string_get(val, e->pfi.pfik_name, -1)); @@ -684,6 +684,9 @@ pf_tbltable(struct snmp_context __unused *ctx, struct snmp_value *val, asn_subid_t which = val->var.subs[sub - 1]; struct pft_entry *e = NULL; + if ((time(NULL) - pft_table_age) > PFT_TABLE_MAXAGE) + pft_refresh(); + switch (op) { case SNMP_OP_SET: return (SNMP_ERR_NOT_WRITEABLE); @@ -707,9 +710,6 @@ pf_tbltable(struct snmp_context __unused *ctx, struct snmp_value *val, abort(); } - if ((time(NULL) - pft_table_age) > PFT_TABLE_MAXAGE) - pft_refresh(); - switch (which) { case LEAF_pfTablesTblDescr: return (string_get(val, e->pft.pfrts_name, -1)); @@ -842,6 +842,9 @@ pf_altqq(struct snmp_context __unused *ctx, struct snmp_value *val, return (SNMP_ERR_NOERROR); } + if ((time(NULL) - pfq_table_age) > PFQ_TABLE_MAXAGE) + pfq_refresh(); + switch (op) { case SNMP_OP_SET: return (SNMP_ERR_NOT_WRITEABLE); @@ -865,9 +868,6 @@ pf_altqq(struct snmp_context __unused *ctx, struct snmp_value *val, abort(); } - if ((time(NULL) - pfq_table_age) > PFQ_TABLE_MAXAGE) - pfq_refresh(); - switch (which) { case LEAF_pfAltqQueueDescr: return (string_get(val, e->altq.qname, -1)); @@ -930,6 +930,9 @@ 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) + pfl_refresh(); + switch (op) { case SNMP_OP_SET: return (SNMP_ERR_NOT_WRITEABLE); @@ -953,9 +956,6 @@ pf_lbltable(struct snmp_context __unused *ctx, struct snmp_value *val, abort(); } - if ((time(NULL) - pfl_table_age) > PFL_TABLE_MAXAGE) - pfl_refresh(); - switch (which) { case LEAF_pfLabelsLblName: return (string_get(val, e->name, -1));