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 support for TSA state. #2926

Merged
merged 15 commits into from Feb 7, 2024
Merged

Conversation

siqbal1986
Copy link
Contributor

@siqbal1986 siqbal1986 commented Oct 12, 2023

These changes enable us to bring certain BFD sessions down when the device goes into TSA. when the device switches to TSB, these sessions are brought up.
What I did
Added a session cache in BFD orch which records sessions with the "tsa_shutdown" parameter and removes/adds these sessions when switching between TSA/TSB.
Why I did it
In TSA a device is not supposed to be forwarding data plane traffic but in the existing implementation, BFD sessions were kept up for Vxlan tunnels with BFD monitoring. This gives the Vxlan tunnel traffic receiver the impression that the device is active but not sending traffic.
How I verified it
The following tests were added
BFD Test - apply and remove TSA

  1. Set up a BFD session with shutdown_bfd_during_tsa=true and checks state DB for session creation.
  2. Apply TSA and verify removal of the said session from app db.
  3. Apply TSB and verify reinstated session is app db.

BFD Test- remove active session in TSA

  1. Set up a BFD session with shutdown_bfd_during_tsa=true and checks state DB for session creation.
  2. Apply TSA and verify removal of the said session from app db.
  3. Remove BFD session configuration form state db.
  4. Apply TSB and verify that the session doesn't come up as it has already been removed.

Details if related

Example

under existing imlementation when a device goes into TSA the BFD sessions remain active
Total number of BFD sessions: 4
Peer Addr     Interface    Vrf      State    Type          Local Addr      TX Interval    RX Interval    Multiplier  Multihop      Local Discriminator
------------  -----------  -------  -------  ------------  ------------  -------------  -------------  ------------  ----------  ---------------------
200.251.17.3  default      default  Up       async_active  10.1.0.32              1000           1000            10  true                            3
200.251.17.1  default      default  Up       async_active  10.1.0.32              1000           1000            10  true                            1
200.251.17.4  default      default  Up       async_active  10.1.0.32              1000           1000            10  true                            4
200.251.17.2  default      default  Up       async_active  10.1.0.32              1000           1000            10  true                            2

With this implementation if a BFD sesion is configured with parameter "tsa_shutdown"= "true"
The sessions are brought down upon TSA.

Total number of BFD sessions: 0
Peer Addr     Interface    Vrf      State    Type          Local Addr      TX Interval    RX Interval    Multiplier  Multihop      Local Discriminator
------------  -----------  -------  -------  ------------  ------------  -------------  -------------  ------------  ----------  ---------------------
When the device is taken out of TSA i.e. TSB, the sessions are brought up again.
Total number of BFD sessions: 4
Peer Addr     Interface    Vrf      State    Type          Local Addr      TX Interval    RX Interval    Multiplier  Multihop      Local Discriminator
------------  -----------  -------  -------  ------------  ------------  -------------  -------------  ------------  ----------  ---------------------
200.251.17.3  default      default  Up       async_active  10.1.0.32              1000           1000            10  true                            3
200.251.17.1  default      default  Up       async_active  10.1.0.32              1000           1000            10  true                            1
200.251.17.4  default      default  Up       async_active  10.1.0.32              1000           1000            10  true                            4
200.251.17.2  default      default  Up       async_active  10.1.0.32              1000           1000            10  true                            2

Copy link
Collaborator

@prsunny prsunny left a comment

Choose a reason for hiding this comment

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

Please provide full description of the behavior as to when TSA is applied with some examples.

orchagent/bfdorch.cpp Outdated Show resolved Hide resolved
orchagent/bfdorch.cpp Outdated Show resolved Hide resolved
@siqbal1986
Copy link
Contributor Author

/azp run

Copy link

Commenter does not have sufficient privileges for PR 2926 in repo sonic-net/sonic-swss

@siqbal1986
Copy link
Contributor Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -298,6 +352,10 @@ bool BfdOrch::create_bfd_session(const string& key, const vector<FieldValueTuple
{
tos = to_uint<uint8_t>(value);
}
else if (fvField(i) == "tsa_shutdown")
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is the purpose of this section?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added a comment in the code and I have changed the name of the field to shutdown_bfd_during_tsa. The BFD tsa shutdown is handled by the bfd cache in the caller function. This block is added to avoid getting the unknown parameter syslog.

@@ -1817,6 +1817,7 @@ void VNetRouteOrch::createBfdSession(const string& vnet, const NextHopKey& endpo
FieldValueTuple fvTuple("local_addr", src_ip.to_string());
data.push_back(fvTuple);
data.emplace_back("multihop", "true");
data.emplace_back("tsa_shutdown", "true");
Copy link
Collaborator

Choose a reason for hiding this comment

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

not clear of the meaning of this variable - 'tsa_shutdown' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed it already and added comments.

tests/test_bfd.py Show resolved Hide resolved
orchagent/bfdorch.cpp Show resolved Hide resolved
orchagent/bfdorch.cpp Show resolved Hide resolved
//specified session gets removed when the device goes into TSA state.
//if this parameter is not specified or set to false for a session, the
// corrosponding BFD session would be maintained even in TSA state.
if (fvField(i) == "shutdown_bfd_during_tsa" && value == "true" )
Copy link
Collaborator

Choose a reason for hiding this comment

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

@arlakshm , fyi (This param can control the individual BFD session state during TSA)


void BfdOrch::handleTsaStateChange(bool tsaState)
{
SWSS_LOG_INFO("BfdOrch TSA state Changed to %d.\n", int(tsaState));
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 change this to NOTICE? , also log the existing 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.

done. now log is in the caller function.

{
SWSS_LOG_ENTER();
tsa_enabled = false;
SWSS_LOG_ERROR("BgpGlobalStateOrch init complete\n");
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this ERROR log, please remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

orchagent/bfdorch.cpp Show resolved Hide resolved
orchagent/bfdorch.cpp Show resolved Hide resolved
@@ -74,6 +74,16 @@ BfdOrch::BfdOrch(DBConnector *db, string tableName, TableConnector stateDbBfdSes

Orch::addExecutor(bfdStateNotificatier);
register_state_change_notif = false;
BgpGlobalStateOrch* bgp_global_state_orch = gDirectory.get<BgpGlobalStateOrch*>();
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 you don't need this section. Just initialize tsa_enabled to false in class and handle TSA change in the normal update path.

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

notify_session_state_down(it.first);
if (!remove_bfd_session(it.first))
{
SWSS_LOG_ERROR("Failed to remove BFD session %s\n", it.first.c_str());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove the error log as its handled in the remove function already

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

{
if (!create_bfd_session(it.first, it.second))
{
SWSS_LOG_ERROR("Failed to create BFD session %s\n", it.first.c_str());
Copy link
Collaborator

Choose a reason for hiding this comment

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

please remove the error log

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

{
notify_session_state_down(it.first);
remove_bfd_session(it.first);
} else
Copy link
Collaborator

Choose a reason for hiding this comment

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

else -> next line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

orchagent/bfdorch.cpp Outdated Show resolved Hide resolved
orchagent/bfdorch.cpp Show resolved Hide resolved
orchagent/bfdorch.cpp Outdated Show resolved Hide resolved
@prsunny
Copy link
Collaborator

prsunny commented Dec 12, 2023

Please check coverage of test.

@@ -3428,6 +3443,83 @@ def test_vnet_orch_24(self, dvs, testlog):
# delete vxlan tunnel
delete_vxlan_tunnel(dvs, tunnel_name)

'''
Test 25 - Test for BFD TSA and TSB behaviour within overlay tunnel routes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

add description of test here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@prsunny prsunny merged commit 3bd0144 into sonic-net:master Feb 7, 2024
14 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.

None yet

3 participants