I have implemented several subagents for BRIDGE-MIB tables using mib2c and mib2c.mfd.conf. They all worked well. Now I came across a problem with RMON-MIB etherStatsTable etherStatsDataSource which is an oid type. If I don't set etherStatsDataSource and let it be the default 0.0, the etherStatsTable subagent works okay. But if I set etherStatsDataSource_len to something not 0 (such as in the following code), it will cause segmentation fault. Here is the code which set etherStatsDataSource in etherStatsTable_cache_load(netsnmp_container * container):

oid etherStatsDataSource[] = {1,3,6,1,2,1,2,2,1,1,1};
rowreq_ctx->data.etherStatsDataSource_len = 11;
memcpy(rowreq_ctx->data.etherStatsDataSource, etherStatsDataSource,
rowreq_ctx->data.etherStatsDataSource_len *
sizeof(rowreq_ctx->data.etherStatsDataSource[0]));

Here is the dump of debug message, notice the Segmentation fault at the end:

trace: sprint_realloc_by_type(): mib.c, 2035:
sprint_by_type: bad type: 195
RMON-MIB::etherStatsDataSource = Wrong Type (should be OBJECT IDENTIFIER): Variable has ba
d type
trace: netsnmp_callback_send(): snmpCallbackDomain.c, 318:
transport_callback: hook_send exit
trace: _sess_read(): snmp_api.c, 5291:
sess_read: not reading 3 (fdset 0xbfffef70 set 0)
trace: snmp_sess_select_info(): snmp_api.c, 5702:
sess_select: for all sessions: 6 (to in 1121868165.141816 sec) 5 3
sess_select: next alarm 11.367354 sec
verbose:sess_select: timer due in 11.367354 sec
verbose:sess_select: setting timer to 11.367354 sec, clear block (was 0)
trace: _sess_read(): snmp_api.c, 5291:
sess_read: not reading 6 (fdset 0xbfffef70 set 0)
trace: _sess_read(): snmp_api.c, 5291:
sess_read: not reading 5 (fdset 0xbfffef70 set 0)
trace: netsnmp_callback_recv(): snmpCallbackDomain.c, 188:
transport_callback: hook_recv enter
trace: netsnmp_callback_recv(): snmpCallbackDomain.c, 214:
transport_callback: hook_recv exit
trace: _sess_process_packet(): snmp_api.c, 4973:
sess_process_packet: session 0x8056c88 fd 3 pkt 0x80baf90 length 1
trace: callback_debug_pdu(): snmpCallbackDomain.c, 91:
dump_recv_callback_transport: PDU: command = 161, errstat = 0, errindex = 0
trace: callback_debug_pdu(): snmpCallbackDomain.c, 93:
dump_recv_callback_transport: var 2:trace: sprint_realloc_by_type(): mib.c, 1975:
output: sprint_by_type, type 195
trace: sprint_realloc_by_type(): mib.c, 2035:
sprint_by_type: bad type: 195
RMON-MIB::etherStatsDataSource = Wrong Type (should be OBJECT IDENTIFIER): Variable has ba
d type
trace: init_agent_snmp_session(): snmp_agent.c, 1244:
snmp_agent: agent_sesion 0x809ec68 created
trace: init_agent_snmp_session(): snmp_agent.c, 1259:
verbose:asp: asp 0x809ec68 reqinfo 0x80ae788 created
trace: netsnmp_subtree_find_first(): agent_registry.c, 158:
subtree: looking for subtree for context: ""
trace: netsnmp_subtree_find_first(): agent_registry.c, 162:
subtree: found one for: ""
trace: netsnmp_add_varbind_to_cache(): snmp_agent.c, 1810:
snmp_agent: add_vb_to_cache(0x809ec68, 1, RMON-MIB::etherStatsDataSource, 0x8059010)
trace: netsnmp_add_varbind_to_cache(): snmp_agent.c, 1872:
snmp_agent: tp->start RMON-MIB::etherStatsTable, tp->end RMON-MIB::statistics.2,
trace: netsnmp_add_varbind_to_cache(): snmp_agent.c, 1892:
verbose:asp: asp 0x809ec68 reqinfo 0x80ae788 assigned to request
trace: netsnmp_add_varbind_to_cache(): snmp_agent.c, 1899:
verbose:asp: asp 0x809ec68 reqinfo 0x80ae788 assigned to request
trace: netsnmp_call_handlers(): agent_handler.c, 498:
handler:calling: main handler bulk_to_next
trace: netsnmp_call_handler(): agent_handler.c, 418:
handler:calling: calling handler bulk_to_next for mode GETNEXT
trace: netsnmp_call_handler(): agent_handler.c, 426:
handler:returned: handler bulk_to_next returned 0
trace: netsnmp_call_handler(): agent_handler.c, 418:
handler:calling: calling handler table for mode GETNEXT
trace: table_helper_handler(): table.c, 184:
helper:table:req: Got request for handler table: base oid:RMON-MIB::etherStatsTable
RMON-MIB::etherStatsDataSource
trace: table_helper_handler(): table.c, 377:
helper:table:col: have at least a column (2)
trace: table_helper_handler(): table.c, 442:
helper:table: not enough for indexes
trace: table_helper_handler(): table.c, 494:
helper:table: looking for 1 indexes
trace: table_helper_handler(): table.c, 503:
helper:table: oid indexes not complete: RMON-MIB::etherStatsDataSource
trace: table_helper_handler(): table.c, 548:
helper:table:results: found 0 indexes
trace: table_helper_handler(): table.c, 556:
helper:table:results: column: 2, indexes: 0trace: sprint_realloc_by_type(): mib.c, 1975:

output: sprint_by_type, type 2
index: type=2(02), value=INTEGER: 0
trace: netsnmp_call_handler(): agent_handler.c, 418:
handler:calling: calling handler cache_handler for mode GETNEXT
trace: netsnmp_cache_helper_handler(): cache_handler.c, 425:
helper:cache_handler: Got request (161) for etherStatsTable: RMON-MIB::etherStatsTabletrac
e: _cache_load(): etherStatsTable_interface.c, 1594:
internal:etherStatsTable:_cache_load: called
trace: etherStatsTable_cache_load(): etherStatsTable_data_access.c, 184:
modify:etherStatsTable:etherStatsTable_cache_load: called
trace: etherStatsTable_allocate_rowreq_ctx(): etherStatsTable_interface.c, 446:
internal:etherStatsTable:etherStatsTable_allocate_rowreq_ctx: called
trace: etherStatsTable_indexes_set(): etherStatsTable_data_get.c, 152:
verbose:etherStatsTable:etherStatsTable_indexes_set: called
trace: etherStatsTable_indexes_set_tbl_idx(): etherStatsTable_data_get.c, 123:
verbose:etherStatsTable:etherStatsTable_indexes_set_tbl_idx: called
trace: etherStatsTable_index_to_oid(): etherStatsTable_interface.c, 318:
verbose:etherStatsTable:etherStatsTable_index_to_oid: called
trace: build_oid_noalloc(): mib.c, 3550:
build_oid_noalloc: generated: iso
modify:etherStatsTable:etherStatsTable_cache_load: inserted 1 records
trace: snmp_alarm_register(): snmp_alarm.c, 430:
snmp_alarm: registered alarm 3, t = 60.000, flags=0x00
trace: set_an_alarm(): snmp_alarm.c, 366:
snmp_alarm: no alarms found to schedule
loaded (60)
trace: netsnmp_cache_reqinfo_insert(): cache_handler.c, 337:
verbose:helper:cache_handler: adding 'cache_info:etherStatsTable' to 0x80ae788
trace: netsnmp_call_handler(): agent_handler.c, 426:
handler:returned: handler cache_handler returned 0
trace: netsnmp_call_handler(): agent_handler.c, 418:
handler:calling: calling handler table_container for mode GETNEXT
trace: _container_table_handler(): table_container.c, 447:
table_container: Mode GETNEXT, Got request:
trace: _data_lookup(): table_container.c, 338:
table_container: data_lookup oid:RMON-MIB::etherStatsDataSource
trace: parse_one_oid_index(): mib.c, 3639:
parse_oid_indexes: Parsed int(2): 1
trace: netsnmp_data_list_add_node(): data_list.c, 106:
data_list: adding key 'table_container:row'
trace: netsnmp_data_list_add_node(): data_list.c, 106:
data_list: adding key 'table_container:container'
trace: netsnmp_call_handler(): agent_handler.c, 418:
handler:calling: calling handler row_merge for mode GET
trace: netsnmp_row_merge_helper_handler(): row_merge.c, 76:
helper:row_merge: Got request (11)
RMON-MIB::etherStatsTable
trace: netsnmp_row_merge_helper_handler(): row_merge.c, 91:
helper:row_merge: only one varbind
trace: netsnmp_call_handler(): agent_handler.c, 418:
handler:calling: calling handler baby_steps for mode GET
trace: _baby_steps_helper(): baby_steps.c, 103:
baby_steps: Got request, mode GET
trace: _baby_steps_helper(): baby_steps.c, 220:
baby_steps: baby step mode pre-request
trace: netsnmp_call_handler(): agent_handler.c, 418:
handler:calling: calling handler baby_steps_mux for mode (null)
baby_steps_mux: mode pre-request
trace: etherStatsTable_pre_request(): etherStatsTable.c, 107:
verbose:etherStatsTable:etherStatsTable_pre_request: called
trace: netsnmp_call_handler(): agent_handler.c, 426:
handler:returned: handler baby_steps_mux returned 0
trace: _baby_steps_helper(): baby_steps.c, 220:
baby_steps: baby step mode object_lookup
trace: netsnmp_call_handler(): agent_handler.c, 418:
handler:calling: calling handler baby_steps_mux for mode (null)
baby_steps_mux: mode object_lookup
trace: _mfd_etherStatsTable_object_lookup(): etherStatsTable_interface.c, 563:
internal:etherStatsTable:_mfd_etherStatsTable_object_lookup: called
trace: etherStatsTable_row_prep(): etherStatsTable_data_access.c, 309:
verbose:etherStatsTable:etherStatsTable_row_prep: called
trace: netsnmp_call_handler(): agent_handler.c, 426:
handler:returned: handler baby_steps_mux returned 0
trace: _baby_steps_helper(): baby_steps.c, 220:
baby_steps: baby step mode original
trace: netsnmp_call_handler(): agent_handler.c, 418:
handler:calling: calling handler baby_steps_mux for mode GET
baby_steps_mux: mode (null)
trace: _mfd_etherStatsTable_get_values(): etherStatsTable_interface.c, 876:
internal:etherStatsTable:_mfd_etherStatsTable_get_values: called
trace: _etherStatsTable_get_column(): etherStatsTable_interface.c, 640:
internal:etherStatsTable:_mfd_etherStatsTable_get_column: called
trace: etherStatsDataSource_get(): etherStatsTable_data_get.c, 320:
verbose:etherStatsTable:etherStatsDataSource_get: called
trace: netsnmp_call_handler(): agent_handler.c, 426:
handler:returned: handler baby_steps_mux returned 0
trace: _baby_steps_helper(): baby_steps.c, 220:
baby_steps: baby step mode post_request
trace: netsnmp_call_handler(): agent_handler.c, 418:
handler:calling: calling handler baby_steps_mux for mode (null)
baby_steps_mux: mode post_request
trace: etherStatsTable_post_request(): etherStatsTable.c, 127:
verbose:etherStatsTable:etherStatsTable_post_request: called
trace: netsnmp_call_handler(): agent_handler.c, 426:
handler:returned: handler baby_steps_mux returned 0
trace: netsnmp_call_handler(): agent_handler.c, 426:
handler:returned: handler baby_steps returned 0
trace: netsnmp_call_handler(): agent_handler.c, 426:
handler:returned: handler row_merge returned 0
trace: netsnmp_call_handler(): agent_handler.c, 426:
handler:returned: handler table_container returned 0
trace: netsnmp_call_handler(): agent_handler.c, 426:
handler:returned: handler table returned 0
trace: netsnmp_handle_request(): snmp_agent.c, 2975:
results: request results (status = 0):
trace: netsnmp_handle_request(): snmp_agent.c, 2978:
results: RMON-MIB::etherStatsDataSource.1 = OID: SNMPv2-SMI::org
trace: netsnmp_callback_hook_build(): snmpCallbackDomain.c, 443:
transport_callback: hook_build enter
trace: netsnmp_callback_hook_build(): snmpCallbackDomain.c, 455:
transport_callback: hook_build exit
trace: netsnmp_callback_send(): snmpCallbackDomain.c, 237:
transport_callback: hook_send enter
trace: callback_debug_pdu(): snmpCallbackDomain.c, 91:
dump_send_callback_transport: PDU: command = 162, errstat = 0, errindex = 0
trace: callback_debug_pdu(): snmpCallbackDomain.c, 93:
dump_send_callback_transport: var 2:RMON-MIB::etherStatsDataSource.1 = OID: SNMPv2-SMI::
org
trace: netsnmp_callback_send(): snmpCallbackDomain.c, 318:
transport_callback: hook_send exit
Segmentation fault

Is there a patch for this problem? ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to