X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_ip4.py;h=a6920f8dba543cdd7f443dfee52af6d5f28b38c4;hb=88d29a9206bbaa70f7772fa157ec6b1ccaf567a8;hp=933958911fe1c1497c9c374b1c5d4b360598ff21;hpb=9fd996275c745faec2843cf3a8b1d15d6f8c9dab;p=vpp.git diff --git a/test/test_ip4.py b/test/test_ip4.py index 933958911fe..a6920f8dba5 100644 --- a/test/test_ip4.py +++ b/test/test_ip4.py @@ -210,6 +210,80 @@ class TestIPv4(VppTestCase): self.verify_capture(i, pkts) +class TestIPV4IfAddrRoute(VppTestCase): + """ IPv4 Interface Addr Route Test Case """ + + @classmethod + def setUpClass(cls): + super(TestIPV4IfAddrRoute, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestIPV4IfAddrRoute, cls).tearDownClass() + + def setUp(self): + super(TestIPV4IfAddrRoute, self).setUp() + + # create 1 pg interface + self.create_pg_interfaces(range(1)) + + for i in self.pg_interfaces: + i.admin_up() + i.config_ip4() + i.resolve_arp() + + def tearDown(self): + super(TestIPV4IfAddrRoute, self).tearDown() + for i in self.pg_interfaces: + i.unconfig_ip4() + i.admin_down() + + def test_ipv4_ifaddr_route(self): + """ IPv4 Interface Address Route test + + Test scenario: + + - Create loopback + - Configure IPv4 address on loopback + - Verify that address is not in the FIB + - Bring loopback up + - Verify that address is in the FIB now + - Bring loopback down + - Verify that address is not in the FIB anymore + - Bring loopback up + - Configure IPv4 address on loopback + - Verify that address is in the FIB now + """ + + # create a loopback and configure IPv4 + loopbacks = self.create_loopback_interfaces(1) + lo_if = self.lo_interfaces[0] + + lo_if.local_ip4_prefix_len = 32 + lo_if.config_ip4() + + # The intf was down when addr was added -> entry not in FIB + fib4_dump = self.vapi.ip_route_dump(0) + self.assertFalse(lo_if.is_ip4_entry_in_fib_dump(fib4_dump)) + + # When intf is brought up, entry is added + lo_if.admin_up() + fib4_dump = self.vapi.ip_route_dump(0) + self.assertTrue(lo_if.is_ip4_entry_in_fib_dump(fib4_dump)) + + # When intf is brought down, entry is removed + lo_if.admin_down() + fib4_dump = self.vapi.ip_route_dump(0) + self.assertFalse(lo_if.is_ip4_entry_in_fib_dump(fib4_dump)) + + # Remove addr, bring up interface, re-add -> entry in FIB + lo_if.unconfig_ip4() + lo_if.admin_up() + lo_if.config_ip4() + fib4_dump = self.vapi.ip_route_dump(0) + self.assertTrue(lo_if.is_ip4_entry_in_fib_dump(fib4_dump)) + + class TestICMPEcho(VppTestCase): """ ICMP Echo Test Case """