diff options
author | Carl Baldwin <carl@ecbaldwin.net> | 2019-07-24 09:01:32 -0600 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2019-08-28 09:06:20 +0900 |
commit | cff2b01d1dc00eadfed8c219c3d7c40018e8ad9c (patch) | |
tree | 6f3cd7fde7cad11d72d104e85393fd7d99166c2f /cmd | |
parent | 7057dccb5ddbbdd22aa547d91aa5c7652879364d (diff) |
Create a clearer line between initial config and updating config
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/gobgpd/main.go | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/cmd/gobgpd/main.go b/cmd/gobgpd/main.go index 8dd0cd52..433bd9ab 100644 --- a/cmd/gobgpd/main.go +++ b/cmd/gobgpd/main.go @@ -317,10 +317,6 @@ func main() { } return case newConfig := <-configCh: - var added, deleted, updated []config.Neighbor - var addedPg, deletedPg, updatedPg []config.PeerGroup - var updatePolicy bool - if c == nil { if err := bgpServer.StartBgp(context.Background(), &api.StartBgpRequest{ Global: config.NewGlobalFromConfigStruct(&newConfig.Global), @@ -425,8 +421,8 @@ func main() { assignGlobalpolicy(bgpServer, &newConfig.Global.ApplyPolicy.Config) - added = newConfig.Neighbors - addedPg = newConfig.PeerGroups + added := newConfig.Neighbors + addedPg := newConfig.PeerGroups if opts.GracefulRestart { for i, n := range added { if n.GracefulRestart.Config.Enabled { @@ -434,10 +430,14 @@ func main() { } } } + + addPeerGroups(bgpServer, addedPg) + addDynamicNeighbors(bgpServer, newConfig.DynamicNeighbors) + addNeighbors(bgpServer, added) } else { - addedPg, deletedPg, updatedPg = config.UpdatePeerGroupConfig(c, newConfig) - added, deleted, updated = config.UpdateNeighborConfig(c, newConfig) - updatePolicy = config.CheckPolicyDifference(config.ConfigSetToRoutingPolicy(c), config.ConfigSetToRoutingPolicy(newConfig)) + addedPg, deletedPg, updatedPg := config.UpdatePeerGroupConfig(c, newConfig) + added, deleted, updated := config.UpdateNeighborConfig(c, newConfig) + updatePolicy := config.CheckPolicyDifference(config.ConfigSetToRoutingPolicy(c), config.ConfigSetToRoutingPolicy(newConfig)) if updatePolicy { log.Info("Policy config is updated") @@ -457,24 +457,25 @@ func main() { assignGlobalpolicy(bgpServer, &newConfig.Global.ApplyPolicy.Config) updatePolicy = true } - } - addPeerGroups(bgpServer, addedPg) - deletePeerGroups(bgpServer, deletedPg) - needsSoftResetIn := updatePeerGroups(bgpServer, updatedPg) - updatePolicy = updatePolicy || needsSoftResetIn - addDynamicNeighbors(bgpServer, newConfig.DynamicNeighbors) - addNeighbors(bgpServer, added) - deleteNeighbors(bgpServer, deleted) - needsSoftResetIn = updateNeighbors(bgpServer, updated) - updatePolicy = updatePolicy || needsSoftResetIn - - if updatePolicy { - if err := bgpServer.ResetPeer(context.Background(), &api.ResetPeerRequest{ - Address: "", - Direction: api.ResetPeerRequest_IN, - Soft: true, - }); err != nil { - log.Warn(err) + + addPeerGroups(bgpServer, addedPg) + deletePeerGroups(bgpServer, deletedPg) + needsSoftResetIn := updatePeerGroups(bgpServer, updatedPg) + updatePolicy = updatePolicy || needsSoftResetIn + addDynamicNeighbors(bgpServer, newConfig.DynamicNeighbors) + addNeighbors(bgpServer, added) + deleteNeighbors(bgpServer, deleted) + needsSoftResetIn = updateNeighbors(bgpServer, updated) + updatePolicy = updatePolicy || needsSoftResetIn + + if updatePolicy { + if err := bgpServer.ResetPeer(context.Background(), &api.ResetPeerRequest{ + Address: "", + Direction: api.ResetPeerRequest_IN, + Soft: true, + }); err != nil { + log.Warn(err) + } } } c = newConfig |