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

[bfdorch] Orchagent support hardware BFD #1883

Merged
merged 15 commits into from
Nov 10, 2021
Merged

Conversation

shi-su
Copy link
Contributor

@shi-su shi-su commented Aug 23, 2021

What I did
Implement bfdorch to program hardware BFD sessions via bfd SAI.
Add vs test for bfd sessions.

Why I did it
To support hardware BFD.

How I verified it
Configure hardware BFD sessions on virtual switches and physical devices and confirm the BFD session is programmed.

Details if related

@shi-su
Copy link
Contributor Author

shi-su commented Aug 24, 2021

Build failure is expected before sonic-net/sonic-swss-common#524 is merged.

@shi-su
Copy link
Contributor Author

shi-su commented Aug 30, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@shi-su shi-su marked this pull request as ready for review September 22, 2021 23:40
@shi-su shi-su requested review from prsunny and removed request for prsunny September 22, 2021 23:41
auto value = fvValue(i);

if (fvField(i) == "tx_interval")
tx_interval = to_uint<uint32_t>(value);
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add opening/closing braces {}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added braces.

@@ -288,6 +289,8 @@ bool OrchDaemon::init()

gMacsecOrch = new MACsecOrch(m_applDb, m_stateDb, macsec_app_tables, gPortsOrch);

gBfdOrch = new BfdOrch(m_applDb, APP_BFD_SESSION_TABLE_NAME);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pass m_stateDB as well to the BfdOrch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for this suggestion, updated the code to pass m_stateDB and STATE_BFD_SESSION_TABLE_NAME to BfdOrch.

@@ -451,6 +451,10 @@ int main(int argc, char **argv)
attr.value.ptr = (void *)on_port_state_change;
attrs.push_back(attr);

attr.id = SAI_SWITCH_ATTR_BFD_SESSION_STATE_CHANGE_NOTIFY;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just thinking if we should do a capability query before setting this. Do you see any issue if we set this on the current flow where vendor SAI don't have BFD support?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good point. I am not sure how it would behave for vendor SAI without BFD support. Will do some research on that.

#define SWSS_BFDORCH_H

#include "orch.h"
#include "intfsorch.h"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please move these headers to .cpp if not referenced in this header file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the headers to .cpp.

auto key = bfd_session_lookup[id].peer;
m_stateBfdSessionTable->hset(key, "state", session_state_loopup.at(state));

bfd_session_lookup[id].state = state;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please add the code for notifying observers? similar to port oper change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added code for notifying observer. For this PR, there will not be anywhere processing these notifications though.

attrs.emplace_back(attr);

attr.id = SAI_BFD_SESSION_ATTR_MIN_TX;
attr.value.u32 = tx_interval * 1000;
Copy link
Collaborator

Choose a reason for hiding this comment

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

define this. don't use magic number

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got this defined as BFD_SESSION_MILLISECOND_TO_MICROSECOND

{
SWSS_LOG_ERROR("Failed to create BFD session %s: destination MAC address required when hardware lookup not valid",
key.c_str());
return false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

return true as no need to retry. Suggest check all return codes in this function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated return value to true and checked other return codes


attrs.emplace_back(attr);

if (dst_mac_provided)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this check can be relaxed as its ok to ignore. In future when modifying attributes are supported, we don't want to have some restriction as to remove certain attributes when some other attributes are modified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check is per SAI definition that mac address is required when and only when SAI_BFD_SESSION_ATTR_HW_LOOKUP_VALID is false. Therefore, I added the check here and the opposite one for SAI_BFD_SESSION_ATTR_HW_LOOKUP_VALID is true.

}
}

const string state_db_key = vrf_name + state_db_key_delimiter + alias + state_db_key_delimiter + peer_address.to_string();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you move this to a separate function so it can be used from both create and remove functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Defined a separate function to generate keys.

SWSS_LOG_ENTER();

m_state_db = shared_ptr<DBConnector>(new DBConnector("STATE_DB", 0));
m_stateBfdSessionTable = unique_ptr<Table>(new Table(m_state_db.get(), STATE_BFD_SESSION_TABLE));
Copy link
Collaborator

Choose a reason for hiding this comment

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

As mentioned, please pass this attributes from orch init

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comment. Moved the attributes to orch init.

{"async_passive", SAI_BFD_SESSION_TYPE_ASYNC_PASSIVE}
};

const map<sai_bfd_session_type_t, string> session_type_loopup =
Copy link
Collaborator

Choose a reason for hiding this comment

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

lookup -> typo?. I would suggest to name as session_type_map. Similarly for session_state

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is.. Thanks for catching it.

{SAI_BFD_SESSION_TYPE_ASYNC_PASSIVE, "async_passive"}
};

const map<sai_bfd_session_state_t, string> session_state_loopup =
Copy link
Collaborator

Choose a reason for hiding this comment

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

lookup -> typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed for this and a few other places.

if (!gPortsOrch->getPort(alias, port))
{
SWSS_LOG_ERROR("Failed to locate port %s", alias.c_str());
return true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should return false as a retry is expected here. port may get created later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated as suggested.

auto key = bfd_session_lookup[id].peer;
m_stateBfdSessionTable.hset(key, "state", session_state_loopup.at(state));

SWSS_LOG_NOTICE("Updated BFD session state for %s to %s", key.c_str(), session_state_loopup.at(state).c_str());
Copy link
Collaborator

@prsunny prsunny Nov 3, 2021

Choose a reason for hiding this comment

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

can you please rephrase this? BFD session state for %s changed from %s to %s. This shall be an important log message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the log message.

prsunny
prsunny previously approved these changes Nov 3, 2021
@shi-su
Copy link
Contributor Author

shi-su commented Nov 8, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@shi-su shi-su merged commit 8119ec0 into sonic-net:master Nov 10, 2021
shi-su added a commit to shi-su/sonic-swss that referenced this pull request Jan 6, 2022
What I did
Implement bfdorch to program hardware BFD sessions via bfd SAI.
Add vs test for bfd sessions.

Why I did it
To support hardware BFD.

How I verified it
Configure hardware BFD sessions on virtual switches and physical devices and confirm the BFD session is programmed.
shi-su added a commit to shi-su/sonic-swss that referenced this pull request Jan 6, 2022
What I did
Implement bfdorch to program hardware BFD sessions via bfd SAI.
Add vs test for bfd sessions.

Why I did it
To support hardware BFD.

How I verified it
Configure hardware BFD sessions on virtual switches and physical devices and confirm the BFD session is programmed.
dgsudharsan pushed a commit to dgsudharsan/sonic-swss that referenced this pull request Jan 10, 2022
What I did
Implement bfdorch to program hardware BFD sessions via bfd SAI.
Add vs test for bfd sessions.

Why I did it
To support hardware BFD.

How I verified it
Configure hardware BFD sessions on virtual switches and physical devices and confirm the BFD session is programmed.
dgsudharsan added a commit to dgsudharsan/sonic-swss that referenced this pull request Jan 11, 2022
shi-su added a commit to shi-su/sonic-swss that referenced this pull request Jan 21, 2022
What I did
Implement bfdorch to program hardware BFD sessions via bfd SAI.
Add vs test for bfd sessions.

Why I did it
To support hardware BFD.

How I verified it
Configure hardware BFD sessions on virtual switches and physical devices and confirm the BFD session is programmed.
shi-su added a commit that referenced this pull request Jan 26, 2022
…oint health monitoring (#2104)

What I did
Cherry-pick changes in #1960, #1883, #1955, #2058

Changes in #1960:
Add functions to create/remove next hop groups for vnet tunnel routes.
Count the reference count of next hop groups to create and remove as needed.
Share the counter of next hop groups with routeorch.
Add vs test

Changes in #1883:
Implement bfdorch to program hardware BFD sessions via bfd SAI.
Add vs test for bfd sessions.

Changes in #1955:
Add functions to create/remove next hop groups for vnet tunnel routes.
Count the reference count of next hop groups to create and remove as needed.
Share the counter of next hop groups with routeorch.
Adapt route endpoint according to the BFD state of endpoints.

Changes in #2058:
Advertise active vnet tunnel routes.

Why I did it
To add support for overlay ECMP with endpoint health monitoring.
EdenGri pushed a commit to EdenGri/sonic-swss that referenced this pull request Feb 28, 2022
* Add CRM CLIs for SRV6 nexthop and my_sid_entry
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.

2 participants