From 0f62519cd77f1cf38dee5b58377d0c347fe619bc Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Tue, 9 May 2017 07:47:09 +0000 Subject: server: ignore routes when local AS is in AS_PATH 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. AS loop detection is done by scanning the full AS path (as specified in the AS_PATH attribute), and checking that the autonomous system number of the local system does not appear in the AS path. Operations of a BGP speaker that is configured to accept routes with its own autonomous system number in the AS path are outside the scope of this document. Also this commit adds support for allow-own-as option to relax this. Signed-off-by: ISHIDA Wataru --- test/lib/base.py | 10 ++++++++-- test/lib/gobgp.py | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'test/lib') diff --git a/test/lib/base.py b/test/lib/base.py index 1f523c32..ef8e7ab7 100644 --- a/test/lib/base.py +++ b/test/lib/base.py @@ -300,12 +300,17 @@ class BGPContainer(Container): name = self.peers[peer]['neigh_addr'].split('/')[0] return name + def update_peer(self, peer, **kwargs): + if peer not in self.peers: + raise Exception('peer not exists') + self.add_peer(peer, **kwargs) + def add_peer(self, peer, passwd=None, vpn=False, is_rs_client=False, policies=None, passive=False, is_rr_client=False, cluster_id=None, flowspec=False, bridge='', reload_config=True, as2=False, graceful_restart=None, local_as=None, prefix_limit=None, - v6=False, llgr=None, vrf='', interface=''): + v6=False, llgr=None, vrf='', interface='', allow_as_in=0): neigh_addr = '' local_addr = '' it = itertools.product(self.ip_addrs, peer.ip_addrs) @@ -346,7 +351,8 @@ class BGPContainer(Container): 'local_as': local_as, 'prefix_limit': prefix_limit, 'llgr': llgr, - 'vrf': vrf} + 'vrf': vrf, + 'allow_as_in': allow_as_in} if self.is_running and reload_config: self.create_config() self.reload_config() diff --git a/test/lib/gobgp.py b/test/lib/gobgp.py index 14fbfe1f..15264bfb 100644 --- a/test/lib/gobgp.py +++ b/test/lib/gobgp.py @@ -357,6 +357,10 @@ class GoBGPContainer(BGPContainer): }, } + n['as-path-options'] = {'config': {}} + if info['allow_as_in'] > 0: + n['as-path-options']['config']['allow-own-as'] = info['allow_as_in'] + if ':' in info['local_addr']: n['transport']['config']['local-address'] = info['local_addr'].split('/')[0] -- cgit v1.2.3