gobgp
gobgp copied to clipboard
Move SelectionOptions and UseMultiplePath to server-local vars
In destination.go there were two global variables used for controlling path and multi-path support for BGP servers, which were populated and modified by gRPC/public API calls. In scenarios where multiple BGP servers are running using the public API it would mean that the last server created would override the options for all running servers. It also lead to data races (Confirmed by using Go's data race detector) that could crash Go's runtime as the value would be overridden unexpectedly.
To resolve this, both options have been moved into the TableManager itself which takes a pointer option to both structs populated via the StartBgp API call. These are then passed to the internal methods as new function parameters, ensuring that every server has a unique copy of these structs.
All tests were updated to conform to the new API.
This one was quite a refactor - I moved everything as function parameters where originally it read the global vars. None of the public API signatures are changed, so I am hoping it's still acceptable. Let me know if anything should be changed, thanks!