diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-11-29 04:08:36 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-12-08 14:45:37 +0900 |
commit | a719a3de6e8b2bb7803e02e7e05ea8e854d6f396 (patch) | |
tree | fbe41ae4055542414a7a02d81c87a0fc57b65f5c /table/adj.go | |
parent | 3213eed6a5aca1625ffa03ab410ffc587121b9da (diff) |
server/table: use only one rib for multiple route server clients
speed up and reduce memory footprint
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/adj.go')
-rw-r--r-- | table/adj.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/table/adj.go b/table/adj.go index 019ad3c8..d7a0555d 100644 --- a/table/adj.go +++ b/table/adj.go @@ -21,16 +21,18 @@ import ( ) type AdjRib struct { + id string accepted map[bgp.RouteFamily]int table map[bgp.RouteFamily]map[string]*Path } -func NewAdjRib(rfList []bgp.RouteFamily) *AdjRib { +func NewAdjRib(id string, rfList []bgp.RouteFamily) *AdjRib { table := make(map[bgp.RouteFamily]map[string]*Path) for _, rf := range rfList { table[rf] = make(map[string]*Path) } return &AdjRib{ + id: id, table: table, accepted: make(map[bgp.RouteFamily]int), } @@ -47,19 +49,21 @@ func (adj *AdjRib) Update(pathList []*Path) { if path.IsWithdraw { if found { delete(adj.table[rf], key) - if !old.Filtered { + if old.Filtered(adj.id) > POLICY_DIRECTION_NONE { adj.accepted[rf]-- } } } else { + n := path.Filtered(adj.id) if found { - if old.Filtered && !path.Filtered { + o := old.Filtered(adj.id) + if o == POLICY_DIRECTION_IN && n == POLICY_DIRECTION_NONE { adj.accepted[rf]++ - } else if !old.Filtered && path.Filtered { + } else if o == POLICY_DIRECTION_NONE && n == POLICY_DIRECTION_IN { adj.accepted[rf]-- } } else { - if !path.Filtered { + if n == POLICY_DIRECTION_NONE { adj.accepted[rf]++ } } @@ -75,7 +79,7 @@ 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 { + if accepted && rr.Filtered(adj.id) > POLICY_DIRECTION_NONE { continue } pathList = append(pathList, rr) |