diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-04-10 22:24:41 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-05-07 21:18:04 +0900 |
commit | 2dbca9e29a6813f2df53261ffaa59b9439c13fdd (patch) | |
tree | 8303b71da5741ffb592bc74738b6548d078a0253 /table | |
parent | 756cc9162afb675dd7ca159b6f07a6d5b927bcc1 (diff) |
use sorted single master table for route server setup
https://github.com/osrg/gobgp/issues/1249
The IN policy was removed. The modification by the IMPORT policy are
visible to all route server peers.
This saves some dozens bytes memory per a path.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r-- | table/adj.go | 29 | ||||
-rw-r--r-- | table/destination.go | 49 | ||||
-rw-r--r-- | table/destination_test.go | 118 | ||||
-rw-r--r-- | table/path.go | 14 | ||||
-rw-r--r-- | table/policy.go | 4 | ||||
-rw-r--r-- | table/table.go | 17 | ||||
-rw-r--r-- | table/table_manager.go | 16 | ||||
-rw-r--r-- | table/table_manager_test.go | 2 |
8 files changed, 70 insertions, 179 deletions
diff --git a/table/adj.go b/table/adj.go index 98c714e6..d16f8d76 100644 --- a/table/adj.go +++ b/table/adj.go @@ -51,23 +51,12 @@ func (adj *AdjRib) Update(pathList []*Path) { if path.IsWithdraw { if found { delete(adj.table[rf], key) - if old.Filtered(adj.id) != POLICY_DIRECTION_IN { - adj.accepted[rf]-- - } + adj.accepted[rf]-- } } else { - n := path.Filtered(adj.id) if found { - o := old.Filtered(adj.id) - if o == POLICY_DIRECTION_IN && n == POLICY_DIRECTION_NONE { - adj.accepted[rf]++ - } else if o != POLICY_DIRECTION_IN && n == POLICY_DIRECTION_IN { - adj.accepted[rf]-- - } } else { - if n == POLICY_DIRECTION_NONE { - adj.accepted[rf]++ - } + adj.accepted[rf]++ } if found && old.Equal(path) { path.setTimestamp(old.GetTimestamp()) @@ -79,12 +68,7 @@ func (adj *AdjRib) Update(pathList []*Path) { func (adj *AdjRib) RefreshAcceptedNumber(rfList []bgp.RouteFamily) { for _, rf := range rfList { - adj.accepted[rf] = 0 - for _, p := range adj.table[rf] { - if p.Filtered(adj.id) != POLICY_DIRECTION_IN { - adj.accepted[rf]++ - } - } + adj.accepted[rf] = len(adj.table[rf]) } } @@ -92,9 +76,6 @@ func (adj *AdjRib) PathList(rfList []bgp.RouteFamily, accepted bool) []*Path { pathList := make([]*Path, 0, adj.Count(rfList)) for _, rf := range rfList { for _, rr := range adj.table[rf] { - if accepted && rr.Filtered(adj.id) == POLICY_DIRECTION_IN { - continue - } pathList = append(pathList, rr) } } @@ -137,9 +118,7 @@ func (adj *AdjRib) DropStale(rfList []bgp.RouteFamily) []*Path { for _, p := range table { if p.IsStale() { delete(table, p.getPrefix()) - if p.Filtered(adj.id) == POLICY_DIRECTION_NONE { - adj.accepted[rf]-- - } + adj.accepted[rf]-- pathList = append(pathList, p.Clone(true)) } } diff --git a/table/destination.go b/table/destination.go index fd32371d..32169f59 100644 --- a/table/destination.go +++ b/table/destination.go @@ -216,34 +216,55 @@ func (dd *Destination) GetAllKnownPathList() []*Path { return dd.knownPathList } -func (dd *Destination) GetKnownPathList(id string) []*Path { +func rsFilter(id string, as uint32, path *Path) bool { + isASLoop := func(as uint32, path *Path) bool { + for _, v := range path.GetAsList() { + if as == v { + return true + } + } + return false + } + + if id != GLOBAL_RIB_NAME && (path.GetSource().Address.String() == id || isASLoop(as, path)) { + return true + } + return false +} + +func (dd *Destination) GetKnownPathList(id string, as uint32) []*Path { list := make([]*Path, 0, len(dd.knownPathList)) for _, p := range dd.knownPathList { - if p.Filtered(id) == POLICY_DIRECTION_NONE { - list = append(list, p) + if rsFilter(id, as, p) { + continue } + list = append(list, p) } return list } -func getBestPath(id string, pathList *paths) *Path { +func getBestPath(id string, as uint32, pathList *paths) *Path { for _, p := range *pathList { - if p.Filtered(id) == POLICY_DIRECTION_NONE && !p.IsNexthopInvalid { + if rsFilter(id, as, p) { + continue + } + + if !p.IsNexthopInvalid { return p } } return nil } -func (dd *Destination) GetBestPath(id string) *Path { - return getBestPath(id, &dd.knownPathList) +func (dd *Destination) GetBestPath(id string, as uint32) *Path { + return getBestPath(id, as, &dd.knownPathList) } func getMultiBestPath(id string, pathList *paths) []*Path { list := make([]*Path, 0, len(*pathList)) var best *Path for _, p := range *pathList { - if p.Filtered(id) == POLICY_DIRECTION_NONE && !p.IsNexthopInvalid { + if !p.IsNexthopInvalid { if best == nil { best = p list = append(list, p) @@ -270,10 +291,10 @@ func (dd *Destination) GetAddPathChanges(id string) []*Path { return l } -func (dd *Destination) GetChanges(id string, peerDown bool) (*Path, *Path, []*Path) { +func (dd *Destination) GetChanges(id string, as uint32, peerDown bool) (*Path, *Path, []*Path) { best, old := func(id string) (*Path, *Path) { - old := getBestPath(id, &dd.oldKnownPathList) - best := dd.GetBestPath(id) + old := getBestPath(id, as, &dd.oldKnownPathList) + best := dd.GetBestPath(id, as) if best != nil && best.Equal(old) { // RFC4684 3.2. Intra-AS VPN Route Distribution // When processing RT membership NLRIs received from internal iBGP @@ -1012,6 +1033,7 @@ func (dest *Destination) String() string { type DestinationSelectOption struct { ID string + AS uint32 VRF *Vrf adj bool Best bool @@ -1028,6 +1050,7 @@ func (old *Destination) Select(option ...DestinationSelectOption) *Destination { adj := false best := false mp := false + as := uint32(0) for _, o := range option { if o.ID != "" { id = o.ID @@ -1038,12 +1061,13 @@ func (old *Destination) Select(option ...DestinationSelectOption) *Destination { adj = o.adj best = o.Best mp = o.MultiPath + as = o.AS } var paths []*Path if adj { paths = old.knownPathList } else { - paths = old.GetKnownPathList(id) + paths = old.GetKnownPathList(id, as) if vrf != nil { ps := make([]*Path, 0, len(paths)) for _, p := range paths { @@ -1077,7 +1101,6 @@ func (old *Destination) Select(option ...DestinationSelectOption) *Destination { new := NewDestination(old.nlri, 0) for _, path := range paths { p := path.Clone(path.IsWithdraw) - p.Filter("", path.Filtered(id)) new.knownPathList = append(new.knownPathList, p) } return new diff --git a/table/destination_test.go b/table/destination_test.go index 48430bd6..f488d4ac 100644 --- a/table/destination_test.go +++ b/table/destination_test.go @@ -66,47 +66,6 @@ func TestDestinationGetNlri(t *testing.T) { assert.Equal(t, r_nlri, nlri) } -func TestCalculate(t *testing.T) { - origin := bgp.NewPathAttributeOrigin(0) - aspathParam := []bgp.AsPathParamInterface{bgp.NewAs4PathParam(2, []uint32{65001})} - aspath := bgp.NewPathAttributeAsPath(aspathParam) - nexthop := bgp.NewPathAttributeNextHop("10.0.0.1") - med := bgp.NewPathAttributeMultiExitDisc(0) - pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} - nlri := bgp.NewIPAddrPrefix(24, "10.10.0.101") - updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, []*bgp.IPAddrPrefix{nlri}) - peer1 := &PeerInfo{AS: 1, Address: net.IP{1, 1, 1, 1}} - path1 := ProcessMessage(updateMsg, peer1, time.Now())[0] - path1.Filter("1", POLICY_DIRECTION_IMPORT) - - action := &AsPathPrependAction{ - asn: 100, - repeat: 10, - } - - path2 := action.Apply(path1.Clone(false), nil) - path1.Filter("2", POLICY_DIRECTION_IMPORT) - path2.Filter("1", POLICY_DIRECTION_IMPORT) - - d := NewDestination(nlri, 0) - d.AddNewPath(path1) - d.AddNewPath(path2) - - d.Calculate() - - assert.Equal(t, len(d.GetKnownPathList("1")), 0) - assert.Equal(t, len(d.GetKnownPathList("2")), 1) - assert.Equal(t, len(d.knownPathList), 2) - - d.AddWithdraw(path1.Clone(true)) - - d.Calculate() - - assert.Equal(t, len(d.GetKnownPathList("1")), 0) - assert.Equal(t, len(d.GetKnownPathList("2")), 0) - assert.Equal(t, len(d.knownPathList), 0) -} - func TestCalculate2(t *testing.T) { origin := bgp.NewPathAttributeOrigin(0) @@ -162,63 +121,6 @@ func TestCalculate2(t *testing.T) { assert.Equal(t, len(d.knownPathList), 3) } -func TestImplicitWithdrawCalculate(t *testing.T) { - origin := bgp.NewPathAttributeOrigin(0) - aspathParam := []bgp.AsPathParamInterface{bgp.NewAs4PathParam(2, []uint32{65001})} - aspath := bgp.NewPathAttributeAsPath(aspathParam) - nexthop := bgp.NewPathAttributeNextHop("10.0.0.1") - med := bgp.NewPathAttributeMultiExitDisc(0) - pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} - nlri := bgp.NewIPAddrPrefix(24, "10.10.0.101") - updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, []*bgp.IPAddrPrefix{nlri}) - peer1 := &PeerInfo{AS: 1, Address: net.IP{1, 1, 1, 1}} - path1 := ProcessMessage(updateMsg, peer1, time.Now())[0] - path1.Filter("1", POLICY_DIRECTION_IMPORT) - - // suppose peer2 has import policy to prepend as-path - action := &AsPathPrependAction{ - asn: 100, - repeat: 1, - } - - path2 := action.Apply(path1.Clone(false), nil) - path1.Filter("2", POLICY_DIRECTION_IMPORT) - path2.Filter("1", POLICY_DIRECTION_IMPORT) - path2.Filter("3", POLICY_DIRECTION_IMPORT) - - d := NewDestination(nlri, 0) - d.AddNewPath(path1) - d.AddNewPath(path2) - - d.Calculate() - - assert.Equal(t, len(d.GetKnownPathList("1")), 0) // peer "1" is the originator - assert.Equal(t, len(d.GetKnownPathList("2")), 1) - assert.Equal(t, d.GetKnownPathList("2")[0].GetAsString(), "100 65001") // peer "2" has modified path {100, 65001} - assert.Equal(t, len(d.GetKnownPathList("3")), 1) - assert.Equal(t, d.GetKnownPathList("3")[0].GetAsString(), "65001") // peer "3" has original path {65001} - assert.Equal(t, len(d.knownPathList), 2) - - // say, we removed peer2's import policy and - // peer1 advertised new path with the same prefix - aspathParam = []bgp.AsPathParamInterface{bgp.NewAs4PathParam(2, []uint32{65001, 65002})} - aspath = bgp.NewPathAttributeAsPath(aspathParam) - pathAttributes = []bgp.PathAttributeInterface{origin, aspath, nexthop, med} - updateMsg = bgp.NewBGPUpdateMessage(nil, pathAttributes, []*bgp.IPAddrPrefix{nlri}) - path3 := ProcessMessage(updateMsg, peer1, time.Now())[0] - path3.Filter("1", POLICY_DIRECTION_IMPORT) - - d.AddNewPath(path3) - d.Calculate() - - assert.Equal(t, len(d.GetKnownPathList("1")), 0) // peer "1" is the originator - assert.Equal(t, len(d.GetKnownPathList("2")), 1) - assert.Equal(t, d.GetKnownPathList("2")[0].GetAsString(), "65001 65002") // peer "2" has new original path {65001, 65002} - assert.Equal(t, len(d.GetKnownPathList("3")), 1) - assert.Equal(t, d.GetKnownPathList("3")[0].GetAsString(), "65001 65002") // peer "3" has new original path {65001, 65002} - assert.Equal(t, len(d.knownPathList), 1) -} - func TestMedTieBreaker(t *testing.T) { nlri := bgp.NewIPAddrPrefix(24, "10.10.0.0") @@ -297,7 +199,7 @@ func TestTimeTieBreaker(t *testing.T) { d.Calculate() assert.Equal(t, len(d.knownPathList), 2) - assert.Equal(t, true, d.GetBestPath("").GetSource().ID.Equal(net.IP{2, 2, 2, 2})) // path from peer2 win + assert.Equal(t, true, d.GetBestPath("", 0).GetSource().ID.Equal(net.IP{2, 2, 2, 2})) // path from peer2 win // this option disables tie breaking by age SelectionOptions.ExternalCompareRouterId = true @@ -308,7 +210,7 @@ func TestTimeTieBreaker(t *testing.T) { d.Calculate() assert.Equal(t, len(d.knownPathList), 2) - assert.Equal(t, true, d.GetBestPath("").GetSource().ID.Equal(net.IP{1, 1, 1, 1})) // path from peer1 win + assert.Equal(t, true, d.GetBestPath("", 0).GetSource().ID.Equal(net.IP{1, 1, 1, 1})) // path from peer1 win } func DestCreatePeer() []*PeerInfo { @@ -462,20 +364,20 @@ func TestMultipath(t *testing.T) { d.AddNewPath(path1) d.AddNewPath(path2) - best, old, multi := d.Calculate().GetChanges(GLOBAL_RIB_NAME, false) + best, old, multi := d.Calculate().GetChanges(GLOBAL_RIB_NAME, 0, false) assert.NotNil(t, best) assert.Equal(t, old, (*Path)(nil)) assert.Equal(t, len(multi), 2) - assert.Equal(t, len(d.GetKnownPathList(GLOBAL_RIB_NAME)), 2) + assert.Equal(t, len(d.GetKnownPathList(GLOBAL_RIB_NAME, 0)), 2) path3 := path2.Clone(true) d.AddWithdraw(path3) dd := d.Calculate() - best, old, multi = dd.GetChanges(GLOBAL_RIB_NAME, false) + best, old, multi = dd.GetChanges(GLOBAL_RIB_NAME, 0, false) assert.Nil(t, best) assert.Equal(t, old, path1) assert.Equal(t, len(multi), 1) - assert.Equal(t, len(d.GetKnownPathList(GLOBAL_RIB_NAME)), 1) + assert.Equal(t, len(d.GetKnownPathList(GLOBAL_RIB_NAME, 0)), 1) peer3 := &PeerInfo{AS: 3, Address: net.IP{3, 3, 3, 3}, ID: net.IP{3, 3, 3, 3}} med = bgp.NewPathAttributeMultiExitDisc(50) @@ -490,10 +392,10 @@ func TestMultipath(t *testing.T) { path4 := ProcessMessage(updateMsg, peer3, time.Now())[0] d.AddNewPath(path4) - best, _, multi = d.Calculate().GetChanges(GLOBAL_RIB_NAME, false) + best, _, multi = d.Calculate().GetChanges(GLOBAL_RIB_NAME, 0, false) assert.NotNil(t, best) assert.Equal(t, len(multi), 1) - assert.Equal(t, len(d.GetKnownPathList(GLOBAL_RIB_NAME)), 2) + assert.Equal(t, len(d.GetKnownPathList(GLOBAL_RIB_NAME, 0)), 2) nexthop = bgp.NewPathAttributeNextHop("192.168.150.2") pathAttributes = []bgp.PathAttributeInterface{ @@ -506,10 +408,10 @@ func TestMultipath(t *testing.T) { path5 := ProcessMessage(updateMsg, peer2, time.Now())[0] d.AddNewPath(path5) - best, _, multi = d.Calculate().GetChanges(GLOBAL_RIB_NAME, false) + best, _, multi = d.Calculate().GetChanges(GLOBAL_RIB_NAME, 0, false) assert.NotNil(t, best) assert.Equal(t, len(multi), 2) - assert.Equal(t, len(d.GetKnownPathList(GLOBAL_RIB_NAME)), 3) + assert.Equal(t, len(d.GetKnownPathList(GLOBAL_RIB_NAME, 0)), 3) UseMultiplePaths.Enabled = false } diff --git a/table/path.go b/table/path.go index 0c201447..4704758e 100644 --- a/table/path.go +++ b/table/path.go @@ -146,7 +146,6 @@ type Path struct { reason BestPathReason parent *Path dels []bgp.BGPAttrType - filtered map[string]PolicyDirection VrfIds []uint16 // For BGP Nexthop Tracking, this field shows if nexthop is invalidated by IGP. IsNexthopInvalid bool @@ -170,7 +169,6 @@ func NewPath(source *PeerInfo, nlri bgp.AddrPrefixInterface, isWithdraw bool, pa }, IsWithdraw: isWithdraw, pathAttrs: pattrs, - filtered: make(map[string]PolicyDirection), } } @@ -182,7 +180,6 @@ func NewEOR(family bgp.RouteFamily) *Path { nlri: nlri, eor: true, }, - filtered: make(map[string]PolicyDirection), } } @@ -339,7 +336,6 @@ func (path *Path) Clone(isWithdraw bool) *Path { return &Path{ parent: path, IsWithdraw: isWithdraw, - filtered: make(map[string]PolicyDirection), IsNexthopInvalid: path.IsNexthopInvalid, } } @@ -396,14 +392,6 @@ func (path *Path) AssignNewUUID() { path.OriginInfo().uuid, _ = uuid.NewV4() } -func (path *Path) Filter(id string, reason PolicyDirection) { - path.filtered[id] = reason -} - -func (path *Path) Filtered(id string) PolicyDirection { - return path.filtered[id] -} - func (path *Path) GetRouteFamily() bgp.RouteFamily { return bgp.AfiSafiToRouteFamily(path.OriginInfo().nlri.AFI(), path.OriginInfo().nlri.SAFI()) } @@ -1094,7 +1082,6 @@ func (path *Path) MarshalJSON() ([]byte, error) { SourceID net.IP `json:"source-id,omitempty"` NeighborIP net.IP `json:"neighbor-ip,omitempty"` Stale bool `json:"stale,omitempty"` - Filtered bool `json:"filtered,omitempty"` UUID string `json:"uuid,omitempty"` ID uint32 `json:"id,omitempty"` }{ @@ -1106,7 +1093,6 @@ func (path *Path) MarshalJSON() ([]byte, error) { SourceID: path.GetSource().ID, NeighborIP: path.GetSource().Address, Stale: path.IsStale(), - Filtered: path.Filtered("") > POLICY_DIRECTION_NONE, UUID: path.UUID().String(), ID: path.GetNlri().PathIdentifier(), }) diff --git a/table/policy.go b/table/policy.go index a7d02b06..299a976b 100644 --- a/table/policy.go +++ b/table/policy.go @@ -2863,9 +2863,7 @@ func (r *RoutingPolicy) ApplyPolicy(id string, dir PolicyDirection, before *Path if before == nil { return nil } - if filtered := before.Filtered(id); filtered > POLICY_DIRECTION_NONE && filtered < dir { - return nil - } + if before.IsWithdraw { return before } diff --git a/table/table.go b/table/table.go index 893c9343..6662376e 100644 --- a/table/table.go +++ b/table/table.go @@ -41,6 +41,7 @@ type LookupPrefix struct { type TableSelectOption struct { ID string + AS uint32 LookupPrefixes []*LookupPrefix VRF *Vrf adj bool @@ -328,10 +329,10 @@ func (t *Table) tableKey(nlri bgp.AddrPrefixInterface) string { return nlri.String() } -func (t *Table) Bests(id string) []*Path { +func (t *Table) Bests(id string, as uint32) []*Path { paths := make([]*Path, 0, len(t.destinations)) for _, dst := range t.destinations { - path := dst.GetBestPath(id) + path := dst.GetBestPath(id, as) if path != nil { paths = append(paths, path) } @@ -350,10 +351,10 @@ func (t *Table) MultiBests(id string) [][]*Path { return paths } -func (t *Table) GetKnownPathList(id string) []*Path { +func (t *Table) GetKnownPathList(id string, as uint32) []*Path { paths := make([]*Path, 0, len(t.destinations)) for _, dst := range t.destinations { - paths = append(paths, dst.GetKnownPathList(id)...) + paths = append(paths, dst.GetKnownPathList(id, as)...) } return paths } @@ -365,6 +366,7 @@ func (t *Table) Select(option ...TableSelectOption) (*Table, error) { prefixes := make([]*LookupPrefix, 0, len(option)) best := false mp := false + as := uint32(0) for _, o := range option { if o.ID != "" { id = o.ID @@ -376,8 +378,9 @@ func (t *Table) Select(option ...TableSelectOption) (*Table, error) { prefixes = append(prefixes, o.LookupPrefixes...) best = o.Best mp = o.MultiPath + as = o.AS } - dOption := DestinationSelectOption{ID: id, VRF: vrf, adj: adj, Best: best, MultiPath: mp} + dOption := DestinationSelectOption{ID: id, AS: as, VRF: vrf, adj: adj, Best: best, MultiPath: mp} dsts := make(map[string]*Destination) if len(prefixes) != 0 { @@ -471,10 +474,10 @@ type TableInfo struct { NumAccepted int } -func (t *Table) Info(id string) *TableInfo { +func (t *Table) Info(id string, as uint32) *TableInfo { var numD, numP int for _, d := range t.destinations { - ps := d.GetKnownPathList(id) + ps := d.GetKnownPathList(id, as) if len(ps) > 0 { numD += 1 numP += len(ps) diff --git a/table/table_manager.go b/table/table_manager.go index 7341df17..0e980404 100644 --- a/table/table_manager.go +++ b/table/table_manager.go @@ -255,7 +255,7 @@ func (manager *TableManager) handleMacMobility(path *Path) []*Destination { if path.IsWithdraw || path.IsLocal() || nlri.RouteType != bgp.EVPN_ROUTE_TYPE_MAC_IP_ADVERTISEMENT { return nil } - for _, path2 := range manager.GetPathList(GLOBAL_RIB_NAME, []bgp.RouteFamily{bgp.RF_EVPN}) { + for _, path2 := range manager.GetPathList(GLOBAL_RIB_NAME, 0, []bgp.RouteFamily{bgp.RF_EVPN}) { if !path2.IsLocal() || path2.GetNlri().(*bgp.EVPNNLRI).RouteType != bgp.EVPN_ROUTE_TYPE_MAC_IP_ADVERTISEMENT { continue } @@ -307,14 +307,14 @@ func (manager *TableManager) getDestinationCount(rfList []bgp.RouteFamily) int { return count } -func (manager *TableManager) GetBestPathList(id string, rfList []bgp.RouteFamily) []*Path { +func (manager *TableManager) GetBestPathList(id string, as uint32, rfList []bgp.RouteFamily) []*Path { if SelectionOptions.DisableBestPathSelection { // Note: If best path selection disabled, there is no best path. return nil } paths := make([]*Path, 0, manager.getDestinationCount(rfList)) for _, t := range manager.tables(rfList...) { - paths = append(paths, t.Bests(id)...) + paths = append(paths, t.Bests(id, as)...) } return paths } @@ -332,10 +332,10 @@ func (manager *TableManager) GetBestMultiPathList(id string, rfList []bgp.RouteF return paths } -func (manager *TableManager) GetPathList(id string, rfList []bgp.RouteFamily) []*Path { +func (manager *TableManager) GetPathList(id string, as uint32, rfList []bgp.RouteFamily) []*Path { paths := make([]*Path, 0, manager.getDestinationCount(rfList)) for _, t := range manager.tables(rfList...) { - paths = append(paths, t.GetKnownPathList(id)...) + paths = append(paths, t.GetKnownPathList(id, as)...) } return paths } @@ -344,7 +344,7 @@ func (manager *TableManager) GetPathListWithNexthop(id string, rfList []bgp.Rout paths := make([]*Path, 0, manager.getDestinationCount(rfList)) for _, rf := range rfList { if t, ok := manager.Tables[rf]; ok { - for _, path := range t.GetKnownPathList(id) { + for _, path := range t.GetKnownPathList(id, 0) { if path.GetNexthop().Equal(nexthop) { paths = append(paths, path) } @@ -366,10 +366,10 @@ func (manager *TableManager) GetDestination(path *Path) *Destination { return t.GetDestination(path.getPrefix()) } -func (manager *TableManager) TableInfo(id string, family bgp.RouteFamily) (*TableInfo, error) { +func (manager *TableManager) TableInfo(id string, as uint32, family bgp.RouteFamily) (*TableInfo, error) { t, ok := manager.Tables[family] if !ok { return nil, fmt.Errorf("address family %s is not configured", family) } - return t.Info(id), nil + return t.Info(id, as), nil } diff --git a/table/table_manager_test.go b/table/table_manager_test.go index cde35a4f..3e2d1e74 100644 --- a/table/table_manager_test.go +++ b/table/table_manager_test.go @@ -32,7 +32,7 @@ import ( func (manager *TableManager) ProcessUpdate(fromPeer *PeerInfo, message *bgp.BGPMessage) ([]*Path, error) { pathList := make([]*Path, 0) for _, d := range manager.ProcessPaths(ProcessMessage(message, fromPeer, time.Now())) { - b, _, _ := d.GetChanges(GLOBAL_RIB_NAME, false) + b, _, _ := d.GetChanges(GLOBAL_RIB_NAME, 0, false) pathList = append(pathList, b) } return pathList, nil |