コード例 #1
0
ファイル: test_routes_v6.py プロジェクト: cfra/quagga-testing
    def test_nexthop_ipv6_ifindex(self):
        # There is currently no multipath support for IPv6 :(
        # Zebra will just merge all the nexthop information
        # into one :/

        self.route.add_nexthop('fe80::23')
        self.route.add_nexthop(ifindex=self.dummy1.index)
        self.zclient.add_route(self.route)
        time.sleep(0.1)

        self.assertIn(str(self.route.dest), self.zebra.rib('O',6))
        self.assertRoutes({
            str(self.route.dest): {
                'nexthops': [
                    {
                        'gate': 'fe80::23',
                        'iface': self.dummy1.name,
                    },
                ],
            },
        }, system.fib(6))

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn(str(self.route.dest), system.fib(6))
        self.assertNotIn(str(self.route.dest), self.zebra.rib('O', 6))
コード例 #2
0
ファイル: test_routes_v4.py プロジェクト: cfra/quagga-testing
    def test_nexthop_ifindex(self):
        route = pyzclient.Route(None, '198.51.100.128/25')
        route.nexthops.append(pyzclient.Nexthop(ifindex=self.dummy1.index))
        route.nexthops.append(pyzclient.Nexthop(ifindex=self.dummy2.index))

        expected_rib = {
            '198.51.100.128/25': {
                'selected': True,
                'nexthops': [
                    {
                        'gate': None,
                        'iface': self.dummy1.name
                    },
                    {
                        'gate': None,
                        'iface': self.dummy2.name
                    }
                ]
            }
        }

        expected_fib = {
            '198.51.100.128/25': {
                'nexthops': [
                    {
                        'gate': None,
                        'iface': self.dummy1.name
                    },
                    {
                        'gate': None,
                        'iface': self.dummy2.name
                    }
                ]
            }
        }

        self.zclient.add_route(route)
        time.sleep(0.1)

        self.assertRoutes(expected_rib, self.zebra.rib('O'))
        self.assertRoutes(expected_fib, system.fib())

        self.zclient.del_route(route)
        time.sleep(0.1)

        self.assertNotIn('198.51.100.128/25', self.zebra.rib('O'))
        self.assertNotIn('198.51.100.128/25', system.fib())

        self.zclient.add_route(route)
        time.sleep(0.1)

        self.assertRoutes(expected_rib, self.zebra.rib('O'))
        self.assertRoutes(expected_fib, system.fib())

        route.nexthops = list(reversed(route.nexthops))
        self.zclient.del_route(route)
        time.sleep(0.1)

        self.assertNotIn('198.51.100.128/25', self.zebra.rib('O'))
        self.assertNotIn('198.51.100.128/25', system.fib())
コード例 #3
0
ファイル: test_routes_v6.py プロジェクト: cfra/quagga-testing
    def test_nexthop_ipv6_ifindex(self):
        # There is currently no multipath support for IPv6 :(
        # Zebra will just merge all the nexthop information
        # into one :/

        self.route.add_nexthop('fe80::23')
        self.route.add_nexthop(ifindex=self.dummy1.index)
        self.zclient.add_route(self.route)
        time.sleep(0.1)

        self.assertIn(str(self.route.dest), self.zebra.rib('O', 6))
        self.assertRoutes(
            {
                str(self.route.dest): {
                    'nexthops': [
                        {
                            'gate': 'fe80::23',
                            'iface': self.dummy1.name,
                        },
                    ],
                },
            }, system.fib(6))

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn(str(self.route.dest), system.fib(6))
        self.assertNotIn(str(self.route.dest), self.zebra.rib('O', 6))
コード例 #4
0
ファイル: test_routes_v6.py プロジェクト: cfra/quagga-testing
    def test_resolve_via_ipv6_ifindex(self):
        self.route.add_nexthop('2001:db8:1:5::1')
        self.bgp_client.add_route(self.route)
        time.sleep(0.1)

        self.assertRoutes(
            {
                str(self.route.dest): {
                    'selected':
                    True,
                    'nexthops': [{
                        'gate':
                        '2001:db8:1:5::1',
                        'resolved': [{
                            'gate': 'fe80::42',
                            'iface': self.dummy1.name
                        }]
                    }]
                }
            }, self.zebra.rib('B', 6))
        self.assertRoutes(
            {
                str(self.route.dest): {
                    'nexthops': [{
                        'gate': 'fe80::42',
                        'iface': self.dummy1.name
                    }]
                }
            }, system.fib(6))

        self.bgp_client.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn(str(self.route.dest), self.zebra.rib('B'))
        self.assertNotIn(str(self.route.dest), system.fib(6))
コード例 #5
0
ファイル: test_routes_v4.py プロジェクト: cfra/quagga-testing
    def test_nexthop_ipv4_invalid(self):
        self.route.add_nexthop('192.0.2.2')
        self.dummy1.addr_del('192.0.2.1/29')
        time.sleep(0.1)

        self.zclient.add_route(self.route)
        time.sleep(0.1)

        # Route should be in RIB, marked as inactive
        self.assertRoutes({
            '198.51.100.128/25': {
                'selected': False,
                'nexthops': [
                    {
                        'gate': '192.0.2.2',
                        'iface': None,
                        'fib': False,
                        'active': False,
                    },
                ]
            },
        }, self.zebra.rib('O'))
        # Route shouldn't be in FIB
        self.assertNotIn('198.51.100.128/25', system.fib())

        # Make the gateway reachable by adding the address
        self.dummy1.addr_add('192.0.2.1/29')
        time.sleep(0.1)

        # RIB should show route as active and fib now
        self.assertRoutes({
            '198.51.100.128/25': {
                'selected': True,
                'nexthops': [
                    {
                        'gate': '192.0.2.2',
                        'iface': self.dummy1.name,
                        'fib': True,
                        'active': True,
                    },
                ]
            },
        }, self.zebra.rib('O'))
        # route should be in fib now
        self.assertRoutes({
            '198.51.100.128/25': {
                'nexthops': [
                    {
                        'gate': '192.0.2.2',
                    },
                ]
            },
        }, system.fib())

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn('198.51.100.128/25', system.fib())
        self.assertNotIn('198.51.100.128/25', self.zebra.rib('O'))
コード例 #6
0
ファイル: test_routes_v6.py プロジェクト: cfra/quagga-testing
    def test_nexthop_ipv6_ifindex_invalid(self):
        self.route.add_nexthop('2001:db8:1:1::2')
        self.route.add_nexthop(ifindex=self.dummy2.index)
        self.zclient.add_route(self.route)
        time.sleep(0.1)

        # Route should be in RIB, but not in fib
        # XXX: Is it right to mark that route as selected and active??
        self.assertRoutes({
            str(self.route.dest): {
#                'selected': False,
                'nexthops': [
                    {
                        'gate': '2001:db8:1:1::2',
                        'iface': self.dummy2.name,
                        'fib': False,
#                        'active': False
                    },
                ]
            },
        }, self.zebra.rib('O',6))
        # Route shouldn't be in FIB
        self.assertNotIn(str(self.route.dest), system.fib(6))

        # Make the gateway reachable by adding an address to the interface
        self.dummy2.addr_add('2001:db8:1:1::1/64', 6)
        time.sleep(0.1)

        # RIB should now show nexthop as installed into FIB
        self.assertRoutes({
            str(self.route.dest): {
                'selected': True,
                'nexthops': [
                    {
                        'gate': '2001:db8:1:1::2',
                        'iface': self.dummy2.name,
                        'fib': True,
                        'active': True
                    },
                ]
            },
        }, self.zebra.rib('O',6))
        # Route should be in FIB
        self.assertRoutes({
            str(self.route.dest): {
                'nexthops': [
                    {
                        'gate': '2001:db8:1:1::2',
                        'iface': self.dummy2.name
                    }
                ]
            },
        }, system.fib(6))

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn(str(self.route.dest), system.fib(6))
        self.assertNotIn(str(self.route.dest), self.zebra.rib('O',6))
コード例 #7
0
ファイル: test_routes_v6.py プロジェクト: cfra/quagga-testing
    def test_nexthop_ipv6_invalid(self):
        self.route.add_nexthop('2001:db8:1:1::2')
        self.dummy1.addr_del('2001:db8:1:1::1/64', 6)
        time.sleep(0.1)

        self.zclient.add_route(self.route)
        time.sleep(0.1)

        # Route should be in RIB, marked as inactive
        self.assertRoutes({
            str(self.route.dest): {
                'selected': False,
                'nexthops': [
                    {
                        'gate': '2001:db8:1:1::2',
                        'iface': None,
                        'fib': False,
                        'active': False,
                    },
                ]
            },
        }, self.zebra.rib('O',6))
        # Route shouldn't be in FIB
        self.assertNotIn(str(self.route.dest), system.fib(6))

        # Make the gateway reachable by adding the address
        self.dummy1.addr_add('2001:db8:1:1::1/64', 6)
        time.sleep(0.1)

        # RIB should show route as active and fib now
        self.assertRoutes({
            str(self.route.dest): {
                'selected': True,
                'nexthops': [
                    {
                        'gate': '2001:db8:1:1::2',
                        'iface': self.dummy1.name,
                        'fib': True,
                        'active': True,
                    },
                ]
            },
        }, self.zebra.rib('O',6))
        # route should be in fib now
        self.assertRoutes({
            str(self.route.dest): {
                'nexthops': [
                    {
                        'gate': '2001:db8:1:1::2',
                    },
                ]
            },
        }, system.fib(6))

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn(str(self.route.dest), system.fib(6))
        self.assertNotIn(str(self.route.dest), self.zebra.rib('O',6))
コード例 #8
0
ファイル: test_routes_v4.py プロジェクト: cfra/quagga-testing
    def test_nexthop_ipv4_ifindex_invalid(self):
        self.route.add_nexthop('192.0.2.2', self.dummy2.index)
        self.zclient.add_route(self.route)
        time.sleep(0.1)

        # Route should be in RIB, but not in fib
        # XXX: Is it right to mark that route as selected and active??
        self.assertRoutes({
            '198.51.100.128/25': {
#                'selected': False,
                'nexthops': [
                    {
                        'gate': '192.0.2.2',
                        'iface': self.dummy2.name,
                        'fib': False,
#                        'active': False
                    },
                ]
            },
        }, self.zebra.rib('O'))
        # Route shouldn't be in FIB
        self.assertNotIn('198.51.100.128/25', system.fib())

        # Make the gateway reachable by adding an address to the interface
        self.dummy2.addr_add('192.0.2.1/29')
        time.sleep(0.1)

        # RIB should now show nexthop as installed into FIB
        self.assertRoutes({
            '198.51.100.128/25': {
                'selected': True,
                'nexthops': [
                    {
                        'gate': '192.0.2.2',
                        'iface': self.dummy2.name,
                        'fib': True,
                        'active': True
                    },
                ]
            },
        }, self.zebra.rib('O'))
        # Route should be in FIB
        self.assertRoutes({
            '198.51.100.128/25': {
                'nexthops': [
                    {
                        'gate': '192.0.2.2',
                        'iface': self.dummy2.name
                    }
                ]
            },
        }, system.fib())

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn('198.51.100.128/25', system.fib())
        self.assertNotIn('198.51.100.128/25', self.zebra.rib('O'))
コード例 #9
0
ファイル: test_routes_v4.py プロジェクト: cfra/quagga-testing
    def test_unresolvable(self):
        self.zebra.config('ip route 192.0.2.255/32 reject')
        self.route.add_nexthop('192.0.2.255')
        self.bgp_client.add_route(self.route)
        time.sleep(0.1)

        self.assertRoutes({
            '198.51.100.128/25': {
                'selected': False,
                'nexthops': [
                    {
                        'gate': '192.0.2.255',
                        'iface': None,
                        'active': False,
                        'fib': False
                    }
                ]
            }
        }, self.zebra.rib('B'))
        self.assertNotIn('198.51.100.128/25', system.fib())

        self.bgp_client.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn('198.51.100.128/25', self.zebra.rib('B'))

        self.zebra.config('no ip route 192.0.2.255/32 reject')
        self.zebra.config('ip route 192.0.2.255/32 Null0')
        self.bgp_client.add_route(self.route)
        time.sleep(0.1)

        self.assertRoutes({
            '198.51.100.128/25': {
                'selected': False,
                'nexthops': [
                    {
                        'gate': '192.0.2.255',
                        'iface': None,
                        'active': False,
                        'fib': False
                    }
                ]
            }
        }, self.zebra.rib('B'))
        self.assertNotIn('198.51.100.128/25', system.fib())

        self.bgp_client.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn('198.51.100.128/25', self.zebra.rib('B'))
コード例 #10
0
ファイル: test_routes_v4.py プロジェクト: cfra/quagga-testing
    def test_multipath_ifindex(self):
        self.route.add_nexthop(ifindex=self.dummy1.index)
        self.route.add_nexthop(ifindex=self.dummy2.index)
        self.zclient.add_route(self.route)
        time.sleep(0.1)

        # XXX: Src is currently not displayed for NEXTHOP_TYPE_IFINDEX
        self.assertRoutes({
            str(self.route.dest): {
                'selected': True,
                'nexthops': [
                    {
                        'active': True,
                        'fib': True,
                        'gate': None,
                        'iface': self.dummy1.name,
#                        'src': '192.0.2.255'
                    },
                    {
                        'active': True,
                        'fib': True,
                        'gate': None,
                        'iface': self.dummy2.name,
#                        'src': '192.0.2.255'
                    },
                ]
            }
        }, self.zebra.rib('O'))
        self.assertRoutes({
            str(self.route.dest): {
                'src': '192.0.2.255',
                'nexthops': [
                    {
                        'gate': None,
                        'iface': self.dummy1.name,
                    },
                    {
                        'gate': None,
                        'iface': self.dummy2.name,
                    }
                ]
            }
        }, system.fib())

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn(str(self.route.dest), self.zebra.rib('O'))
        self.assertNotIn(str(self.route.dest), system.fib())
コード例 #11
0
ファイル: test_routes_v4.py プロジェクト: cfra/quagga-testing
    def test_multipath_ipv4_ifindex(self):
        self.route.add_nexthop('192.0.2.2', ifindex=self.dummy1.index)
        self.route.add_nexthop('192.0.2.3', ifindex=self.dummy1.index)
        self.zclient.add_route(self.route)
        time.sleep(0.1)

        self.assertRoutes({
            str(self.route.dest): {
                'selected': True,
                'nexthops': [
                    {
                        'active': True,
                        'fib': True,
                        'gate': '192.0.2.2',
                        'iface': self.dummy1.name,
                        'src': '192.0.2.255'
                    },
                    {
                        'active': True,
                        'fib': True,
                        'gate': '192.0.2.3',
                        'iface': self.dummy1.name,
                        'src': '192.0.2.255'
                    },
                ]
            }
        }, self.zebra.rib('O'))
        self.assertRoutes({
            str(self.route.dest): {
                'src': '192.0.2.255',
                'nexthops': [
                    {
                        'gate': '192.0.2.2',
                        'iface': self.dummy1.name,
                    },
                    {
                        'gate': '192.0.2.3',
                        'iface': self.dummy1.name,
                    }
                ]
            }
        }, system.fib())

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn(str(self.route.dest), self.zebra.rib('O'))
        self.assertNotIn(str(self.route.dest), system.fib())
コード例 #12
0
ファイル: test_routes_v4.py プロジェクト: cfra/quagga-testing
    def test_excessive_nexthops(self):
        route = pyzclient.Route(None, '198.51.100.128/25')
        for i in range(2,126):
            route.nexthops.append(pyzclient.Nexthop('192.0.2.%d' % i))
        self.zclient.add_route(route)
        time.sleep(0.1)

        rib = self.zebra.rib('O')
        # Assert that the route has been completely installed into fib
        self.assertRoutes({
            '198.51.100.128/25': {
                'selected': True,
                'nexthops': [
                    {
                        'gate': '192.0.2.%d' % i,
                    } for i in range(2,126)
                ]
            }
        }, rib)

        # Examine the FIB flags in the RIB and determine which nexthops
        # should be in the FIB
        fib_nexthops = []
        expected_fib = {
            '198.51.100.128/25': {
                'nexthops': fib_nexthops
            }
        }
        for nexthop in rib['198.51.100.128/25']['nexthops']:
            if not nexthop['fib']:
                continue

            fib_nexthops.append({
                'gate': nexthop['gate'],
                'iface': nexthop['iface']
            })

        # Check that at least one nexthop has been installed into fib
        self.assertTrue(fib_nexthops)
        self.assertRoutes(expected_fib, system.fib())

        route.nexhops = list(reversed(route.nexthops))
        self.zclient.del_route(route)
        time.sleep(0.1)

        self.assertNotIn('198.51.100.128/25', self.zebra.rib('O'))
        self.assertNotIn('198.51.100.128/25', system.fib())
コード例 #13
0
ファイル: test_routes_v4.py プロジェクト: cfra/quagga-testing
    def test_resolve_via_multipath_ipv4(self):
        self.setUpMultipath()
        self.route.add_nexthop('192.0.2.57')
        self.bgp_client.add_route(self.route)
        time.sleep(0.1)

        self.assertRoutes({
            '198.51.100.128/25': {
                'selected': True,
                'nexthops': [
                    {
                        'gate': '192.0.2.57',
                        'resolved': [
                            {
                                'gate': '192.0.2.4',
                                'iface': self.dummy1.name
                            },
                            {
                                'gate': '192.0.2.5',
                                'iface': self.dummy1.name
                            }
                        ]
                    }
                ]
            }
        }, self.zebra.rib('B'))

        self.assertRoutes({
            '198.51.100.128/25': {
                'nexthops': [
                    {
                        'gate': '192.0.2.4',
                        'iface': self.dummy1.name
                    },
                    {
                        'gate': '192.0.2.5',
                        'iface': self.dummy1.name
                    }
                ]
            }
        }, system.fib())

        self.bgp_client.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn('198.51.100.128/25', self.zebra.rib('B'))
        self.assertNotIn('198.51.100.128/25', system.fib())
コード例 #14
0
ファイル: test_routes_v4.py プロジェクト: cfra/quagga-testing
    def do_multipath_test(self):
        self.route.add_nexthop('192.0.2.2')
        self.route.add_nexthop('192.0.2.10')
        self.zclient.add_route(self.route)
        time.sleep(0.1)

        self.assertRoutes({
            str(self.route.dest): {
                'selected': True,
                'nexthops': [
                    {
                        'active': True,
                        'fib': True,
                        'gate': '192.0.2.2',
                        'iface': self.dummy1.name,
                    },
                    {
                        'active': False,
                        'fib': False,
                        'gate': '192.0.2.10',
                        'iface': self.dummy2.name,
                    }
                ]
            }
        }, self.zebra.rib('O'))
        self.assertRoutes({
            str(self.route.dest): {
                'nexthops': [
                    {
                        'gate': '192.0.2.2',
                        'iface': self.dummy1.name,
                    }
                ]
            }
        }, system.fib())

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn(str(self.route.dest), self.zebra.rib('O'))
        self.assertNotIn(str(self.route.dest), system.fib())
コード例 #15
0
ファイル: test_routes_v6.py プロジェクト: cfra/quagga-testing
    def test_nexthop_ifindex(self):
        self.route.add_nexthop(ifindex=self.dummy1.index)
        self.zclient.add_route(self.route)
        time.sleep(0.1)

        self.assertIn(str(self.route.dest), self.zebra.rib('O', 6))
        self.assertRoutes({
            str(self.route.dest): {
                'nexthops': [
                    {
                        'gate': None,
                        'iface': self.dummy1.name,
                    },
                ],
            },
        }, system.fib(6))

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn(str(self.route.dest), system.fib(6))
        self.assertNotIn(str(self.route.dest), self.zebra.rib('O',6))
コード例 #16
0
ファイル: test_routes_v4.py プロジェクト: cfra/quagga-testing
    def test_nexthop_ipv4_ifindex(self):
        self.route.add_nexthop('192.0.2.2', self.dummy1.index)
        self.zclient.add_route(self.route)
        time.sleep(0.1)

        self.assertIn('198.51.100.128/25', self.zebra.rib('O'))
        self.assertRoutes({
            '198.51.100.128/25': {
                'nexthops': [
                    {
                        'gate': '192.0.2.2',
                        'iface': self.dummy1.name,
                    },
                ],
            },
        }, system.fib())

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn('198.51.100.128/25', system.fib())
        self.assertNotIn('198.51.100.128/25', self.zebra.rib('O'))
コード例 #17
0
ファイル: test_routes_v6.py プロジェクト: cfra/quagga-testing
    def test_nexthop_ipv6(self):
        self.route.add_nexthop('2001:db8:1:1::2')

        self.zclient.add_route(self.route)
        time.sleep(0.1)

        self.assertIn(str(self.route.dest), self.zebra.rib('O',6))
        self.assertRoutes({
            str(self.route.dest): {
                'nexthops': [
                    {
                        'gate': '2001:db8:1:1::2',
                        'iface': self.dummy1.name,
                    },
                ],
            },
        }, system.fib(6))

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn(str(self.route.dest), system.fib(6))
        self.assertNotIn(str(self.route.dest), self.zebra.rib('O',6))
コード例 #18
0
ファイル: test_routes_v6.py プロジェクト: cfra/quagga-testing
    def test_nexthop_ifindex(self):
        self.route.add_nexthop(ifindex=self.dummy1.index)
        self.zclient.add_route(self.route)
        time.sleep(0.1)

        self.assertIn(str(self.route.dest), self.zebra.rib('O', 6))
        self.assertRoutes(
            {
                str(self.route.dest): {
                    'nexthops': [
                        {
                            'gate': None,
                            'iface': self.dummy1.name,
                        },
                    ],
                },
            }, system.fib(6))

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn(str(self.route.dest), system.fib(6))
        self.assertNotIn(str(self.route.dest), self.zebra.rib('O', 6))
コード例 #19
0
ファイル: test_routes_v6.py プロジェクト: cfra/quagga-testing
    def test_resolve_via_ipv6_ifindex(self):
        self.route.add_nexthop('2001:db8:1:5::1')
        self.bgp_client.add_route(self.route)
        time.sleep(0.1)

        self.assertRoutes({
            str(self.route.dest): {
                'selected': True,
                'nexthops': [
                    {
                        'gate': '2001:db8:1:5::1',
                        'resolved': [
                            {
                                'gate': 'fe80::42',
                                'iface': self.dummy1.name
                            }
                        ]
                    }
                ]
            }
        }, self.zebra.rib('B',6))
        self.assertRoutes({
            str(self.route.dest): {
                'nexthops': [
                    {
                        'gate': 'fe80::42',
                        'iface': self.dummy1.name
                    }
                ]
            }
        }, system.fib(6))

        self.bgp_client.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn(str(self.route.dest), self.zebra.rib('B'))
        self.assertNotIn(str(self.route.dest), system.fib(6))
コード例 #20
0
ファイル: test_routes_v6.py プロジェクト: cfra/quagga-testing
    def test_nexthop_ipv6(self):
        self.route.add_nexthop('2001:db8:1:1::2')

        self.zclient.add_route(self.route)
        time.sleep(0.1)

        self.assertIn(str(self.route.dest), self.zebra.rib('O', 6))
        self.assertRoutes(
            {
                str(self.route.dest): {
                    'nexthops': [
                        {
                            'gate': '2001:db8:1:1::2',
                            'iface': self.dummy1.name,
                        },
                    ],
                },
            }, system.fib(6))

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn(str(self.route.dest), system.fib(6))
        self.assertNotIn(str(self.route.dest), self.zebra.rib('O', 6))
コード例 #21
0
ファイル: test_routes_v6.py プロジェクト: cfra/quagga-testing
    def test_unresolvable(self):
        self.route.add_nexthop('2001:db8:3::1')
        self.bgp_client.add_route(self.route)
        time.sleep(0.1)

        self.assertRoutes({
            str(self.route.dest): {
                'selected': False,
                'nexthops': [
                    {
                        'gate': '2001:db8:3::1',
                        'iface': None,
                        'active': False,
                        'fib': False
                    }
                ]
            }
        }, self.zebra.rib('B',6))
        self.assertNotIn('198.51.100.128/25', system.fib(6))

        self.bgp_client.del_route(self.route)
        time.sleep(0.1)
        self.assertNotIn('198.51.100.128/25', self.zebra.rib('B',6))
コード例 #22
0
ファイル: test_routes_v6.py プロジェクト: cfra/quagga-testing
    def test_unresolvable(self):
        self.route.add_nexthop('2001:db8:3::1')
        self.bgp_client.add_route(self.route)
        time.sleep(0.1)

        self.assertRoutes(
            {
                str(self.route.dest): {
                    'selected':
                    False,
                    'nexthops': [{
                        'gate': '2001:db8:3::1',
                        'iface': None,
                        'active': False,
                        'fib': False
                    }]
                }
            }, self.zebra.rib('B', 6))
        self.assertNotIn('198.51.100.128/25', system.fib(6))

        self.bgp_client.del_route(self.route)
        time.sleep(0.1)
        self.assertNotIn('198.51.100.128/25', self.zebra.rib('B', 6))
コード例 #23
0
ファイル: test_addr.py プロジェクト: cfra/quagga-testing
    def test_addrdel_routedel(self):
        self.dummy.up()
        self.dummy.addr_add('192.0.2.1/24')
        self.zebra.config('ip route 198.51.100.0/28 192.0.2.2')

        # Route should be in RIB and marked as active&fib
        self.assertRoutes(
            {
                '198.51.100.0/28': {
                    'selected':
                    True,
                    'nexthops': [
                        {
                            'gate': '192.0.2.2',
                            'iface': self.dummy.name,
                            'fib': True,
                            'active': True,
                        },
                    ]
                },
            }, self.zebra.rib('S'))
        # Route should be in fib
        self.assertRoutes(
            {
                '198.51.100.0/28': {
                    'nexthops': [
                        {
                            'gate': '192.0.2.2',
                            'iface': self.dummy.name
                        },
                    ]
                },
            }, system.fib())

        self.dummy.addr_del('192.0.2.1/24')
        time.sleep(.1)

        # Route should be in RIB and marked as inactive
        self.assertRoutes(
            {
                '198.51.100.0/28': {
                    'selected':
                    False,
                    'nexthops': [
                        {
                            'gate': '192.0.2.2',
                            'iface': None,
                            'fib': False,
                            'active': False,
                        },
                    ]
                },
            }, self.zebra.rib('S'))
        # Route should not be in FIB
        self.assertNotIn('198.51.100.0/28', system.fib())

        self.dummy.addr_add('192.0.2.1/24')
        time.sleep(.1)

        # Route should be in RIB and marked as active&fib
        self.assertRoutes(
            {
                '198.51.100.0/28': {
                    'selected':
                    True,
                    'nexthops': [
                        {
                            'gate': '192.0.2.2',
                            'iface': self.dummy.name,
                            'fib': True,
                            'active': True,
                        },
                    ]
                },
            }, self.zebra.rib('S'))
        # Route should be in fib
        self.assertRoutes(
            {
                '198.51.100.0/28': {
                    'nexthops': [
                        {
                            'gate': '192.0.2.2',
                            'iface': self.dummy.name
                        },
                    ]
                },
            }, system.fib())
コード例 #24
0
ファイル: test_routes_v6.py プロジェクト: cfra/quagga-testing
    def test_nexthop_ipv6_ifindex_invalid(self):
        self.route.add_nexthop('2001:db8:1:1::2')
        self.route.add_nexthop(ifindex=self.dummy2.index)
        self.zclient.add_route(self.route)
        time.sleep(0.1)

        # Route should be in RIB, but not in fib
        # XXX: Is it right to mark that route as selected and active??
        self.assertRoutes(
            {
                str(self.route.dest): {
                    #                'selected': False,
                    'nexthops': [
                        {
                            'gate': '2001:db8:1:1::2',
                            'iface': self.dummy2.name,
                            'fib': False,
                            #                        'active': False
                        },
                    ]
                },
            },
            self.zebra.rib('O', 6))
        # Route shouldn't be in FIB
        self.assertNotIn(str(self.route.dest), system.fib(6))

        # Make the gateway reachable by adding an address to the interface
        self.dummy2.addr_add('2001:db8:1:1::1/64', 6)
        time.sleep(0.1)

        # RIB should now show nexthop as installed into FIB
        self.assertRoutes(
            {
                str(self.route.dest): {
                    'selected':
                    True,
                    'nexthops': [
                        {
                            'gate': '2001:db8:1:1::2',
                            'iface': self.dummy2.name,
                            'fib': True,
                            'active': True
                        },
                    ]
                },
            }, self.zebra.rib('O', 6))
        # Route should be in FIB
        self.assertRoutes(
            {
                str(self.route.dest): {
                    'nexthops': [{
                        'gate': '2001:db8:1:1::2',
                        'iface': self.dummy2.name
                    }]
                },
            }, system.fib(6))

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn(str(self.route.dest), system.fib(6))
        self.assertNotIn(str(self.route.dest), self.zebra.rib('O', 6))
コード例 #25
0
ファイル: test_routes_v6.py プロジェクト: cfra/quagga-testing
    def test_nexthop_ipv6_invalid(self):
        self.route.add_nexthop('2001:db8:1:1::2')
        self.dummy1.addr_del('2001:db8:1:1::1/64', 6)
        time.sleep(0.1)

        self.zclient.add_route(self.route)
        time.sleep(0.1)

        # Route should be in RIB, marked as inactive
        self.assertRoutes(
            {
                str(self.route.dest): {
                    'selected':
                    False,
                    'nexthops': [
                        {
                            'gate': '2001:db8:1:1::2',
                            'iface': None,
                            'fib': False,
                            'active': False,
                        },
                    ]
                },
            }, self.zebra.rib('O', 6))
        # Route shouldn't be in FIB
        self.assertNotIn(str(self.route.dest), system.fib(6))

        # Make the gateway reachable by adding the address
        self.dummy1.addr_add('2001:db8:1:1::1/64', 6)
        time.sleep(0.1)

        # RIB should show route as active and fib now
        self.assertRoutes(
            {
                str(self.route.dest): {
                    'selected':
                    True,
                    'nexthops': [
                        {
                            'gate': '2001:db8:1:1::2',
                            'iface': self.dummy1.name,
                            'fib': True,
                            'active': True,
                        },
                    ]
                },
            }, self.zebra.rib('O', 6))
        # route should be in fib now
        self.assertRoutes(
            {
                str(self.route.dest): {
                    'nexthops': [
                        {
                            'gate': '2001:db8:1:1::2',
                        },
                    ]
                },
            }, system.fib(6))

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn(str(self.route.dest), system.fib(6))
        self.assertNotIn(str(self.route.dest), self.zebra.rib('O', 6))
コード例 #26
0
ファイル: test_routes_v4.py プロジェクト: cfra/quagga-testing
    def do_singlepath_test(self):
        # This route should make it through the filter
        self.route.add_nexthop('192.0.2.2')
        self.zclient.add_route(self.route)
        time.sleep(0.1)

        self.assertRoutes({
            str(self.route.dest): {
                'selected': True,
                'nexthops': [
                    {
                        'active': True,
                        'fib': True,
                        'gate': '192.0.2.2',
                        'iface': self.dummy1.name,
                    }
                ]
            }
        }, self.zebra.rib('O'))
        self.assertRoutes({
            str(self.route.dest): {
                'nexthops': [
                    {
                        'gate': '192.0.2.2',
                        'iface': self.dummy1.name,
                    }
                ]
            }
        }, system.fib())

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn(str(self.route.dest), self.zebra.rib('O'))
        self.assertNotIn(str(self.route.dest), system.fib())

        # This route should be filtered by the route-map
        self.route.nexthops = []
        self.route.add_nexthop('192.0.2.10')
        self.zclient.add_route(self.route)
        time.sleep(0.1)

        self.assertRoutes({
            str(self.route.dest): {
                'selected': False,
                'nexthops': [
                    {
                        'active': False,
                        'fib': False,
                        'gate': '192.0.2.10',
                        'iface': self.dummy2.name,
                    }
                ]
            }
        }, self.zebra.rib('O'))
        self.assertNotIn(str(self.route.dest), system.fib())

        self.zclient.del_route(self.route)
        time.sleep(0.1)

        self.assertNotIn(str(self.route.dest), self.zebra.rib('O'))
        self.assertNotIn(str(self.route.dest), system.fib())
コード例 #27
0
ファイル: test_routes_v4.py プロジェクト: cfra/quagga-testing
    def test_recursive_deactivate(self):
        self.setUpPrefixList()
        self.zebra.config("no ip protocol ospf")
        self.zebra.config("ip protocol bgp route-map match-test")

        resolving_route = pyzclient.Route(None, '192.0.2.16/29')
        resolving_route.add_nexthop('192.0.2.2')
        self.zclient.add_route(resolving_route)
        time.sleep(0.1)

        with contextlib.closing(pyzclient.ZClient(pyzclient.ZEBRA_ROUTE_BGP)) as bgp_client:
            self.route.rib_flags |= pyzclient.ZEBRA_FLAG_INTERNAL
            self.route.add_nexthop('192.0.2.17')
            bgp_client.add_route(self.route)
            time.sleep(0.1)

            # 192.0.2.17 isn't matched by the prefix list, therefore, the route is rejected
            self.assertRoutes({
                str(self.route.dest): {
                    'selected': False,
                    'nexthops': [
                        {
                            'gate': '192.0.2.17',
                            'fib': False,
                            'active': False
                        }
                    ]
                }
            }, self.zebra.rib('B'))
            self.assertNotIn(str(self.route.dest), system.fib())

            bgp_client.del_route(self.route)
            time.sleep(0.1)

            self.assertNotIn(str(self.route.dest), self.zebra.rib('B'))
            self.assertNotIn(str(self.route.dest), system.fib())

            # permit 192.0.2.17 and re-add route
            self.zebra.config("ip prefix-list test1 seq 10 permit 192.0.2.17/32")

            bgp_client.add_route(self.route)
            time.sleep(0.1)

            self.assertRoutes({
                str(self.route.dest): {
                    'selected': True,
                    'nexthops': [
                        {
                            'active': True,
                            'gate': '192.0.2.17',
                            'resolved': [
                                {
                                    'gate': '192.0.2.2',
                                    'iface': self.dummy1.name,
                                    'fib': True,
                                    'active': True
                                }
                            ],
                        }
                    ]
                }
            }, self.zebra.rib('B'))
            self.assertRoutes({
                str(self.route.dest): {
                    'nexthops': [
                        {
                            'gate': '192.0.2.2',
                            'iface': self.dummy1.name
                        }
                    ]
                }
            }, system.fib())

            bgp_client.del_route(self.route)
            time.sleep(0.1)

            self.assertNotIn(str(self.route.dest), self.zebra.rib('B'))
            self.assertNotIn(str(self.route.dest), system.fib())