Net-snmp master agentx not speaking the same protocol as a perlsubagent? - SNMP

This is a discussion on Net-snmp master agentx not speaking the same protocol as a perlsubagent? - SNMP ; Hi, I'm developing a perl agentx subagent for net-snmp 5.4.1. The mib that this agent is handling contains a few Counter64 (which are not correctly handled by the perl agent, but that's not my main issue). The first counter64 is ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Net-snmp master agentx not speaking the same protocol as a perlsubagent?

  1. Net-snmp master agentx not speaking the same protocol as a perlsubagent?

    Hi,

    I'm developing a perl agentx subagent for net-snmp 5.4.1.
    The mib that this agent is handling contains a few Counter64 (which are
    not correctly handled by the perl agent, but that's not my main issue).
    The first counter64 is enterprises.20267.200.1.6.0. The rest is either
    gauge or counter32.

    The problem is the following:

    the enterprises.20267.200.1.6.0 oid is a counter64 (whose vallue size is <
    32bits).
    When requesting this value from snmpwalk, snmpget, snmpbulkwalk or
    snmpbulkget in v2c mode, the right value is returned:

    snmpbulkget -r1 -Cn1 -Cr0 -v 2c -c public 192.168.168.14
    ..1.3.6.1.4.1.20267.200.1.6
    SNMPv2-SMI::enterprises.20267.200.1.6.0 = Counter64: 3095605758

    (in this example, I patched agent.xs to be able to feed a struct counter64
    to snmp_set_var_typed_value to get the real result, otherwise the high and
    low part of the counter where swapped on amd64/i386).

    But when I try to fetch multiple oids at the same time with the following
    command (which is a mimic of what OpenNMS data collection daemon is
    producing), I get no answer:

    (sorry if it wraps)
    snmpbulkget -r1 -Cn2 -Cr0 -v 2c -c public 192.168.168.14
    ..1.3.6.1.4.1.20267.200.1.6 .1.3.6.1.4.1.20267.200.1.7
    Timeout: No Response from 192.168.168.14

    I added debug logs to the subagent (by adding a snmp_debug_token("ALL") in
    agent.xs) and the full log seems ok, so the subagent doesn't seem to be
    the culprit. I can see the answer of the subagent to the master as it
    should be:

    dumph_send: AgentX Header
    dumpx_send: 01 12 00 00
    dumpv_send: Version: 1
    trace: agentx_realloc_build_header(): mibgroup/agentx/protocol.c, 616:
    dumpv_send: Command: 18 (Response)
    trace: agentx_realloc_build_header(): mibgroup/agentx/protocol.c, 619:
    dumpv_send: Flags: 00
    trace: agentx_realloc_build_header(): mibgroup/agentx/protocol.c, 622:
    dumph_send: Session ID
    dumpx_send: 07 00 00 00
    dumpv_send: Integer: 7 (0x07)
    trace: agentx_realloc_build_header(): mibgroup/agentx/protocol.c, 631:
    dumph_send: Transaction ID
    dumpx_send: 01 00 00 00
    dumpv_send: Integer: 1 (0x01)
    trace: agentx_realloc_build_header(): mibgroup/agentx/protocol.c, 640:
    dumph_send: Request ID
    dumpx_send: 02 00 00 00
    dumpv_send: Integer: 2 (0x02)
    trace: agentx_realloc_build_header(): mibgroup/agentx/protocol.c, 649:
    dumph_send: Dummy Length :-(
    dumpx_send: 00 00 00 00
    dumpv_send: Integer: 0 (0x00)
    trace: _agentx_realloc_build(): mibgroup/agentx/protocol.c, 716:
    dumph_send: AgentX Payload
    dumpx_send: 00 00 00 00
    dumpv_send: Integer: 0 (0x00)
    trace: _agentx_realloc_build(): mibgroup/agentx/protocol.c, 903:
    dumph_send: Response
    dumpx_send: 00 00 00 00
    dumpv_send: sysUpTime: 0
    dumpx_send: 00 00
    dumpv_send: Short: 0 (0x00)
    dumpx_send: 00 00
    dumpv_send: Short: 0 (0x00)
    trace: _agentx_realloc_build(): mibgroup/agentx/protocol.c, 919:
    dumph_send: Response errors
    dumpx_send: 00 00 00 00
    dumpv_send: errstat: 0
    trace: _agentx_realloc_build(): mibgroup/agentx/protocol.c, 922:
    dumpv_send: errindex: 0
    trace: _agentx_realloc_build(): mibgroup/agentx/protocol.c, 934:
    dumph_send: Get* Variable List
    trace: agentx_realloc_build_varbind(): mibgroup/agentx/protocol.c, 400:
    dumph_send: VarBind
    trace: agentx_realloc_build_varbind(): mibgroup/agentx/protocol.c, 401:
    dumph_send: type
    dumpx_send: 46 00
    dumpv_send: Short: 70 (0x46)
    trace: agentx_realloc_build_varbind(): mibgroup/agentx/protocol.c, 447:
    dumph_send: name
    trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 224:
    dumpv_send: OID: enterprises.20267.200.1.6.0
    trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 265:
    dumph_send: OID Header
    dumpx_send: 06 04 00 00
    dumpv_send: # subids: 6 (0x06)
    trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 269:
    dumpv_send: prefix: 4 (0x04)
    trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 271:
    dumpv_send: inclusive: 0 (0x00)
    trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 275:
    dumph_send: OID Segments
    dumpx_send: 01 00 00 00
    dumpv_send: Integer: 1 (0x01)
    dumpx_send: 2B 4F 00 00
    dumpv_send: Integer: 20267 (0x4F2B)
    dumpx_send: C8 00 00 00
    dumpv_send: Integer: 200 (0xC8)
    dumpx_send: 01 00 00 00
    dumpv_send: Integer: 1 (0x01)
    dumpx_send: 06 00 00 00
    dumpv_send: Integer: 6 (0x06)
    dumpx_send: 00 00 00 00
    dumpv_send: Integer: 0 (0x00)
    trace: agentx_realloc_build_varbind(): mibgroup/agentx/protocol.c, 456:
    dumph_send: value
    trace: agentx_realloc_build_varbind(): mibgroup/agentx/protocol.c, 551:
    dumph_send: Build Counter64 (low, high)
    dumpx_send: E8 83 84 B8
    dumpv_send: Integer: 3095692264 (0xB88483E8)
    dumpx_send: 00 00 00 00
    dumpv_send: Integer: 0 (0x00)
    trace: agentx_realloc_build_varbind(): mibgroup/agentx/protocol.c, 400:
    dumph_send: VarBind
    trace: agentx_realloc_build_varbind(): mibgroup/agentx/protocol.c, 401:
    dumph_send: type
    dumpx_send: 42 00
    dumpv_send: Short: 66 (0x42)
    trace: agentx_realloc_build_varbind(): mibgroup/agentx/protocol.c, 447:
    dumph_send: name
    trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 224:
    dumpv_send: OID: enterprises.20267.200.1.7.0
    trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 265:
    dumph_send: OID Header
    dumpx_send: 06 04 00 00
    dumpv_send: # subids: 6 (0x06)
    trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 269:
    dumpv_send: prefix: 4 (0x04)
    trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 271:
    dumpv_send: inclusive: 0 (0x00)
    trace: agentx_realloc_build_oid(): mibgroup/agentx/protocol.c, 275:
    dumph_send: OID Segments
    dumpx_send: 01 00 00 00
    dumpv_send: Integer: 1 (0x01)
    dumpx_send: 2B 4F 00 00
    dumpv_send: Integer: 20267 (0x4F2B)
    dumpx_send: C8 00 00 00
    dumpv_send: Integer: 200 (0xC8)
    dumpx_send: 01 00 00 00
    dumpv_send: Integer: 1 (0x01)
    dumpx_send: 07 00 00 00
    dumpv_send: Integer: 7 (0x07)
    dumpx_send: 00 00 00 00
    dumpv_send: Integer: 0 (0x00)
    trace: agentx_realloc_build_varbind(): mibgroup/agentx/protocol.c, 456:
    dumph_send: value
    dumpx_send: 01 00 00 00
    dumpv_send: Integer: 1 (0x01)
    dumpx_send: 54 00 00 00
    dumpv_send: Integer: 84 (0x54)
    trace: _agentx_realloc_build(): mibgroup/agentx/protocol.c, 1006:
    agentx_build: packet built okay


    But what the master receives is different (or it parses differently):

    dumph_recv: AgentX Header
    trace: agentx_parse_header(): mibgroup/agentx/protocol.c, 1464:
    dumph_recv: Version
    dumpx_recv: 01
    dumpv_recv: Version: 1
    trace: agentx_parse_header(): mibgroup/agentx/protocol.c, 1471:
    dumph_recv: Command
    dumpx_recv: 12
    dumpv_recv: Command: 18 (Response)
    trace: agentx_parse_header(): mibgroup/agentx/protocol.c, 1479:
    dumph_recv: Flags
    dumpx_recv: 00
    dumpv_recv: Flags: 0x0
    trace: agentx_parse_header(): mibgroup/agentx/protocol.c, 1486:
    dumph_recv: Reserved Byte
    dumpx_recv: 00
    dumpv_recv: Reserved: 0x0
    trace: agentx_parse_header(): mibgroup/agentx/protocol.c, 1492:
    dumph_recv: Session ID
    dumpx_recv: 07 00 00 00
    dumpv_recv: Integer: 7 (0x07)
    trace: agentx_parse_header(): mibgroup/agentx/protocol.c, 1500:
    dumph_recv: Transaction ID
    dumpx_recv: 01 00 00 00
    dumpv_recv: Integer: 1 (0x01)
    trace: agentx_parse_header(): mibgroup/agentx/protocol.c, 1508:
    dumph_recv: Packet ID
    dumpx_recv: 02 00 00 00
    dumpv_recv: Integer: 2 (0x02)
    trace: agentx_parse_header(): mibgroup/agentx/protocol.c, 1515:
    dumph_recv: Payload Length
    dumpx_recv: 54 00 00 00
    dumpv_recv: Integer: 84 (0x54)
    trace: agentx_parse(): mibgroup/agentx/protocol.c, 1607:
    dumph_recv: PDU
    dumpx_recv: 00 00 00 00
    dumpv_recv: Integer: 0 (0x00)
    dumpx_recv: 00 00
    dumpv_recv: Short: 0 (0x00)
    dumpx_recv: 00 00
    dumpv_recv: Short: 0 (0x00)
    trace: agentx_parse(): mibgroup/agentx/protocol.c, 1820:
    dumph_recv: VarBindList
    trace: agentx_parse_varbind(): mibgroup/agentx/protocol.c, 1344:
    dumph_recv: VarBind:
    trace: agentx_parse_varbind(): mibgroup/agentx/protocol.c, 1345:
    dumph_recv: Type
    dumpx_recv: 46 00
    dumpv_recv: Short: 70 (0x46)
    trace: agentx_parse_oid(): mibgroup/agentx/protocol.c, 1118:
    dumph_recv: OID Header
    dumpx_recv: 06 04 00 00
    dumpv_recv: # subids: 6 (0x06)
    trace: agentx_parse_oid(): mibgroup/agentx/protocol.c, 1122:
    dumpv_recv: prefix: 4 (0x04)
    trace: agentx_parse_oid(): mibgroup/agentx/protocol.c, 1125:
    dumpv_recv: inclusive: 0 (0x00)
    trace: agentx_parse_oid(): mibgroup/agentx/protocol.c, 1130:
    dumph_recv: OID Segments
    parse_oid
    sizeof(oid) = 8
    dumpx_recv: 01 00 00 00
    dumpv_recv: Integer: 1 (0x01)
    dumpx_recv: 2B 4F 00 00
    dumpv_recv: Integer: 20267 (0x4F2B)
    dumpx_recv: C8 00 00 00
    dumpv_recv: Integer: 200 (0xC8)
    dumpx_recv: 01 00 00 00
    dumpv_recv: Integer: 1 (0x01)
    dumpx_recv: 06 00 00 00
    dumpv_recv: Integer: 6 (0x06)
    dumpx_recv: 00 00 00 00
    dumpv_recv: Integer: 0 (0x00)
    trace: agentx_parse_oid(): mibgroup/agentx/protocol.c, 1205:
    dumpv_recv: OID: SNMPv2-SMI::enterprises.20267.200.1.6.0
    dumpx_recv: 00 00 00 00
    dumpv_recv: Integer: 0 (0x00)
    dumpx_recv: E8 83 84 B8
    dumpv_recv: Integer: 3095692264 (0xB88483E8)
    trace: agentx_parse_varbind(): mibgroup/agentx/protocol.c, 1344:
    dumph_recv: VarBind:
    trace: agentx_parse_varbind(): mibgroup/agentx/protocol.c, 1345:

    Here it seems to have stripped a few bytes (like varbind type and such):

    dumph_recv: Type
    dumpx_recv: 01 00
    dumpv_recv: Short: 1 (0x01)
    trace: agentx_parse_oid(): mibgroup/agentx/protocol.c, 1118:
    dumph_recv: OID Header
    dumpx_recv: 2B 4F 00 00
    dumpv_recv: # subids: 43 (0x2B)
    trace: agentx_parse_oid(): mibgroup/agentx/protocol.c, 1122:
    dumpv_recv: prefix: 79 (0x4F)
    trace: agentx_parse_oid(): mibgroup/agentx/protocol.c, 1125:
    dumpv_recv: inclusive: 0 (0x00)
    trace: agentx_parse_oid(): mibgroup/agentx/protocol.c, 1130:
    dumph_recv: OID Segments
    parse_oid
    sizeof(oid) = 8
    trace: agentx_parse_oid(): mibgroup/agentx/protocol.c, 1165:
    agentx: Incomplete Object IDtrace: _sess_process_packet(): snmp_api.c, 5173:
    sess_process_packet: parse fail

    Note that the issue seems to be only on amd64, I couldn't trigger it on a
    net-snmp 5.4.1 running on i386.

    Any idea what could be wrong?
    --
    Brice Figureau
    Days of Wonder


    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    Net-snmp-users mailing list
    Net-snmp-users@lists.sourceforge.net
    Please see the following page to unsubscribe or change other options:
    https://lists.sourceforge.net/lists/...net-snmp-users


  2. Re: Net-snmp master agentx not speaking the same protocol as aperl subagent?

    Hi again,

    I found the issue, see below:

    On Sun, July 20, 2008 18:18, Brice Figureau wrote:
    > [snipped the whole trace]
    > trace: agentx_parse_oid(): mibgroup/agentx/protocol.c, 1205:
    > dumpv_recv: OID: SNMPv2-SMI::enterprises.20267.200.1.6.0
    > dumpx_recv: 00 00 00 00
    > dumpv_recv: Integer: 0 (0x00)
    > dumpx_recv: E8 83 84 B8
    > dumpv_recv: Integer: 3095692264 (0xB88483E8)
    > trace: agentx_parse_varbind(): mibgroup/agentx/protocol.c, 1344:
    > dumph_recv: VarBind:
    > trace: agentx_parse_varbind(): mibgroup/agentx/protocol.c, 1345:


    agentx_parse_varbind was increasing the buffer pointer of 2 * sizeof(long)
    after decoding a counter64. This is incorrect since on amd64 sizeof(long)
    is 8 bytes and not 4 bytes. It was just then jumping over the next
    varbind.

    I attached a patch to fix this issue, which I'll also register on
    sourceforge.

    --
    Brice Figureau
    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    Net-snmp-users mailing list
    Net-snmp-users@lists.sourceforge.net
    Please see the following page to unsubscribe or change other options:
    https://lists.sourceforge.net/lists/...net-snmp-users


+ Reply to Thread