diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-04-12 10:16:34 +0000 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-04-19 09:56:41 +0900 |
commit | 332766189685028c4f9852e4285fb1a9025223cc (patch) | |
tree | f04106d60bf45f578e7168d42d3dcf3d04be5fd5 | |
parent | 291d56f8df8213b77ff30b37abf2bee03ad45304 (diff) |
server: send local withdrawal paths regardless of path calculation result
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r-- | server/peer.go | 8 | ||||
-rw-r--r-- | server/server.go | 4 | ||||
-rw-r--r-- | test/scenario_test/bgp_router_test.py | 28 |
3 files changed, 37 insertions, 3 deletions
diff --git a/server/peer.go b/server/peer.go index 6f4f6992..0f6b37ec 100644 --- a/server/peer.go +++ b/server/peer.go @@ -166,7 +166,7 @@ func (peer *Peer) getBestFromLocal(rfList []bgp.RouteFamily) ([]*table.Path, []* return pathList, filtered } -func (peer *Peer) processOutgoingPaths(paths []*table.Path) []*table.Path { +func (peer *Peer) processOutgoingPaths(paths, withdrawals []*table.Path) []*table.Path { if peer.fsm.state != bgp.BGP_FSM_ESTABLISHED { return nil } @@ -179,6 +179,12 @@ func (peer *Peer) processOutgoingPaths(paths []*table.Path) []*table.Path { } outgoing := make([]*table.Path, 0, len(paths)) + for _, path := range withdrawals { + if path.IsLocal() { + outgoing = append(outgoing, path) + } + } + options := &table.PolicyOptions{ Neighbor: peer.fsm.peerInfo.Address, } diff --git a/server/server.go b/server/server.go index 71e569b2..cf6f3af9 100644 --- a/server/server.go +++ b/server/server.go @@ -477,7 +477,7 @@ func (server *BgpServer) dropPeerAllRoutes(peer *Peer, families []bgp.RouteFamil if peer.isRouteServerClient() != targetPeer.isRouteServerClient() || targetPeer == peer { continue } - if paths := targetPeer.processOutgoingPaths(best[targetPeer.TableID()]); len(paths) > 0 { + if paths := targetPeer.processOutgoingPaths(best[targetPeer.TableID()], nil); len(paths) > 0 { msgs = append(msgs, newSenderMsg(targetPeer, paths, nil, false)) } } @@ -746,7 +746,7 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) ([] if (peer == nil && targetPeer.isRouteServerClient()) || (peer != nil && peer.isRouteServerClient() != targetPeer.isRouteServerClient()) { continue } - if paths := targetPeer.processOutgoingPaths(best[targetPeer.TableID()]); len(paths) > 0 { + if paths := targetPeer.processOutgoingPaths(best[targetPeer.TableID()], withdrawn); len(paths) > 0 { msgs = append(msgs, newSenderMsg(targetPeer, paths, nil, false)) } } diff --git a/test/scenario_test/bgp_router_test.py b/test/scenario_test/bgp_router_test.py index 9486ac44..d5059e00 100644 --- a/test/scenario_test/bgp_router_test.py +++ b/test/scenario_test/bgp_router_test.py @@ -303,6 +303,7 @@ class GoBGPTestBase(unittest.TestCase): self.assertTrue(paths[0]['nexthop'] in n_addrs) q3.stop() + del self.quaggas['q3'] time.sleep(3) @@ -310,6 +311,33 @@ class GoBGPTestBase(unittest.TestCase): self.assertTrue(len(paths) == 1) self.assertTrue(paths[0]['nexthop'] in n_addrs) + def test_18_check_withdrawal(self): + g1 = self.gobgp + q1 = self.quaggas['q1'] + q2 = self.quaggas['q2'] + + g1.add_route('30.0.0.0/24') + q1.add_route('30.0.0.0/24') + + self.test_01_neighbor_established() + + self.test_02_check_gobgp_global_rib() + + paths = g1.get_adj_rib_out(q1, '30.0.0.0/24') + self.assertTrue(len(paths) == 1) + self.assertTrue(paths[0]['source-id'] == '<nil>') + paths = g1.get_adj_rib_out(q2, '30.0.0.0/24') + self.assertTrue(len(paths) == 1) + self.assertTrue(paths[0]['source-id'] == '<nil>') + + g1.local('gobgp global rib del 30.0.0.0/24') + + paths = g1.get_adj_rib_out(q1, '30.0.0.0/24') + self.assertTrue(len(paths) == 0) + paths = g1.get_adj_rib_out(q2, '30.0.0.0/24') + self.assertTrue(len(paths) == 1) + self.assertTrue(paths[0]['source-id'] == '192.168.0.2') + if __name__ == '__main__': if os.geteuid() is not 0: |