diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-05-28 23:00:49 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-05-28 23:20:59 +0900 |
commit | df6c998bc1718e093aabdeab6ef0f857ccc229d1 (patch) | |
tree | 3c8699bbf01a0abf0515ddd81640e1054f624d23 | |
parent | ff09df9841485e6dec5ac228d6c1a55c1f2e5245 (diff) |
table: update accepted number in adj-in rib after softreset-in
update accepted number in adj-in rib after AllowOwnAs has changed.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | server/server.go | 19 | ||||
-rw-r--r-- | table/adj.go | 6 | ||||
-rw-r--r-- | test/scenario_test/aspath_test.py | 6 |
3 files changed, 18 insertions, 13 deletions
diff --git a/server/server.go b/server/server.go index f6d0a8b8..5a1dd8fc 100644 --- a/server/server.go +++ b/server/server.go @@ -1751,24 +1751,31 @@ func (s *BgpServer) softResetIn(addr string, family bgp.RouteFamily) error { return err } for _, peer := range peers { - pathList := []*table.Path{} families := []bgp.RouteFamily{family} if family == bgp.RouteFamily(0) { families = peer.configuredRFlist() } + pathList := make([]*table.Path, 0, peer.adjRibIn.Count(families)) for _, path := range peer.adjRibIn.PathList(families, false) { // RFC4271 9.1.2 Phase 2: Route Selection // // If the AS_PATH attribute of a BGP route contains an AS loop, the BGP // route should be excluded from the Phase 2 decision function. + isLooped := false if aspath := path.GetAsPath(); aspath != nil { - if hasOwnASLoop(peer.fsm.peerInfo.LocalAS, int(peer.fsm.pConf.AsPathOptions.Config.AllowOwnAs), aspath) { - continue - } + isLooped = hasOwnASLoop(peer.fsm.peerInfo.LocalAS, int(peer.fsm.pConf.AsPathOptions.Config.AllowOwnAs), aspath) + } + if path.IsAsLooped() != isLooped { + // can't modify the existing one. needs to create one + path = path.Clone(false) + path.SetAsLooped(isLooped) + // update accepted counter + peer.adjRibIn.Update([]*table.Path{path}) + } + if !path.IsAsLooped() { + pathList = append(pathList, path) } - pathList = append(pathList, path.Clone(false)) } - peer.adjRibIn.RefreshAcceptedNumber(families) s.propagateUpdate(peer, pathList) } return err diff --git a/table/adj.go b/table/adj.go index 9e4ce528..871a6813 100644 --- a/table/adj.go +++ b/table/adj.go @@ -73,12 +73,6 @@ func (adj *AdjRib) Update(pathList []*Path) { } } -func (adj *AdjRib) RefreshAcceptedNumber(rfList []bgp.RouteFamily) { - for _, rf := range rfList { - adj.accepted[rf] = len(adj.table[rf]) - } -} - func (adj *AdjRib) PathList(rfList []bgp.RouteFamily, accepted bool) []*Path { pathList := make([]*Path, 0, adj.Count(rfList)) for _, rf := range rfList { diff --git a/test/scenario_test/aspath_test.py b/test/scenario_test/aspath_test.py index bd9f107a..25518bfa 100644 --- a/test/scenario_test/aspath_test.py +++ b/test/scenario_test/aspath_test.py @@ -89,7 +89,11 @@ class GoBGPTestBase(unittest.TestCase): def test_04_check_accept_as_loop(self): def f(): - self.assertEqual(len(self.g2.get_global_rib()), 1) + adj = self.g2.get_neighbor(self.q1)['state']['adj-table'] + self.assertTrue('received' in adj) + self.assertEqual(adj['received'], 1) + self.assertTrue('accepted' in adj) + self.assertEqual(adj['accepted'], 1) assert_several_times(f) |