Discussion:
Problem with snmptable, snmpwalk for a table with gaps in column ids
Aaron Young
2009-09-16 20:50:08 UTC
Permalink
I've experienced an issue with 5.4.2.1 where my table has non-contiguous
column ids, and both snmpwalk and snmptable seem to stop at the gap.

i.e. (column ids 2,3,10)

snmptable -v2c -Ci -c public localhost:1616 mxOtherTable
SNMP table: MPATHIX-MIB::mxOtherTable

index mxOtherIdentity mxOtherState mxOtherErrorMsg
1 Joe's Chicken and Waffles ok ?
2 Sal's donut shoppe ok ?

If I use snmptable in GETNEXT or v1 mode it works fine.

An snmpwalk on the table oid will also stop at the gap:

snmpwalk -v2c -Ci -c public localhost:1616 mxOtherTable
MPATHIX-MIB::mxOtherTable = No Such Object available on this agent at this
OID
MPATHIX-MIB::mxOtherIdentity.1 = STRING: Joe's Chicken and Waffles
MPATHIX-MIB::mxOtherIdentity.2 = STRING: Sal's donut shoppe
MPATHIX-MIB::mxOtherState.1 = INTEGER: ok(1)
MPATHIX-MIB::mxOtherState.2 = INTEGER: ok(1)

This is in Solaris x86 built in 64-bit mode, communicating with snmpd
through agentx

Here's how I built my table:


static oid tableOid[] = { 1, 3, 6, 1, 4, 1, 8276, 1, 2, 1, 6 };

int defaultState = 1;

std::string tableName = "mxOtherTable";
static netsnmp_table_data_set* table
= netsnmp_create_table_data_set( tableName.c_str() );

// disallow SET
table->allow_creation = 0;

// add index
netsnmp_table_dataset_add_index( table, ASN_INTEGER );

// add columns
// column #
// type
// writable
// default value
// default value len

netsnmp_table_set_multi_add_default_row( table,
2, ASN_OCTET_STR, 0, NULL, 0,
3, ASN_INTEGER, 0, &defaultState, sizeof( defaultState ),
20, ASN_OCTET_STR, 0, NULL, 0,
0 );

netsnmp_handler_registration* regInfo
= netsnmp_create_handler_registration
( tableName.c_str(), NULL,
tableOid, OID_LENGTH(tableOid),
HANDLER_CAN_RWRITE );

netsnmp_register_table_data_set( regInfo, table, NULL);

netsnmp_register_auto_data_table( table, NULL );


// add
netsnmp_table_row* newRow = netsnmp_create_table_data_row();

int index = 1;
netsnmp_table_row_add_index( newRow, ASN_INTEGER,
&index, sizeof( index ) );

std::string identity = "Joe's Chicken and Waffles";
netsnmp_set_row_column (newRow, 2, ASN_OCTET_STR,
identity.c_str(), identity.length() );

netsnmp_set_row_column (newRow, 3, ASN_INTEGER,
reinterpret_cast<const char*>(&defaultState), sizeof( defaultState ) );

std::string errorMsg = "Waffle-lite";
netsnmp_set_row_column (newRow, 20, ASN_OCTET_STR,
errorMsg.c_str(), errorMsg.length() );

netsnmp_table_dataset_add_row( table, newRow );

// add
netsnmp_table_row* newRow2 = netsnmp_create_table_data_row();

index++;
netsnmp_table_row_add_index( newRow2, ASN_INTEGER,
&index, sizeof( index ) );

identity = "Sal's donut shoppe";
netsnmp_set_row_column (newRow2, 2, ASN_OCTET_STR,
identity.c_str(), identity.length() );

netsnmp_set_row_column (newRow2, 3, ASN_INTEGER,
reinterpret_cast<const char*>(&defaultState), sizeof( defaultState ) );

errorMsg = "full of donuts";
netsnmp_set_row_column (newRow2, 20, ASN_OCTET_STR,
errorMsg.c_str(), errorMsg.length() );

netsnmp_table_dataset_add_row( table, newRow2 );


Any ideas on what the problem may be?

-Aaron
Aaron Young
2009-09-16 22:56:32 UTC
Permalink
I tried using the valid_columns struct, didn't change anything:

netsnmp_table_set_multi_add_default_row( table,
2, ASN_OCTET_STR, 0, NULL, 0,
3, ASN_INTEGER, 0, &defaultState, sizeof( defaultState ),
20, ASN_OCTET_STR, 0, NULL, 0,
0 );

netsnmp_handler_registration* regInfo
= netsnmp_create_handler_registration
( tableName.c_str(), NULL,
tableOid, OID_LENGTH(tableOid),
HANDLER_CAN_RWRITE );

netsnmp_table_registration_info* table_info
= SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
table_info->indexes = snmp_clone_varbind(table->table->indexes_template);
table_info->min_column = 2;
table_info->max_column = 20;

table_info->valid_columns = SNMP_MALLOC_TYPEDEF(netsnmp_column_info);
table_info->valid_columns->isRange = 0;
table_info->valid_columns->list_count = 3;
table_info->valid_columns->details.list = static_cast<unsigned int*>(
malloc(sizeof(unsigned int)*3));
table_info->valid_columns->details.list[0] = 2;
table_info->valid_columns->details.list[1] = 3;
table_info->valid_columns->details.list[2] = 20;
table_info->valid_columns->next = 0;

netsnmp_register_table_data_set(regInfo, table, table_info);

netsnmp_register_auto_data_table( table, NULL );

-Aaron
Post by Aaron Young
I've experienced an issue with 5.4.2.1 where my table has non-contiguous
column ids, and both snmpwalk and snmptable seem to stop at the gap.
i.e. (column ids 2,3,10)
snmptable -v2c -Ci -c public localhost:1616 mxOtherTable
SNMP table: MPATHIX-MIB::mxOtherTable
index mxOtherIdentity mxOtherState mxOtherErrorMsg
1 Joe's Chicken and Waffles ok ?
2 Sal's donut shoppe ok ?
If I use snmptable in GETNEXT or v1 mode it works fine.
snmpwalk -v2c -Ci -c public localhost:1616 mxOtherTable
MPATHIX-MIB::mxOtherTable = No Such Object available on this agent at this
OID
MPATHIX-MIB::mxOtherIdentity.1 = STRING: Joe's Chicken and Waffles
MPATHIX-MIB::mxOtherIdentity.2 = STRING: Sal's donut shoppe
MPATHIX-MIB::mxOtherState.1 = INTEGER: ok(1)
MPATHIX-MIB::mxOtherState.2 = INTEGER: ok(1)
This is in Solaris x86 built in 64-bit mode, communicating with snmpd
through agentx
static oid tableOid[] = { 1, 3, 6, 1, 4, 1, 8276, 1, 2, 1, 6 };
int defaultState = 1;
std::string tableName = "mxOtherTable";
static netsnmp_table_data_set* table
= netsnmp_create_table_data_set( tableName.c_str() );
// disallow SET
table->allow_creation = 0;
// add index
netsnmp_table_dataset_add_index( table, ASN_INTEGER );
// add columns
// column #
// type
// writable
// default value
// default value len
netsnmp_table_set_multi_add_default_row( table,
2, ASN_OCTET_STR, 0, NULL, 0,
3, ASN_INTEGER, 0, &defaultState, sizeof( defaultState ),
20, ASN_OCTET_STR, 0, NULL, 0,
0 );
netsnmp_handler_registration* regInfo
= netsnmp_create_handler_registration
( tableName.c_str(), NULL,
tableOid, OID_LENGTH(tableOid),
HANDLER_CAN_RWRITE );
netsnmp_register_table_data_set( regInfo, table, NULL);
netsnmp_register_auto_data_table( table, NULL );
// add
netsnmp_table_row* newRow = netsnmp_create_table_data_row();
int index = 1;
netsnmp_table_row_add_index( newRow, ASN_INTEGER,
&index, sizeof( index ) );
std::string identity = "Joe's Chicken and Waffles";
netsnmp_set_row_column (newRow, 2, ASN_OCTET_STR,
identity.c_str(), identity.length() );
netsnmp_set_row_column (newRow, 3, ASN_INTEGER,
reinterpret_cast<const char*>(&defaultState), sizeof( defaultState ) );
std::string errorMsg = "Waffle-lite";
netsnmp_set_row_column (newRow, 20, ASN_OCTET_STR,
errorMsg.c_str(), errorMsg.length() );
netsnmp_table_dataset_add_row( table, newRow );
// add
netsnmp_table_row* newRow2 = netsnmp_create_table_data_row();
index++;
netsnmp_table_row_add_index( newRow2, ASN_INTEGER,
&index, sizeof( index ) );
identity = "Sal's donut shoppe";
netsnmp_set_row_column (newRow2, 2, ASN_OCTET_STR,
identity.c_str(), identity.length() );
netsnmp_set_row_column (newRow2, 3, ASN_INTEGER,
reinterpret_cast<const char*>(&defaultState), sizeof( defaultState ) );
errorMsg = "full of donuts";
netsnmp_set_row_column (newRow2, 20, ASN_OCTET_STR,
errorMsg.c_str(), errorMsg.length() );
netsnmp_table_dataset_add_row( table, newRow2 );
Any ideas on what the problem may be?
-Aaron
------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register
now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Net-snmp-users mailing list
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
Aaron Young
2009-10-06 16:46:23 UTC
Permalink
After much tracking down I believe I narrowed the problem down to an
assumption of contiguous indices in table_data.c.

Any getnext request on the last row of a column followed by a gap would
produce nonsense. This patch seems to fix the problem:


--- table_data.c.orig Tue Oct 6 12:33:16 2009
+++ table_data.c Tue Oct 6 12:36:22 2009
@@ -529,7 +529,9 @@
}
}
if (!row) {
- table_info->colnum++;
+ table_info->colnum =
+ netsnmp_closest_column(table_info->colnum + 1,
+ table_reg_info->valid_columns);
if (table_info->colnum <= table_reg_info->max_column) {
row = table->first_row;
}
Post by Aaron Young
I've experienced an issue with 5.4.2.1 where my table has non-contiguous
column ids, and both snmpwalk and snmptable seem to stop at the gap.
i.e. (column ids 2,3,10)
snmptable -v2c -Ci -c public localhost:1616 mxOtherTable
SNMP table: MPATHIX-MIB::mxOtherTable
index mxOtherIdentity mxOtherState mxOtherErrorMsg
1 Joe's Chicken and Waffles ok ?
2 Sal's donut shoppe ok ?
If I use snmptable in GETNEXT or v1 mode it works fine.
snmpwalk -v2c -Ci -c public localhost:1616 mxOtherTable
MPATHIX-MIB::mxOtherTable = No Such Object available on this agent at this
OID
MPATHIX-MIB::mxOtherIdentity.1 = STRING: Joe's Chicken and Waffles
MPATHIX-MIB::mxOtherIdentity.2 = STRING: Sal's donut shoppe
MPATHIX-MIB::mxOtherState.1 = INTEGER: ok(1)
MPATHIX-MIB::mxOtherState.2 = INTEGER: ok(1)
This is in Solaris x86 built in 64-bit mode, communicating with snmpd
through agentx
static oid tableOid[] = { 1, 3, 6, 1, 4, 1, 8276, 1, 2, 1, 6 };
int defaultState = 1;
std::string tableName = "mxOtherTable";
static netsnmp_table_data_set* table
= netsnmp_create_table_data_set( tableName.c_str() );
// disallow SET
table->allow_creation = 0;
// add index
netsnmp_table_dataset_add_index( table, ASN_INTEGER );
// add columns
// column #
// type
// writable
// default value
// default value len
netsnmp_table_set_multi_add_default_row( table,
2, ASN_OCTET_STR, 0, NULL, 0,
3, ASN_INTEGER, 0, &defaultState, sizeof( defaultState ),
20, ASN_OCTET_STR, 0, NULL, 0,
0 );
netsnmp_handler_registration* regInfo
= netsnmp_create_handler_registration
( tableName.c_str(), NULL,
tableOid, OID_LENGTH(tableOid),
HANDLER_CAN_RWRITE );
netsnmp_register_table_data_set( regInfo, table, NULL);
netsnmp_register_auto_data_table( table, NULL );
// add
netsnmp_table_row* newRow = netsnmp_create_table_data_row();
int index = 1;
netsnmp_table_row_add_index( newRow, ASN_INTEGER,
&index, sizeof( index ) );
std::string identity = "Joe's Chicken and Waffles";
netsnmp_set_row_column (newRow, 2, ASN_OCTET_STR,
identity.c_str(), identity.length() );
netsnmp_set_row_column (newRow, 3, ASN_INTEGER,
reinterpret_cast<const char*>(&defaultState), sizeof( defaultState ) );
std::string errorMsg = "Waffle-lite";
netsnmp_set_row_column (newRow, 20, ASN_OCTET_STR,
errorMsg.c_str(), errorMsg.length() );
netsnmp_table_dataset_add_row( table, newRow );
// add
netsnmp_table_row* newRow2 = netsnmp_create_table_data_row();
index++;
netsnmp_table_row_add_index( newRow2, ASN_INTEGER,
&index, sizeof( index ) );
identity = "Sal's donut shoppe";
netsnmp_set_row_column (newRow2, 2, ASN_OCTET_STR,
identity.c_str(), identity.length() );
netsnmp_set_row_column (newRow2, 3, ASN_INTEGER,
reinterpret_cast<const char*>(&defaultState), sizeof( defaultState ) );
errorMsg = "full of donuts";
netsnmp_set_row_column (newRow2, 20, ASN_OCTET_STR,
errorMsg.c_str(), errorMsg.length() );
netsnmp_table_dataset_add_row( table, newRow2 );
Any ideas on what the problem may be?
-Aaron
------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register
now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Net-snmp-users mailing list
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
Loading...