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

Prevent Profile Creation for Invalid Cable Length #2

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0abfe00
[SWSS:portsorch] fix child_ports checking in addLagMember and removeL…
baorliu Feb 24, 2025
82632ea
Added Change to Skip Route Programming if NH is link/oper down (#3520)
abdosi Feb 24, 2025
3a80d64
Set Port UPDATE_DSCP attribute when TC_TO_DSCP map is attached (#3517)
kperumalbfn Feb 24, 2025
887e3a5
Add appliance entry validation (#3494)
mukeshmv Feb 27, 2025
8c778bf
[smartswitch] Add support for ENI Based Forwarding (#3398)
vivekrnv Feb 27, 2025
a0fcac9
Initialize Port oper error map only once (#3538)
prgeor Mar 3, 2025
1b2a8e6
[copp]: Use non-zero trap priority for default trap group (#3502)
prabhataravind Mar 3, 2025
7a965ca
Optimize counter initialization by reducing the number of bulk counte…
stephenxs Mar 4, 2025
74e9e63
Prevent lossless profile creation for 0m cable
jianyuewu Feb 24, 2025
3494eae
Keep PGs, remove losslesss profiles when 0m cable
jianyuewu Mar 5, 2025
439ac82
Remove unnecessary prints and refactor UT
jianyuewu Mar 5, 2025
6a93999
Update log level to info
jianyuewu Mar 7, 2025
4b0bb1c
Merge branch 'master' into skip_0m_profile
jianyuewu Mar 7, 2025
8447919
Update test_macsec.py (#3549)
Pterosaur Mar 10, 2025
da18966
[MCLAG] Fix a race condition when moving MAC addresses to MCLAG peer …
puffc Mar 10, 2025
8398865
Update gitignore for fabricmgrd, stpmgrd, and the p4orch_tests binari…
theasianpianist Mar 11, 2025
ae4789c
Use software_bfd instead of switch_type. (#3525)
dypet Mar 11, 2025
92be63e
Merge branch 'master' into skip_0m_profile
jianyuewu Mar 12, 2025
a07838d
[orchagent] Do not restore port admin if port admin is configured (#3…
PJHsieh Mar 12, 2025
f763d20
Merge branch 'master' into skip_0m_profile
jianyuewu Mar 13, 2025
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
8 changes: 8 additions & 0 deletions .azure-pipelines/docker-sonic-vs/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ elif [ "$HWSKU" == "DPU-2P" ]; then
cp /usr/share/sonic/hwsku/sai_dpu_2p.profile /usr/share/sonic/hwsku/sai.profile
fi

if [ "$BFDOFFLOAD" == "false" ]; then
if ! grep -q "SAI_VS_BFD_OFFLOAD_SUPPORTED=" /usr/share/sonic/hwsku/sai.profile; then
echo 'SAI_VS_BFD_OFFLOAD_SUPPORTED=false' >> /usr/share/sonic/hwsku/sai.profile
else
sed -i "s/SAI_VS_BFD_OFFLOAD_SUPPORTED.*/SAI_VS_BFD_OFFLOAD_SUPPORTED=false/g" /usr/share/sonic/hwsku/sai.profile
fi
fi

mkdir -p /etc/swss/config.d/

rm -f /var/run/rsyslogd.pid
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ cfgmgr/sflowmgrd
cfgmgr/macsecmgrd
cfgmgr/coppmgrd
cfgmgr/tunnelmgrd
cfgmgr/fabricmgrd
cfgmgr/stpmgrd
fpmsyncd/fpmsyncd
gearsyncd/gearsyncd
mclagsyncd/mclagsyncd
Expand Down Expand Up @@ -94,3 +96,4 @@ tests/tests.log
tests/tests.trs
tests/mock_tests/**/*log
tests/mock_tests/**/*trs
orchagent/p4orch/tests/p4orch_tests
20 changes: 20 additions & 0 deletions cfgmgr/buffermgrdyn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,26 @@ task_process_status BufferMgrDynamic::refreshPgsForPort(const string &port, cons
continue;
}

// If cable len is 0m, remove lossless PG, keep lossy PG.
if (cable_length == "0m" && portPg.lossless)
{
if (oldProfile.empty())
{
SWSS_LOG_INFO("No lossless profile found for port %s when cable length is set to '0m'.", port.c_str());
continue;
}

if (m_bufferProfileLookup.find(oldProfile) != m_bufferProfileLookup.end())
{
m_bufferProfileLookup[oldProfile].port_pgs.erase(key);
}

updateBufferObjectToDb(key, oldProfile, false);
profilesToBeReleased.insert(oldProfile);
portPg.running_profile_name.clear();
continue;
}

string threshold;
// Calculate new headroom size
if (portPg.static_configured)
Expand Down
2 changes: 2 additions & 0 deletions orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ orchagent_SOURCES = \
response_publisher.cpp \
nvgreorch.cpp \
zmqorch.cpp \
dash/dashenifwdorch.cpp \
dash/dashenifwdinfo.cpp \
dash/dashorch.cpp \
dash/dashrouteorch.cpp \
dash/dashvnetorch.cpp \
Expand Down
12 changes: 12 additions & 0 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ extern Directory<Orch*> gDirectory;

const int TCP_PROTOCOL_NUM = 6; // TCP protocol number

#define MAC_EXACT_MATCH "ff:ff:ff:ff:ff:ff"

acl_rule_attr_lookup_t aclMatchLookup =
{
{ MATCH_IN_PORTS, SAI_ACL_ENTRY_ATTR_FIELD_IN_PORTS },
Expand Down Expand Up @@ -79,6 +81,8 @@ acl_rule_attr_lookup_t aclMatchLookup =
{ MATCH_TUNNEL_VNI, SAI_ACL_ENTRY_ATTR_FIELD_TUNNEL_VNI },
{ MATCH_INNER_ETHER_TYPE, SAI_ACL_ENTRY_ATTR_FIELD_INNER_ETHER_TYPE },
{ MATCH_INNER_IP_PROTOCOL, SAI_ACL_ENTRY_ATTR_FIELD_INNER_IP_PROTOCOL },
{ MATCH_INNER_SRC_MAC, SAI_ACL_ENTRY_ATTR_FIELD_INNER_SRC_MAC },
{ MATCH_INNER_DST_MAC, SAI_ACL_ENTRY_ATTR_FIELD_INNER_DST_MAC },
{ MATCH_INNER_L4_SRC_PORT, SAI_ACL_ENTRY_ATTR_FIELD_INNER_L4_SRC_PORT },
{ MATCH_INNER_L4_DST_PORT, SAI_ACL_ENTRY_ATTR_FIELD_INNER_L4_DST_PORT },
{ MATCH_BTH_OPCODE, SAI_ACL_ENTRY_ATTR_FIELD_BTH_OPCODE},
Expand Down Expand Up @@ -648,6 +652,7 @@ void AclRule::TunnelNH::clear()
vxlan_orch->removeNextHopTunnel(tunnel_name, endpoint_ip, mac, vni);
}


string AclTableType::getName() const
{
return m_name;
Expand Down Expand Up @@ -908,6 +913,13 @@ bool AclRule::validateAddMatch(string attr_name, string attr_value)
{
matchData.data.booldata = (attr_name == "true");
}
else if (attr_name == MATCH_INNER_DST_MAC || attr_name == MATCH_INNER_SRC_MAC)
{
swss::MacAddress mac(attr_value);
swss::MacAddress mask(MAC_EXACT_MATCH);
memcpy(matchData.data.mac, mac.getMac(), sizeof(sai_mac_t));
memcpy(matchData.mask.mac, mask.getMac(), sizeof(sai_mac_t));
}
else if (attr_name == MATCH_IN_PORTS)
{
auto ports = tokenize(attr_value, ',');
Expand Down
2 changes: 2 additions & 0 deletions orchagent/aclorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
#define MATCH_INNER_IP_PROTOCOL "INNER_IP_PROTOCOL"
#define MATCH_INNER_L4_SRC_PORT "INNER_L4_SRC_PORT"
#define MATCH_INNER_L4_DST_PORT "INNER_L4_DST_PORT"
#define MATCH_INNER_SRC_MAC "INNER_SRC_MAC"
#define MATCH_INNER_DST_MAC "INNER_DST_MAC"
#define MATCH_BTH_OPCODE "BTH_OPCODE"
#define MATCH_AETH_SYNDROME "AETH_SYNDROME"
#define MATCH_TUNNEL_TERM "TUNNEL_TERM"
Expand Down
55 changes: 53 additions & 2 deletions orchagent/bfdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ void BfdOrch::doTask(Consumer &consumer)
SWSS_LOG_ENTER();
BgpGlobalStateOrch* bgp_global_state_orch = gDirectory.get<BgpGlobalStateOrch*>();
bool tsa_enabled = false;
bool use_software_bfd = true;
if (bgp_global_state_orch)
{
tsa_enabled = bgp_global_state_orch->getTsaState();
use_software_bfd = bgp_global_state_orch->getSoftwareBfd();
}
auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
Expand All @@ -128,7 +130,8 @@ void BfdOrch::doTask(Consumer &consumer)

if (op == SET_COMMAND)
{
if (gMySwitchType == "dpu") {
if (use_software_bfd)
{
//program entry in software BFD table
m_stateSoftBfdSessionTable->set(createStateDBKey(key), data);
it = consumer.m_toSync.erase(it);
Expand Down Expand Up @@ -176,7 +179,8 @@ void BfdOrch::doTask(Consumer &consumer)
}
else if (op == DEL_COMMAND)
{
if (gMySwitchType == "dpu") {
if (use_software_bfd)
{
//delete entry from software BFD table
m_stateSoftBfdSessionTable->del(createStateDBKey(key));
it = consumer.m_toSync.erase(it);
Expand Down Expand Up @@ -704,6 +708,8 @@ BgpGlobalStateOrch::BgpGlobalStateOrch(DBConnector *db, string tableName):
{
SWSS_LOG_ENTER();
tsa_enabled = false;
bool ipv6 = true;
bfd_offload = (offload_supported(!ipv6) && offload_supported(ipv6));
}

BgpGlobalStateOrch::~BgpGlobalStateOrch(void)
Expand All @@ -716,6 +722,51 @@ bool BgpGlobalStateOrch::getTsaState()
SWSS_LOG_ENTER();
return tsa_enabled;
}

bool BgpGlobalStateOrch::getSoftwareBfd()
{
SWSS_LOG_ENTER();
return !bfd_offload;
}

bool BgpGlobalStateOrch::offload_supported(bool get_ipv6)
{
sai_attribute_t attr;
sai_status_t status;
sai_attr_capability_t capability;

attr.id = SAI_SWITCH_ATTR_SUPPORTED_IPV4_BFD_SESSION_OFFLOAD_TYPE;
if(get_ipv6)
{
attr.id = SAI_SWITCH_ATTR_SUPPORTED_IPV6_BFD_SESSION_OFFLOAD_TYPE;
}

status = sai_query_attribute_capability(gSwitchId, SAI_OBJECT_TYPE_SWITCH,
attr.id, &capability);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Unable to query BFD offload capability");
return false;
}
if (!capability.set_implemented)
{
SWSS_LOG_ERROR("BFD offload type not implemented");
return false;
}

uint32_t list[1] = { 1 };
attr.value.u32list.count = 1;
attr.value.u32list.list = list;
status = sai_switch_api->get_switch_attribute(gSwitchId, 1, &attr);
if(status == SAI_STATUS_SUCCESS && attr.value.u32list.count > 0)
{
SWSS_LOG_INFO("BFD offload type: %d", attr.value.u32list.list[0]);
return (attr.value.u32list.list[0] != SAI_BFD_SESSION_OFFLOAD_TYPE_NONE);
}
SWSS_LOG_ERROR("Could not get supported BFD offload type, rv: %d", status);
return false;
}

void BgpGlobalStateOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();
Expand Down
3 changes: 3 additions & 0 deletions orchagent/bfdorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ class BgpGlobalStateOrch : public Orch
BgpGlobalStateOrch(swss::DBConnector *db, std::string tableName);
virtual ~BgpGlobalStateOrch(void);
bool getTsaState();
bool getSoftwareBfd();

private:
bool tsa_enabled;
bool bfd_offload;
bool offload_supported(bool get_ipv6);

};
#endif /* SWSS_BFDORCH_H */
3 changes: 3 additions & 0 deletions orchagent/bufferorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1858,6 +1858,7 @@ void BufferOrch::doTask()
continue;
consumer->drain();
}
gPortsOrch->flushCounters();
}

void BufferOrch::doTask(Consumer &consumer)
Expand Down Expand Up @@ -1921,4 +1922,6 @@ void BufferOrch::doTask(Consumer &consumer)
{
(this->*(m_bufferFlushHandlerMap[map_type_name]))(consumer);
}

gPortsOrch->flushCounters();
}
10 changes: 7 additions & 3 deletions orchagent/copporch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,17 @@ void CoppOrch::initDefaultTrapIds()
attr.value.oid = m_trap_group_map[default_trap_group];
trap_id_attrs.push_back(attr);

/* Mellanox platform doesn't support trap priority setting */
/* Marvell platform doesn't support trap priority. */
/*
* Use a default trap priority > 0 to avoid undesirable packet trapping
* behavior on some platforms that use 0 as default SAI-internal priority.
* Note: Mellanox and Marvell platforms don't support trap priority setting.
*/

char *platform = getenv("platform");
if (!platform || (!strstr(platform, MLNX_PLATFORM_SUBSTRING) && (!strstr(platform, MRVL_PRST_PLATFORM_SUBSTRING))))
{
attr.id = SAI_HOSTIF_TRAP_ATTR_TRAP_PRIORITY;
attr.value.u32 = 0;
attr.value.u32 = 1;
trap_id_attrs.push_back(attr);
}

Expand Down
Loading