summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-03-16 15:37:42 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-03-14 07:58:05 +0900
commit3d8ab0941100303930f657c1f8e9d9b5268840f7 (patch)
tree606cfa1d9afa26ce1ebab5ab3eed246f2863ff13
parent1adbb78a02c37c55545e9f143f135d3995c1884d (diff)
cli: return error when querying RIB of un-established peer
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r--gobgp/cmd/neighbor.go15
-rw-r--r--test/scenario_test/global_policy_test.py10
2 files changed, 23 insertions, 2 deletions
diff --git a/gobgp/cmd/neighbor.go b/gobgp/cmd/neighbor.go
index 9fbffdc2..20821c7e 100644
--- a/gobgp/cmd/neighbor.go
+++ b/gobgp/cmd/neighbor.go
@@ -478,6 +478,21 @@ func showNeighborRib(r string, name string, args []string) error {
return err
}
+ switch r {
+ case CMD_LOCAL, CMD_ADJ_IN, CMD_ACCEPTED, CMD_REJECTED, CMD_ADJ_OUT:
+ if len(rib.Destinations) == 0 {
+ peer, err := client.GetNeighbor(context.Background(), &api.Arguments{
+ Name: name,
+ })
+ if err != nil {
+ return err
+ }
+ if ApiStruct2Peer(peer).Info.BgpState != "BGP_FSM_ESTABLISHED" {
+ return fmt.Errorf("Neighbor %v's BGP session is not established", name)
+ }
+ }
+ }
+
isResultSorted := func(rf bgp.RouteFamily) bool {
switch rf {
case bgp.RF_IPv4_UC, bgp.RF_IPv6_UC:
diff --git a/test/scenario_test/global_policy_test.py b/test/scenario_test/global_policy_test.py
index 2cad385d..b6f3d86f 100644
--- a/test/scenario_test/global_policy_test.py
+++ b/test/scenario_test/global_policy_test.py
@@ -96,6 +96,8 @@ class GoBGPTestBase(unittest.TestCase):
self.gobgp.wait_for(expected_state=BGP_FSM_IDLE, peer=q3)
for q in self.quaggas.itervalues():
+ if q.name == 'q3':
+ continue
self.assertTrue(len(self.gobgp.get_adj_rib_out(q)) == 0)
def test_05_enable_peer(self):
@@ -118,6 +120,8 @@ class GoBGPTestBase(unittest.TestCase):
self.gobgp.wait_for(expected_state=BGP_FSM_IDLE, peer=q3)
for q in self.quaggas.itervalues():
+ if q.name == 'q3':
+ continue
self.assertTrue(len(self.gobgp.get_adj_rib_out(q)) == 0)
def test_07_adv_to_one_peer(self):
@@ -132,6 +136,8 @@ class GoBGPTestBase(unittest.TestCase):
def test_08_check_adj_rib_out(self):
for q in self.quaggas.itervalues():
+ if q.name == 'q3':
+ continue
paths = self.gobgp.get_adj_rib_out(q)
if q == self.quaggas['q1']:
self.assertTrue(len(paths) == 2)
@@ -146,11 +152,11 @@ class GoBGPTestBase(unittest.TestCase):
def test_10_check_adj_rib_out(self):
for q in self.quaggas.itervalues():
+ if q.name == 'q3':
+ continue
paths = self.gobgp.get_adj_rib_out(q)
if q != self.quaggas['q3']:
self.assertTrue(len(paths) == 2)
- else:
- self.assertTrue(len(paths) == 0)
for path in paths:
if q == self.quaggas['q1']:
self.assertTrue(community_exists(path, '65100:10'))