diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2017-09-12 14:13:09 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-10-05 11:09:31 +0900 |
commit | 6416a6dafbfe78360b31ce5340722bab48a077c2 (patch) | |
tree | 545a74128259e72e7ab25ef40903382953a9b7bd /server | |
parent | 52a47a5fdcf7263a7b5b0a365f2491cac70014a5 (diff) |
server: Avoid applying policy multiply when updating path
Currently, UpdatePath() of BgpServer will apply policy multiply, and
this causes the unexpected result of policy configurations.
This patch avoids this multiple policy application.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'server')
-rw-r--r-- | server/server.go | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/server/server.go b/server/server.go index 46776e03..bb208846 100644 --- a/server/server.go +++ b/server/server.go @@ -660,7 +660,7 @@ func (server *BgpServer) RSimportPaths(peer *Peer, pathList []*table.Path) []*ta func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) { var dsts []*table.Destination - var gBestList, gOldList, bestList, oldList []*table.Path + var gBestList, gOldList []*table.Path var mpathList [][]*table.Path rib := server.globalRib @@ -701,7 +701,7 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) { // match the Route Target in question. // // A BGP speaker should generate the minimum set of BGP VPN route - // updates (advertisements and/or withdrawls) necessary to transition + // updates (advertisements and/or withdraws) necessary to transition // between the previous and current state of the route distribution // graph that is derived from Route Target membership information. if peer != nil && path != nil && path.GetRouteFamily() == bgp.RF_RTC_UC { @@ -745,14 +745,20 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) { server.notifyBestWatcher(gBestList, mpathList) } + server.propagateUpdateToNeighbors(peer, dsts, gBestList, gOldList) +} + +func (server *BgpServer) propagateUpdateToNeighbors(peer *Peer, dsts []*table.Destination, gBestList, gOldList []*table.Path) { families := make(map[bgp.RouteFamily][]*table.Destination) for _, dst := range dsts { - if families[dst.Family()] == nil { - families[dst.Family()] = make([]*table.Destination, 0, len(dsts)) + family := dst.Family() + if families[family] == nil { + families[family] = make([]*table.Destination, 0, len(dsts)) } - families[dst.Family()] = append(families[dst.Family()], dst) + families[family] = append(families[family], dst) } + var bestList, oldList []*table.Path for family, l := range families { for _, targetPeer := range server.neighborMap { if (peer == nil && targetPeer.isRouteServerClient()) || (peer != nil && peer.isRouteServerClient() != targetPeer.isRouteServerClient()) { @@ -1324,8 +1330,10 @@ func (s *BgpServer) UpdatePath(vrfId string, pathList []*table.Path) error { if err := s.fixupApiPath(vrfId, pathList); err != nil { return err } - - s.propagateUpdate(nil, pathList) + dsts := s.globalRib.ProcessPaths(pathList) + gBestList, gOldList, gMPathList := dstsToPaths(table.GLOBAL_RIB_NAME, dsts, false) + s.notifyBestWatcher(gBestList, gMPathList) + s.propagateUpdateToNeighbors(nil, dsts, gBestList, gOldList) return nil }, true) return err |