From 6dc41141f63edb0ffbf5fc1543e3b77984afa034 Mon Sep 17 00:00:00 2001 From: Marian Pritsak Date: Sun, 17 Feb 2019 19:22:51 +0200 Subject: [PATCH] [intfsorch] Wait for interface prior to prefix Interface table entries must be handled in the following order: 1. INTF_NAME 2. INTF_NAME:PREFIX We need to wait for interface with VRF information prior to creating IP addresses Signed-off-by: Marian Pritsak --- orchagent/intfsorch.cpp | 8 +++++++ tests/conftest.py | 1 + tests/test_crm.py | 10 ++++++++ tests/test_dirbcast.py | 1 + tests/test_interface.py | 3 +++ tests/test_mirror.py | 2 ++ tests/test_nhg.py | 3 +++ tests/test_route.py | 2 ++ tests/test_warm_reboot.py | 48 +++++++++++++++++++++++++++++++++++++++ 9 files changed, 78 insertions(+) diff --git a/orchagent/intfsorch.cpp b/orchagent/intfsorch.cpp index 4421caae8cf..d8fec5322d6 100644 --- a/orchagent/intfsorch.cpp +++ b/orchagent/intfsorch.cpp @@ -268,6 +268,14 @@ void IntfsOrch::doTask(Consumer &consumer) continue; } + /* Wait for the Interface entry first */ + auto it_intfs = m_syncdIntfses.find(alias); + if (ip_prefix_in_key && it_intfs == m_syncdIntfses.end()) + { + it++; + continue; + } + Port port; if (!gPortsOrch->getPort(alias, port)) { diff --git a/tests/conftest.py b/tests/conftest.py index 70ca0b1f964..a14cc654bed 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -690,6 +690,7 @@ def add_ip_address(self, interface, ip): tbl = swsscommon.Table(self.cdb, tbl_name) fvs = swsscommon.FieldValuePairs([("NULL", "NULL")]) tbl.set(interface + "|" + ip, fvs) + tbl.set(interface, fvs) time.sleep(1) def add_neighbor(self, interface, ip, mac): diff --git a/tests/test_crm.py b/tests/test_crm.py index eeba6f5a4b0..87f1beebe78 100644 --- a/tests/test_crm.py +++ b/tests/test_crm.py @@ -103,6 +103,7 @@ def test_CrmIpv4Route(dvs, testlog): config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) intf_tbl = swsscommon.Table(config_db, "INTERFACE") fvs = swsscommon.FieldValuePairs([("NULL","NULL")]) + intf_tbl.set("Ethernet0", fvs) intf_tbl.set("Ethernet0|10.0.0.0/31", fvs) dvs.runcmd("ifconfig Ethernet0 up") @@ -163,6 +164,7 @@ def test_CrmIpv6Route(dvs, testlog): config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) intf_tbl = swsscommon.Table(config_db, "INTERFACE") fvs = swsscommon.FieldValuePairs([("NULL","NULL")]) + intf_tbl.set("Ethernet0", fvs) intf_tbl.set("Ethernet0|fc00::1/126", fvs) dvs.runcmd("ifconfig Ethernet0 up") @@ -223,6 +225,7 @@ def test_CrmIpv4Nexthop(dvs, testlog): intf_tbl = swsscommon.Table(config_db, "INTERFACE") fvs = swsscommon.FieldValuePairs([("NULL","NULL")]) intf_tbl.set("Ethernet0|10.0.0.0/31", fvs) + intf_tbl.set("Ethernet0", fvs) dvs.runcmd("ifconfig Ethernet0 up") dvs.runcmd("crm config polling interval 1") @@ -274,6 +277,7 @@ def test_CrmIpv6Nexthop(dvs, testlog): config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) intf_tbl = swsscommon.Table(config_db, "INTERFACE") fvs = swsscommon.FieldValuePairs([("NULL","NULL")]) + intf_tbl.set("Ethernet0", fvs) intf_tbl.set("Ethernet0|fc00::1/126", fvs) dvs.runcmd("ifconfig Ethernet0 up") @@ -322,6 +326,7 @@ def test_CrmIpv4Neighbor(dvs, testlog): config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) intf_tbl = swsscommon.Table(config_db, "INTERFACE") fvs = swsscommon.FieldValuePairs([("NULL","NULL")]) + intf_tbl.set("Ethernet0", fvs) intf_tbl.set("Ethernet0|10.0.0.0/31", fvs) dvs.runcmd("ifconfig Ethernet0 up") @@ -374,6 +379,7 @@ def test_CrmIpv6Neighbor(dvs, testlog): config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) intf_tbl = swsscommon.Table(config_db, "INTERFACE") fvs = swsscommon.FieldValuePairs([("NULL","NULL")]) + intf_tbl.set("Ethernet0", fvs) intf_tbl.set("Ethernet0|fc00::1/126", fvs) dvs.runcmd("ifconfig Ethernet0 up") @@ -422,6 +428,8 @@ def test_CrmNexthopGroup(dvs, testlog): config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) intf_tbl = swsscommon.Table(config_db, "INTERFACE") fvs = swsscommon.FieldValuePairs([("NULL","NULL")]) + intf_tbl.set("Ethernet0", fvs) + intf_tbl.set("Ethernet4", fvs) intf_tbl.set("Ethernet0|10.0.0.0/31", fvs) intf_tbl.set("Ethernet4|10.0.0.2/31", fvs) dvs.runcmd("ifconfig Ethernet0 up") @@ -489,6 +497,8 @@ def test_CrmNexthopGroupMember(dvs, testlog): config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) intf_tbl = swsscommon.Table(config_db, "INTERFACE") fvs = swsscommon.FieldValuePairs([("NULL","NULL")]) + intf_tbl.set("Ethernet0", fvs) + intf_tbl.set("Ethernet4", fvs) intf_tbl.set("Ethernet0|10.0.0.0/31", fvs) intf_tbl.set("Ethernet4|10.0.0.2/31", fvs) dvs.runcmd("ifconfig Ethernet0 up") diff --git a/tests/test_dirbcast.py b/tests/test_dirbcast.py index b05b505bd69..34e86286f3e 100644 --- a/tests/test_dirbcast.py +++ b/tests/test_dirbcast.py @@ -23,6 +23,7 @@ def test_DirectedBroadcast(dvs, testlog): # create vlan interface in config db tbl = swsscommon.Table(db, "VLAN_INTERFACE") fvs = swsscommon.FieldValuePairs([("family", "IPv4")]) + tbl.set("Vlan100", fvs) tbl.set("Vlan100|192.169.0.1/27", fvs) time.sleep(1) diff --git a/tests/test_interface.py b/tests/test_interface.py index 7d33f7ed50d..0ff67dcc00a 100644 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -19,11 +19,13 @@ def add_ip_address(self, interface, ip): tbl = swsscommon.Table(self.cdb, "INTERFACE") fvs = swsscommon.FieldValuePairs([("NULL", "NULL")]) tbl.set(interface + "|" + ip, fvs) + tbl.set(interface, fvs) time.sleep(2) # IPv6 netlink message needs longer time def remove_ip_address(self, interface, ip): tbl = swsscommon.Table(self.cdb, "INTERFACE") tbl._del(interface + "|" + ip); + tbl._del(interface); time.sleep(1) def set_mtu(self, interface, mtu): @@ -243,6 +245,7 @@ def add_ip_address(self, interface, ip): tbl = swsscommon.Table(self.cdb, "PORTCHANNEL_INTERFACE") fvs = swsscommon.FieldValuePairs([("NULL", "NULL")]) tbl.set(interface + "|" + ip, fvs) + tbl.set(interface, fvs) time.sleep(1) def remove_ip_address(self, interface, ip): diff --git a/tests/test_mirror.py b/tests/test_mirror.py index d1a29840406..bd182036ba9 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -37,6 +37,7 @@ def add_ip_address(self, interface, ip): tbl = swsscommon.Table(self.cdb, tbl_name) fvs = swsscommon.FieldValuePairs([("NULL", "NULL")]) tbl.set(interface + "|" + ip, fvs) + tbl.set(interface, fvs) time.sleep(1) def remove_ip_address(self, interface, ip): @@ -48,6 +49,7 @@ def remove_ip_address(self, interface, ip): tbl_name = "INTERFACE" tbl = swsscommon.Table(self.cdb, tbl_name) tbl._del(interface + "|" + ip) + tbl._del(interface) time.sleep(1) def add_neighbor(self, interface, ip, mac): diff --git a/tests/test_nhg.py b/tests/test_nhg.py index 57b96edaae4..97a70d571ee 100644 --- a/tests/test_nhg.py +++ b/tests/test_nhg.py @@ -9,6 +9,9 @@ def test_route_nhg(dvs, testlog): config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) intf_tbl = swsscommon.Table(config_db, "INTERFACE") fvs = swsscommon.FieldValuePairs([("NULL","NULL")]) + intf_tbl.set("Ethernet0", fvs) + intf_tbl.set("Ethernet4", fvs) + intf_tbl.set("Ethernet8", fvs) intf_tbl.set("Ethernet0|10.0.0.0/31", fvs) intf_tbl.set("Ethernet4|10.0.0.2/31", fvs) intf_tbl.set("Ethernet8|10.0.0.4/31", fvs) diff --git a/tests/test_route.py b/tests/test_route.py index bb8f8de6d47..d6f4a502c75 100644 --- a/tests/test_route.py +++ b/tests/test_route.py @@ -11,6 +11,8 @@ def test_RouteAdd(dvs, testlog): fvs = swsscommon.FieldValuePairs([("NULL","NULL")]) intf_tbl.set("Ethernet0|10.0.0.0/31", fvs) intf_tbl.set("Ethernet4|10.0.0.2/31", fvs) + intf_tbl.set("Ethernet0", fvs) + intf_tbl.set("Ethernet4", fvs) dvs.runcmd("ifconfig Ethernet0 up") dvs.runcmd("ifconfig Ethernet4 up") diff --git a/tests/test_warm_reboot.py b/tests/test_warm_reboot.py index 69ade76982f..7198f578cf8 100644 --- a/tests/test_warm_reboot.py +++ b/tests/test_warm_reboot.py @@ -124,6 +124,8 @@ def test_PortSyncdWarmRestart(dvs, testlog): fvs = swsscommon.FieldValuePairs([("NULL","NULL")]) intf_tbl.set("Ethernet16|11.0.0.1/29", fvs) intf_tbl.set("Ethernet20|11.0.0.9/29", fvs) + intf_tbl.set("Ethernet16", fvs) + intf_tbl.set("Ethernet20", fvs) dvs.runcmd("ifconfig Ethernet16 up") dvs.runcmd("ifconfig Ethernet20 up") @@ -190,6 +192,8 @@ def test_PortSyncdWarmRestart(dvs, testlog): intf_tbl._del("Ethernet16|11.0.0.1/29") intf_tbl._del("Ethernet20|11.0.0.9/29") + intf_tbl._del("Ethernet16") + intf_tbl._del("Ethernet20") time.sleep(2) @@ -248,6 +252,8 @@ def test_VlanMgrdWarmRestart(dvs, testlog): fvs = swsscommon.FieldValuePairs([("NULL","NULL")]) intf_tbl.set("Vlan16|11.0.0.1/29", fvs) intf_tbl.set("Vlan20|11.0.0.9/29", fvs) + intf_tbl.set("Vlan16", fvs) + intf_tbl.set("Vlan20", fvs) dvs.runcmd("ifconfig Vlan16 up") dvs.runcmd("ifconfig Vlan20 up") @@ -303,6 +309,8 @@ def test_VlanMgrdWarmRestart(dvs, testlog): intf_tbl._del("Vlan16|11.0.0.1/29") intf_tbl._del("Vlan20|11.0.0.9/29") + intf_tbl._del("Vlan16") + intf_tbl._del("Vlan20") time.sleep(2) def stop_neighsyncd(dvs): @@ -407,6 +415,10 @@ def test_swss_neighbor_syncup(dvs, testlog): intf_tbl.set("{}|28.0.0.9/24".format(intfs[1]), fvs) intf_tbl.set("{}|2400::1/64".format(intfs[0]), fvs) intf_tbl.set("{}|2800::1/64".format(intfs[1]), fvs) + intf_tbl.set("{}".format(intfs[0]), fvs) + intf_tbl.set("{}".format(intfs[1]), fvs) + intf_tbl.set("{}".format(intfs[0]), fvs) + intf_tbl.set("{}".format(intfs[1]), fvs) dvs.runcmd("ifconfig {} up".format(intfs[0])) dvs.runcmd("ifconfig {} up".format(intfs[1])) @@ -739,6 +751,10 @@ def test_swss_neighbor_syncup(dvs, testlog): intf_tbl._del("{}|28.0.0.9/24".format(intfs[1])) intf_tbl._del("{}|2400::1/64".format(intfs[0])) intf_tbl._del("{}|2800::1/64".format(intfs[1])) + intf_tbl._del("{}".format(intfs[0])) + intf_tbl._del("{}".format(intfs[1])) + intf_tbl._del("{}".format(intfs[0])) + intf_tbl._del("{}".format(intfs[1])) time.sleep(2) @@ -754,6 +770,8 @@ def test_OrchagentWarmRestartReadyCheck(dvs, testlog): fvs = swsscommon.FieldValuePairs([("NULL","NULL")]) intf_tbl.set("Ethernet0|10.0.0.0/31", fvs) intf_tbl.set("Ethernet4|10.0.0.2/31", fvs) + intf_tbl.set("Ethernet0", fvs) + intf_tbl.set("Ethernet4", fvs) dvs.runcmd("ifconfig Ethernet0 up") dvs.runcmd("ifconfig Ethernet4 up") @@ -797,6 +815,8 @@ def test_OrchagentWarmRestartReadyCheck(dvs, testlog): intf_tbl._del("Ethernet0|10.0.0.0/31") intf_tbl._del("Ethernet4|10.0.0.2/31") + intf_tbl._del("Ethernet0") + intf_tbl._del("Ethernet4") time.sleep(2) # recover for test cases after this one. @@ -822,6 +842,9 @@ def test_swss_port_state_syncup(dvs, testlog): intf_tbl.set("Ethernet0|10.0.0.0/31", fvs) intf_tbl.set("Ethernet4|10.0.0.2/31", fvs) intf_tbl.set("Ethernet8|10.0.0.4/31", fvs) + intf_tbl.set("Ethernet0", fvs) + intf_tbl.set("Ethernet4", fvs) + intf_tbl.set("Ethernet8", fvs) dvs.runcmd("ifconfig Ethernet0 up") dvs.runcmd("ifconfig Ethernet4 up") dvs.runcmd("ifconfig Ethernet8 up") @@ -854,6 +877,9 @@ def test_swss_port_state_syncup(dvs, testlog): intf_tbl._del("Ethernet0|10.0.0.0/31") intf_tbl._del("Ethernet4|10.0.0.2/31") intf_tbl._del("Ethernet8|10.0.0.4/31") + intf_tbl._del("Ethernet0") + intf_tbl._del("Ethernet4") + intf_tbl._del("Ethernet8") time.sleep(2) dvs.stop_swss() @@ -880,6 +906,9 @@ def test_swss_port_state_syncup(dvs, testlog): intf_tbl.set("Ethernet0|10.0.0.0/31", fvs) intf_tbl.set("Ethernet4|10.0.0.2/31", fvs) intf_tbl.set("Ethernet8|10.0.0.4/31", fvs) + intf_tbl.set("Ethernet0", fvs) + intf_tbl.set("Ethernet4", fvs) + intf_tbl.set("Ethernet8", fvs) time.sleep(3) for i in [0, 1, 2]: @@ -929,6 +958,9 @@ def test_swss_port_state_syncup(dvs, testlog): intf_tbl._del("Ethernet0|10.0.0.0/31") intf_tbl._del("Ethernet4|10.0.0.2/31") intf_tbl._del("Ethernet8|10.0.0.4/31") + intf_tbl._del("Ethernet0") + intf_tbl._del("Ethernet4") + intf_tbl._del("Ethernet8") time.sleep(2) @@ -987,6 +1019,12 @@ def test_routing_WarmRestart(dvs, testlog): intf_tbl.set("{}|1220::1/64".format(intfs[1]), fvs) intf_tbl.set("{}|133.0.0.1/24".format(intfs[2]), fvs) intf_tbl.set("{}|1330::1/64".format(intfs[2]), fvs) + intf_tbl.set("{}".format(intfs[0]), fvs) + intf_tbl.set("{}".format(intfs[0]), fvs) + intf_tbl.set("{}".format(intfs[1]), fvs) + intf_tbl.set("{}".format(intfs[1]), fvs) + intf_tbl.set("{}".format(intfs[2]), fvs) + intf_tbl.set("{}".format(intfs[2]), fvs) dvs.runcmd("ip link set {} up".format(intfs[0])) dvs.runcmd("ip link set {} up".format(intfs[1])) dvs.runcmd("ip link set {} up".format(intfs[2])) @@ -1578,6 +1616,12 @@ def test_routing_WarmRestart(dvs, testlog): intf_tbl._del("{}|1220::1/64".format(intfs[1])) intf_tbl._del("{}|133.0.0.1/24".format(intfs[2])) intf_tbl._del("{}|1330::1/64".format(intfs[2])) + intf_tbl._del("{}".format(intfs[0])) + intf_tbl._del("{}".format(intfs[0])) + intf_tbl._del("{}".format(intfs[1])) + intf_tbl._del("{}".format(intfs[1])) + intf_tbl._del("{}".format(intfs[2])) + intf_tbl._del("{}".format(intfs[2])) time.sleep(2) @@ -1661,6 +1705,8 @@ def test_system_warmreboot_neighbor_syncup(dvs, testlog): dvs.runcmd("ip addr flush dev Ethernet{}".format(i*4)) intf_tbl.set("Ethernet{}|{}.0.0.1/24".format(i*4, i*4), fvs) intf_tbl.set("Ethernet{}|{}00::1/64".format(i*4, i*4), fvs) + intf_tbl.set("Ethernet{}".format(i*4, i*4), fvs) + intf_tbl.set("Ethernet{}".format(i*4, i*4), fvs) dvs.runcmd("ip link set Ethernet{} up".format(i*4, i*4)) dvs.servers[i].runcmd("ip link set up dev eth0") dvs.servers[i].runcmd("ip addr flush dev eth0") @@ -1895,4 +1941,6 @@ def test_system_warmreboot_neighbor_syncup(dvs, testlog): for i in range(8, 8+NUM_INTF): intf_tbl._del("Ethernet{}|{}.0.0.1/24".format(i*4, i*4)) intf_tbl._del("Ethernet{}|{}00::1/64".format(i*4, i*4)) + intf_tbl._del("Ethernet{}".format(i*4, i*4)) + intf_tbl._del("Ethernet{}".format(i*4, i*4))