From 8347c6c94c441e6a2ec4869890a8808208610273 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Fri, 13 Apr 2018 19:50:41 +0900 Subject: table: remove VrfIds member in Path structure Signed-off-by: FUJITA Tomonori --- server/server.go | 10 ++++++++-- server/zclient.go | 9 ++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'server') 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) } -- cgit v1.2.3