Skip to content

Commit

Permalink
[intfsorch] Wait for interface prior to prefix (sonic-net#796)
Browse files Browse the repository at this point in the history
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 <marianp@mellanox.com>
  • Loading branch information
marian-pritsak authored and prsunny committed Jun 20, 2019
1 parent 3f93ee3 commit 185e9a1
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 0 deletions.
8 changes: 8 additions & 0 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,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))
{
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,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):
Expand Down
10 changes: 10 additions & 0 deletions tests/test_crm.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,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")

Expand Down Expand Up @@ -165,6 +166,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")

Expand Down Expand Up @@ -225,6 +227,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")
Expand Down Expand Up @@ -276,6 +279,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")

Expand Down Expand Up @@ -324,6 +328,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")

Expand Down Expand Up @@ -376,6 +381,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")

Expand Down Expand Up @@ -424,6 +430,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")
Expand Down Expand Up @@ -491,6 +499,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")
Expand Down
1 change: 1 addition & 0 deletions tests/test_dirbcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,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):
Expand All @@ -54,6 +55,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):
Expand Down
3 changes: 3 additions & 0 deletions tests/test_nhg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
48 changes: 48 additions & 0 deletions tests/test_warm_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand 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)


Expand Down Expand Up @@ -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")

Expand Down Expand 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):
Expand Down Expand Up @@ -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]))

Expand Down Expand Up @@ -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)


Expand All @@ -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")

Expand Down Expand 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.
Expand All @@ -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")
Expand Down Expand 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()
Expand All @@ -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]:
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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]))
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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))

0 comments on commit 185e9a1

Please sign in to comment.