Hi,

I use snmpd on OpenBSD 7.4 and try to get it work with PyAgentX3 [1] in order to provide additional data to the SNMP daemon. To test it, I use the minimal agent as provided in the PyAgentX3 readme (with the "print" function adjusted to Python 3). The respective config line for snmpd looks as simple as it could be:

agentx

Connection management and registration between the two processes work. Unfortunately, no data is returned when issuing a GET command using both OpenBSD's "snmp get" on the local machine and NET-SNMP's "snmpget" on a remote Linux machine. Instead the connection to the subagent is aborted. Same applies to a "walk".

The reason for that appears to be a check of the packetID in the AgentX PDU header by snmpd. From what I understand from RFC 2257, it is expected that the packetID of a response must the same as in the corresponding request. PyAgentX3 correctly does that. However, snmpd drops the response PDU during the handling of AX_PDU_TYPE_RESPONSE in ax_recv (ax.c) because it does not know the packet id, i.e. it's not in ax_packetids.

From my point of view, this is due to appl_agentx_get calling ax_get with the request_id externally provided from the client (?). In ax_get, ax_pdu_header is called with that request_id. In turn, ax_pdu_header only asks for new IDs in case it is non-zero:

        if (packetid == 0)
                packetid = ax_packetid(ax);
        /* possible fix
        else if (type == AX_PDU_TYPE_GET /*NEXT ?! */)
                ax_record_packetid(packetid)
        */

So essentially, the request ID is passed through to the agentx subagent but not recorded in the array of known IDs causing the refusal of the subagent's response and finally connection close of the agentx socket.

Since I am not an agentx/snmp(d) expert, I'm not sure if that's a bug in snmpd or expected behavior. I would be happy if somebody could confirm either way.

That being said, my current fix was to disable the check for known ids in the handling of AX_PDU_TYPE_RESPONSEs, but that's apparently a bad idea. With that, however, both walking tree and getting the respective OIDs work as intended. Maybe the pseudo code above would be a better fix.

Regards, Steffen

[1] https://github.com/rprinz08/pyagentx3

Reply via email to