sharpsnmplib icon indicating copy to clipboard operation
sharpsnmplib copied to clipboard

UserRegistry is not thread safe

Open mjanulaitis opened this issue 3 years ago • 0 comments

While the SNMP Trap Server is running, we discover new devices on the fly as they are added to the system so we can include the V3 Engine ID in the target user configuration. The UserRegistry is using a Dictionary and not thread safe so it seems there is no way to add new users and/or devices safely. To add a new user or modify a user (add an engine ID), we would need to tear down the server and rebuild it from scratch. In an environment with 1000s of devices that may be discovered at any time this format is unworkable. The UserRegistry should either be using locks around the calls or should be using a ConcurrentDictionary. I would vote for simplicity and use the locks since there are no async calls. Also on a side note if an admin wants to boot a user, the server would also have to be torn down are re-built which lends itself to lost traps and informs. Finally, the MessageFactory needs to be updated to maintain a locking mechanism while the IPrivacyProvider is read since this is where the Engine IDs are inserted. Does this make sense?

mjanulaitis avatar Jun 08 '22 16:06 mjanulaitis