summaryrefslogtreecommitdiffhomepage
path: root/test/scenario_test/lib/gobgp.py
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-07-03 11:40:02 +0900
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-07-03 11:40:02 +0900
commitb02f24e01213a19b92ebd96b703e0240fdf8d3ff (patch)
treea591d3d8eaa1fc437f4a0b11f5705c9e8eeb589b /test/scenario_test/lib/gobgp.py
parentc922dd575ac2c35afe3c6fb3ffea66e9b621c23e (diff)
server: bug fix of extra as-path prepending
When gobgp originates a route, the generated route had incorrect as-path. this patch fix this bug. Scenario test is also added to check this. [before] $ gobgp neighbor global rib Network Next Hop AS_PATH Age Attrs *> 10.0.1.0/24 192.168.10.3 65001 00:03:20 [{Origin: IGP} {Med: 0}] *> 10.0.2.0/24 192.168.10.4 65002 00:03:36 [{Origin: IGP} {Med: 200}] *> 10.10.0.0/24 0.0.0.0 65000 00:03:37 [{Origin: IGP}] $ gobgp neighbor 192.168.10.5 adj-out Network Next Hop AS_PATH Attrs 10.0.1.0/24 192.168.10.2 65000 65001 [{Origin: IGP}] 10.0.2.0/24 192.168.10.2 65000 65002 [{Origin: IGP}] 10.10.0.0/24 192.168.10.2 65000 65000 [{Origin: IGP}] [after] $ gobgp neighbor global rib Network Next Hop AS_PATH Age Attrs *> 10.0.1.0/24 192.168.10.3 65001 00:03:20 [{Origin: IGP} {Med: 0}] *> 10.0.2.0/24 192.168.10.4 65002 00:03:36 [{Origin: IGP} {Med: 200}] *> 10.10.0.0/24 0.0.0.0 00:03:37 [{Origin: IGP}] $ gobgp neighbor 192.168.10.5 adj-out Network Next Hop AS_PATH Attrs 10.0.1.0/24 192.168.10.2 65000 65001 [{Origin: IGP}] 10.0.2.0/24 192.168.10.2 65000 65002 [{Origin: IGP}] 10.10.0.0/24 192.168.10.2 65000 [{Origin: IGP}] Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'test/scenario_test/lib/gobgp.py')
-rw-r--r--test/scenario_test/lib/gobgp.py30
1 files changed, 28 insertions, 2 deletions
diff --git a/test/scenario_test/lib/gobgp.py b/test/scenario_test/lib/gobgp.py
index 4e26b922..3b7ec5ba 100644
--- a/test/scenario_test/lib/gobgp.py
+++ b/test/scenario_test/lib/gobgp.py
@@ -18,6 +18,7 @@ import json
import toml
import subprocess
import select
+from itertools import chain
class GoBGPContainer(BGPContainer):
@@ -52,6 +53,28 @@ class GoBGPContainer(BGPContainer):
self._start_gobgp()
return self.WAIT_FOR_BOOT
+ def _get_as_path(self, path):
+ asps = (p['as_paths'] for p in path['attrs'] if
+ p['type'] == BGP_ATTR_TYPE_AS_PATH)
+ asps = chain.from_iterable(asps)
+ asns = (asp['asns'] for asp in asps)
+ return list(chain.from_iterable(asns))
+
+ def _trigger_peer_cmd(self, cmd, peer):
+ if peer not in self.peers:
+ raise Exception('not found peer {0}'.format(peer.router_id))
+ peer_addr = self.peers[peer]['neigh_addr'].split('/')[0]
+ cmd = "docker exec {0} gobgp neighbor {1} {2}".format(self.name,
+ peer_addr,
+ cmd)
+ local(str(cmd), capture=True)
+
+ def disable_peer(self, peer):
+ self._trigger_peer_cmd('disable', peer)
+
+ def enable_peer(self, peer):
+ self._trigger_peer_cmd('enable', peer)
+
def get_local_rib(self, peer, rf='ipv4'):
if peer not in self.peers:
raise Exception('not found peer {0}'.format(peer.router_id))
@@ -80,7 +103,7 @@ class GoBGPContainer(BGPContainer):
gobgp = '/go/bin/gobgp'
cmd = 'docker exec {0} {1} neighbor {2}'\
' adj-{3} {4} -a {5} -j'.format(self.name, gobgp, peer_addr,
- adj_type, prefix, rf)
+ adj_type, prefix, rf)
output = local(cmd, capture=True)
return json.loads(output)
@@ -135,7 +158,6 @@ class GoBGPContainer(BGPContainer):
continue
raise Exception('timeout')
-
def create_config(self):
config = {'Global': {'As': self.asn, 'RouterId': self.router_id}}
for peer, info in self.peers.iteritems():
@@ -188,3 +210,7 @@ class GoBGPContainer(BGPContainer):
def reload_config(self):
cmd = 'docker exec {0} /usr/bin/pkill gobgpd -SIGHUP'.format(self.name)
local(cmd, capture=True)
+ for v in self.routes.itervalues():
+ cmd = 'docker exec {0} gobgp global '\
+ 'rib add {1} -a {2}'.format(self.name, v['prefix'], v['rf'])
+ local(cmd, capture=True)