diff options
-rw-r--r-- | server/peer.go | 27 | ||||
-rw-r--r-- | server/server.go | 27 |
2 files changed, 18 insertions, 36 deletions
diff --git a/server/peer.go b/server/peer.go index 15c25353..eaf1e4ac 100644 --- a/server/peer.go +++ b/server/peer.go @@ -35,7 +35,6 @@ type Peer struct { tableId string fsm *FSM adjRibIn *table.AdjRib - adjRibOut *table.AdjRib outgoing *channels.InfiniteChannel policy *table.RoutingPolicy localRib *table.TableManager @@ -58,7 +57,6 @@ func NewPeer(g *config.Global, conf *config.Neighbor, loc *table.TableManager, p } rfs, _ := config.AfiSafis(conf.AfiSafis).ToRfList() peer.adjRibIn = table.NewAdjRib(peer.ID(), rfs) - peer.adjRibOut = table.NewAdjRib(peer.ID(), rfs) return peer } @@ -237,10 +235,11 @@ func (peer *Peer) filterpath(path, old *table.Path) *table.Path { // special handling for RTC nlri // see comments in (*Destination).Calculate() if path != nil && path.GetRouteFamily() == bgp.RF_RTC_UC && !path.IsWithdraw { - // if we already sent the same nlri, ignore this - if peer.adjRibOut.Exists(path) { - return nil - } + + // If we already sent the same nlri, send unnecessary + // update. Fix this after the API change between table + // and server packages. + dst := peer.localRib.GetDestination(path) path = nil // we send a path even if it is not a best path @@ -289,11 +288,9 @@ func (peer *Peer) filterpath(path, old *table.Path) *table.Path { // Procedure section (Section 4.7). Note that this requirement // implies that such routes should be withdrawn from any such neighbor. if path != nil && !path.IsWithdraw && !peer.isLLGREnabledFamily(path.GetRouteFamily()) && path.IsLLGRStale() { - if peer.adjRibOut.Exists(path) { - path = path.Clone(true) - } else { - return nil - } + // we send unnecessary withdrawn even if we didn't + // sent the route. + path = path.Clone(true) } // remove local-pref attribute @@ -347,8 +344,6 @@ func (peer *Peer) processOutgoingPaths(paths, olds []*table.Path) []*table.Path outgoing = append(outgoing, p) } } - - peer.adjRibOut.Update(outgoing) return outgoing } @@ -372,9 +367,7 @@ func (peer *Peer) handleRouteRefresh(e *FsmMsg) []*table.Path { return nil } rfList := []bgp.RouteFamily{rf} - peer.adjRibOut.Drop(rfList) accepted, filtered := peer.getBestFromLocal(rfList) - peer.adjRibOut.Update(accepted) for _, path := range filtered { path.IsWithdraw = true accepted = append(accepted, path) @@ -541,7 +534,8 @@ func (peer *Peer) ToConfig() *config.Neighbor { if peer.fsm.state == bgp.BGP_FSM_ESTABLISHED { rfList := peer.configuredRFlist() - conf.State.AdjTable.Advertised = uint32(peer.adjRibOut.Count(rfList)) + pathList, _ := peer.getBestFromLocal(rfList) + conf.State.AdjTable.Advertised = uint32(len(pathList)) conf.State.AdjTable.Received = uint32(peer.adjRibIn.Count(rfList)) conf.State.AdjTable.Accepted = uint32(peer.adjRibIn.Accepted(rfList)) @@ -556,5 +550,4 @@ func (peer *Peer) ToConfig() *config.Neighbor { func (peer *Peer) DropAll(rfList []bgp.RouteFamily) { peer.adjRibIn.Drop(rfList) - peer.adjRibOut.Drop(rfList) } diff --git a/server/server.go b/server/server.go index 0f113305..6b336849 100644 --- a/server/server.go +++ b/server/server.go @@ -565,7 +565,7 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) []* } var candidates []*table.Path if path.IsWithdraw { - candidates = peer.adjRibOut.PathList(fs, false) + candidates, _ = peer.getBestFromLocal(peer.configuredRFlist()) } else { candidates = rib.GetBestPathList(peer.TableID(), fs) } @@ -745,7 +745,6 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) { } if len(pathList) > 0 { - peer.adjRibOut.Update(pathList) sendFsmOutgoingMsg(peer, pathList, nil, false) } } else { @@ -881,7 +880,6 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) { } paths, _ := p.getBestFromLocal(p.configuredRFlist()) if len(paths) > 0 { - p.adjRibOut.Update(paths) sendFsmOutgoingMsg(p, paths, nil, false) } } @@ -923,7 +921,6 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) { } } if paths, _ := peer.getBestFromLocal(families); len(paths) > 0 { - peer.adjRibOut.Update(paths) sendFsmOutgoingMsg(peer, paths, nil, false) } } @@ -1401,26 +1398,14 @@ func (s *BgpServer) softResetOut(addr string, family bgp.RouteFamily, deferral b } } - sentPathList := peer.adjRibOut.PathList(families, false) - peer.adjRibOut.Drop(families) pathList, filtered := peer.getBestFromLocal(families) if len(pathList) > 0 { - peer.adjRibOut.Update(pathList) sendFsmOutgoingMsg(peer, pathList, nil, false) } if deferral == false && len(filtered) > 0 { withdrawnList := make([]*table.Path, 0, len(filtered)) for _, p := range filtered { - found := false - for _, sentPath := range sentPathList { - if p.GetNlri() == sentPath.GetNlri() { - found = true - break - } - } - if found { - withdrawnList = append(withdrawnList, p.Clone(true)) - } + withdrawnList = append(withdrawnList, p.Clone(true)) } sendFsmOutgoingMsg(peer, withdrawnList, nil, false) } @@ -1559,7 +1544,9 @@ func (s *BgpServer) GetAdjRib(addr string, family bgp.RouteFamily, in bool, pref if in { adjRib = peer.adjRibIn } else { - adjRib = peer.adjRibOut + adjRib = table.NewAdjRib(peer.ID(), peer.configuredRFlist()) + accepted, _ := peer.getBestFromLocal(peer.configuredRFlist()) + adjRib.Update(accepted) } rib, err = adjRib.Select(family, false, table.TableSelectOption{ID: id, LookupPrefixes: prefixes}) } @@ -1609,7 +1596,9 @@ func (s *BgpServer) GetAdjRibInfo(addr string, family bgp.RouteFamily, in bool) if in { adjRib = peer.adjRibIn } else { - adjRib = peer.adjRibOut + adjRib = table.NewAdjRib(peer.ID(), peer.configuredRFlist()) + accepted, _ := peer.getBestFromLocal(peer.configuredRFlist()) + adjRib.Update(accepted) } info, err = adjRib.TableInfo(family) } |