From 30456e9ffd7508f96db90df2b035ad2e5cfeb904 Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Fri, 22 Apr 2016 07:30:40 +0000 Subject: config: fix bug of UpdateConfig() avoid reconfiguration when policy configuration is not changed Signed-off-by: ISHIDA Wataru --- config/serve.go | 14 +++----------- gobgpd/main.go | 4 ++-- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/config/serve.go b/config/serve.go index 3b4d7acd..21196433 100644 --- a/config/serve.go +++ b/config/serve.go @@ -76,15 +76,8 @@ func ConfigSetToRoutingPolicy(c *BgpConfigSet) *RoutingPolicy { } } -func UpdateConfig(curC *BgpConfigSet, newC *BgpConfigSet) (*BgpConfigSet, []Neighbor, []Neighbor, []Neighbor, bool) { - bgpConfig := &BgpConfigSet{} - if curC == nil { - bgpConfig.Global = newC.Global - curC = bgpConfig - } else { - // can't update the global config - bgpConfig.Global = curC.Global - } +func UpdateConfig(curC, newC *BgpConfigSet) ([]Neighbor, []Neighbor, []Neighbor, bool) { + added := []Neighbor{} deleted := []Neighbor{} updated := []Neighbor{} @@ -103,8 +96,7 @@ func UpdateConfig(curC *BgpConfigSet, newC *BgpConfigSet) (*BgpConfigSet, []Neig } } - bgpConfig.Neighbors = newC.Neighbors - return bgpConfig, added, deleted, updated, CheckPolicyDifference(ConfigSetToRoutingPolicy(curC), ConfigSetToRoutingPolicy(newC)) + return added, deleted, updated, CheckPolicyDifference(ConfigSetToRoutingPolicy(curC), ConfigSetToRoutingPolicy(newC)) } func CheckPolicyDifference(currentPolicy *RoutingPolicy, newPolicy *RoutingPolicy) bool { diff --git a/gobgpd/main.go b/gobgpd/main.go index d955599f..192b85f9 100644 --- a/gobgpd/main.go +++ b/gobgpd/main.go @@ -229,13 +229,13 @@ func main() { } else { var updatePolicy bool - c, added, deleted, updated, updatePolicy = config.UpdateConfig(c, newConfig) + added, deleted, updated, updatePolicy = config.UpdateConfig(c, newConfig) if updatePolicy { log.Info("Policy config is updated") p := config.ConfigSetToRoutingPolicy(newConfig) bgpServer.UpdatePolicy(*p) } - + c = newConfig } for _, p := range added { -- cgit v1.2.3