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] add local discriminator to state DB #2629

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion orchagent/bfdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,11 @@ bool BfdOrch::create_bfd_session(const string& key, const vector<FieldValueTuple
attrs.emplace_back(attr);
fvVector.emplace_back("type", session_type_lookup.at(bfd_session_type));

uint32_t local_discriminator = bfd_gen_id();
attr.id = SAI_BFD_SESSION_ATTR_LOCAL_DISCRIMINATOR;
attr.value.u32 = bfd_gen_id();
attr.value.u32 = local_discriminator;
attrs.emplace_back(attr);
fvVector.emplace_back("local_discriminator", to_string(local_discriminator));

attr.id = SAI_BFD_SESSION_ATTR_UDP_SRC_PORT;
attr.value.u32 = bfd_src_port();
Expand Down
22 changes: 11 additions & 11 deletions tests/test_bfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_addRemoveBfdSession(self, dvs):

# Check STATE_DB entry related to the BFD session
expected_sdb_values = {"state": "Down", "type": "async_active", "local_addr" : "10.0.0.1", "tx_interval" :"1000",
"rx_interval" : "1000", "multiplier" : "10", "multihop": "false"}
"rx_interval" : "1000", "multiplier" : "10", "multihop": "false", "local_discriminator" : "1"}
self.check_state_bfd_session_value("default|default|10.0.0.2", expected_sdb_values)

# Send BFD session state notification to update BFD session state
Expand Down Expand Up @@ -108,7 +108,7 @@ def test_addRemoveBfdSession_ipv6(self, dvs):

# Check STATE_DB entry related to the BFD session
expected_sdb_values = {"state": "Down", "type": "async_active", "local_addr" : "2000::1", "tx_interval" :"1000",
"rx_interval" : "1000", "multiplier" : "10", "multihop": "false"}
"rx_interval" : "1000", "multiplier" : "10", "multihop": "false", "local_discriminator" : "2"}
self.check_state_bfd_session_value("default|default|2000::2", expected_sdb_values)

# Send BFD session state notification to update BFD session state
Expand Down Expand Up @@ -150,7 +150,7 @@ def test_addRemoveBfdSession_interface(self, dvs):

# Check STATE_DB entry related to the BFD session
expected_sdb_values = {"state": "Down", "type": "async_active", "local_addr" : "10.0.0.1", "tx_interval" :"1000",
"rx_interval" : "1000", "multiplier" : "10", "multihop": "false"}
"rx_interval" : "1000", "multiplier" : "10", "multihop": "false", "local_discriminator" : "3"}
self.check_state_bfd_session_value("default|Ethernet0|10.0.0.2", expected_sdb_values)

# Send BFD session state notification to update BFD session state
Expand Down Expand Up @@ -192,7 +192,7 @@ def test_addRemoveBfdSession_txrx_interval(self, dvs):

# Check STATE_DB entry related to the BFD session
expected_sdb_values = {"state": "Down", "type": "async_active", "local_addr" : "10.0.0.1", "tx_interval" :"300",
"rx_interval" : "500", "multiplier" : "10", "multihop": "false"}
"rx_interval" : "500", "multiplier" : "10", "multihop": "false", "local_discriminator" : "4"}
self.check_state_bfd_session_value("default|default|10.0.0.2", expected_sdb_values)

# Send BFD session state notification to update BFD session state
Expand Down Expand Up @@ -233,7 +233,7 @@ def test_addRemoveBfdSession_multiplier(self, dvs):

# Check STATE_DB entry related to the BFD session
expected_sdb_values = {"state": "Down", "type": "async_active", "local_addr" : "10.0.0.1", "tx_interval" :"1000",
"rx_interval" : "1000", "multiplier" : "5", "multihop": "false"}
"rx_interval" : "1000", "multiplier" : "5", "multihop": "false", "local_discriminator" : "5"}
self.check_state_bfd_session_value("default|default|10.0.0.2", expected_sdb_values)

# Send BFD session state notification to update BFD session state
Expand Down Expand Up @@ -274,7 +274,7 @@ def test_addRemoveBfdSession_multihop(self, dvs):

# Check STATE_DB entry related to the BFD session
expected_sdb_values = {"state": "Down", "type": "async_active", "local_addr" : "10.0.0.1", "tx_interval" :"1000",
"rx_interval" : "1000", "multiplier" : "10", "multihop": "true"}
"rx_interval" : "1000", "multiplier" : "10", "multihop": "true", "local_discriminator" : "6"}
self.check_state_bfd_session_value("default|default|10.0.0.2", expected_sdb_values)

# Send BFD session state notification to update BFD session state
Expand Down Expand Up @@ -314,7 +314,7 @@ def test_addRemoveBfdSession_type(self, dvs):

# Check STATE_DB entry related to the BFD session
expected_sdb_values = {"state": "Down", "type": "demand_active", "local_addr" : "10.0.0.1", "tx_interval" :"1000",
"rx_interval" : "1000", "multiplier" : "10", "multihop": "false"}
"rx_interval" : "1000", "multiplier" : "10", "multihop": "false", "local_discriminator" : "7"}
self.check_state_bfd_session_value("default|default|10.0.0.2", expected_sdb_values)

# Send BFD session state notification to update BFD session state
Expand Down Expand Up @@ -357,7 +357,7 @@ def test_multipleBfdSessions(self, dvs):
# Check STATE_DB entry related to the BFD session 1
key_state_db1 = "default|default|10.0.0.2"
expected_sdb_values1 = {"state": "Down", "type": "async_active", "local_addr" : "10.0.0.1", "tx_interval" :"1000",
"rx_interval" : "1000", "multiplier" : "10", "multihop": "false"}
"rx_interval" : "1000", "multiplier" : "10", "multihop": "false", "local_discriminator" : "8"}
self.check_state_bfd_session_value(key_state_db1, expected_sdb_values1)

# Create BFD session 2
Expand Down Expand Up @@ -385,7 +385,7 @@ def test_multipleBfdSessions(self, dvs):
# Check STATE_DB entry related to the BFD session 2
key_state_db2 = "default|default|10.0.1.2"
expected_sdb_values2 = {"state": "Down", "type": "async_active", "local_addr" : "10.0.0.1", "tx_interval" :"300",
"rx_interval" : "500", "multiplier" : "10", "multihop": "false"}
"rx_interval" : "500", "multiplier" : "10", "multihop": "false", "local_discriminator" : "9"}
self.check_state_bfd_session_value(key_state_db2, expected_sdb_values2)

# Create BFD session 3
Expand All @@ -411,7 +411,7 @@ def test_multipleBfdSessions(self, dvs):
# Check STATE_DB entry related to the BFD session 3
key_state_db3 = "default|default|2000::2"
expected_sdb_values3 = {"state": "Down", "type": "demand_active", "local_addr" : "2000::1", "tx_interval" :"1000",
"rx_interval" : "1000", "multiplier" : "10", "multihop": "false"}
"rx_interval" : "1000", "multiplier" : "10", "multihop": "false", "local_discriminator" : "10"}
self.check_state_bfd_session_value(key_state_db3, expected_sdb_values3)

# Create BFD session 4
Expand All @@ -437,7 +437,7 @@ def test_multipleBfdSessions(self, dvs):
# Check STATE_DB entry related to the BFD session 4
key_state_db4 = "default|default|3000::2"
expected_sdb_values4 = {"state": "Down", "type": "async_active", "local_addr" : "3000::1", "tx_interval" :"1000",
"rx_interval" : "1000", "multiplier" : "10", "multihop": "false"}
"rx_interval" : "1000", "multiplier" : "10", "multihop": "false", "local_discriminator" : "11"}
self.check_state_bfd_session_value(key_state_db4, expected_sdb_values4)

# Update BFD session states
Expand Down