Skip to content

Commit

Permalink
Merge branch 'master' into evpn_vxlan_vxlanmgr
Browse files Browse the repository at this point in the history
  • Loading branch information
srj102 committed May 19, 2020
2 parents a6bd9ff + 727a518 commit 6c6aed7
Show file tree
Hide file tree
Showing 70 changed files with 5,519 additions and 3,005 deletions.
3 changes: 2 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SUBDIRS = fpmsyncd neighsyncd portsyncd natsyncd orchagent swssconfig cfgmgr tests

SUBDIRS = fpmsyncd neighsyncd portsyncd mclagsyncd natsyncd orchagent swssconfig cfgmgr tests

if HAVE_LIBTEAM
SUBDIRS += teamsyncd
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
VS[![VS](https://sonic-jenkins.westus2.cloudapp.azure.com/job/vs/job/sonic-swss-build/badge/icon)](https://sonic-jenkins.westus2.cloudapp.azure.com/job/vs/job/sonic-swss-build/)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/Azure/sonic-swss.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Azure/sonic-swss/alerts/)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/Azure/sonic-swss.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Azure/sonic-swss/context:python)
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/Azure/sonic-swss.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Azure/sonic-swss/context:cpp)

[![VS](https://sonic-jenkins.westus2.cloudapp.azure.com/job/vs/job/sonic-swss-build/badge/icon?subject=VS%20build)](https://sonic-jenkins.westus2.cloudapp.azure.com/job/vs/job/sonic-swss-build/)

# SONiC - SWitch State Service - SWSS

Expand Down
15 changes: 15 additions & 0 deletions cfgmgr/buffermgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,21 @@ task_process_status BufferMgr::doSpeedUpdateTask(string port, string speed)
buffer_profile_key +
"]";

/* Check if PG Mapping is already then log message and return. */

m_cfgBufferPgTable.get(buffer_pg_key, fvVector);

for (auto& prop : fvVector)
{
if ((fvField(prop) == "profile") && (profile_ref == fvValue(prop)))
{
SWSS_LOG_NOTICE("PG to Buffer Profile Mapping %s already present", buffer_pg_key.c_str());
return task_process_status::task_success;
}
}

fvVector.clear();

fvVector.push_back(make_pair("profile", profile_ref));
m_cfgBufferPgTable.set(buffer_pg_key, fvVector);
return task_process_status::task_success;
Expand Down
6 changes: 3 additions & 3 deletions cfgmgr/natmgrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ int main(int argc, char **argv)
CFG_ACL_RULE_TABLE_NAME
};

DBConnector cfgDb(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector appDb(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector stateDb(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector cfgDb("CONFIG_DB", 0);
DBConnector appDb("APPL_DB", 0);
DBConnector stateDb("STATE_DB", 0);

cleanupNotifier = std::make_shared<swss::NotificationProducer>(&appDb, "NAT_DB_CLEANUP_NOTIFICATION");

Expand Down
1 change: 1 addition & 0 deletions cfgmgr/nbrmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <netinet/in.h>
#include <net/if.h>
#include <unistd.h>
#include <netlink/cache.h>

#include "logger.h"
#include "tokenize.h"
Expand Down
8 changes: 8 additions & 0 deletions cfgmgr/vrfmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ VrfMgr::VrfMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, con
}
else
{
// No deletion of mgmt table from kernel
if (vrfName.compare("mgmt") == 0)
{
SWSS_LOG_NOTICE("Skipping remove vrf device %s", vrfName.c_str());
rowType = LINK_ROW;
break;
}

SWSS_LOG_NOTICE("Remove vrf device %s", vrfName.c_str());
cmd.str("");
cmd.clear();
Expand Down
11 changes: 11 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ AC_ARG_ENABLE(debug,
esac],[debug=false])
AM_CONDITIONAL(DEBUG, test x$debug = xtrue)

AC_ARG_WITH(extra-inc,
[ --with-extra-inc=DIR
prefix where extra includes are installed],
[AC_SUBST(CPPFLAGS, "$CPPFLAGS -I${withval} -I${withval}/swss -I${withval}/sai")])

AC_ARG_WITH(extra-lib,
[ --with-extra-lib=DIR
prefix where extra libraries are installed],
[AC_SUBST(LDFLAGS, "$LDFLAGS -L${withval}")])

CFLAGS_COMMON="-std=c++14 -Wall -fPIC -Wno-write-strings -I/usr/include/libnl3 -I/usr/include/swss"

CFLAGS_COMMON+=" -Werror"
Expand Down Expand Up @@ -82,6 +92,7 @@ AC_CONFIG_FILES([
natsyncd/Makefile
portsyncd/Makefile
teamsyncd/Makefile
mclagsyncd/Makefile
swssconfig/Makefile
cfgmgr/Makefile
tests/Makefile
Expand Down
39 changes: 39 additions & 0 deletions lgtm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
path_classifiers:
test:
exclude: tests
extraction:
python:
python_setup:
version: "2"
cpp:
prepare:
packages:
- libxml-simple-perl
- aspell
- aspell-en
- libhiredis-dev
- libnl-3-dev
- libnl-genl-3-dev
- libnl-route-3-dev
- libnl-nf-3-dev
- swig3.0
- libpython2.7-dev
- libgtest-dev
- dh-exec
- doxygen
- graphviz
after_prepare:
- git clone https://github.com/Azure/sonic-swss-common; pushd sonic-swss-common; ./autogen.sh; fakeroot dpkg-buildpackage -us -uc -b; popd
- dpkg-deb -x libswsscommon_1.0.0_amd64.deb $LGTM_WORKSPACE
- dpkg-deb -x libswsscommon-dev_1.0.0_amd64.deb $LGTM_WORKSPACE
- git clone --recursive https://github.com/Azure/sonic-sairedis; pushd sonic-sairedis; ./autogen.sh; DEB_BUILD_OPTIONS=nocheck SWSS_COMMON_INC="$LGTM_WORKSPACE/usr/include" SWSS_COMMON_LIB="$LGTM_WORKSPACE/usr/lib/x86_64-linux-gnu" fakeroot debian/rules binary-syncd-vs; popd
- dpkg-deb -x libsairedis_1.0.0_amd64.deb $LGTM_WORKSPACE
- dpkg-deb -x libsairedis-dev_1.0.0_amd64.deb $LGTM_WORKSPACE
- dpkg-deb -x libsaimetadata_1.0.0_amd64.deb $LGTM_WORKSPACE
- dpkg-deb -x libsaimetadata-dev_1.0.0_amd64.deb $LGTM_WORKSPACE
- dpkg-deb -x libsaivs_1.0.0_amd64.deb $LGTM_WORKSPACE
- dpkg-deb -x libsaivs-dev_1.0.0_amd64.deb $LGTM_WORKSPACE
configure:
command:
- ./autogen.sh
- ./configure --prefix=/usr --with-extra-inc=$LGTM_WORKSPACE/usr/include --with-extra-lib=$LGTM_WORKSPACE/usr/lib/x86_64-linux-gnu
15 changes: 15 additions & 0 deletions mclagsyncd/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
INCLUDES = -I $(top_srcdir)

bin_PROGRAMS = mclagsyncd

if DEBUG
DBGFLAGS = -ggdb -DDEBUG
else
DBGFLAGS = -g
endif

mclagsyncd_SOURCES = mclagsyncd.cpp mclaglink.cpp

mclagsyncd_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON)
mclagsyncd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON)
mclagsyncd_LDADD = -lnl-3 -lnl-route-3 -lswsscommon
164 changes: 164 additions & 0 deletions mclagsyncd/mclag.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
/* Copyright(c) 2016-2019 Nephos.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see <http://www.gnu.org/licenses/>.
*
* The full GNU General Public License is included in this distribution in
* the file called "COPYING".
*
* Maintainer: Jim Jiang from nephos
*/

#ifndef _MCLAG_H
#define _MCLAG_H
#define MCLAG_DEFAULT_IP 0x7f000006

enum MCLAG_FDB_OP_TYPE {
MCLAG_FDB_OPER_ADD =1,
MCLAG_FDB_OPER_DEL = 2,
};

enum MCLAG_FDB_TYPE {
MCLAG_FDB_TYPE_STATIC = 1,
MCLAG_FDB_TYPE_DYNAMIC = 2,
};

/*
* default port for mclag connections
*/
#define MCLAG_DEFAULT_PORT 2626

/*
* Largest message that can be sent to or received from the MCLAG.
*/
#define MCLAG_MAX_MSG_LEN 4096
#define MCLAG_MAX_SEND_MSG_LEN 4096

typedef struct mclag_msg_hdr_t_ {
/*
* Protocol version.
*/
uint8_t version;

/*
* Type of message, see below.
*/
uint8_t msg_type;

/*
* Length of entire message, including the header.
*/
uint16_t msg_len;
}mclag_msg_hdr_t;

#define MCLAG_PROTO_VERSION 1
#define MCLAG_MSG_HDR_LEN (sizeof (mclag_msg_hdr_t))

/*syncd send msg type to iccpd*/
typedef enum mclag_syncd_msg_type_e_ {
MCLAG_SYNCD_MSG_TYPE_NONE = 0,
MCLAG_SYNCD_MSG_TYPE_FDB_OPERATION = 1
}mclag_syncd_msg_type_e;

/*iccpd send msg type to syncd*/
typedef enum mclag_msg_type_e_ {
MCLAG_MSG_TYPE_NONE = 0,
MCLAG_MSG_TYPE_PORT_ISOLATE = 1,
MCLAG_MSG_TYPE_PORT_MAC_LEARN_MODE = 2,
MCLAG_MSG_TYPE_FLUSH_FDB = 3,
MCLAG_MSG_TYPE_SET_INTF_MAC = 4,
MCLAG_MSG_TYPE_SET_FDB = 5,
MCLAG_MSG_TYPE_FLUSH_FDB_BY_PORT = 6,
MCLAG_MSG_TYPE_GET_FDB_CHANGES = 20
}mclag_msg_type_e;

typedef struct mclag_sub_option_hdr_t_ {
uint8_t op_type;

/*
* Length of option value, not including the header.
*/
uint16_t op_len;
}mclag_sub_option_hdr_t;

#define MCLAG_SUB_OPTION_HDR_LEN (sizeof (mclag_sub_option_hdr_t))

typedef enum mclag_sub_option_type_e_ {
MCLAG_SUB_OPTION_TYPE_NONE = 0,
MCLAG_SUB_OPTION_TYPE_ISOLATE_SRC = 1,
MCLAG_SUB_OPTION_TYPE_ISOLATE_DST = 2,
MCLAG_SUB_OPTION_TYPE_MAC_LEARN_ENABLE = 3,
MCLAG_SUB_OPTION_TYPE_MAC_LEARN_DISABLE = 4,
MCLAG_SUB_OPTION_TYPE_SET_MAC_SRC = 5,
MCLAG_SUB_OPTION_TYPE_SET_MAC_DST = 6
} mclag_sub_option_type_e;

static inline size_t
mclag_msg_len (const mclag_msg_hdr_t *hdr)
{
return hdr->msg_len;
}

/*
* mclag_msg_data_len
*/
static inline size_t
mclag_msg_data_len (const mclag_msg_hdr_t *hdr)
{
return (mclag_msg_len (hdr) - MCLAG_MSG_HDR_LEN);
}

/*
* mclag_msg_hdr_ok
*
* Returns TRUE if a message header looks well-formed.
*/
static inline int
mclag_msg_hdr_ok (const mclag_msg_hdr_t *hdr)
{
size_t msg_len;

if (hdr->msg_type == MCLAG_MSG_TYPE_NONE)
return 0;

msg_len = mclag_msg_len (hdr);

if (msg_len < MCLAG_MSG_HDR_LEN || msg_len > MCLAG_MAX_MSG_LEN)
return 0;

return 1;
}

/*
* mclag_msg_ok
*
* Returns TRUE if a message looks well-formed.
*
* @param len The length in bytes from 'hdr' to the end of the buffer.
*/
static inline int
mclag_msg_ok (const mclag_msg_hdr_t *hdr, size_t len)
{
if (len < MCLAG_MSG_HDR_LEN)
return 0;

if (!mclag_msg_hdr_ok (hdr))
return 0;

if (mclag_msg_len (hdr) > len)
return 0;

return 1;
}


#endif
Loading

0 comments on commit 6c6aed7

Please sign in to comment.