summaryrefslogtreecommitdiffhomepage
path: root/table/table.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-04-10 22:24:41 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-05-07 21:18:04 +0900
commit2dbca9e29a6813f2df53261ffaa59b9439c13fdd (patch)
tree8303b71da5741ffb592bc74738b6548d078a0253 /table/table.go
parent756cc9162afb675dd7ca159b6f07a6d5b927bcc1 (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/table.go')
-rw-r--r--table/table.go17
1 files changed, 10 insertions, 7 deletions
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)