Skip to content

Commit

Permalink
[BFD]Clean up state_db BFD entries on swss restart (#2434)
Browse files Browse the repository at this point in the history
*[BFD]Clean up state_db BFD entries on swss restart (#2434)
  • Loading branch information
dgsudharsan authored and yxieca committed Sep 1, 2022
1 parent f4a6945 commit 39f5cdf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
11 changes: 11 additions & 0 deletions orchagent/bfdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ BfdOrch::BfdOrch(DBConnector *db, string tableName, TableConnector stateDbBfdSes
DBConnector *notificationsDb = new DBConnector("ASIC_DB", 0);
m_bfdStateNotificationConsumer = new swss::NotificationConsumer(notificationsDb, "NOTIFICATIONS");
auto bfdStateNotificatier = new Notifier(m_bfdStateNotificationConsumer, this, "BFD_STATE_NOTIFICATIONS");

// Clean up state database BFD entries
vector<string> keys;

m_stateBfdSessionTable.getKeys(keys);

for (auto alias : keys)
{
m_stateBfdSessionTable.del(alias);
}

Orch::addExecutor(bfdStateNotificatier);
register_state_change_notif = false;
}
Expand Down
20 changes: 20 additions & 0 deletions tests/test_bfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,3 +464,23 @@ def test_multipleBfdSessions(self, dvs):
self.adb.wait_for_deleted_entry("ASIC_STATE:SAI_OBJECT_TYPE_BFD_SESSION", session3)
self.remove_bfd_session(key4)
self.adb.wait_for_deleted_entry("ASIC_STATE:SAI_OBJECT_TYPE_BFD_SESSION", session4)

def test_bfd_state_db_clear(self, dvs):
self.setup_db(dvs)

bfdSessions = self.get_exist_bfd_session()

# Create BFD session
fieldValues = {"local_addr": "10.0.0.1", "type": "demand_active"}
self.create_bfd_session("default:default:10.0.0.2", fieldValues)
self.adb.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_BFD_SESSION", len(bfdSessions) + 1)

# Checked created BFD session in ASIC_DB
createdSessions = self.get_exist_bfd_session() - bfdSessions
assert len(createdSessions) == 1
dvs.stop_swss()
dvs.start_swss()

time.sleep(5)
keys = self.sdb.get_keys("BFD_SESSION_TABLE")
assert len(keys) == 0

0 comments on commit 39f5cdf

Please sign in to comment.