-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for BFD notification (#903)
Add sairedis and syncd support to handle and send back BFD session state change notifications.
- Loading branch information
Showing
22 changed files
with
428 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#include "NotificationBfdSessionStateChange.h" | ||
|
||
#include "swss/logger.h" | ||
|
||
#include "meta/sai_serialize.h" | ||
|
||
using namespace sairedis; | ||
|
||
NotificationBfdSessionStateChange::NotificationBfdSessionStateChange( | ||
_In_ const std::string& serializedNotification): | ||
Notification( | ||
SAI_SWITCH_NOTIFICATION_TYPE_BFD_SESSION_STATE_CHANGE, | ||
serializedNotification), | ||
m_bfdSessionStateNotificationData(nullptr) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
sai_deserialize_bfd_session_state_ntf( | ||
serializedNotification, | ||
m_count, | ||
&m_bfdSessionStateNotificationData); | ||
} | ||
|
||
NotificationBfdSessionStateChange::~NotificationBfdSessionStateChange() | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
sai_deserialize_free_bfd_session_state_ntf(m_count, m_bfdSessionStateNotificationData); | ||
} | ||
|
||
sai_object_id_t NotificationBfdSessionStateChange::getSwitchId() const | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
// this notification don't contain switch id field | ||
|
||
return SAI_NULL_OBJECT_ID; | ||
} | ||
|
||
sai_object_id_t NotificationBfdSessionStateChange::getAnyObjectId() const | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
if (m_bfdSessionStateNotificationData == nullptr) | ||
{ | ||
return SAI_NULL_OBJECT_ID; | ||
} | ||
|
||
for (uint32_t idx = 0; idx < m_count; idx++) | ||
{ | ||
if (m_bfdSessionStateNotificationData[idx].bfd_session_id != SAI_NULL_OBJECT_ID) | ||
{ | ||
return m_bfdSessionStateNotificationData[idx].bfd_session_id; | ||
} | ||
} | ||
|
||
return SAI_NULL_OBJECT_ID; | ||
} | ||
|
||
void NotificationBfdSessionStateChange::processMetadata( | ||
_In_ std::shared_ptr<saimeta::Meta> meta) const | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
meta->meta_sai_on_bfd_session_state_change(m_count, m_bfdSessionStateNotificationData); | ||
} | ||
|
||
void NotificationBfdSessionStateChange::executeCallback( | ||
_In_ const sai_switch_notifications_t& switchNotifications) const | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
if (switchNotifications.on_bfd_session_state_change) | ||
{ | ||
switchNotifications.on_bfd_session_state_change(m_count, m_bfdSessionStateNotificationData); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
|
||
#include "Notification.h" | ||
|
||
namespace sairedis | ||
{ | ||
class NotificationBfdSessionStateChange: | ||
public Notification | ||
{ | ||
public: | ||
|
||
NotificationBfdSessionStateChange( | ||
_In_ const std::string& serializedNotification); | ||
|
||
virtual ~NotificationBfdSessionStateChange(); | ||
|
||
public: | ||
|
||
virtual sai_object_id_t getSwitchId() const override; | ||
|
||
virtual sai_object_id_t getAnyObjectId() const override; | ||
|
||
virtual void processMetadata( | ||
_In_ std::shared_ptr<saimeta::Meta> meta) const override; | ||
|
||
virtual void executeCallback( | ||
_In_ const sai_switch_notifications_t& switchNotifications) const override; | ||
|
||
private: | ||
|
||
uint32_t m_count; | ||
|
||
sai_bfd_session_state_notification_t *m_bfdSessionStateNotificationData; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.