Hi net-snmp-coders, It will be greatly helpful if we have some suggestions on the below problem and the solution proposed.
Regards, Prakash.V --- On Fri, 5/21/10, surya prakash <[email protected]> wrote: > From: surya prakash <[email protected]> > Subject: Socket leak in snmpd process when trapsink is configured > To: "net-snmp-coders" <[email protected]> > Date: Friday, May 21, 2010, 3:48 PM > Hi, > > We are using net-snmp version 5.4.2.1. > We do see socket leakage in net-snmp when we add trap > receiver to snmpd.conf file and sending a SIGHUP signal to > snmpd process to update configurations. > > Continual update of snmpd.conf file followed by SIGHUP > signal quickly makes the file descriptor count to 1023 > (default maximum count) and after that no traps were sent to > the destined host. > > On analyzing the code, we see the following behavior. > > For each trap receiver host configured (trapsink handle), > snmpd creates a new socket and in turn calls the > notifyTable_register_notifications()function of > snmpNotifyTable.c passing the net-snmp session > information. > In this register function, three structures are created and > added to their corresponding list > a. targetAddrTable_struct > b. targetParamTable_struct > c. snmpNotifyTable_data > > The socket session earlier created was assigned to > ptr->sess = ss; // targetAddrTable_struct > > > When a SIGHUP signal is sent to the snmpd process, snmpd.c > calls notifyTable_unregister_notifications() function where > only the list (snmpNotifyTable_data) was cleaned leaving the > other 2 tables undisturbed. This causes the socket to remain > open. > > Again the update_config() function reads the configuration > file and creates a new structure and socket for each > ‘trapsink’ handle it encounters. > > Once it reaches the maximum count, snmpd does not able to > create a socket for trap notification and hence the trap is > not sent. > > Comment on top of unregister_notification function points > not to do many SIGHUP calls. > > As the entries in the list is keep on added for new > ‘trapsink’ handle, it also reaches the MAX entries as > mentioned below (though only few entries in the list are > active) > > for (i = 0; i < MAX_ENTRIES; i++) { > sprintf(buf, "internal%d", i); > if (get_addrForName(buf) == > NULL && get_paramEntry(buf) == NULL) > break; > } > if (i == MAX_ENTRIES) { > snmp_log(LOG_ERR, > > "Can't register new trap destination: max > limit reached: %d", > > MAX_ENTRIES); > > > Can you please tell us why those structures (sockets) are > not cleaned when SIGHUP signal is called. > > To overcome the above issues, we called functions to > cleanup the residue 2 tables in unregister_notification > function. > > /* Free the target Address table and target Param table > when > * snmpd re-reads the > configuration. > */ > snmpTargetParamTable_dellist(); > /* Param table clean */ > snmpTargetAddrTable_dellist(); > /* Address table clean */ > > > Also found one invalid free in > snmpTargetAddrTable_dispose() function in > snmpTargerAddrTable.c and we commented that. > > SNMP_FREE(reaped->tAddress); > > After making these changes, snmpd process runs without any > problem (No Socket leakages) even after the process is > restated 2000 times (by issuing SIGHUP signal). > > Can you please tell us that the above code changes does not > have any other side effects? > > > Regards, > Surya. > > > > ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ Net-snmp-coders mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
