summaryrefslogtreecommitdiffhomepage
path: root/table/adj.go
diff options
context:
space:
mode:
Diffstat (limited to 'table/adj.go')
-rw-r--r--table/adj.go16
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)