Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rajiv Asati's Update to plugin_impl_gobgp.go #24

Merged
merged 2 commits into from
May 9, 2018

Commits on Apr 29, 2018

  1. Rajiv Asati's Update to plugin_impl_gobgp.go

    Ligato code does NOT work with external .yaml file, because of this:
    //
    	func (plugin *Plugin) applyExternalConfig() {
    	var externalCfg *config.Bgp
    	found, err := plugin.PluginConfig.GetValue(externalCfg)
    //
    The above code (line 70) defined externalCfg of pointer type and passed it as-is in PluginConfig.GetValue(externalCfg) in line 71. That meant passing a different memory address from where the external file really was (remember, every time a variable is passed as parameter, a new copy of the variable is created), resulting in a garbage being passed to ParseConfigFromYamlFile function inside p.GetConfigName(), which then returned an error.
    
    Instead, define config.Bgp variable as a pointer to the address where the external .yaml file is, and pass the same pointer in PluginConfig.GetValue(externalCfg) in line 71. 
    https://gobyexample.com/pointers
    http://goinbigdata.com/golang-pass-by-pointer-vs-pass-by-value/
    rajiva1 committed Apr 29, 2018
    Configuration menu
    Copy the full SHA
    cb5edc0 View commit details
    Browse the repository at this point in the history

Commits on May 9, 2018

  1. Rajiv Asati's Update to applyExternalConfig()

    Signed-off-by: Rajiv Asati <rajiva@cisco.com>
    
    Ligato BGP code fails if used with an external .yaml file, because line 70 defined externalCfg of pointer type and passed it as-is in PluginConfig.GetValue() in line 71, as shown below:
    //
    	func (plugin *Plugin) applyExternalConfig() {
    	var externalCfg *config.Bgp
    	found, err := plugin.PluginConfig.GetValue(externalCfg)
    //
    The above meant passing a different memory address from where the external file really was (remember, every time a variable is passed as parameter, a new copy of the variable is created), resulting in a garbage being passed to ParseConfigFromYamlFile() function inside p.GetConfigName(), which then returned an error.
    
    Fix is to define config.Bgp variable as a pointer to the address where the external .yaml file is, and pass the same pointer in PluginConfig.GetValue() in line 71 and 80. 
    
    https://gobyexample.com/pointers
    http://goinbigdata.com/golang-pass-by-pointer-vs-pass-by-value/
    rajiva1 committed May 9, 2018
    Configuration menu
    Copy the full SHA
    34f1a50 View commit details
    Browse the repository at this point in the history