summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-09-30 20:44:12 -0700
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-09-30 20:44:12 -0700
commitd79b23967a3b0ea0faeccf1b1ed893b49c5356e9 (patch)
tree6334fa81d58110f12e7f47284a3a2cd4c6e59ad1 /server/server.go
parentdfe1b71fd28496110436ff15bf135feec02f181e (diff)
server: add vrf support to bestpath watch
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go33
1 files changed, 21 insertions, 12 deletions
diff --git a/server/server.go b/server/server.go
index 37a4b6a9..7b47b67b 100644
--- a/server/server.go
+++ b/server/server.go
@@ -403,6 +403,25 @@ func clonePathList(pathList []*table.Path) []*table.Path {
return l
}
+func (server *BgpServer) notifyBestWatcher(best map[string][]*table.Path, multipath [][]*table.Path) {
+ clonedM := make([][]*table.Path, len(multipath))
+ for i, pathList := range multipath {
+ clonedM[i] = clonePathList(pathList)
+ }
+ clonedB := clonePathList(best[table.GLOBAL_RIB_NAME])
+ for _, p := range clonedB {
+ switch p.GetRouteFamily() {
+ case bgp.RF_IPv4_VPN, bgp.RF_IPv6_VPN:
+ for _, vrf := range server.globalRib.Vrfs {
+ if table.CanImportToVrf(vrf, p) {
+ p.VrfIds = append(p.VrfIds, uint16(vrf.Id))
+ }
+ }
+ }
+ }
+ server.notifyWatcher(WATCH_EVENT_TYPE_BEST_PATH, &WatchEventBestPath{PathList: clonedB, MultiPathList: clonedM})
+}
+
func (server *BgpServer) dropPeerAllRoutes(peer *Peer, families []bgp.RouteFamily) {
ids := make([]string, 0, len(server.neighborMap))
if peer.isRouteServerClient() {
@@ -417,13 +436,8 @@ func (server *BgpServer) dropPeerAllRoutes(peer *Peer, families []bgp.RouteFamil
}
for _, rf := range families {
best, _, multipath := server.globalRib.DeletePathsByPeer(ids, peer.fsm.peerInfo, rf)
-
if !peer.isRouteServerClient() {
- clonedMpath := make([][]*table.Path, len(multipath))
- for i, pathList := range multipath {
- clonedMpath[i] = clonePathList(pathList)
- }
- server.notifyWatcher(WATCH_EVENT_TYPE_BEST_PATH, &WatchEventBestPath{PathList: clonePathList(best[table.GLOBAL_RIB_NAME]), MultiPathList: clonedMpath})
+ server.notifyBestWatcher(best, multipath)
}
for _, targetPeer := range server.neighborMap {
@@ -572,12 +586,7 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) []*
if len(best[table.GLOBAL_RIB_NAME]) == 0 {
return alteredPathList
}
- clonedMpath := make([][]*table.Path, len(multipath))
- for i, pathList := range multipath {
- clonedMpath[i] = clonePathList(pathList)
- }
- server.notifyWatcher(WATCH_EVENT_TYPE_BEST_PATH, &WatchEventBestPath{PathList: clonePathList(best[table.GLOBAL_RIB_NAME]), MultiPathList: clonedMpath})
-
+ server.notifyBestWatcher(best, multipath)
}
for _, targetPeer := range server.neighborMap {