summaryrefslogtreecommitdiffhomepage
path: root/cmd/gobgpd/main.go
diff options
context:
space:
mode:
authorCarl Baldwin <carl@ecbaldwin.net>2019-07-24 09:01:32 -0600
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2019-08-28 09:06:20 +0900
commitcff2b01d1dc00eadfed8c219c3d7c40018e8ad9c (patch)
tree6f3cd7fde7cad11d72d104e85393fd7d99166c2f /cmd/gobgpd/main.go
parent7057dccb5ddbbdd22aa547d91aa5c7652879364d (diff)
Create a clearer line between initial config and updating config
Diffstat (limited to 'cmd/gobgpd/main.go')
-rw-r--r--cmd/gobgpd/main.go55
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