-
Notifications
You must be signed in to change notification settings - Fork 533
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
Conversation
Build failure is expected before sonic-net/sonic-swss-common#524 is merged. |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
auto value = fvValue(i); | ||
|
||
if (fvField(i) == "tx_interval") | ||
tx_interval = to_uint<uint32_t>(value); |
There was a problem hiding this comment.
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 {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added braces.
orchagent/orchdaemon.cpp
Outdated
@@ -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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
orchagent/bfdorch.h
Outdated
#define SWSS_BFDORCH_H | ||
|
||
#include "orch.h" | ||
#include "intfsorch.h" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
orchagent/bfdorch.cpp
Outdated
attrs.emplace_back(attr); | ||
|
||
attr.id = SAI_BFD_SESSION_ATTR_MIN_TX; | ||
attr.value.u32 = tx_interval * 1000; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
orchagent/bfdorch.cpp
Outdated
{ | ||
SWSS_LOG_ERROR("Failed to create BFD session %s: destination MAC address required when hardware lookup not valid", | ||
key.c_str()); | ||
return false; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
orchagent/bfdorch.cpp
Outdated
|
||
attrs.emplace_back(attr); | ||
|
||
if (dst_mac_provided) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
orchagent/bfdorch.cpp
Outdated
} | ||
} | ||
|
||
const string state_db_key = vrf_name + state_db_key_delimiter + alias + state_db_key_delimiter + peer_address.to_string(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
orchagent/bfdorch.cpp
Outdated
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)); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
orchagent/bfdorch.cpp
Outdated
{"async_passive", SAI_BFD_SESSION_TYPE_ASYNC_PASSIVE} | ||
}; | ||
|
||
const map<sai_bfd_session_type_t, string> session_type_loopup = |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
orchagent/bfdorch.cpp
Outdated
{SAI_BFD_SESSION_TYPE_ASYNC_PASSIVE, "async_passive"} | ||
}; | ||
|
||
const map<sai_bfd_session_state_t, string> session_state_loopup = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lookup -> typo?
There was a problem hiding this comment.
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.
orchagent/bfdorch.cpp
Outdated
if (!gPortsOrch->getPort(alias, port)) | ||
{ | ||
SWSS_LOG_ERROR("Failed to locate port %s", alias.c_str()); | ||
return true; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated as suggested.
orchagent/bfdorch.cpp
Outdated
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()); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the log message.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
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.
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.
This reverts commit 63bc849.
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.
…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.
* Add CRM CLIs for SRV6 nexthop and my_sid_entry
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