Skip to content

Commit 1b6a42a

Browse files
authored
Merge branch 'sonic-net:master' into vrrp_orch
2 parents c7a0f8e + 0929d86 commit 1b6a42a

40 files changed

+1482
-180
lines changed

README.md

+73-31
Original file line numberDiff line numberDiff line change
@@ -21,55 +21,97 @@ The SWitch State Service (SWSS) is a collection of software that provides a data
2121

2222
## Getting Started
2323

24-
### Install
24+
### Prerequisites
25+
26+
Install the following dependencies:
27+
```
28+
sudo apt install redis-server
29+
sudo apt install libhiredis0.14
30+
sudo apt install libzmq5 libzmq3-dev
31+
sudo apt install libboost-serialization1.74.0
32+
sudo apt install libboost1.71-dev
33+
sudo apt install libasan6
34+
```
35+
**Note:** If your are using Ubuntu 18.04, install `libhiredis0.13` instead.
36+
37+
Visit the [official sonic-buildimage Azure pipeline for the VS platform](https://dev.azure.com/mssonic/build/_build?definitionId=142&view=branches) and choose the branch that matches the sonic-swss branch you are trying to build or install. Then select the latest successful build.
38+
From the Summary tab, access build artifacts.
39+
<img width="1048" alt="image" src="https://github.com/user-attachments/assets/faa6f08d-788b-4801-8439-3f31a52efaa1">
40+
Download the folder `sonic-buildimage.vs/target/debs/{your host machine's Debian code name}`. You can check the Debian code name of your machine by running `cat /etc/debian_version`.
41+
<img width="1022" alt="image" src="https://github.com/user-attachments/assets/1ad750eb-252c-4913-b14f-91b5533a1295">
42+
Extract the downloaded zip file using `unzip sonic-buildimage.vs.zip`. Then navigate to `sonic-buildimage.vs/target/debs/{Debian code name}/` and install the following Debian packages:
43+
```
44+
sudo dpkg -i libdashapi_1.0.0_amd64.deb libnl-3-200_3.5.0-1_amd64.deb libnl-3-dev_3.5.0-1_amd64.deb libnl-cli-3-200_3.5.0-1_amd64.deb libnl-cli-3-dev_3.5.0-1_amd64.deb libnl-genl-3-200_3.5.0-1_amd64.deb libnl-genl-3-dev_3.5.0-1_amd64.deb libnl-nf-3-200_3.5.0-1_amd64.deb libnl-nf-3-dev_3.5.0-1_amd64.deb libnl-route-3-200_3.5.0-1_amd64.deb libnl-route-3-dev_3.5.0-1_amd64.deb libprotobuf32_3.21.12-3_amd64.deb libsaimetadata_1.0.0_amd64.deb libsaimetadata-dev_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb libsairedis-dev_1.0.0_amd64.deb libsaivs_1.0.0_amd64.deb libsaivs-dev_1.0.0_amd64.deb libswsscommon_1.0.0_amd64.deb libswsscommon-dev_1.0.0_amd64.deb libteam5_1.31-1_amd64.deb libteamdctl0_1.31-1_amd64.deb libyang_1.0.73_amd64.deb libyang-dev_1.0.73_amd64.deb python3-swsscommon_1.0.0_amd64.deb
45+
```
46+
**Note:** You can also [build these packages yourself (for the VS platform)](https://github.com/sonic-net/sonic-buildimage/blob/master/README.md).
47+
48+
Now, you can either directly install the SONiC SWSS package or you can build it from source and then install it. To install the SONiC SWSS package that is already in `sonic-buildimage.vs/target/debs/{Debian code name}/`, simply run the following command:
49+
```
50+
sudo dpkg -i swss_1.0.0_amd64.deb
51+
```
2552

26-
Before installing, add key and package sources:
53+
#### Install from Source
2754

28-
sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
29-
echo 'deb http://apt-mo.trafficmanager.net/repos/sonic/ trusty main' | sudo tee -a /etc/apt/sources.list.d/sonic.list
30-
sudo apt-get update
55+
Install build dependencies:
56+
```
57+
sudo apt install libtool
58+
sudo apt install autoconf automake
59+
sudo apt install dh-exec
60+
sudo apt install nlohmann-json3-dev
61+
sudo apt install libgmock-dev
62+
```
3163

32-
Install dependencies:
64+
Clone the `sonic-swss` repository on your host machine: `git clone https://github.com/sonic-net/sonic-swss.git`.
3365

34-
sudo apt-get install redis-server -t trusty
35-
sudo apt-get install libhiredis0.13 -t trusty
36-
sudo apt-get install libzmq5 libzmq3-dev
37-
38-
Install building dependencies:
66+
Make sure that SAI header files exist in `/usr/include/sai`. Since you have already installed `libsairedis-dev`, `libsaimetadata-dev`, and `libsaivs-dev`, this should already be the case. If you have compiled `libsairedis` yourself, make sure that the SAI header files are copied to `/usr/include/sai`.
3967

40-
sudo apt-get install libtool
41-
sudo apt-get install autoconf automake
42-
sudo apt-get install dh-exec
68+
You can compile and install from source using:
69+
```
70+
./autogen.sh
71+
./configure
72+
make && sudo make install
73+
```
74+
**Note:** This will NOT run the mock tests located under `tests/mock_tests`.
4375

44-
There are a few different ways you can install SONiC-SWSS.
76+
You can also build a debian package using:
77+
```
78+
./autogen.sh
79+
fakeroot debian/rules binary
80+
```
81+
## Common issues
4582

46-
#### Install from Debian Repo
83+
#### Cannot find `libboost-serialization1.74.0`
4784

48-
For your convenience, you can install prepared packages on Debian Jessie:
85+
Unfortunately, `libboost-serialization1.74.0` is not officially supported on Ubuntu 20.04 (focal) even though it is supported on Debian 11 (bullseye). Therefore, you must build this package from source. You can use a script similar to [this one](https://github.com/ulikoehler/deb-buildscripts/blob/master/deb-boost.sh), but you only need to create a package for the Boost serialization library. You should also make sure that the generated package is named `libboost-serialization1.74.0`. After the package is created, you can install it by running `sudo dpkg -i libboost-serialization1.74.0_1.74.0_amd64.deb`.
4986

50-
sudo apt-get install swss
87+
#### Dependency issue when installing `libzmq3-dev`
5188

52-
#### Install from Source
89+
If you cannot install `libzmq3-dev` because of dependency issues, please check the version of `libkrb5` packages installed on your host machine:
90+
```
91+
sudo dpkg -l | grep "libkrb5"
92+
```
93+
If the version is not `1.17-6ubuntu4.7`, then you need to install the correct version:
5394

54-
Checkout the source: `git clone https://github.com/sonic-net/sonic-swss.git` and install it yourself.
95+
sudo apt install libkrb5support0=1.17-6ubuntu4.7
96+
sudo apt install libzmq3-dev
5597

56-
Get SAI header files into /usr/include/sai. Put the SAI header files that you use to compile
57-
libsairedis into /usr/include/sai
98+
**Warning:** This may remove many packages that are already installed on your system. Please take note of what is being removed.
5899

59-
Install prerequisite packages:
100+
**Note:** Do NOT install `*krb5*` packages that are located in the `sonic-buildimage.vs` folder that you downloaded. These packages have a higher version and will cause dependency issues.
60101

61-
sudo apt-get install libswsscommon libswsscommon-dev libsairedis libsairedis-dev
102+
#### Dependency issues when installing some package
62103

63-
You can compile and install from source using:
104+
If you run into dependency issues during the installation of a package, you can run `sudo apt -f install` to fix the issue. But note that if `apt` is unable to fix the dependency problem, it will attempt to remove the broken package(s).
64105

65-
./autogen.sh
66-
./configure
67-
make && sudo make install
106+
#### Too many open files
68107

69-
You can also build a debian package using:
108+
If you get a C++ exception with the description "Too many open files" during the mock tests, you should check the maximum number of open files that are permitted on your system:
109+
```
110+
ulimit -a | grep "open files"
111+
```
112+
You can increase it by executing this command: `ulimit -n 8192`. Feel free to change `8192`. This value worked fine for me.
70113

71-
./autogen.sh
72-
fakeroot debian/rules binary
114+
**Note:** This change is only valid for the current terminal session. If you want a persistent change, append `ulimit -n 8192` to `~/.bashrc`.
73115

74116
## Need Help?
75117

cfgmgr/vlanmgr.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ VlanMgr::VlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c
7979
// /sbin/bridge vlan del vid 1 dev Bridge self;
8080
// /sbin/ip link del dummy 2>/dev/null;
8181
// /sbin/ip link add dummy type dummy &&
82-
// /sbin/ip link set dummy master Bridge"
82+
// /sbin/ip link set dummy master Bridge &&
83+
// /sbin/ip link set dummy up"
8384

8485
const std::string cmds = std::string("")
8586
+ BASH_CMD + " -c \""
@@ -90,7 +91,8 @@ VlanMgr::VlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c
9091
+ BRIDGE_CMD + " vlan del vid " + DEFAULT_VLAN_ID + " dev " + DOT1Q_BRIDGE_NAME + " self; "
9192
+ IP_CMD + " link del dev dummy 2>/dev/null; "
9293
+ IP_CMD + " link add dummy type dummy && "
93-
+ IP_CMD + " link set dummy master " + DOT1Q_BRIDGE_NAME + "\"";
94+
+ IP_CMD + " link set dummy master " + DOT1Q_BRIDGE_NAME + " && "
95+
+ IP_CMD + " link set dummy up" + "\"";
9496

9597
std::string res;
9698
EXEC_WITH_ERROR_THROW(cmds, res);

fpmsyncd/fpmsyncd.cpp

+58-4
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,34 @@
99
#include "subscriberstatetable.h"
1010
#include "warmRestartHelper.h"
1111
#include "fpmsyncd/fpmlink.h"
12+
#include "fpmsyncd/fpmsyncd.h"
1213
#include "fpmsyncd/routesync.h"
1314

1415
#include <netlink/route/route.h>
1516

1617
using namespace std;
1718
using namespace swss;
1819

20+
// gSelectTimeout specifies the maximum wait time in milliseconds (-1 == infinite)
21+
static int gSelectTimeout;
22+
#define INFINITE -1
23+
#define FLUSH_TIMEOUT 500 // 500 milliseconds
24+
static int gFlushTimeout = FLUSH_TIMEOUT;
25+
// consider the traffic is small if pipeline contains < 500 entries
26+
#define SMALL_TRAFFIC 500
27+
28+
/**
29+
* @brief fpmsyncd invokes redispipeline's flush with a timer
30+
*
31+
* redispipeline would automatically flush itself when full,
32+
* but fpmsyncd can invoke pipeline's flush even if it's not full yet.
33+
*
34+
* By setting gSelectTimeout, fpmsyncd controls the flush interval.
35+
*
36+
* @param pipeline reference to the pipeline to be flushed
37+
*/
38+
void flushPipeline(RedisPipeline& pipeline);
39+
1940
/*
2041
* Default warm-restart timer interval for routing-stack app. To be used only if
2142
* no explicit value has been defined in configuration.
@@ -61,7 +82,7 @@ int main(int argc, char **argv)
6182
DBConnector applStateDb("APPL_STATE_DB", 0);
6283
std::unique_ptr<NotificationConsumer> routeResponseChannel;
6384

64-
RedisPipeline pipeline(&db);
85+
RedisPipeline pipeline(&db, ROUTE_SYNC_PPL_SIZE);
6586
RouteSync sync(&pipeline);
6687

6788
DBConnector stateDb("STATE_DB", 0);
@@ -152,12 +173,14 @@ int main(int argc, char **argv)
152173
sync.m_warmStartHelper.setState(WarmStart::WSDISABLED);
153174
}
154175

176+
gSelectTimeout = INFINITE;
177+
155178
while (true)
156179
{
157180
Selectable *temps;
158181

159182
/* Reading FPM messages forever (and calling "readMe" to read them) */
160-
s.select(&temps);
183+
s.select(&temps, gSelectTimeout);
161184

162185
/*
163186
* Upon expiration of the warm-restart timer or eoiu Hold Timer, proceed to run the
@@ -286,8 +309,7 @@ int main(int argc, char **argv)
286309
}
287310
else if (!warmStartEnabled || sync.m_warmStartHelper.isReconciled())
288311
{
289-
pipeline.flush();
290-
SWSS_LOG_DEBUG("Pipeline flushed");
312+
flushPipeline(pipeline);
291313
}
292314
}
293315
}
@@ -304,3 +326,35 @@ int main(int argc, char **argv)
304326

305327
return 1;
306328
}
329+
330+
void flushPipeline(RedisPipeline& pipeline) {
331+
332+
size_t remaining = pipeline.size();
333+
334+
if (remaining == 0) {
335+
gSelectTimeout = INFINITE;
336+
return;
337+
}
338+
339+
int idle = pipeline.getIdleTime();
340+
341+
// flush the pipeline if
342+
// 1. traffic is not scaled (only prevent fpmsyncd from flushing ppl too frequently in the scaled case)
343+
// 2. the idle time since last flush has exceeded gFlushTimeout
344+
// 3. idle <= 0, due to system clock drift, should not happen since we already use steady_clock for timing
345+
if (remaining < SMALL_TRAFFIC || idle >= gFlushTimeout || idle <= 0) {
346+
347+
pipeline.flush();
348+
349+
gSelectTimeout = INFINITE;
350+
351+
SWSS_LOG_DEBUG("Pipeline flushed");
352+
}
353+
else
354+
{
355+
// skip flushing ppl and set the timeout of fpmsyncd select function to be (gFlushTimeout - idle)
356+
// so that fpmsyncd select function would block at most for (gFlushTimeout - idle)
357+
// by doing this, we make sure every entry eventually gets flushed
358+
gSelectTimeout = gFlushTimeout - idle;
359+
}
360+
}

fpmsyncd/fpmsyncd.h

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef __FPMSYNCD__
2+
#define __FPMSYNCD__
3+
4+
5+
// redispipeline has a maximum capacity of 50000 entries
6+
#define ROUTE_SYNC_PPL_SIZE 50000
7+
8+
#endif

mclagsyncd/mclaglink.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ void MclagLink::setPortIsolate(char *msg)
193193
BRCM_PLATFORM_SUBSTRING,
194194
BFN_PLATFORM_SUBSTRING,
195195
CTC_PLATFORM_SUBSTRING,
196-
MRVL_PLATFORM_SUBSTRING
196+
MRVL_PRST_PLATFORM_SUBSTRING
197197
};
198198

199199
const char *platform = getenv("platform");

mclagsyncd/mclaglink.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#define BRCM_PLATFORM_SUBSTRING "broadcom"
5555
#define BFN_PLATFORM_SUBSTRING "barefoot"
5656
#define CTC_PLATFORM_SUBSTRING "centec"
57-
#define MRVL_PLATFORM_SUBSTRING "marvell"
57+
#define MRVL_PRST_PLATFORM_SUBSTRING "marvell-prestera"
5858

5959
using namespace std;
6060

orchagent/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dist_swss_DATA = \
2020
pfc_detect_marvell_teralynx.lua \
2121
pfc_detect_mellanox.lua \
2222
pfc_detect_broadcom.lua \
23-
pfc_detect_marvell.lua \
23+
pfc_detect_marvell_prestera.lua \
2424
pfc_detect_barefoot.lua \
2525
pfc_detect_nephos.lua \
2626
pfc_detect_cisco-8000.lua \

orchagent/aclorch.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -3306,7 +3306,7 @@ void AclOrch::init(vector<TableConnector>& connectors, PortsOrch *portOrch, Mirr
33063306
platform == CISCO_8000_PLATFORM_SUBSTRING ||
33073307
platform == MLNX_PLATFORM_SUBSTRING ||
33083308
platform == BFN_PLATFORM_SUBSTRING ||
3309-
platform == MRVL_PLATFORM_SUBSTRING ||
3309+
platform == MRVL_PRST_PLATFORM_SUBSTRING ||
33103310
platform == MRVL_TL_PLATFORM_SUBSTRING ||
33113311
platform == NPS_PLATFORM_SUBSTRING ||
33123312
platform == XS_PLATFORM_SUBSTRING ||
@@ -3327,7 +3327,7 @@ void AclOrch::init(vector<TableConnector>& connectors, PortsOrch *portOrch, Mirr
33273327
};
33283328
}
33293329

3330-
if ( platform == MRVL_PLATFORM_SUBSTRING ||
3330+
if ( platform == MRVL_PRST_PLATFORM_SUBSTRING ||
33313331
platform == MRVL_TL_PLATFORM_SUBSTRING ||
33323332
platform == VS_PLATFORM_SUBSTRING)
33333333
{
@@ -3362,7 +3362,7 @@ void AclOrch::init(vector<TableConnector>& connectors, PortsOrch *portOrch, Mirr
33623362
// In Broadcom DNX platform also, V4 and V6 rules are stored in different tables
33633363
if (platform == MLNX_PLATFORM_SUBSTRING ||
33643364
platform == CISCO_8000_PLATFORM_SUBSTRING ||
3365-
platform == MRVL_PLATFORM_SUBSTRING ||
3365+
platform == MRVL_PRST_PLATFORM_SUBSTRING ||
33663366
platform == XS_PLATFORM_SUBSTRING ||
33673367
(platform == BRCM_PLATFORM_SUBSTRING && sub_platform == BRCM_DNX_PLATFORM_SUBSTRING))
33683368
{
@@ -5938,7 +5938,7 @@ bool MetaDataMgr::isValidMetaData(uint16_t metadata)
59385938

59395939
uint16_t MetaDataMgr::getFreeMetaData(uint8_t dscp)
59405940
{
5941-
uint16_t metadata = metaMax + 1;
5941+
uint16_t metadata = (uint16_t)(metaMax + 1);
59425942
SWSS_LOG_INFO("Metadata Request for dscp %d", dscp);
59435943

59445944
if (initComplete)
@@ -5962,7 +5962,7 @@ uint16_t MetaDataMgr::getFreeMetaData(uint8_t dscp)
59625962
m_dscpMetadata[dscp] = metadata;
59635963
SWSS_LOG_INFO("New Metadata %d allocated for dscp %d", metadata, dscp);
59645964
}
5965-
m_MetadataRef[metadata] += 1;
5965+
m_MetadataRef[metadata] = (uint16_t)(m_MetadataRef[metadata] + 1);
59665966
}
59675967
else
59685968
{
@@ -5975,7 +5975,7 @@ void MetaDataMgr::recycleMetaData(uint16_t metadata)
59755975
{
59765976
if (initComplete)
59775977
{
5978-
m_MetadataRef[metadata] -= 1;
5978+
m_MetadataRef[metadata] = (uint16_t)(m_MetadataRef[metadata] - 1);
59795979
SWSS_LOG_INFO("Freeing Metadata %d refcount %d", metadata, m_MetadataRef[metadata]);
59805980
if (m_MetadataRef[metadata] == 0)
59815981
{

0 commit comments

Comments
 (0)