-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MCLAG feature for SONIC #2514
MCLAG feature for SONIC #2514
Changes from 24 commits
97d51af
d99e9d6
0dff4db
db361fd
fcc3421
7b99945
68621fd
4ebb4d0
027a8df
1a9fb62
896aa41
de6ecb7
d2130aa
7b89a06
db3cc0b
f20e570
2cdea01
b61688b
25490d1
9c81ed1
e417140
48b8c53
bc194ea
0b08967
c4b6059
f49200a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} | ||
FROM docker-config-engine-stretch | ||
|
||
ARG docker_container_name | ||
RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf | ||
|
||
## Make apt-get non-interactive | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update && \ | ||
apt-get install -f -y \ | ||
libdbus-1-3 \ | ||
libdaemon0 \ | ||
libpython2.7 \ | ||
# Install redis-tools dependencies | ||
# TODO: implicitly install dependencies | ||
libatomic1 \ | ||
libjemalloc1 \ | ||
liblua5.1-0 \ | ||
lua-bitop \ | ||
lua-cjson | ||
|
||
RUN apt-get -y install ebtables | ||
RUN apt-get -y install -f kmod | ||
|
||
COPY \ | ||
{% for deb in docker_iccpd_debs.split(' ') -%} | ||
debs/{{ deb }}{{' '}} | ||
{%- endfor -%} | ||
debs/ | ||
|
||
RUN dpkg -i \ | ||
{% for deb in docker_iccpd_debs.split(' ') -%} | ||
debs/{{ deb }}{{' '}} | ||
{%- endfor %} | ||
|
||
COPY ["start.sh", "iccpd.sh", "/usr/bin/"] | ||
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] | ||
COPY ["iccpd.j2", "/usr/share/sonic/templates/"] | ||
|
||
RUN chmod +x /usr/bin/start.sh /usr/bin/iccpd.sh | ||
RUN apt-get clean -y && \ | ||
apt-get autoclean -y && \ | ||
apt-get autoremove -y && \ | ||
rm -rf /debs | ||
|
||
ENTRYPOINT ["/usr/bin/supervisord"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
DOCKER_EXEC_FLAGS="i" | ||
|
||
# Determine whether stdout is on a terminal | ||
if [ -t 1 ] ; then | ||
DOCKER_EXEC_FLAGS+="t" | ||
fi | ||
|
||
docker exec -$DOCKER_EXEC_FLAGS iccpd mclagdctl "$@" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% for mclag_id in MC_LAG %} | ||
mclag_id:{{mclag_id}} | ||
local_ip:{{MC_LAG[mclag_id]['local_ip']}} | ||
peer_ip:{{MC_LAG[mclag_id]['peer_ip']}} | ||
{% if MC_LAG[mclag_id].has_key('peer_link') %} | ||
peer_link:{{MC_LAG[mclag_id]['peer_link']}} | ||
{% endif %} | ||
mclag_interface:{{MC_LAG[mclag_id]['mclag_interface']}} | ||
{% endfor %} | ||
system_mac:{{DEVICE_METADATA['localhost']['mac']}} | ||
|
||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
function start_app { | ||
rm -f /var/run/iccpd/* | ||
mclagsyncd & | ||
iccpd | ||
} | ||
|
||
function clean_up { | ||
pkill -9 mclagsyncd | ||
pkill -9 iccpd | ||
exit | ||
} | ||
|
||
trap clean_up SIGTERM SIGKILL | ||
start_app | ||
read |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
|
||
ICCPD_CONF_PATH=/etc/iccpd | ||
|
||
rm -rf $ICCPD_CONF_PATH | ||
mkdir -p $ICCPD_CONF_PATH | ||
|
||
sonic-cfggen -d -t /usr/share/sonic/templates/iccpd.j2 > $ICCPD_CONF_PATH/iccpd.conf | ||
|
||
mkdir -p /var/sonic | ||
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status | ||
|
||
rm -f /var/run/rsyslogd.pid | ||
|
||
supervisorctl start rsyslogd | ||
|
||
supervisorctl start iccpd |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[supervisord] | ||
logfile_maxbytes=1MB | ||
logfile_backups=2 | ||
nodaemon=true | ||
|
||
[program:start.sh] | ||
command=/usr/bin/start.sh | ||
priority=1 | ||
autostart=true | ||
autorestart=false | ||
stdout_logfile=syslog | ||
stderr_logfile=syslog | ||
|
||
[program:rsyslogd] | ||
command=/usr/sbin/rsyslogd -n | ||
priority=2 | ||
autostart=false | ||
autorestart=false | ||
stdout_logfile=syslog | ||
stderr_logfile=syslog | ||
|
||
[program:iccpd] | ||
command=/usr/bin/iccpd.sh | ||
priority=3 | ||
autostart=false | ||
autorestart=false | ||
stdout_logfile=syslog | ||
stderr_logfile=syslog | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,6 +191,9 @@ start() { | |
{%- if docker_container_name != "database" %} | ||
-v /usr/share/sonic/device/$PLATFORM/$HWSKU:/usr/share/sonic/hwsku:ro \ | ||
{%- endif %} | ||
{%- if docker_container_name == "iccpd" %} | ||
-v /lib/modules:/lib/modules:ro \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need lib modules? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MCLAG uses lib module ebtable_filter and ebtables There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you document how ebtable_filter and ebtables are used in the design document, it needs to be review. besides, even mclag is uses ebtable, it does not mean we need to mount /lib/modules into the docker. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jianjundong, @shine4chen , can you please address this comment? Please raise a separate PR for this. Thanks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We found that lib module ebtable_filter and ebtables are already installed in the docker default by someone, thus no need to do this here. These codes are removed by lguohan in PR '[docker-iccp]: do not mount kernel module into iccp container (#4372)'. |
||
{%- endif %} | ||
{%- if sonic_asic_platform != "mellanox" %} | ||
--tmpfs /tmp \ | ||
{%- endif %} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[Unit] | ||
Description=ICCPD container | ||
Requires=updategraph.service swss.service | ||
After=updategraph.service swss.service | ||
|
||
[Service] | ||
User={{ sonicadmin_user }} | ||
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start | ||
ExecStart=/usr/bin/{{docker_container_name}}.sh wait | ||
ExecStop=/usr/bin/{{docker_container_name}}.sh stop | ||
|
||
[Install] | ||
WantedBy=multi-user.target swss.service |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# docker image for iccpd agent | ||
|
||
DOCKER_ICCPD = docker-iccpd.gz | ||
abdosi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$(DOCKER_ICCPD)_PATH = $(DOCKERS_PATH)/docker-iccpd | ||
$(DOCKER_ICCPD)_DEPENDS += $(SWSS) $(REDIS_TOOLS) $(ICCPD) | ||
$(DOCKER_ICCPD)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_STRETCH) | ||
SONIC_DOCKER_IMAGES += $(DOCKER_ICCPD) | ||
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_ICCPD) | ||
|
||
SONIC_STRETCH_DOCKERS += $(DOCKER_ICCPD) | ||
|
||
$(DOCKER_ICCPD)_CONTAINER_NAME = iccpd | ||
$(DOCKER_ICCPD)_RUN_OPT += --net=host --privileged -t | ||
abdosi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$(DOCKER_ICCPD)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro | ||
|
||
$(DOCKER_ICCPD)_BASE_IMAGE_FILES += mclagdctl:/usr/bin/mclagdctl |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# iccpd package | ||
|
||
ICCPD_VERSION = 0.0.5 | ||
|
||
ICCPD = iccpd_$(ICCPD_VERSION)_amd64.deb | ||
$(ICCPD)_DEPENDS += $(LIBNL_GENL3_DEV) $(LIBNL_CLI_DEV) | ||
$(ICCPD)_RDEPENDS += $(LIBNL_GENL3) $(LIBNL_CLI) | ||
$(ICCPD)_SRC_PATH = $(SRC_PATH)/iccpd | ||
SONIC_MAKE_DEBS += $(ICCPD) | ||
# SONIC_STRETCH_DEBS += $(ICCPD) | ||
|
||
# Export these variables so they can be used in a sub-make | ||
export ICCPD_VERSION | ||
export ICCPD |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.ONESHELL: | ||
SHELL = /bin/bash | ||
.SHELLFLAGS += -e | ||
|
||
MAIN_TARGET = iccpd_$(ICCPD_VERSION)_amd64.deb | ||
DEB_PATH = debian | ||
|
||
all: iccpd-build mclagdctl-build | ||
|
||
iccpd-build: | ||
make -C src | ||
|
||
mclagdctl-build: | ||
make -C src/mclagdctl | ||
|
||
$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : | ||
make all | ||
if [ ! -d $(DEB_PATH)/usr/bin ]; then | ||
mkdir -p $(DEB_PATH)/usr/bin | ||
fi | ||
cp iccpd $(DEB_PATH)/usr/bin/iccpd | ||
cp src/mclagdctl/mclagdctl $(DEB_PATH)/usr/bin/mclagdctl | ||
chmod +x $(DEB_PATH)/usr/bin/iccpd | ||
chmod +x $(DEB_PATH)/usr/bin/mclagdctl | ||
md5sum $(DEB_PATH)/usr/bin/iccpd > $(DEB_PATH)/DEBIAN/md5sums | ||
md5sum $(DEB_PATH)/usr/bin/mclagdctl >> $(DEB_PATH)/DEBIAN/md5sums | ||
dpkg-deb -b $(DEB_PATH) $(DEST)/$(MAIN_TARGET) | ||
|
||
clean: iccpd-clean mclagdctl-clean | ||
|
||
iccpd-clean: | ||
make -C src clean | ||
|
||
mclagdctl-clean: | ||
make -C src/mclagdctl clean |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Package: iccpd-0.0.5-amd64 | ||
Source: nps | ||
Version: 0.0.5 | ||
Architecture: amd64 | ||
Maintainer: Simon Ji <Simon.Ji@nephosinc.com> | ||
Installed-Size: 1508 | ||
Depends: | ||
Section: main | ||
Priority: extra | ||
Homepage: https://github.com/NephosInc/SONiC | ||
Description: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* app_csm.h | ||
* | ||
* Copyright(c) 2016-2019 Nephos/Estinet. | ||
* | ||
* 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: jianjun, grace Li from nephos | ||
*/ | ||
|
||
#ifndef APP_CSM_H_ | ||
#define APP_CSM_H_ | ||
|
||
#include <sys/queue.h> | ||
|
||
#include "../include/mlacp_fsm.h" | ||
|
||
struct CSM; | ||
|
||
enum APP_CONNECTION_STATE | ||
{ | ||
APP_NONEXISTENT, | ||
APP_RESET, | ||
APP_CONNSENT, | ||
APP_CONNREC, | ||
APP_CONNECTING, | ||
APP_OPERATIONAL | ||
}; | ||
|
||
typedef enum APP_CONNECTION_STATE APP_CONNECTION_STATE_E; | ||
|
||
struct AppCSM | ||
{ | ||
struct mLACP mlacp; | ||
APP_CONNECTION_STATE_E current_state; | ||
|
||
uint32_t rx_connect_msg_id; | ||
uint32_t tx_connect_msg_id; | ||
uint32_t invalid_msg_id; | ||
|
||
TAILQ_HEAD(app_msg_list, Msg) app_msg_list; | ||
|
||
uint8_t invalid_msg : 1; | ||
uint8_t nak_msg : 1; | ||
}; | ||
|
||
void app_csm_init(struct CSM*, int all); | ||
void app_csm_finalize(struct CSM*); | ||
void app_csm_transit(struct CSM*); | ||
int app_csm_prepare_iccp_msg(struct CSM*, char*, size_t); | ||
void app_csm_enqueue_msg(struct CSM*, struct Msg*); | ||
struct Msg* app_csm_dequeue_msg(struct CSM*); | ||
void app_csm_correspond_from_msg(struct CSM*, struct Msg*); | ||
void app_csm_correspond_from_connect_msg(struct CSM*, struct Msg*); | ||
void app_csm_correspond_from_connect_ack_msg(struct CSM*, struct Msg*); | ||
int app_csm_prepare_nak_msg(struct CSM*, char*, size_t); | ||
int app_csm_prepare_connect_msg(struct CSM*, char*, size_t); | ||
int app_csm_prepare_connect_ack_msg(struct CSM*, char*, size_t); | ||
|
||
#endif /* APP_CSM_H_ */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello there - I am testing iccpd, and observet his jinja does not render in any correct data format, whitespace control might need some looking at.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jpsenior, We checked the format of iccpd.j2 carefully, and can not replicate this issue.