Skip to content

Commit

Permalink
Merge branch 'master' into meter_counters
Browse files Browse the repository at this point in the history
  • Loading branch information
sundar-pds authored Dec 2, 2024
2 parents 32cb753 + 0929d86 commit ea67933
Show file tree
Hide file tree
Showing 34 changed files with 1,224 additions and 148 deletions.
104 changes: 73 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,55 +21,97 @@ The SWitch State Service (SWSS) is a collection of software that provides a data

## Getting Started

### Install
### Prerequisites

Install the following dependencies:
```
sudo apt install redis-server
sudo apt install libhiredis0.14
sudo apt install libzmq5 libzmq3-dev
sudo apt install libboost-serialization1.74.0
sudo apt install libboost1.71-dev
sudo apt install libasan6
```
**Note:** If your are using Ubuntu 18.04, install `libhiredis0.13` instead.

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.
From the Summary tab, access build artifacts.
<img width="1048" alt="image" src="https://github.com/user-attachments/assets/faa6f08d-788b-4801-8439-3f31a52efaa1">
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`.
<img width="1022" alt="image" src="https://github.com/user-attachments/assets/1ad750eb-252c-4913-b14f-91b5533a1295">
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:
```
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
```
**Note:** You can also [build these packages yourself (for the VS platform)](https://github.com/sonic-net/sonic-buildimage/blob/master/README.md).

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:
```
sudo dpkg -i swss_1.0.0_amd64.deb
```

Before installing, add key and package sources:
#### Install from Source

sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
echo 'deb http://apt-mo.trafficmanager.net/repos/sonic/ trusty main' | sudo tee -a /etc/apt/sources.list.d/sonic.list
sudo apt-get update
Install build dependencies:
```
sudo apt install libtool
sudo apt install autoconf automake
sudo apt install dh-exec
sudo apt install nlohmann-json3-dev
sudo apt install libgmock-dev
```

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

sudo apt-get install redis-server -t trusty
sudo apt-get install libhiredis0.13 -t trusty
sudo apt-get install libzmq5 libzmq3-dev

Install building dependencies:
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`.

sudo apt-get install libtool
sudo apt-get install autoconf automake
sudo apt-get install dh-exec
You can compile and install from source using:
```
./autogen.sh
./configure
make && sudo make install
```
**Note:** This will NOT run the mock tests located under `tests/mock_tests`.

There are a few different ways you can install SONiC-SWSS.
You can also build a debian package using:
```
./autogen.sh
fakeroot debian/rules binary
```
## Common issues

#### Install from Debian Repo
#### Cannot find `libboost-serialization1.74.0`

For your convenience, you can install prepared packages on Debian Jessie:
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`.

sudo apt-get install swss
#### Dependency issue when installing `libzmq3-dev`

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

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

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

Install prerequisite packages:
**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.

sudo apt-get install libswsscommon libswsscommon-dev libsairedis libsairedis-dev
#### Dependency issues when installing some package

You can compile and install from source using:
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).

./autogen.sh
./configure
make && sudo make install
#### Too many open files

You can also build a debian package using:
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:
```
ulimit -a | grep "open files"
```
You can increase it by executing this command: `ulimit -n 8192`. Feel free to change `8192`. This value worked fine for me.

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

## Need Help?

Expand Down
6 changes: 4 additions & 2 deletions cfgmgr/vlanmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ VlanMgr::VlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c
// /sbin/bridge vlan del vid 1 dev Bridge self;
// /sbin/ip link del dummy 2>/dev/null;
// /sbin/ip link add dummy type dummy &&
// /sbin/ip link set dummy master Bridge"
// /sbin/ip link set dummy master Bridge &&
// /sbin/ip link set dummy up"

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

std::string res;
EXEC_WITH_ERROR_THROW(cmds, res);
Expand Down
2 changes: 1 addition & 1 deletion mclagsyncd/mclaglink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void MclagLink::setPortIsolate(char *msg)
BRCM_PLATFORM_SUBSTRING,
BFN_PLATFORM_SUBSTRING,
CTC_PLATFORM_SUBSTRING,
MRVL_PLATFORM_SUBSTRING
MRVL_PRST_PLATFORM_SUBSTRING
};

const char *platform = getenv("platform");
Expand Down
2 changes: 1 addition & 1 deletion mclagsyncd/mclaglink.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#define BRCM_PLATFORM_SUBSTRING "broadcom"
#define BFN_PLATFORM_SUBSTRING "barefoot"
#define CTC_PLATFORM_SUBSTRING "centec"
#define MRVL_PLATFORM_SUBSTRING "marvell"
#define MRVL_PRST_PLATFORM_SUBSTRING "marvell-prestera"

using namespace std;

Expand Down
2 changes: 1 addition & 1 deletion orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dist_swss_DATA = \
pfc_detect_marvell_teralynx.lua \
pfc_detect_mellanox.lua \
pfc_detect_broadcom.lua \
pfc_detect_marvell.lua \
pfc_detect_marvell_prestera.lua \
pfc_detect_barefoot.lua \
pfc_detect_nephos.lua \
pfc_detect_cisco-8000.lua \
Expand Down
6 changes: 3 additions & 3 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3306,7 +3306,7 @@ void AclOrch::init(vector<TableConnector>& connectors, PortsOrch *portOrch, Mirr
platform == CISCO_8000_PLATFORM_SUBSTRING ||
platform == MLNX_PLATFORM_SUBSTRING ||
platform == BFN_PLATFORM_SUBSTRING ||
platform == MRVL_PLATFORM_SUBSTRING ||
platform == MRVL_PRST_PLATFORM_SUBSTRING ||
platform == MRVL_TL_PLATFORM_SUBSTRING ||
platform == NPS_PLATFORM_SUBSTRING ||
platform == XS_PLATFORM_SUBSTRING ||
Expand All @@ -3327,7 +3327,7 @@ void AclOrch::init(vector<TableConnector>& connectors, PortsOrch *portOrch, Mirr
};
}

if ( platform == MRVL_PLATFORM_SUBSTRING ||
if ( platform == MRVL_PRST_PLATFORM_SUBSTRING ||
platform == MRVL_TL_PLATFORM_SUBSTRING ||
platform == VS_PLATFORM_SUBSTRING)
{
Expand Down Expand Up @@ -3362,7 +3362,7 @@ void AclOrch::init(vector<TableConnector>& connectors, PortsOrch *portOrch, Mirr
// In Broadcom DNX platform also, V4 and V6 rules are stored in different tables
if (platform == MLNX_PLATFORM_SUBSTRING ||
platform == CISCO_8000_PLATFORM_SUBSTRING ||
platform == MRVL_PLATFORM_SUBSTRING ||
platform == MRVL_PRST_PLATFORM_SUBSTRING ||
platform == XS_PLATFORM_SUBSTRING ||
(platform == BRCM_PLATFORM_SUBSTRING && sub_platform == BRCM_DNX_PLATFORM_SUBSTRING))
{
Expand Down
33 changes: 33 additions & 0 deletions orchagent/bulker.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,20 @@ struct SaiBulkerTraits<sai_next_hop_group_api_t>
//using bulk_set_entry_attribute_fn = sai_bulk_object_set_attribute_fn;
};

template<>
struct SaiBulkerTraits<sai_next_hop_api_t>
{
using entry_t = sai_object_id_t;
using api_t = sai_next_hop_api_t;
using create_entry_fn = sai_create_next_hop_fn;
using remove_entry_fn = sai_remove_next_hop_fn;
using set_entry_attribute_fn = sai_set_next_hop_attribute_fn;
using bulk_create_entry_fn = sai_bulk_object_create_fn;
using bulk_remove_entry_fn = sai_bulk_object_remove_fn;
// TODO: wait until available in SAI
//using bulk_set_entry_attribute_fn = sai_bulk_object_set_attribute_fn;
};

template<>
struct SaiBulkerTraits<sai_mpls_api_t>
{
Expand Down Expand Up @@ -1001,6 +1015,7 @@ class ObjectBulker
// Creating
if (!creating_entries.empty())
{
create_statuses.clear();
std::vector<sai_object_id_t *> rs;
std::vector<sai_attribute_t const*> tss;
std::vector<uint32_t> cs;
Expand Down Expand Up @@ -1078,6 +1093,10 @@ class ObjectBulker
return removing_entries.size();
}

sai_status_t create_status(sai_object_id_t object) {
return create_statuses[object];
}

private:
struct object_entry
{
Expand Down Expand Up @@ -1117,6 +1136,8 @@ class ObjectBulker
// TODO: wait until available in SAI
//typename Ts::bulk_set_entry_attribute_fn set_entries_attribute;

std::unordered_map<sai_object_id_t, sai_status_t> create_statuses;

sai_status_t flush_removing_entries(
_Inout_ std::vector<sai_object_id_t> &rs)
{
Expand Down Expand Up @@ -1175,6 +1196,7 @@ class ObjectBulker

for (size_t i = 0; i < count; i++)
{
create_statuses.emplace(object_ids[i], statuses[i]);
sai_object_id_t *pid = rs[i];
*pid = (statuses[i] == SAI_STATUS_SUCCESS) ? object_ids[i] : SAI_NULL_OBJECT_ID;
}
Expand Down Expand Up @@ -1229,6 +1251,17 @@ inline ObjectBulker<sai_next_hop_group_api_t>::ObjectBulker(SaiBulkerTraits<sai_
//set_entries_attribute = ;
}

template <>
inline ObjectBulker<sai_next_hop_api_t>::ObjectBulker(SaiBulkerTraits<sai_next_hop_api_t>::api_t *api, sai_object_id_t switch_id, size_t max_bulk_size) :
switch_id(switch_id),
max_bulk_size(max_bulk_size)
{
create_entries = api->create_next_hops;
remove_entries = api->remove_next_hops;
// TODO: wait until available in SAI
//set_entries_attribute = ;
}

template <>
inline ObjectBulker<sai_dash_vnet_api_t>::ObjectBulker(SaiBulkerTraits<sai_dash_vnet_api_t>::api_t *api, sai_object_id_t switch_id, size_t max_bulk_size) :
switch_id(switch_id),
Expand Down
4 changes: 2 additions & 2 deletions orchagent/copporch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void CoppOrch::initDefaultTrapIds()
/* Mellanox platform doesn't support trap priority setting */
/* Marvell platform doesn't support trap priority. */
char *platform = getenv("platform");
if (!platform || (!strstr(platform, MLNX_PLATFORM_SUBSTRING) && (!strstr(platform, MRVL_PLATFORM_SUBSTRING))))
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;
Expand Down Expand Up @@ -1015,7 +1015,7 @@ bool CoppOrch::getAttribsFromTrapGroup (vector<FieldValueTuple> &fv_tuple,
/* Mellanox platform doesn't support trap priority setting */
/* Marvell platform doesn't support trap priority. */
char *platform = getenv("platform");
if (!platform || (!strstr(platform, MLNX_PLATFORM_SUBSTRING) && (!strstr(platform, MRVL_PLATFORM_SUBSTRING))))
if (!platform || (!strstr(platform, MLNX_PLATFORM_SUBSTRING) && (!strstr(platform, MRVL_PRST_PLATFORM_SUBSTRING))))
{
attr.id = SAI_HOSTIF_TRAP_ATTR_TRAP_PRIORITY,
attr.value.u32 = (uint32_t)stoul(fvValue(*i));
Expand Down
18 changes: 12 additions & 6 deletions orchagent/dash/dashvnetorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,19 @@ bool DashVnetOrch::addOutboundCaToPa(const string& key, VnetMapBulkContext& ctxt
outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr);
}

outbound_ca_to_pa_attr.id = SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OVERLAY_DMAC;
memcpy(outbound_ca_to_pa_attr.value.mac, ctxt.metadata.mac_address().c_str(), sizeof(sai_mac_t));
outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr);
if (ctxt.metadata.has_mac_address())
{
outbound_ca_to_pa_attr.id = SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OVERLAY_DMAC;
memcpy(outbound_ca_to_pa_attr.value.mac, ctxt.metadata.mac_address().c_str(), sizeof(sai_mac_t));
outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr);
}

outbound_ca_to_pa_attr.id = SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_USE_DST_VNET_VNI;
outbound_ca_to_pa_attr.value.booldata = ctxt.metadata.use_dst_vni();
outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr);
if (ctxt.metadata.has_use_dst_vni())
{
outbound_ca_to_pa_attr.id = SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_USE_DST_VNET_VNI;
outbound_ca_to_pa_attr.value.booldata = ctxt.metadata.use_dst_vni();
outbound_ca_to_pa_attrs.push_back(outbound_ca_to_pa_attr);
}

object_statuses.emplace_back();
outbound_ca_to_pa_bulker_.create_entry(&object_statuses.back(), &outbound_ca_to_pa_entry,
Expand Down
3 changes: 2 additions & 1 deletion orchagent/mplsrouteorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,8 @@ bool RouteOrch::addLabelRoute(LabelRouteBulkContext& ctx, const NextHopGroupKey
m_neighOrch->isNeighborResolved(nexthop))
{
/* since IP neighbor NH exists, neighbor is resolved, add MPLS NH */
if (m_neighOrch->addNextHop(nexthop))
NeighborContext ctx = NeighborContext(nexthop);
if (m_neighOrch->addNextHop(ctx))
{
next_hop_id = m_neighOrch->getNextHopId(nexthop);
}
Expand Down
Loading

0 comments on commit ea67933

Please sign in to comment.