diff options
author | mageshgv <mageshgv@gmail.com> | 2019-10-08 14:35:33 -0700 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2019-10-15 20:58:16 +0900 |
commit | 0235f7c67539e199eb59e7ffb09409e07a8d13e0 (patch) | |
tree | ce88a843a13a5f708268212176759ff54ae812f7 /pkg/server/server.go | |
parent | bfb371d0c2f543c7dd5ee4afa112a6546c886ec2 (diff) |
Support vrfs in zapi multipath
Diffstat (limited to 'pkg/server/server.go')
-rw-r--r-- | pkg/server/server.go | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/pkg/server/server.go b/pkg/server/server.go index c5dd18f3..4fbb76ff 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -698,26 +698,39 @@ func clonePathList(pathList []*table.Path) []*table.Path { return l } +func (s *BgpServer) setPathVrfIdMap(paths []*table.Path, m map[uint32]bool) { + for _, p := range paths { + switch p.GetRouteFamily() { + case bgp.RF_IPv4_VPN, bgp.RF_IPv6_VPN: + for _, vrf := range s.globalRib.Vrfs { + if vrf.Id != 0 && table.CanImportToVrf(vrf, p) { + m[uint32(vrf.Id)] = true + } + } + default: + m[zebra.VRF_DEFAULT] = true + } + } +} + +// Note: the destination would be the same for all the paths passed here +// The wather (only zapi) needs a unique list of vrf IDs func (s *BgpServer) notifyBestWatcher(best []*table.Path, multipath [][]*table.Path) { if table.SelectionOptions.DisableBestPathSelection { // Note: If best path selection disabled, no best path to notify. return } + m := make(map[uint32]bool) clonedM := make([][]*table.Path, len(multipath)) for i, pathList := range multipath { clonedM[i] = clonePathList(pathList) + if table.UseMultiplePaths.Enabled { + s.setPathVrfIdMap(clonedM[i], m) + } } clonedB := clonePathList(best) - m := make(map[uint32]bool) - for _, p := range clonedB { - switch p.GetRouteFamily() { - case bgp.RF_IPv4_VPN, bgp.RF_IPv6_VPN: - for _, vrf := range s.globalRib.Vrfs { - if vrf.Id != 0 && table.CanImportToVrf(vrf, p) { - m[uint32(vrf.Id)] = true - } - } - } + if !table.UseMultiplePaths.Enabled { + s.setPathVrfIdMap(clonedB, m) } w := &watchEventBestPath{PathList: clonedB, MultiPathList: clonedM} if len(m) > 0 { |