esnet/enos

MP-VPN: Possibly duplicate callback objects leading to weird behavior

bmah888 opened this issue · 2 comments

When we run the vpn command, it checks to see if the current Python environment has a callback object (for receiving PACKET_IN notifications). If it doesn't it creates one and registers it to receive notifications. Note that when the login session terminates, the callback listener continues to exist and process notifications.

A second login session will create another callback object, which could also be receiving notifications. Odd things could happen if a notification gets processed by both callback objects.

A workaround for this problem is to only run the vpn command within an environment that has been saved via pyenv save, and on subsequent logins, use pyenv load to reattach to the same environment before doing any vpn commands. Care needs to be taken to make sure that at most one Python / SSH session is using a given environment at a time.

This environment management could be made more automatic.

The proposed fix is to implement the VPN Service JAVA API (enos #23 ). This will create effectively a java singleton wrapping up the python instance running the MP-VPN. This requires a little refactoring of vpn.py: currently the "API" of the vpn service is functions in vpn.py. In other word, they are not in the VPNService class and, in the Java world, everything is a class.

This refactoring is very small and the risk is really low.

Commit of the branch lomax-enos-113 fixes this problem