def setUpClass(cls): gobgp_ctn_image_name = parser_option.gobgp_image base.TEST_PREFIX = parser_option.test_prefix g1 = GoBGPContainer(name='g1', asn=65000, router_id='192.168.0.1', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) g2 = GoBGPContainer(name='g2', asn=65001, router_id='192.168.0.2', ctn_image_name=gobgp_ctn_image_name) e1 = ExaBGPContainer(name='e1', asn=65002, router_id='192.168.0.3') ctns = [g1, g2, e1] cls.clients = {cli.name: cli for cli in (g2, e1)} initial_wait_time = max(ctn.run() for ctn in ctns) time.sleep(initial_wait_time) for cli in cls.clients.values(): # Omit "passwd" to avoid a issue on ExaBGP version 4.0.5: # https://github.com/Exa-Networks/exabgp/issues/766 g1.add_peer(cli, is_rs_client=True, passive=True, prefix_limit=10) cli.add_peer(g1) # advertise a route from route-server-clients g2.add_route('10.0.0.0/24') e1.add_route('10.0.1.0/24') cls.gobgp = g1
def setUpClass(cls): gobgp_ctn_image_name = parser_option.gobgp_image base.TEST_PREFIX = parser_option.test_prefix g1 = GoBGPContainer(name='g1', asn=65000, router_id='192.168.0.1', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) g2 = GoBGPContainer(name='g2', asn=65001, router_id='192.168.0.2', ctn_image_name=gobgp_ctn_image_name) e1 = ExaBGPContainer(name='e1', asn=65002, router_id='192.168.0.3') ctns = [g1, g2, e1] cls.clients = {cli.name: cli for cli in (g2, e1)} initial_wait_time = max(ctn.run() for ctn in ctns) time.sleep(initial_wait_time) for cli in list(cls.clients.values()): # Omit "passwd" to avoid a issue on ExaBGP version 4.0.5: # https://github.com/Exa-Networks/exabgp/issues/766 g1.add_peer(cli, is_rs_client=True, passive=True, prefix_limit=10) cli.add_peer(g1) # advertise a route from route-server-clients g2.add_route('10.0.0.0/24') e1.add_route('10.0.1.0/24') cls.gobgp = g1
def setUpClass(cls): gobgp_ctn_image_name = parser_option.gobgp_image base.TEST_PREFIX = parser_option.test_prefix g1 = GoBGPContainer(name='g1', asn=65000, router_id='192.168.0.1', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) g2 = GoBGPContainer(name='g2', asn=65001, router_id='192.168.0.2', ctn_image_name=gobgp_ctn_image_name) e1 = ExaBGPContainer(name='e1', asn=65002, router_id='192.168.0.3') ctns = [g1, g2, e1] cls.clients = {cli.name: cli for cli in (g2, e1)} initial_wait_time = max(ctn.run() for ctn in ctns) time.sleep(initial_wait_time) for cli in cls.clients.values(): g1.add_peer(cli, is_rs_client=True, passwd='passwd', passive=True, prefix_limit=10) cli.add_peer(g1, passwd='passwd') # advertise a route from route-server-clients g2.add_route('10.0.0.0/24') e1.add_route('10.0.1.0/24') cls.gobgp = g1
def test_03_add_peer(self): q = ExaBGPContainer(name='q4', asn=65004, router_id='192.168.0.5') q.add_route('10.10.0.0/24') time.sleep(q.run()) self.gobgp.add_peer(q) q.add_peer(self.gobgp) self.gobgp.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=q) self.quaggas['q4'] = q for q in self.quaggas.itervalues(): self.assertTrue(len(self.gobgp.get_adj_rib_out(q)) == 0)
def test_03_add_peer(self): q = ExaBGPContainer(name='q4', asn=65004, router_id='192.168.0.5') time.sleep(q.run()) self.gobgp.add_peer(q) q.add_peer(self.gobgp) q.add_route('10.10.0.0/24') self.gobgp.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=q) self.quaggas['q4'] = q for q in self.quaggas.values(): self.assertEqual(len(self.gobgp.get_adj_rib_out(q)), 0)
def setUpClass(cls): gobgp_ctn_image_name = parser_option.gobgp_image base.TEST_PREFIX = parser_option.test_prefix g1 = GoBGPContainer(name='g1', asn=65000, router_id='192.168.0.1', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) e1 = ExaBGPContainer(name='e1', asn=65000, router_id='192.168.0.2') ctns = [g1, e1] # advertise a route from q1, q2 matchs = ['destination 10.0.0.0/24', 'source 20.0.0.0/24'] thens = ['discard'] e1.add_route(route='flow1', rf='ipv4-flowspec', matchs=matchs, thens=thens) matchs2 = [ 'tcp-flags S', 'protocol ==tcp ==udp', "packet-length '>1000&<2000'" ] thens2 = [ 'rate-limit 9600', 'redirect 0.10:100', 'mark 20', 'action sample' ] g1.add_route(route='flow1', rf='ipv4-flowspec', matchs=matchs2, thens=thens2) matchs3 = ['destination 2001::/24/10', 'source 2002::/24/15'] thens3 = ['discard'] e1.add_route(route='flow2', rf='ipv6-flowspec', matchs=matchs3, thens=thens3) matchs4 = ['destination 2001::/24 10', "label '==100'"] thens4 = ['discard'] g1.add_route(route='flow2', rf='ipv6-flowspec', matchs=matchs4, thens=thens4) initial_wait_time = max(ctn.run() for ctn in ctns) time.sleep(initial_wait_time) # ibgp peer. loop topology for a, b in combinations(ctns, 2): a.add_peer(b, flowspec=True) b.add_peer(a, flowspec=True) cls.gobgp = g1 cls.exabgp = e1
def setUpClass(cls): gobgp_ctn_image_name = parser_option.gobgp_image base.TEST_PREFIX = parser_option.test_prefix g1 = GoBGPContainer(name='g1', asn=65000, router_id='192.168.0.1', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) e1 = ExaBGPContainer(name='e1', asn=65000, router_id='192.168.0.2') ctns = [g1, e1] # advertise a route from q1, q2 matchs = ['destination 10.0.0.0/24', 'source 20.0.0.0/24'] thens = ['discard'] e1.add_route(route='flow1', rf='ipv4-flowspec', matchs=matchs, thens=thens) matchs2 = ['tcp-flags S', 'protocol ==tcp ==udp', "packet-length '>1000&<2000'", "source-port '!=2&!=22&!=222'"] thens2 = ['rate-limit 9600', 'redirect 0.10:100', 'mark 20', 'action sample'] g1.add_route(route='flow1', rf='ipv4-flowspec', matchs=matchs2, thens=thens2) matchs3 = ['destination 2001::/24/10', 'source 2002::/24/15'] thens3 = ['discard'] e1.add_route(route='flow2', rf='ipv6-flowspec', matchs=matchs3, thens=thens3) matchs4 = ['destination 2001::/24 10', "label '==100'"] thens4 = ['discard'] g1.add_route(route='flow2', rf='ipv6-flowspec', matchs=matchs4, thens=thens4) initial_wait_time = max(ctn.run() for ctn in ctns) time.sleep(initial_wait_time) # ibgp peer. loop topology for a, b in combinations(ctns, 2): a.add_peer(b, flowspec=True) b.add_peer(a, flowspec=True) cls.gobgp = g1 cls.exabgp = e1
def setUpClass(cls): gobgp_ctn_image_name = parser_option.gobgp_image base.TEST_PREFIX = parser_option.test_prefix g1 = GoBGPContainer(name='g1', asn=65000, router_id='192.168.0.1', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) g2 = GoBGPContainer(name='g2', asn=65000, router_id='192.168.0.2', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) e1 = ExaBGPContainer(name='e1', asn=65000, router_id='192.168.0.3') ctns = [g1, g2, e1] e1.add_route(route='192.168.100.0/24', identifier=10, aspath=[100, 200, 300]) e1.add_route(route='192.168.100.0/24', identifier=20, aspath=[100, 200]) e1.add_route(route='192.168.100.0/24', identifier=30, aspath=[100]) initial_wait_time = max(ctn.run() for ctn in ctns) time.sleep(initial_wait_time) g1.add_peer(e1, addpath=True) e1.add_peer(g1, addpath=True) g1.add_peer(g2, addpath=False, is_rr_client=True) g2.add_peer(g1, addpath=False) cls.g1 = g1 cls.g2 = g2 cls.e1 = e1