NetSNMP implements all versions of the SNMP, AgentX and SMUX protocols. It is also serves as a software suite and API for implementing sub-agents such as the SNMPStats Module, which I wrote for OpenSER.
I have provided several patches for the NetSNMP system:
SNMPv3 Notifications – Context Support
NetSNMP has SNMPv3 support, but was previously missing the ability to send context aware notifications (informs and traps). I wrote a patch to update the API to provide this functionality. The patch has been accepted into the mainline, and will be part of the next official NetSNMP release. Details of this patch can be found here.
Sub-Agent – Multi-threaded Event-Driven support
The traditional NetSNMP sub-agent architecture consists of a single threaded event loop that blocks while waiting for an SNMP request. When a GET/SET request is received, a data source is fetched/updated, and the loop then goes back to sleep while it awaits the next SNMP request. This approach works perfectly when data is only needed when asked for, such as with the IF-MIB’s ifTable. This model breaks down however, when a subagent needs to asynchronously handle both SNMP and non-SNMP events. For example, we may need a table to be removed whenever a user logs out of a system, even if an SNMP client is partway through reading that table.
In many cases the only way to cleanly achieve asynchronously functionality is through multi-threaded design. Unfortunately, the NetSNMP API lacked multi-threaded sub-agent support despite being a highly sought-after feature. With a taste for challenges, I decided to implement this functionality.
This patch was probably one of my most complicated open source contributions, as it involved going through a massive single threaded 15 year old code base in an attempt to make it multithreaded. That being said, it was also probably the most rewarding patch I’ve worked on. The lengthy patch and accompanying comments can be found here:
SNMPv3 Context Memory Leaks
The above patch allowed me to write a multi-threaded sub-agent which added or removed three distinct tables under a unique SNMPv3 context in response to a unique external event. However, I noticed there was a significant memory leak, which was attributed to many complexly related structures not being freed when a table was removed under a given context. I created a patch which correctly freed this memory. Combined with the multithreaded patch above, NetSNMP and the sub-agent ran for 20 hours crash and memory leak free in a test run consisting of 300,000 table addition and removals, all while simultaneously having three tight-loop snmpwalk requests on the same tables.
The memory leak patch and associated comments are available here.
Comments
Leave a comment Trackback