diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-04-13 19:50:41 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-05-07 21:18:04 +0900 |
commit | 8347c6c94c441e6a2ec4869890a8808208610273 (patch) | |
tree | 1308721425963e629492cddd8767e24e845f09ce /server | |
parent | 6110fad59441454c8a6f534874ae29b770098b73 (diff) |
table: remove VrfIds member in Path structure
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/server.go | 10 | ||||
-rw-r--r-- | server/zclient.go | 9 |
2 files changed, 14 insertions, 5 deletions
diff --git a/server/server.go b/server/server.go index 51346da9..d533dc60 100644 --- a/server/server.go +++ b/server/server.go @@ -480,17 +480,22 @@ func (server *BgpServer) notifyBestWatcher(best []*table.Path, multipath [][]*ta clonedM[i] = clonePathList(pathList) } clonedB := clonePathList(best) + m := make(map[string]uint16) for _, p := range clonedB { switch p.GetRouteFamily() { case bgp.RF_IPv4_VPN, bgp.RF_IPv6_VPN: for _, vrf := range server.globalRib.Vrfs { if vrf.Id != 0 && table.CanImportToVrf(vrf, p) { - p.VrfIds = append(p.VrfIds, uint16(vrf.Id)) + m[p.GetNlri().String()] = uint16(vrf.Id) } } } } - server.notifyWatcher(WATCH_EVENT_TYPE_BEST_PATH, &WatchEventBestPath{PathList: clonedB, MultiPathList: clonedM}) + w := &WatchEventBestPath{PathList: clonedB, MultiPathList: clonedM} + if len(m) > 0 { + w.Vrf = m + } + server.notifyWatcher(WATCH_EVENT_TYPE_BEST_PATH, w) } func (server *BgpServer) notifyPrePolicyUpdateWatcher(peer *Peer, pathList []*table.Path, msg *bgp.BGPMessage, timestamp time.Time, payload []byte) { @@ -2369,6 +2374,7 @@ type WatchEventTable struct { type WatchEventBestPath struct { PathList []*table.Path MultiPathList [][]*table.Path + Vrf map[string]uint16 } type WatchEventMessage struct { diff --git a/server/zclient.go b/server/zclient.go index 7c311643..12f5357f 100644 --- a/server/zclient.go +++ b/server/zclient.go @@ -501,10 +501,13 @@ func (z *zebraClient) loop() { } } else { for _, path := range msg.PathList { - if len(path.VrfIds) == 0 { - path.VrfIds = []uint16{0} + vrfs := []uint16{0} + if msg.Vrf != nil { + if v, ok := msg.Vrf[path.GetNlri().String()]; ok { + vrfs = append(vrfs, v) + } } - for _, i := range path.VrfIds { + for _, i := range vrfs { if body, isWithdraw := newIPRouteBody(pathList{path}); body != nil { z.client.SendIPRoute(i, body, isWithdraw) } |