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, config_format=parser_option.config_format) q1 = ExaBGPContainer(name='q1', asn=65001, router_id='192.168.0.2') q2 = ExaBGPContainer(name='q2', asn=65002, router_id='192.168.0.3') q3 = ExaBGPContainer(name='q3', asn=65003, router_id='192.168.0.4') qs = [q1, q2, q3] ctns = [g1, q1, q2, q3] initial_wait_time = max(ctn.run() for ctn in ctns) time.sleep(initial_wait_time) g1.local('gobgp global policy export add default reject') for q in qs: g1.add_peer(q) q.add_peer(g1) # advertise a route from q1, q2, q3 for idx, q in enumerate(qs): route = '10.0.{0}.0/24'.format(idx + 1) q.add_route(route) cls.gobgp = g1 cls.quaggas = {'q1': q1, 'q2': q2, 'q3': q3}
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) rs_clients = [ ExaBGPContainer(name='q{0}'.format(i + 1), asn=(65001 + i), router_id='192.168.0.{0}'.format(i + 2)) for i in range(4)] ctns = [g1] + rs_clients initial_wait_time = max(ctn.run() for ctn in ctns) time.sleep(initial_wait_time) for i, rs_client in enumerate(rs_clients): g1.add_peer(rs_client, is_rs_client=True) as2 = False if i > 1: as2 = True rs_client.add_peer(g1, as2=as2) # advertise a route from route-server-clients for idx, rs_client in enumerate(rs_clients): route = '10.0.{0}.0/24'.format(idx + 1) rs_client.add_route(route) if idx < 2: route = '10.0.10.0/24' rs_client.add_route(route) cls.gobgp = g1 cls.quaggas = {x.name: x for x in rs_clients}
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=65000, router_id='192.168.0.2', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) g3 = GoBGPContainer(name='g3', asn=65000, router_id='192.168.0.3', 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.4') ctns = [g1, g2, g3, e1] 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) g1.add_peer(g3, addpath=True, is_rr_client=True) g3.add_peer(g1, addpath=True) cls.g1 = g1 cls.g2 = g2 cls.g3 = g3 cls.e1 = 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=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_11_add_ibgp_peer(self): q = ExaBGPContainer(name='q5', asn=65000, router_id='192.168.0.6') time.sleep(q.run()) self.quaggas['q5'] = q self.gobgp.add_peer(q) q.add_peer(self.gobgp) self.gobgp.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=q)
def test_02_add_neighbor(self): e2 = ExaBGPContainer(name='e2', asn=65001, router_id='192.168.0.4') time.sleep(e2.run()) self.gobgp.add_peer(e2, is_rs_client=True) e2.add_peer(self.gobgp) self.gobgp.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=e2) self.clients[e2.name] = e2
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 boot(env): gobgp_ctn_image_name = env.parser_option.gobgp_image log_level = env.parser_option.gobgp_log_level g1 = GoBGPContainer(name='g1', asn=65000, router_id='192.168.0.1', ctn_image_name=gobgp_ctn_image_name, log_level=log_level) e1 = ExaBGPContainer(name='e1', asn=65001, router_id='192.168.0.2') e2 = ExaBGPContainer(name='e2', asn=65001, router_id='192.168.0.2') ctns = [g1, e1, e2] initial_wait_time = max(ctn.run() for ctn in ctns) time.sleep(initial_wait_time) for q in [e1, e2]: g1.add_peer(q, is_rs_client=True) q.add_peer(g1) env.g1 = g1 env.e1 = e1 env.e2 = e2
def test_19_check_grpc_add_neighbor(self): g1 = self.gobgp e1 = ExaBGPContainer(name='e1', asn=65000, router_id='192.168.0.7') time.sleep(e1.run()) e1.add_peer(g1) self.quaggas['e1'] = e1 n = e1.peers[g1]['local_addr'].split('/')[0] g1.local('gobgp n add {0} as 65000'.format(n)) g1.add_peer(e1, reload_config=False) g1.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=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=65001, router_id='192.168.0.2') ctns = [g1, e1] initial_wait_time = max(ctn.run() for ctn in ctns) time.sleep(initial_wait_time) g1.add_peer(e1, treat_as_withdraw=True) e1.add_peer(g1) cls.g1 = g1 cls.e1 = 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
def setUpClass(cls): gobgp_ctn_image_name = parser_option.gobgp_image base.TEST_PREFIX = parser_option.test_prefix cls.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) cls.e1 = ExaBGPContainer(name='e1', asn=65000, router_id='192.168.0.2') cls.y1 = YABGPContainer(name='y1', asn=65000, router_id='192.168.0.3') ctns = [cls.g1, cls.e1, cls.y1] initial_wait_time = max(ctn.run() for ctn in ctns) time.sleep(initial_wait_time) # Add FlowSpec routes into GoBGP. cls.g1.add_route( route='ipv4/all', rf='ipv4-flowspec', matchs=[ 'destination 11.1.0.0/24', 'source 11.2.0.0/24', "protocol '==tcp &=udp icmp >igmp >=egp <ipip <=rsvp !=gre'", "port '==80 &=90 8080 >9090 >=8180 <9190 <=8081 !=9091 &!443'", 'destination-port 80', 'source-port 8080', 'icmp-type 0', 'icmp-code 2', "tcp-flags '==S &=SA A !F !=U =!R'", 'packet-length 100', 'dscp 12', 'fragment dont-fragment is-fragment+first-fragment', ], thens=['discard']) cls.g1.add_route( route='ipv6/dst/src/label', # others are tested on IPv4 rf='ipv6-flowspec', matchs=[ 'destination 2001:1::/64 10', 'source 2001:2::/64 15', 'label 12', ], thens=['discard']) cls.g1.add_peer(cls.e1, flowspec=True) cls.e1.add_peer(cls.g1, flowspec=True) cls.g1.add_peer(cls.y1, flowspec=True) cls.y1.add_peer(cls.g1, flowspec=True) cls.g1.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=cls.e1) cls.g1.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=cls.y1) # Add FlowSpec routes into ExaBGP. cls.e1.add_route(route='ipv4/all', rf='ipv4-flowspec', matchs=[ 'destination 12.1.0.0/24', 'source 12.2.0.0/24', 'protocol =tcp', 'port >=80', 'destination-port >5000', 'source-port 8080', 'icmp-type <1', 'icmp-code <=2', "tcp-flags FIN", 'packet-length >100&<200', 'dscp 12', 'fragment dont-fragment', ], thens=['discard']) cls.e1.add_route( route='ipv6/dst/src/protocol/label', # others are tested on IPv4 rf='ipv6-flowspec', matchs=[ 'destination 2002:1::/64/10', 'source 2002:2::/64/15', 'next-header udp', 'flow-label >100', ], thens=['discard']) # Add FlowSpec routes into YABGP. cls.y1.add_route( route='ipv4/all', rf='ipv4-flowspec', matchs=[ 'destination 13.1.0.0/24', 'source 13.2.0.0/24', "protocol =6|=17", # "port", # not seem to be supported 'destination-port =80', 'source-port <8080|>9090', 'icmp-type >=1', 'icmp-code <2', # "tcp-flags", # not seem to be supported via REST API 'packet-length <=100', 'dscp =12', # "fragment", # not seem to be supported via REST API ], thens=['traffic-rate:0:0']) # 'discard'