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 default TOS value for BFD session #2689

Merged
merged 4 commits into from
Mar 7, 2023
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
11 changes: 11 additions & 0 deletions orchagent/bfdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ using namespace swss;
#define BFD_SESSION_DEFAULT_TX_INTERVAL 1000
#define BFD_SESSION_DEFAULT_RX_INTERVAL 1000
#define BFD_SESSION_DEFAULT_DETECT_MULTIPLIER 10
// TOS: default 6-bit DSCP value 48, default 2-bit ecn value 0. 48<<2 = 192
#define BFD_SESSION_DEFAULT_TOS 192
#define BFD_SESSION_MILLISECOND_TO_MICROSECOND 1000
#define BFD_SRCPORTINIT 49152
#define BFD_SRCPORTMAX 65536
Expand Down Expand Up @@ -243,6 +245,7 @@ bool BfdOrch::create_bfd_session(const string& key, const vector<FieldValueTuple
uint32_t tx_interval = BFD_SESSION_DEFAULT_TX_INTERVAL;
uint32_t rx_interval = BFD_SESSION_DEFAULT_RX_INTERVAL;
uint8_t multiplier = BFD_SESSION_DEFAULT_DETECT_MULTIPLIER;
uint8_t tos = BFD_SESSION_DEFAULT_TOS;
bool multihop = false;
MacAddress dst_mac;
bool dst_mac_provided = false;
Expand Down Expand Up @@ -291,6 +294,10 @@ bool BfdOrch::create_bfd_session(const string& key, const vector<FieldValueTuple
dst_mac = MacAddress(value);
dst_mac_provided = true;
}
else if (fvField(i) == "tos")
{
tos = to_uint<uint8_t>(value);
}
else
SWSS_LOG_ERROR("Unsupported BFD attribute %s\n", fvField(i).c_str());
}
Expand Down Expand Up @@ -352,6 +359,10 @@ bool BfdOrch::create_bfd_session(const string& key, const vector<FieldValueTuple
attrs.emplace_back(attr);
fvVector.emplace_back("multiplier", to_string(multiplier));

attr.id = SAI_BFD_SESSION_ATTR_TOS;
attr.value.u8 = tos;
attrs.emplace_back(attr);

if (multihop)
{
attr.id = SAI_BFD_SESSION_ATTR_MULTIHOP;
Expand Down
13 changes: 12 additions & 1 deletion tests/test_bfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_addRemoveBfdSession(self, dvs):
bfdSessions = self.get_exist_bfd_session()

# Create BFD session
fieldValues = {"local_addr": "10.0.0.1"}
fieldValues = {"local_addr": "10.0.0.1","tos":"64"}
self.create_bfd_session("default:default:10.0.0.2", fieldValues)
self.adb.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_BFD_SESSION", len(bfdSessions) + 1)

Expand All @@ -62,6 +62,7 @@ def test_addRemoveBfdSession(self, dvs):
"SAI_BFD_SESSION_ATTR_SRC_IP_ADDRESS": "10.0.0.1",
"SAI_BFD_SESSION_ATTR_DST_IP_ADDRESS": "10.0.0.2",
"SAI_BFD_SESSION_ATTR_TYPE": "SAI_BFD_SESSION_TYPE_ASYNC_ACTIVE",
"SAI_BFD_SESSION_ATTR_TOS": "64",
"SAI_BFD_SESSION_ATTR_IPHDR_VERSION": "4"
}
self.check_asic_bfd_session_value(session, expected_adb_values)
Expand Down Expand Up @@ -102,6 +103,7 @@ def test_addRemoveBfdSession_ipv6(self, dvs):
"SAI_BFD_SESSION_ATTR_SRC_IP_ADDRESS": "2000::1",
"SAI_BFD_SESSION_ATTR_DST_IP_ADDRESS": "2000::2",
"SAI_BFD_SESSION_ATTR_TYPE": "SAI_BFD_SESSION_TYPE_ASYNC_ACTIVE",
"SAI_BFD_SESSION_ATTR_TOS": "192",
"SAI_BFD_SESSION_ATTR_IPHDR_VERSION": "6"
}
self.check_asic_bfd_session_value(session, expected_adb_values)
Expand Down Expand Up @@ -142,6 +144,7 @@ def test_addRemoveBfdSession_interface(self, dvs):
"SAI_BFD_SESSION_ATTR_SRC_IP_ADDRESS": "10.0.0.1",
"SAI_BFD_SESSION_ATTR_DST_IP_ADDRESS": "10.0.0.2",
"SAI_BFD_SESSION_ATTR_TYPE": "SAI_BFD_SESSION_TYPE_ASYNC_ACTIVE",
"SAI_BFD_SESSION_ATTR_TOS": "192",
"SAI_BFD_SESSION_ATTR_IPHDR_VERSION": "4",
"SAI_BFD_SESSION_ATTR_HW_LOOKUP_VALID": "false",
"SAI_BFD_SESSION_ATTR_DST_MAC_ADDRESS": "00:02:03:04:05:06"
Expand Down Expand Up @@ -184,6 +187,7 @@ def test_addRemoveBfdSession_txrx_interval(self, dvs):
"SAI_BFD_SESSION_ATTR_SRC_IP_ADDRESS": "10.0.0.1",
"SAI_BFD_SESSION_ATTR_DST_IP_ADDRESS": "10.0.0.2",
"SAI_BFD_SESSION_ATTR_TYPE": "SAI_BFD_SESSION_TYPE_ASYNC_ACTIVE",
"SAI_BFD_SESSION_ATTR_TOS": "192",
"SAI_BFD_SESSION_ATTR_IPHDR_VERSION": "4",
"SAI_BFD_SESSION_ATTR_MIN_TX": "300000",
"SAI_BFD_SESSION_ATTR_MIN_RX": "500000",
Expand Down Expand Up @@ -226,6 +230,7 @@ def test_addRemoveBfdSession_multiplier(self, dvs):
"SAI_BFD_SESSION_ATTR_SRC_IP_ADDRESS": "10.0.0.1",
"SAI_BFD_SESSION_ATTR_DST_IP_ADDRESS": "10.0.0.2",
"SAI_BFD_SESSION_ATTR_TYPE": "SAI_BFD_SESSION_TYPE_ASYNC_ACTIVE",
"SAI_BFD_SESSION_ATTR_TOS": "192",
"SAI_BFD_SESSION_ATTR_IPHDR_VERSION": "4",
"SAI_BFD_SESSION_ATTR_MULTIPLIER": "5"
}
Expand Down Expand Up @@ -267,6 +272,7 @@ def test_addRemoveBfdSession_multihop(self, dvs):
"SAI_BFD_SESSION_ATTR_SRC_IP_ADDRESS": "10.0.0.1",
"SAI_BFD_SESSION_ATTR_DST_IP_ADDRESS": "10.0.0.2",
"SAI_BFD_SESSION_ATTR_TYPE": "SAI_BFD_SESSION_TYPE_ASYNC_ACTIVE",
"SAI_BFD_SESSION_ATTR_TOS": "192",
"SAI_BFD_SESSION_ATTR_IPHDR_VERSION": "4",
"SAI_BFD_SESSION_ATTR_MULTIHOP": "true"
}
Expand Down Expand Up @@ -308,6 +314,7 @@ def test_addRemoveBfdSession_type(self, dvs):
"SAI_BFD_SESSION_ATTR_SRC_IP_ADDRESS": "10.0.0.1",
"SAI_BFD_SESSION_ATTR_DST_IP_ADDRESS": "10.0.0.2",
"SAI_BFD_SESSION_ATTR_TYPE": "SAI_BFD_SESSION_TYPE_DEMAND_ACTIVE",
"SAI_BFD_SESSION_ATTR_TOS": "192",
"SAI_BFD_SESSION_ATTR_IPHDR_VERSION": "4"
}
self.check_asic_bfd_session_value(session, expected_adb_values)
Expand Down Expand Up @@ -350,6 +357,7 @@ def test_multipleBfdSessions(self, dvs):
"SAI_BFD_SESSION_ATTR_SRC_IP_ADDRESS": "10.0.0.1",
"SAI_BFD_SESSION_ATTR_DST_IP_ADDRESS": "10.0.0.2",
"SAI_BFD_SESSION_ATTR_TYPE": "SAI_BFD_SESSION_TYPE_ASYNC_ACTIVE",
"SAI_BFD_SESSION_ATTR_TOS": "192",
"SAI_BFD_SESSION_ATTR_IPHDR_VERSION": "4"
}
self.check_asic_bfd_session_value(session1, expected_adb_values)
Expand All @@ -376,6 +384,7 @@ def test_multipleBfdSessions(self, dvs):
"SAI_BFD_SESSION_ATTR_SRC_IP_ADDRESS": "10.0.0.1",
"SAI_BFD_SESSION_ATTR_DST_IP_ADDRESS": "10.0.1.2",
"SAI_BFD_SESSION_ATTR_TYPE": "SAI_BFD_SESSION_TYPE_ASYNC_ACTIVE",
"SAI_BFD_SESSION_ATTR_TOS": "192",
"SAI_BFD_SESSION_ATTR_IPHDR_VERSION": "4",
"SAI_BFD_SESSION_ATTR_MIN_TX": "300000",
"SAI_BFD_SESSION_ATTR_MIN_RX": "500000",
Expand Down Expand Up @@ -404,6 +413,7 @@ def test_multipleBfdSessions(self, dvs):
"SAI_BFD_SESSION_ATTR_SRC_IP_ADDRESS": "2000::1",
"SAI_BFD_SESSION_ATTR_DST_IP_ADDRESS": "2000::2",
"SAI_BFD_SESSION_ATTR_TYPE": "SAI_BFD_SESSION_TYPE_DEMAND_ACTIVE",
"SAI_BFD_SESSION_ATTR_TOS": "192",
"SAI_BFD_SESSION_ATTR_IPHDR_VERSION": "6"
}
self.check_asic_bfd_session_value(session3, expected_adb_values)
Expand All @@ -430,6 +440,7 @@ def test_multipleBfdSessions(self, dvs):
"SAI_BFD_SESSION_ATTR_SRC_IP_ADDRESS": "3000::1",
"SAI_BFD_SESSION_ATTR_DST_IP_ADDRESS": "3000::2",
"SAI_BFD_SESSION_ATTR_TYPE": "SAI_BFD_SESSION_TYPE_ASYNC_ACTIVE",
"SAI_BFD_SESSION_ATTR_TOS": "192",
"SAI_BFD_SESSION_ATTR_IPHDR_VERSION": "6"
}
self.check_asic_bfd_session_value(session4, expected_adb_values)
Expand Down