mirror of
https://github.com/osrg/gobgp.git
synced 2024-05-11 05:55:10 +00:00
config: fix bug of UpdateConfig()
avoid reconfiguration when policy configuration is not changed Signed-off-by: ISHIDA Wataru <[email protected]>
This commit is contained in:
+3
-11
@@ -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 {
|
||||
|
||||
+2
-2
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user