We currently abuse sysORTable to display information in a way that it shouldn't. According to SNMPv2-MIB: "The (conceptual) table listing the capabilities of the local SNMP application acting as a command responder with respect to various MIB modules. SNMP entities having dynamically-configurable support of MIB modules will have a dynamically-varying number of conceptual rows."
I must admit that from a first glance our usage seems correct, but I found the following text in RFC2741 (AGENTX): An Object Identifier containing the value of an invocation of the AGENT-CAPABILITIES macro, which the master agent exports as a value of sysORID for the indicated context. (Recall that the value of an invocation of an AGENT- CAPABILITIES macro is an object identifier that describes a precise level of support with respect to implemented MIB modules. A more complete discussion of the AGENT- CAPABILITIES macro and related sysORID values can be found in section 6 of STD 58, RFC 2580 [7].) And if we look at section 6.6 of RFC 2580: 6.6. Mapping of the AGENT-CAPABILITIES value The value of an invocation of the AGENT-CAPABILITIES macro is an OBJECT IDENTIFIER, which names the value of sysORID [3] for which this capabilities statement is valid. This means that that the OIDs used in the sysORTable need to reference an AGENT-CAPABILITIES macro, which need to be defined separately and we currently don't have those. Apart from the above we also falsely return sysORIndex, which has MAX-ACCESS not-accessible. I propose we remove the sysORTable code until we either: 1) Have a proper AGENT-CAPABILITIES file for snmpd(8) 2) Have proper support for agentx-AddAgentCaps-PDU This removes falsities from our code and allows us to reimplement it in a more scalable way for agentx support in the future. OK? martijn@ ps. I know that net-snmp does something similar, but that doesn't mean I would like to copy their spec-violations. Index: mib.c =================================================================== --- mib.c (revision 1) +++ mib.c (working copy) @@ -65,7 +65,6 @@ int mib_getsys(struct oid *, struct ber_oid *, struct ber_element **); int mib_getsnmp(struct oid *, struct ber_oid *, struct ber_element **); -int mib_sysor(struct oid *, struct ber_oid *, struct ber_element **); int mib_setsnmp(struct oid *, struct ber_oid *, struct ber_element **); static struct oid mib_tree[] = MIB_TREE; @@ -75,7 +74,6 @@ /* base MIB tree */ static struct oid base_mib[] = { - { MIB(mib_2), OID_MIB }, { MIB(sysDescr), OID_RD, mib_getsys }, { MIB(sysOID), OID_RD, mib_getsys }, { MIB(sysUpTime), OID_RD, mib_getsys }, @@ -84,11 +82,6 @@ { MIB(sysLocation), OID_RW, mib_getsys, mps_setstr }, { MIB(sysServices), OID_RS, mib_getsys }, { MIB(sysORLastChange), OID_RD, mps_getts }, - { MIB(sysORIndex), OID_TRD, mib_sysor }, - { MIB(sysORID), OID_TRD, mib_sysor }, - { MIB(sysORDescr), OID_TRD, mib_sysor }, - { MIB(sysORUpTime), OID_TRD, mib_sysor }, - { MIB(snmp), OID_MIB }, { MIB(snmpInPkts), OID_RD, mib_getsnmp }, { MIB(snmpOutPkts), OID_RD, mib_getsnmp }, { MIB(snmpInBadVersions), OID_RD, mib_getsnmp }, @@ -190,68 +183,6 @@ } int -mib_sysor(struct oid *oid, struct ber_oid *o, struct ber_element **elm) -{ - struct ber_element *ber = *elm; - u_int32_t idx = 1, nmib = 0; - struct oid *next, *miboid; - char buf[SNMPD_MAXSTRLEN]; - - /* Count MIB root OIDs in the tree */ - for (next = NULL; - (next = smi_foreach(next, OID_MIB)) != NULL; nmib++); - - /* Get and verify the current row index */ - idx = o->bo_id[OIDIDX_sysOREntry]; - if (idx > nmib) - return (1); - - /* Find the MIB root element for this Id */ - for (next = miboid = NULL, nmib = 1; - (next = smi_foreach(next, OID_MIB)) != NULL; nmib++) { - if (nmib == idx) - miboid = next; - } - if (miboid == NULL) - return (-1); - - /* Tables need to prepend the OID on their own */ - ber = ober_add_oid(ber, o); - - switch (o->bo_id[OIDIDX_sysOR]) { - case 1: - ber = ober_add_integer(ber, idx); - break; - case 2: - ber = ober_add_oid(ber, &miboid->o_id); - break; - case 3: - /* - * This should be a description of the MIB. - * But we use the symbolic OID string for now, it may - * help to display names of internal OIDs. - */ - smi_oid2string(&miboid->o_id, buf, sizeof(buf), 0); - ber = ober_add_string(ber, buf); - break; - case 4: - /* - * We do not support dynamic loading of MIB at runtime, - * the sysORUpTime value of 0 will indicate "loaded at - * startup". - */ - ber = ober_add_integer(ber, 0); - ober_set_header(ber, - BER_CLASS_APPLICATION, SNMP_T_TIMETICKS); - break; - default: - return (-1); - } - - return (0); -} - -int mib_getsnmp(struct oid *oid, struct ber_oid *o, struct ber_element **elm) { struct snmp_stats *stats = &snmpd_env->sc_stats; @@ -333,12 +264,10 @@ int mib_usmstats(struct oid *, struct ber_oid *, struct ber_element **); static struct oid usm_mib[] = { - { MIB(snmpEngine), OID_MIB }, { MIB(snmpEngineID), OID_RD, mib_engine }, { MIB(snmpEngineBoots), OID_RD, mib_engine }, { MIB(snmpEngineTime), OID_RD, mib_engine }, { MIB(snmpEngineMaxMsgSize), OID_RD, mib_engine }, - { MIB(usmStats), OID_MIB }, { MIB(usmStatsUnsupportedSecLevels), OID_RD, mib_usmstats }, { MIB(usmStatsNotInTimeWindow), OID_RD, mib_usmstats }, { MIB(usmStatsUnknownUserNames), OID_RD, mib_usmstats }, @@ -419,7 +348,6 @@ int kinfo_args(struct kinfo_proc *, char **); static struct oid hr_mib[] = { - { MIB(host), OID_MIB }, { MIB(hrSystemUptime), OID_RD, mib_hrsystemuptime }, { MIB(hrSystemDate), OID_RD, mib_hrsystemdate }, { MIB(hrSystemProcesses), OID_RD, mib_hrsystemprocs }, @@ -1013,7 +941,6 @@ static u_int8_t ether_zeroaddr[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static struct oid if_mib[] = { - { MIB(ifMIB), OID_MIB }, { MIB(ifName), OID_TRD, mib_ifxtable }, { MIB(ifInMulticastPkts), OID_TRD, mib_ifxtable }, { MIB(ifInBroadcastPkts), OID_TRD, mib_ifxtable }, @@ -1446,7 +1373,6 @@ int mib_memiftable(struct oid *, struct ber_oid *, struct ber_element **); static struct oid openbsd_mib[] = { - { MIB(pfMIBObjects), OID_MIB }, { MIB(pfRunning), OID_RD, mib_pfinfo }, { MIB(pfRuntime), OID_RD, mib_pfinfo }, { MIB(pfDebug), OID_RD, mib_pfinfo }, @@ -1619,7 +1545,6 @@ { MIB(pfsyncIp6PktsSent), OID_RD, mib_pfsyncstats }, { MIB(pfsyncNoMemory), OID_RD, mib_pfsyncstats }, { MIB(pfsyncOutputErrors), OID_RD, mib_pfsyncstats }, - { MIB(sensorsMIBObjects), OID_MIB }, { MIB(sensorNumber), OID_RD, mib_sensornum }, { MIB(sensorIndex), OID_TRD, mib_sensors }, { MIB(sensorDescr), OID_TRD, mib_sensors }, @@ -1628,7 +1553,6 @@ { MIB(sensorValue), OID_TRD, mib_sensors }, { MIB(sensorUnits), OID_TRD, mib_sensors }, { MIB(sensorStatus), OID_TRD, mib_sensors }, - { MIB(carpMIBObjects), OID_MIB }, { MIB(carpAllow), OID_RD, mib_carpsysctl }, { MIB(carpPreempt), OID_RD, mib_carpsysctl }, { MIB(carpLog), OID_RD, mib_carpsysctl }, @@ -1657,7 +1581,6 @@ { MIB(carpIfState), OID_TRD, mib_carpiftable }, { MIB(carpGroupName), OID_TRD, mib_carpgrouptable }, { MIB(carpGroupDemote), OID_TRD, mib_carpgrouptable }, - { MIB(memMIBObjects), OID_MIB }, { MIB(memMIBVersion), OID_RD, mps_getint, NULL, NULL, OIDVER_OPENBSD_MEM }, { MIB(memIfName), OID_TRD, mib_memiftable }, @@ -3052,7 +2975,6 @@ mib_physaddrtable(struct oid *, struct ber_oid *, struct ber_oid *); static struct oid ip_mib[] = { - { MIB(ipMIB), OID_MIB }, { MIB(ipForwarding), OID_RD, mib_ipforwarding }, { MIB(ipDefaultTTL), OID_RD, mib_ipdefaultttl }, { MIB(ipInReceives), OID_RD, mib_ipstat }, @@ -3536,7 +3458,6 @@ int mib_ipfroute(struct oid *, struct ber_oid *, struct ber_element **); static struct oid ipf_mib[] = { - { MIB(ipfMIB), OID_MIB }, { MIB(ipfInetCidrRouteNumber), OID_RD, mib_ipfnroutes }, { MIB(ipfRouteEntIfIndex), OID_TRD, mib_ipfroute, NULL, @@ -3776,7 +3697,6 @@ int mib_diskio(struct oid *oid, struct ber_oid *o, struct ber_element **elm); static struct oid diskio_mib[] = { - { MIB(ucdDiskIOMIB), OID_MIB }, { MIB(diskIOIndex), OID_TRD, mib_diskio }, { MIB(diskIODevice), OID_TRD, mib_diskio }, { MIB(diskIONRead), OID_TRD, mib_diskio }, @@ -3873,7 +3793,6 @@ int mib_dot1dtable(struct oid *, struct ber_oid *, struct ber_element **); static struct oid bridge_mib[] = { - { MIB(dot1dBridge), OID_MIB }, { MIB(dot1dBaseBridgeAddress) }, { MIB(dot1dBaseNumPorts), OID_RD, mib_ifnumber }, { MIB(dot1dBaseType), OID_RD, mps_getint, NULL, Index: snmpd.h =================================================================== --- snmpd.h (revision 2) +++ snmpd.h (working copy) @@ -325,7 +325,6 @@ #define OID_IFSET 0x04 /* only if user-specified value */ #define OID_DYNAMIC 0x08 /* free allocated data */ #define OID_TABLE 0x10 /* dynamic sub-elements */ -#define OID_MIB 0x20 /* root-OID of a supported MIB */ #define OID_KEY 0x40 /* lookup tables */ #define OID_REGISTERED 0x80 /* OID registered by subagent */