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

sonic-swss: bfdorch changes to support software bfd sessions #3406

Merged
merged 29 commits into from
Feb 13, 2025

Conversation

abdbaig
Copy link
Contributor

@abdbaig abdbaig commented Dec 1, 2024

What I did

  • Added logic in bfdorch to check for switch_type value of dpu and if it's dpu, program BFD sessions in a new software BFD session table in STATE_DB, instead of programming sessions in the HW through ASIC_DB. This table will be monitored by bgpcfgd which will program BFD sessions in FRR accordingly.
  • Added pytest testcases

Why I did it

As part of the Smartswitch project, BFD sessions need to be run between DPU and NPU but DPU doesn't currently support BFD hardware offload.
HLD: https://github.com/kperumalbfn/SONiC/blob/master/doc/smart-switch/BFD/SmartSwitchDpuLivenessUsingBfd.md

HA manager (hamgrd) will be responsible for programming BFD sessions in the DPU by programming BFD_SESSION_TABLE in APP_DB (just like it's currently done for NPU), but bfdorch needs to now program software BFD sessions if it's running on the DPU.

How I verified it

  • Added a new test_soft_bfd.py test file and verified the tests passed.

Details if related

@abdbaig abdbaig requested a review from prsunny as a code owner December 1, 2024 22:04
Copy link
Contributor

@siqbal1986 siqbal1986 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good. jsut a few minor comments

extern sai_bfd_api_t* sai_bfd_api;
extern sai_object_id_t gSwitchId;
extern sai_object_id_t gVirtualRouterId;
extern PortsOrch* gPortsOrch;
extern sai_switch_api_t* sai_switch_api;
extern Directory<Orch*> gDirectory;
extern string gMySwitchType;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why extra space

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

orchagent/bfdorch.cpp Show resolved Hide resolved

# Check BFD session 3 in STATE_DB
createdSessions = self.get_exist_bfd_session() - bfdSessions
bfdSessions = self.get_exist_bfd_session()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please add a test in test_vnet.py where a vnet route with BFD session is created and added, that way we can be sure that it works fine with VNET routes as well.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prsunny is software BFD on DPU over VNET a requirement? Currently not supported

@@ -81,6 +100,21 @@ BfdOrch::~BfdOrch(void)
SWSS_LOG_ENTER();
}

std::string BfdOrch::replaceFirstTwoColons(const std::string &input) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please rename to something like createStateDBKey.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

tests/test_soft_bfd.py Fixed Show resolved Hide resolved
tests/test_soft_bfd.py Fixed Show resolved Hide resolved
tests/test_soft_bfd.py Fixed Show resolved Hide resolved
@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

kperumalbfn
kperumalbfn previously approved these changes Feb 6, 2025
@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).


// Clean up state database software BFD entries
if (gMySwitchType == "dpu") {
m_stateSoftBfdSessionTable->getKeys(keys);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have to check for 'dpu' here. Clean it anyways based on getKeys function

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -101,6 +130,13 @@ void BfdOrch::doTask(Consumer &consumer)

if (op == SET_COMMAND)
{
if (gMySwitchType == "dpu") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, this should be based on capability query and not based on 'dpu'. This check lacks flexibility if we've to enable software bfd for any future use case. Suggest doing a capability check via SAI api for offload and if it returns NOT Supported or implemented, then enable softbfd.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current design checks for switch type DPU in bgpcfgd and bfdmon as well: sonic-net/sonic-buildimage#20981. Additionally, the SAI call in VS reports that offload is supported; the pytests run on VS so there would be no way to cover and test the new code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should've been based on feature flag. bfdmon to run if software bfd feature is enabled. Since its already merged, we may have to take it as a different PR. @kperumalbfn for viz

swss::NotificationConsumer* m_bfdStateNotificationConsumer;
bool register_state_change_notif;
std::map<std::string, vector<FieldValueTuple>> bfd_session_cache;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert changes not related to PR

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dypet
Copy link

dypet commented Feb 12, 2025

@kperumalbfn thanks for the approval; can this be merged?

@kperumalbfn
Copy link
Contributor

@kperumalbfn thanks for the approval; can this be merged?

@dypet Please check and resolve @prsunny comments.

@dypet
Copy link

dypet commented Feb 12, 2025

@kperumalbfn thanks for the approval; can this be merged?

@dypet Please check and resolve @prsunny comments.

@kperumalbfn @prsunny Responded to comments.

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@prsunny prsunny merged commit 29b7db3 into sonic-net:master Feb 13, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants