summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/server.go10
-rw-r--r--server/zclient.go9
-rw-r--r--table/path.go1
3 files changed, 14 insertions, 6 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)
}
diff --git a/table/path.go b/table/path.go
index 4704758e..b36f07eb 100644
--- a/table/path.go
+++ b/table/path.go
@@ -146,7 +146,6 @@ type Path struct {
reason BestPathReason
parent *Path
dels []bgp.BGPAttrType
- VrfIds []uint16
// For BGP Nexthop Tracking, this field shows if nexthop is invalidated by IGP.
IsNexthopInvalid bool
}