Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BFD]Clean up state_db BFD entries on swss restart #2434

Merged
merged 2 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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