Skip to content

Commit 1eb2daa

Browse files
authored
Merge branch 'master' into bhouse-nexthop/dot3stats
2 parents 8bc6c3a + e304021 commit 1eb2daa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3606
-692
lines changed

.azure-pipelines/build-docker-sonic-vs-template.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,18 @@ jobs:
146146
path: $(Build.ArtifactStagingDirectory)/download
147147
patterns: '**/target/debs/${{ parameters.debian_version }}/framework_*.deb'
148148
displayName: "Download sonic-buildimage sonic-framework package"
149-
149+
- task: DownloadPipelineArtifact@2
150+
inputs:
151+
source: specific
152+
project: build
153+
pipeline: sonic-net.sonic-platform-vpp
154+
artifact: vpp
155+
runVersion: 'latestFromBranch'
156+
runBranch: 'refs/heads/main'
157+
allowPartiallySucceededBuilds: true
158+
path: $(Build.ArtifactStagingDirectory)/download
159+
displayName: "Download sonic platform-vpp deb packages"
160+
condition: eq('${{ parameters.arch }}', 'amd64')
150161
- script: |
151162
set -ex
152163
echo $(Build.DefinitionName).$(Build.BuildNumber)

.azure-pipelines/build-template.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,45 @@ jobs:
179179
set -ex
180180
cd download
181181
sudo dpkg -i $(find common -type f -name '*.deb')
182+
cd ..
183+
workingDirectory: $(Build.ArtifactStagingDirectory)
184+
displayName: "Install libnl3"
185+
- task: DownloadPipelineArtifact@2
186+
inputs:
187+
source: specific
188+
project: build
189+
pipeline: sonic-net.sonic-platform-vpp
190+
artifact: vpp
191+
runVersion: 'latestFromBranch'
192+
runBranch: 'refs/heads/main'
193+
allowPartiallySucceededBuilds: true
194+
path: $(Build.ArtifactStagingDirectory)/download
195+
displayName: "Download sonic platform-vpp deb packages"
196+
condition: eq('${{ parameters.arch }}', 'amd64')
197+
- script: |
198+
set -ex
199+
sudo env VPP_INSTALL_SKIP_SYSCTL=1 dpkg -i download/libvppinfra-dev_*_${{ parameters.arch }}.deb
200+
sudo env VPP_INSTALL_SKIP_SYSCTL=1 dpkg -i download/libvppinfra_*_${{ parameters.arch }}.deb
201+
sudo env VPP_INSTALL_SKIP_SYSCTL=1 dpkg -i download/vpp_*_${{ parameters.arch }}.deb
202+
sudo env VPP_INSTALL_SKIP_SYSCTL=1 dpkg -i download/vpp-crypto-engines_*_${{ parameters.arch }}.deb
203+
sudo env VPP_INSTALL_SKIP_SYSCTL=1 dpkg -i download/vpp-dbg_*_${{ parameters.arch }}.deb
204+
sudo env VPP_INSTALL_SKIP_SYSCTL=1 dpkg -i download/vpp-dev_*_${{ parameters.arch }}.deb
205+
sudo env VPP_INSTALL_SKIP_SYSCTL=1 dpkg -i download/vpp-plugin-core_*_${{ parameters.arch }}.deb
206+
sudo env VPP_INSTALL_SKIP_SYSCTL=1 dpkg -i download/vpp-plugin-devtools_*_${{ parameters.arch }}.deb
207+
sudo env VPP_INSTALL_SKIP_SYSCTL=1 dpkg -i download/vpp-plugin-dpdk_*_${{ parameters.arch }}.deb
208+
sudo env VPP_INSTALL_SKIP_SYSCTL=1 dpkg -i download/python3-vpp-api_*_${{ parameters.arch }}.deb
209+
workingDirectory: $(Build.ArtifactStagingDirectory)
210+
displayName: "Install sonic platform-vpp packages"
211+
condition: eq('${{ parameters.arch }}', 'amd64')
212+
- script: |
213+
set -ex
214+
cd download
182215
sudo dpkg -i $(find swsscommon -type f -name '*.deb')
183216
sudo dpkg -i $(find sairedis -type f -name '*.deb')
184217
cd ..
185218
rm -rf download
186219
workingDirectory: $(Build.ArtifactStagingDirectory)
187-
displayName: "Install libnl3, sonic swss common and sairedis"
220+
displayName: "Install sonic swss common and sairedis"
188221
- script: |
189222
set -ex
190223
tar czf pytest.tgz tests

.azure-pipelines/docker-sonic-vs/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@ RUN dpkg --purge python3-swsscommon sonic-db-cli libsaimetadata libsairedis libs
1717

1818
RUN apt-get update
1919

20+
# vpp package configure requires to set:
21+
# permission denied on key "vm.nr_hugepages"
22+
# permission denied on key "vm.hugetlb_shm_group"
23+
# permission denied on key "fs.protected_fifos"
24+
# permission denied on key "fs.protected_hardlinks"
25+
# permission denied on key "fs.protected_regular"
26+
# permission denied on key "fs.protected_symlinks"
27+
28+
# which can't be done during "docker build" command
29+
# so let's put "true" command as sysctl, and after install let's bring it back
30+
31+
RUN cp /usr/sbin/sysctl /usr/sbin/sysctl.org
32+
RUN cp /usr/bin/true /usr/sbin/sysctl
33+
34+
RUN apt install -y $(ls /debs/*.deb | grep vpp)
35+
36+
RUN mv /usr/sbin/sysctl.org /usr/sbin/sysctl
37+
2038
RUN apt install -y /debs/libdashapi_1.0.0_amd64.deb \
2139
/debs/libswsscommon_1.0.0_amd64.deb \
2240
/debs/python3-swsscommon_1.0.0_amd64.deb \

cfgmgr/intfmgr.cpp

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ void IntfMgr::addLoopbackIntf(const string &alias)
198198
stringstream cmd;
199199
string res;
200200

201-
cmd << IP_CMD << " link add " << alias << " mtu " << LOOPBACK_DEFAULT_MTU_STR << " type dummy && ";
202-
cmd << IP_CMD << " link set " << alias << " up";
201+
cmd << IP_CMD << " link add " << alias << " mtu " << LOOPBACK_DEFAULT_MTU_STR << " type dummy";
203202
int ret = swss::exec(cmd.str(), res);
204203
if (ret)
205204
{
@@ -487,28 +486,43 @@ void IntfMgr::updateSubIntfAdminStatus(const string &alias, const string &admin)
487486
}
488487
}
489488

490-
std::string IntfMgr::setHostSubIntfAdminStatus(const string &alias, const string &admin_status, const string &parent_admin_status)
489+
bool IntfMgr::setIntfAdminStatus(const string &alias, const string &admin_status)
491490
{
492491
stringstream cmd;
493492
string res, cmd_str;
494493

494+
SWSS_LOG_INFO("intf %s admin_status: %s", alias.c_str(), admin_status.c_str());
495+
cmd << IP_CMD " link set " << shellquote(alias) << " " << shellquote(admin_status);
496+
cmd_str = cmd.str();
497+
int ret = swss::exec(cmd_str, res);
498+
if (ret && !isIntfStateOk(alias))
499+
{
500+
// Can happen when a DEL notification is sent by portmgrd immediately followed by a new SET notification
501+
SWSS_LOG_WARN("Setting admin_status to %s netdev failed with cmd:%s, rc:%d, error:%s",
502+
alias.c_str(), cmd_str.c_str(), ret, res.c_str());
503+
return false;
504+
}
505+
else if (ret)
506+
{
507+
throw runtime_error(cmd_str + " : " + res);
508+
}
509+
return true;
510+
}
511+
512+
std::string IntfMgr::setHostSubIntfAdminStatus(const string &alias, const string &admin_status, const string &parent_admin_status)
513+
{
495514
if (parent_admin_status == "up" || admin_status == "down")
496515
{
497-
SWSS_LOG_INFO("subintf %s admin_status: %s", alias.c_str(), admin_status.c_str());
498-
cmd << IP_CMD " link set " << shellquote(alias) << " " << shellquote(admin_status);
499-
cmd_str = cmd.str();
500-
int ret = swss::exec(cmd_str, res);
501-
if (ret && !isIntfStateOk(alias))
516+
try
502517
{
503-
// Can happen when a DEL notification is sent by portmgrd immediately followed by a new SET notification
504-
SWSS_LOG_WARN("Setting admin_status to %s netdev failed with cmd:%s, rc:%d, error:%s",
505-
alias.c_str(), cmd_str.c_str(), ret, res.c_str());
518+
setIntfAdminStatus(alias, admin_status);
519+
return admin_status;
506520
}
507-
else if (ret)
521+
catch (const std::runtime_error &e)
508522
{
509-
throw runtime_error(cmd_str + " : " + res);
523+
SWSS_LOG_NOTICE("Set Host subinterface %s admin_status set failure %s failure. Runtime error: %s", alias.c_str(), admin_status.c_str(), e.what());
524+
throw;
510525
}
511-
return admin_status;
512526
}
513527
else
514528
{
@@ -843,6 +857,29 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
843857
m_loopbackIntfList.insert(alias);
844858
SWSS_LOG_INFO("Added %s loopback interface", alias.c_str());
845859
}
860+
861+
if (adminStatus.empty())
862+
{
863+
adminStatus = "up";
864+
}
865+
else if (adminStatus != "up" && adminStatus != "down")
866+
{
867+
SWSS_LOG_WARN("Got incorrect value for admin_status as %s for intf %s, defaulting as up", adminStatus.c_str(), alias.c_str());
868+
adminStatus = "up";
869+
}
870+
871+
try
872+
{
873+
if (setIntfAdminStatus(alias, adminStatus))
874+
{
875+
FieldValueTuple newAdminFvTuple("admin_status", adminStatus);
876+
data.push_back(newAdminFvTuple);
877+
}
878+
}
879+
catch (const std::runtime_error &e)
880+
{
881+
SWSS_LOG_WARN("Lo interface ip link set admin status %s failure. Runtime error: %s", adminStatus.c_str(), e.what());
882+
}
846883
}
847884
else
848885
{

cfgmgr/intfmgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class IntfMgr : public Orch
6464
std::string getIntfMtu(const std::string &alias);
6565
void addHostSubIntf(const std::string&intf, const std::string &subIntf, const std::string &vlan);
6666
std::string setHostSubIntfMtu(const std::string &alias, const std::string &mtu, const std::string &parent_mtu);
67+
bool setIntfAdminStatus(const std::string &alias, const std::string &admin_status);
6768
std::string setHostSubIntfAdminStatus(const std::string &alias, const std::string &admin_status, const std::string &parent_admin_status);
6869
void removeHostSubIntf(const std::string &subIntf);
6970
void setSubIntfStateOk(const std::string &alias);

cfgmgr/stpmgr.cpp

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -410,95 +410,109 @@ void StpMgr::doStpVlanPortTask(Consumer &consumer)
410410
}
411411
}
412412

413-
void StpMgr::processStpPortAttr(const string op, vector<FieldValueTuple>&tupEntry, const string intfName)
413+
void StpMgr::processStpPortAttr(const string op,
414+
vector<FieldValueTuple> &tupEntry,
415+
const string intfName)
414416
{
415-
STP_PORT_CONFIG_MSG *msg;
417+
STP_PORT_CONFIG_MSG *msg = nullptr;
416418
uint32_t len = 0;
417419
int vlanCnt = 0;
418420
vector<VLAN_ATTR> vlan_list;
419421

422+
// If we're setting this port's attributes, retrieve the list of VLANs for it.
420423
if (op == SET_COMMAND)
424+
{
421425
vlanCnt = getAllPortVlan(intfName, vlan_list);
426+
}
422427

423-
len = (uint32_t)(sizeof(STP_PORT_CONFIG_MSG) + (vlanCnt * sizeof(VLAN_ATTR)));
424-
msg = (STP_PORT_CONFIG_MSG *)calloc(1, len);
428+
// Allocate enough space for STP_PORT_CONFIG_MSG + all VLAN_ATTR entries.
429+
len = static_cast<uint32_t>(
430+
sizeof(STP_PORT_CONFIG_MSG) + (vlanCnt * sizeof(VLAN_ATTR))
431+
);
432+
msg = static_cast<STP_PORT_CONFIG_MSG *>(calloc(1, len));
425433
if (!msg)
426434
{
427-
SWSS_LOG_ERROR("mem failed for %s", intfName.c_str());
435+
SWSS_LOG_ERROR("calloc failed for interface %s", intfName.c_str());
428436
return;
429437
}
430438

431-
strncpy(msg->intf_name, intfName.c_str(), IFNAMSIZ-1);
432-
msg->count = vlanCnt;
433-
SWSS_LOG_INFO("Vlan count %d", vlanCnt);
439+
// Copy interface name and VLAN count into the message.
440+
strncpy(msg->intf_name, intfName.c_str(), IFNAMSIZ - 1);
441+
msg->count = vlanCnt;
442+
SWSS_LOG_INFO("VLAN count for %s is %d", intfName.c_str(), vlanCnt);
434443

435-
if(msg->count)
444+
// If there are VLANs, copy them into the message structure.
445+
if (msg->count > 0)
436446
{
437-
int i = 0;
438-
#pragma GCC diagnostic push
439-
#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
440-
VLAN_ATTR *attr = msg->vlan_list;
441-
#pragma GCC diagnostic pop
442-
for (auto p = vlan_list.begin(); p != vlan_list.end(); p++)
447+
for (int i = 0; i < msg->count; i++)
443448
{
444-
attr[i].inst_id = p->inst_id;
445-
attr[i].mode = p->mode;
446-
SWSS_LOG_DEBUG("Inst:%d Mode:%d", p->inst_id, p->mode);
447-
i++;
449+
msg->vlan_list[i].inst_id = vlan_list[i].inst_id;
450+
msg->vlan_list[i].mode = vlan_list[i].mode;
451+
msg->vlan_list[i].vlan_id = vlan_list[i].vlan_id;
452+
SWSS_LOG_DEBUG("Inst:%d Mode:%d",
453+
vlan_list[i].inst_id,
454+
vlan_list[i].mode);
448455
}
449456
}
450457

458+
// Populate message fields based on the operation (SET or DEL).
451459
if (op == SET_COMMAND)
452460
{
453-
msg->opcode = STP_SET_COMMAND;
454-
msg->priority = -1;
461+
msg->opcode = STP_SET_COMMAND;
462+
msg->priority = -1; // Default priority unless specified
455463

456-
for (auto i : tupEntry)
464+
for (auto &fvt : tupEntry)
457465
{
458-
SWSS_LOG_DEBUG("Field: %s Val: %s", fvField(i).c_str(), fvValue(i).c_str());
459-
if (fvField(i) == "enabled")
466+
const auto &field = fvField(fvt);
467+
const auto &value = fvValue(fvt);
468+
469+
SWSS_LOG_DEBUG("Field: %s, Value: %s", field.c_str(), value.c_str());
470+
471+
if (field == "enabled")
460472
{
461-
msg->enabled = (fvValue(i) == "true") ? 1 : 0;
473+
msg->enabled = (value == "true") ? 1 : 0;
462474
}
463-
else if (fvField(i) == "root_guard")
475+
else if (field == "root_guard")
464476
{
465-
msg->root_guard = (fvValue(i) == "true") ? 1 : 0;
477+
msg->root_guard = (value == "true") ? 1 : 0;
466478
}
467-
else if (fvField(i) == "bpdu_guard")
479+
else if (field == "bpdu_guard")
468480
{
469-
msg->bpdu_guard = (fvValue(i) == "true") ? 1 : 0;
481+
msg->bpdu_guard = (value == "true") ? 1 : 0;
470482
}
471-
else if (fvField(i) == "bpdu_guard_do_disable")
483+
else if (field == "bpdu_guard_do_disable")
472484
{
473-
msg->bpdu_guard_do_disable = (fvValue(i) == "true") ? 1 : 0;
485+
msg->bpdu_guard_do_disable = (value == "true") ? 1 : 0;
474486
}
475-
else if (fvField(i) == "path_cost")
487+
else if (field == "path_cost")
476488
{
477-
msg->path_cost = stoi(fvValue(i).c_str());
489+
msg->path_cost = stoi(value);
478490
}
479-
else if (fvField(i) == "priority")
491+
else if (field == "priority")
480492
{
481-
msg->priority = stoi(fvValue(i).c_str());
493+
msg->priority = stoi(value);
482494
}
483-
else if (fvField(i) == "portfast")
495+
else if (field == "portfast")
484496
{
485-
msg->portfast = (fvValue(i) == "true") ? 1 : 0;
497+
msg->portfast = (value == "true") ? 1 : 0;
486498
}
487-
else if (fvField(i) == "uplink_fast")
499+
else if (field == "uplink_fast")
488500
{
489-
msg->uplink_fast = (fvValue(i) == "true") ? 1 : 0;
501+
msg->uplink_fast = (value == "true") ? 1 : 0;
490502
}
491503
}
492504
}
493505
else if (op == DEL_COMMAND)
494506
{
495-
msg->opcode = STP_DEL_COMMAND;
507+
msg->opcode = STP_DEL_COMMAND;
496508
msg->enabled = 0;
497509
}
498510

499-
sendMsgStpd(STP_PORT_CONFIG, len, (void *)msg);
500-
if (msg)
501-
free(msg);
511+
// Send the fully prepared message to the STP daemon.
512+
sendMsgStpd(STP_PORT_CONFIG, len, reinterpret_cast<void *>(msg));
513+
514+
// Clean up.
515+
free(msg);
502516
}
503517

504518
void StpMgr::doStpPortTask(Consumer &consumer)

0 commit comments

Comments
 (0)