Skip to content

Commit 524cf9e

Browse files
shine4chenshine.chenshine.chen
authored
MCLAG feature for SONIC (#2514)
* MCLAG feature for sonic * MCLAG feature for sonic * remove binary file * remove unused dockerfile update docker-iccpd to stretch-based container Signed-off-by: shine.chen <[email protected]> * minor fix for isolation port setting Signed-off-by: shine.chen <[email protected]> * iccpd docker would start on demand Signed-off-by: shine.chen <[email protected]> * Add x attribute on mclagdctl file Signed-off-by: shine.chen <[email protected]> * add warm-reboot support for MCLAG Signed-off-by: shine.chen <[email protected]> * merge to master branch and reformat iccpd file Signed-off-by: shine.chen <[email protected]> * fix some bugs and make peer-link configuration optional Signed-off-by: shine.chen <[email protected]> * refactor code per Brcm review Signed-off-by: shine.chen <[email protected]> * correct a typo Signed-off-by: shine.chen <[email protected]> * * optimize iccpd arp/mac sync process * refine code according to brcm opinoin * unify function return value Signed-off-by: shine.chen <[email protected]> * * optimize warm-reboot process * estabish iccpd connection with configurated src-ip Signed-off-by: shine.chen <[email protected]> * fix a typo Signed-off-by: shine.chen <[email protected]> * optimize some code * add some debug info * optimize bridge mac setting * fix vlan mac sync issue on standby node Signed-off-by: shine.chen <[email protected]> * optimize some code Signed-off-by: shine.chen <[email protected]> * fix some bugs for warm-reboot Signed-off-by: shine.chen <[email protected]> * refine log level Signed-off-by: shine.chen <[email protected]> * refine iccpd syslog & skip arp packet whose src ip is local ip Signed-off-by: shine.chen <[email protected]> * remove iccpd dependency with teamd Signed-off-by: shine.chen <[email protected]> * print log level when dump mclag status Signed-off-by: shine.chen <[email protected]> * revise per community review Signed-off-by: shine.chen <[email protected]> Co-authored-by: shine.chen <[email protected]> Co-authored-by: shine.chen <[email protected]>
1 parent abbd871 commit 524cf9e

Some content is hidden

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

55 files changed

+15620
-0
lines changed

dockers/docker-iccpd/Dockerfile.j2

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %}
2+
FROM docker-config-engine-stretch
3+
4+
ARG docker_container_name
5+
RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf
6+
7+
## Make apt-get non-interactive
8+
ENV DEBIAN_FRONTEND=noninteractive
9+
10+
RUN apt-get update && \
11+
apt-get install -f -y \
12+
libdbus-1-3 \
13+
libdaemon0 \
14+
libpython2.7 \
15+
# Install redis-tools dependencies
16+
# TODO: implicitly install dependencies
17+
libatomic1 \
18+
libjemalloc1 \
19+
liblua5.1-0 \
20+
lua-bitop \
21+
lua-cjson
22+
23+
RUN apt-get -y install ebtables
24+
RUN apt-get -y install -f kmod
25+
26+
COPY \
27+
{% for deb in docker_iccpd_debs.split(' ') -%}
28+
debs/{{ deb }}{{' '}}
29+
{%- endfor -%}
30+
debs/
31+
32+
RUN dpkg -i \
33+
{% for deb in docker_iccpd_debs.split(' ') -%}
34+
debs/{{ deb }}{{' '}}
35+
{%- endfor %}
36+
37+
COPY ["start.sh", "iccpd.sh", "/usr/bin/"]
38+
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
39+
COPY ["iccpd.j2", "/usr/share/sonic/templates/"]
40+
41+
RUN chmod +x /usr/bin/start.sh /usr/bin/iccpd.sh
42+
RUN apt-get clean -y && \
43+
apt-get autoclean -y && \
44+
apt-get autoremove -y && \
45+
rm -rf /debs
46+
47+
ENTRYPOINT ["/usr/bin/supervisord"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
DOCKER_EXEC_FLAGS="i"
4+
5+
# Determine whether stdout is on a terminal
6+
if [ -t 1 ] ; then
7+
DOCKER_EXEC_FLAGS+="t"
8+
fi
9+
10+
docker exec -$DOCKER_EXEC_FLAGS iccpd mclagdctl "$@"

dockers/docker-iccpd/iccpd.j2

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{% for mclag_id in MC_LAG %}
2+
mclag_id:{{mclag_id}}
3+
local_ip:{{MC_LAG[mclag_id]['local_ip']}}
4+
peer_ip:{{MC_LAG[mclag_id]['peer_ip']}}
5+
{% if MC_LAG[mclag_id].has_key('peer_link') %}
6+
peer_link:{{MC_LAG[mclag_id]['peer_link']}}
7+
{% endif %}
8+
mclag_interface:{{MC_LAG[mclag_id]['mclag_interface']}}
9+
{% endfor %}
10+
system_mac:{{DEVICE_METADATA['localhost']['mac']}}
11+

dockers/docker-iccpd/iccpd.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
function start_app {
4+
rm -f /var/run/iccpd/*
5+
mclagsyncd &
6+
iccpd
7+
}
8+
9+
function clean_up {
10+
pkill -9 mclagsyncd
11+
pkill -9 iccpd
12+
exit
13+
}
14+
15+
trap clean_up SIGTERM SIGKILL
16+
start_app
17+
read

dockers/docker-iccpd/start.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
4+
ICCPD_CONF_PATH=/etc/iccpd
5+
6+
rm -rf $ICCPD_CONF_PATH
7+
mkdir -p $ICCPD_CONF_PATH
8+
9+
sonic-cfggen -d -t /usr/share/sonic/templates/iccpd.j2 > $ICCPD_CONF_PATH/iccpd.conf
10+
11+
mkdir -p /var/sonic
12+
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status
13+
14+
rm -f /var/run/rsyslogd.pid
15+
16+
supervisorctl start rsyslogd
17+
18+
supervisorctl start iccpd

dockers/docker-iccpd/supervisord.conf

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[supervisord]
2+
logfile_maxbytes=1MB
3+
logfile_backups=2
4+
nodaemon=true
5+
6+
[program:start.sh]
7+
command=/usr/bin/start.sh
8+
priority=1
9+
autostart=true
10+
autorestart=false
11+
stdout_logfile=syslog
12+
stderr_logfile=syslog
13+
14+
[program:rsyslogd]
15+
command=/usr/sbin/rsyslogd -n
16+
priority=2
17+
autostart=false
18+
autorestart=false
19+
stdout_logfile=syslog
20+
stderr_logfile=syslog
21+
22+
[program:iccpd]
23+
command=/usr/bin/iccpd.sh
24+
priority=3
25+
autostart=false
26+
autorestart=false
27+
stdout_logfile=syslog
28+
stderr_logfile=syslog
29+

files/build_templates/docker_image_ctl.j2

+3
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ start() {
231231
{%- if docker_container_name != "database" %}
232232
-v /usr/share/sonic/device/$PLATFORM/$HWSKU/$DEV:/usr/share/sonic/hwsku:ro \
233233
{%- endif %}
234+
{%- if docker_container_name == "iccpd" %}
235+
-v /lib/modules:/lib/modules:ro \
236+
{%- endif %}
234237
{%- if sonic_asic_platform != "mellanox" %}
235238
--tmpfs /tmp \
236239
{%- endif %}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Unit]
2+
Description=ICCPD container
3+
Requires=updategraph.service swss.service
4+
After=updategraph.service swss.service
5+
6+
[Service]
7+
User={{ sonicadmin_user }}
8+
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
9+
ExecStart=/usr/bin/{{docker_container_name}}.sh wait
10+
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
11+
12+
[Install]
13+
WantedBy=multi-user.target swss.service

files/build_templates/sonic_debian_extension.j2

+3
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,9 @@ if [ -f {{service}} ]; then
427427
echo "{{service}}" | sudo tee -a $GENERATED_SERVICE_FILE
428428
fi
429429
{% endfor %}
430+
if [ -f iccpd.service ]; then
431+
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl disable iccpd.service
432+
fi
430433
sudo LANG=C chroot $FILESYSTEM_ROOT fuser -km /sys || true
431434
sudo LANG=C chroot $FILESYSTEM_ROOT umount -lf /sys
432435
{% endif %}

rules/config

+5
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ SONIC_DPKG_CACHE_SOURCE ?= /var/cache/sonic/artifacts
115115
# Default VS build memory preparation
116116
DEFAULT_VS_PREPARE_MEM = yes
117117

118+
119+
# ENABLE_ICCPD - build docker-iccpd for mclag support
120+
ENABLE_ICCPD = y
121+
118122
# ENABLE_SYSTEM_SFLOW - build docker-sonic-sflow for sFlow support
119123
ENABLE_SFLOW = y
120124

@@ -126,3 +130,4 @@ ENABLE_RESTAPI = n
126130

127131
# ENABLE_NAT - build docker-sonic-nat for nat support
128132
ENABLE_NAT = y
133+

rules/docker-iccpd.mk

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# docker image for iccpd agent
2+
3+
DOCKER_ICCPD = docker-iccpd.gz
4+
$(DOCKER_ICCPD)_PATH = $(DOCKERS_PATH)/docker-iccpd
5+
$(DOCKER_ICCPD)_DEPENDS += $(SWSS) $(REDIS_TOOLS) $(ICCPD)
6+
$(DOCKER_ICCPD)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_STRETCH)
7+
8+
ifeq ($(ENABLE_ICCPD), y)
9+
SONIC_DOCKER_IMAGES += $(DOCKER_ICCPD)
10+
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_ICCPD)
11+
SONIC_STRETCH_DOCKERS += $(DOCKER_ICCPD)
12+
endif
13+
14+
$(DOCKER_ICCPD)_CONTAINER_NAME = iccpd
15+
$(DOCKER_ICCPD)_RUN_OPT += --privileged -t
16+
$(DOCKER_ICCPD)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
17+
18+
$(DOCKER_ICCPD)_BASE_IMAGE_FILES += mclagdctl:/usr/bin/mclagdctl

rules/iccpd.mk

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# iccpd package
2+
3+
ICCPD_VERSION = 0.0.5
4+
5+
ICCPD = iccpd_$(ICCPD_VERSION)_amd64.deb
6+
$(ICCPD)_DEPENDS += $(LIBNL_GENL3_DEV) $(LIBNL_CLI_DEV)
7+
$(ICCPD)_RDEPENDS += $(LIBNL_GENL3) $(LIBNL_CLI)
8+
$(ICCPD)_SRC_PATH = $(SRC_PATH)/iccpd
9+
SONIC_MAKE_DEBS += $(ICCPD)
10+
# SONIC_STRETCH_DEBS += $(ICCPD)
11+
12+
# Export these variables so they can be used in a sub-make
13+
export ICCPD_VERSION
14+
export ICCPD

src/iccpd/Makefile

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.ONESHELL:
2+
SHELL = /bin/bash
3+
.SHELLFLAGS += -e
4+
5+
MAIN_TARGET = iccpd_$(ICCPD_VERSION)_amd64.deb
6+
DEB_PATH = debian
7+
8+
all: iccpd-build mclagdctl-build
9+
10+
iccpd-build:
11+
make -C src
12+
13+
mclagdctl-build:
14+
make -C src/mclagdctl
15+
16+
$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
17+
make all
18+
if [ ! -d $(DEB_PATH)/usr/bin ]; then
19+
mkdir -p $(DEB_PATH)/usr/bin
20+
fi
21+
cp iccpd $(DEB_PATH)/usr/bin/iccpd
22+
cp src/mclagdctl/mclagdctl $(DEB_PATH)/usr/bin/mclagdctl
23+
chmod +x $(DEB_PATH)/usr/bin/iccpd
24+
chmod +x $(DEB_PATH)/usr/bin/mclagdctl
25+
md5sum $(DEB_PATH)/usr/bin/iccpd > $(DEB_PATH)/DEBIAN/md5sums
26+
md5sum $(DEB_PATH)/usr/bin/mclagdctl >> $(DEB_PATH)/DEBIAN/md5sums
27+
dpkg-deb -b $(DEB_PATH) $(DEST)/$(MAIN_TARGET)
28+
29+
clean: iccpd-clean mclagdctl-clean
30+
31+
iccpd-clean:
32+
make -C src clean
33+
34+
mclagdctl-clean:
35+
make -C src/mclagdctl clean

src/iccpd/debian/DEBIAN/control

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Package: iccpd-0.0.5-amd64
2+
Source: nps
3+
Version: 0.0.5
4+
Architecture: amd64
5+
Maintainer: Simon Ji <[email protected]>
6+
Installed-Size: 1508
7+
Depends:
8+
Section: main
9+
Priority: extra
10+
Homepage: https://github.com/NephosInc/SONiC
11+
Description:
12+

src/iccpd/include/app_csm.h

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* app_csm.h
3+
*
4+
* Copyright(c) 2016-2019 Nephos/Estinet.
5+
*
6+
* This program is free software; you can redistribute it and/or modify it
7+
* under the terms and conditions of the GNU General Public License,
8+
* version 2, as published by the Free Software Foundation.
9+
*
10+
* This program is distributed in the hope it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13+
* more details.
14+
*
15+
* You should have received a copy of the GNU General Public License along with
16+
* this program; if not, see <http://www.gnu.org/licenses/>.
17+
*
18+
* The full GNU General Public License is included in this distribution in
19+
* the file called "COPYING".
20+
*
21+
* Maintainer: jianjun, grace Li from nephos
22+
*/
23+
24+
#ifndef APP_CSM_H_
25+
#define APP_CSM_H_
26+
27+
#include <sys/queue.h>
28+
29+
#include "../include/mlacp_fsm.h"
30+
31+
struct CSM;
32+
33+
enum APP_CONNECTION_STATE
34+
{
35+
APP_NONEXISTENT,
36+
APP_RESET,
37+
APP_CONNSENT,
38+
APP_CONNREC,
39+
APP_CONNECTING,
40+
APP_OPERATIONAL
41+
};
42+
43+
typedef enum APP_CONNECTION_STATE APP_CONNECTION_STATE_E;
44+
45+
struct AppCSM
46+
{
47+
struct mLACP mlacp;
48+
APP_CONNECTION_STATE_E current_state;
49+
50+
uint32_t rx_connect_msg_id;
51+
uint32_t tx_connect_msg_id;
52+
uint32_t invalid_msg_id;
53+
54+
TAILQ_HEAD(app_msg_list, Msg) app_msg_list;
55+
56+
uint8_t invalid_msg : 1;
57+
uint8_t nak_msg : 1;
58+
};
59+
60+
void app_csm_init(struct CSM*, int all);
61+
void app_csm_finalize(struct CSM*);
62+
void app_csm_transit(struct CSM*);
63+
int app_csm_prepare_iccp_msg(struct CSM*, char*, size_t);
64+
void app_csm_enqueue_msg(struct CSM*, struct Msg*);
65+
struct Msg* app_csm_dequeue_msg(struct CSM*);
66+
void app_csm_correspond_from_msg(struct CSM*, struct Msg*);
67+
void app_csm_correspond_from_connect_msg(struct CSM*, struct Msg*);
68+
void app_csm_correspond_from_connect_ack_msg(struct CSM*, struct Msg*);
69+
int app_csm_prepare_nak_msg(struct CSM*, char*, size_t);
70+
int app_csm_prepare_connect_msg(struct CSM*, char*, size_t);
71+
int app_csm_prepare_connect_ack_msg(struct CSM*, char*, size_t);
72+
73+
#endif /* APP_CSM_H_ */

0 commit comments

Comments
 (0)