summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-05-28 15:22:02 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-05-28 22:53:38 +0900
commitff09df9841485e6dec5ac228d6c1a55c1f2e5245 (patch)
tree486db15c6c702137e88d95d74b79a2c6f50975e8 /table
parenta75bcf3e9ee18e4e61f4852cae34d54df5cef868 (diff)
table: fix accepted number in adj-in rib
fix accepted number in adj-in rib when it has an as-looped path. adding another member to Path struct is pain. Should be fixed later. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r--table/adj.go20
-rw-r--r--table/path.go9
2 files changed, 26 insertions, 3 deletions
diff --git a/table/adj.go b/table/adj.go
index 54e0a324..9e4ce528 100644
--- a/table/adj.go
+++ b/table/adj.go
@@ -49,12 +49,21 @@ func (adj *AdjRib) Update(pathList []*Path) {
if path.IsWithdraw {
if found {
delete(adj.table[rf], key)
- adj.accepted[rf]--
+ if !old.IsAsLooped() {
+ adj.accepted[rf]--
+ }
}
} else {
if found {
+ if old.IsAsLooped() && !path.IsAsLooped() {
+ adj.accepted[rf]++
+ } else if !old.IsAsLooped() && path.IsAsLooped() {
+ adj.accepted[rf]--
+ }
} else {
- adj.accepted[rf]++
+ if !path.IsAsLooped() {
+ adj.accepted[rf]++
+ }
}
if found && old.Equal(path) {
path.setTimestamp(old.GetTimestamp())
@@ -74,6 +83,9 @@ 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.IsAsLooped() {
+ continue
+ }
pathList = append(pathList, rr)
}
}
@@ -116,7 +128,9 @@ func (adj *AdjRib) DropStale(rfList []bgp.RouteFamily) []*Path {
for _, p := range table {
if p.IsStale() {
delete(table, p.getPrefix())
- adj.accepted[rf]--
+ if !p.IsAsLooped() {
+ adj.accepted[rf]--
+ }
pathList = append(pathList, p.Clone(true))
}
}
diff --git a/table/path.go b/table/path.go
index 3e4fbff3..62f277d4 100644
--- a/table/path.go
+++ b/table/path.go
@@ -144,6 +144,7 @@ type Path struct {
dels []bgp.BGPAttrType
// For BGP Nexthop Tracking, this field shows if nexthop is invalidated by IGP.
IsNexthopInvalid bool
+ aslooped bool
}
func NewPath(source *PeerInfo, nlri bgp.AddrPrefixInterface, isWithdraw bool, pattrs []bgp.PathAttributeInterface, timestamp time.Time, noImplicitWithdraw bool) *Path {
@@ -394,6 +395,14 @@ func (path *Path) IsStale() bool {
return path.OriginInfo().stale
}
+func (path *Path) IsAsLooped() bool {
+ return path.aslooped
+}
+
+func (path *Path) SetAsLooped(y bool) {
+ path.aslooped = y
+}
+
func (path *Path) IsLLGRStale() bool {
for _, c := range path.GetCommunities() {
if c == bgp.COMMUNITY_LLGR_STALE {