summaryrefslogtreecommitdiffhomepage
path: root/config/serve.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-08-05 15:48:25 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-08-05 17:25:12 +0900
commit0b5bb073128b3000f383927a997d4a40d274f569 (patch)
tree27dfee4b4f436857e91ff549635e8ced5ff61c25 /config/serve.go
parent0d14f7dca2f77f661e4baaaa9d85ff3d0967fe34 (diff)
fix policy dynamic update
handle dynamic policy peer binding Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'config/serve.go')
-rw-r--r--config/serve.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/config/serve.go b/config/serve.go
index 74529a16..a3beea30 100644
--- a/config/serve.go
+++ b/config/serve.go
@@ -35,16 +35,16 @@ func ReadConfigfileServe(path string, configCh chan BgpConfigSet, reloadCh chan
}
}
-func inSlice(n Neighbor, b []Neighbor) bool {
- for _, nb := range b {
+func inSlice(n Neighbor, b []Neighbor) int {
+ for i, nb := range b {
if nb.NeighborConfig.NeighborAddress.String() == n.NeighborConfig.NeighborAddress.String() {
- return true
+ return i
}
}
- return false
+ return -1
}
-func UpdateConfig(curC *Bgp, newC *Bgp) (*Bgp, []Neighbor, []Neighbor) {
+func UpdateConfig(curC *Bgp, newC *Bgp) (*Bgp, []Neighbor, []Neighbor, []Neighbor) {
bgpConfig := Bgp{}
if curC == nil {
bgpConfig.Global = newC.Global
@@ -55,21 +55,26 @@ func UpdateConfig(curC *Bgp, newC *Bgp) (*Bgp, []Neighbor, []Neighbor) {
}
added := []Neighbor{}
deleted := []Neighbor{}
+ updated := []Neighbor{}
for _, n := range newC.Neighbors.NeighborList {
- if inSlice(n, curC.Neighbors.NeighborList) == false {
+ if idx := inSlice(n, curC.Neighbors.NeighborList); idx < 0 {
added = append(added, n)
+ } else {
+ if !reflect.DeepEqual(n.ApplyPolicy, curC.Neighbors.NeighborList[idx].ApplyPolicy) {
+ updated = append(updated, n)
+ }
}
}
for _, n := range curC.Neighbors.NeighborList {
- if inSlice(n, newC.Neighbors.NeighborList) == false {
+ if inSlice(n, newC.Neighbors.NeighborList) < 0 {
deleted = append(deleted, n)
}
}
bgpConfig.Neighbors.NeighborList = newC.Neighbors.NeighborList
- return &bgpConfig, added, deleted
+ return &bgpConfig, added, deleted, updated
}
func CheckPolicyDifference(currentPolicy *RoutingPolicy, newPolicy *RoutingPolicy) bool {