diff --git a/.gitmodules b/.gitmodules index b2ffb2b26fff..8fd8d25e6e42 100644 --- a/.gitmodules +++ b/.gitmodules @@ -72,3 +72,7 @@ [submodule "src/sonic-ztp"] path = src/sonic-ztp url = https://github.com/Azure/sonic-ztp +[submodule "src/sonic-stp"] + path = src/sonic-stp + url = https://github.com/Azure/sonic-stp + diff --git a/dockers/docker-stp/Dockerfile.j2 b/dockers/docker-stp/Dockerfile.j2 new file mode 100644 index 000000000000..b5d49caced93 --- /dev/null +++ b/dockers/docker-stp/Dockerfile.j2 @@ -0,0 +1,37 @@ +{% 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 \ + libjansson4 \ + libpython2.7 \ + # Install redis-tools dependencies + # TODO: implicitly install dependencies + libjemalloc1 \ + ebtables + +{% if docker_stp_debs.strip() -%} +# Copy locally-built Debian package dependencies +{{ copy_files("debs/", docker_stp_debs.split(' '), "/debs/") }} + +# Install locally-built Debian packages and implicitly install their dependencies +{{ install_debian_packages(docker_stp_debs.split(' ')) }} +{%- endif %} + +RUN apt-get clean -y && \ + apt-get autoclean -y && \ + apt-get autoremove -y && \ + rm -rf /debs + +COPY ["start.sh", "/usr/bin/"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] + +ENTRYPOINT ["/usr/bin/supervisord"] diff --git a/dockers/docker-stp/base_image_files/stpctl b/dockers/docker-stp/base_image_files/stpctl new file mode 100755 index 000000000000..ee3420db2395 --- /dev/null +++ b/dockers/docker-stp/base_image_files/stpctl @@ -0,0 +1,5 @@ +#!/bin/bash + +# -t option needed only for shell, not for commands + +docker exec -i stp stpctl "$@" diff --git a/dockers/docker-stp/start.sh b/dockers/docker-stp/start.sh new file mode 100755 index 000000000000..1720366534f7 --- /dev/null +++ b/dockers/docker-stp/start.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +rm -f /var/run/rsyslogd.pid +rm -f /var/run/stpd/* +rm -f /var/run/stpmgrd/* + +supervisorctl start rsyslogd + +supervisorctl start stpd + +supervisorctl start stpmgrd + diff --git a/dockers/docker-stp/supervisord.conf b/dockers/docker-stp/supervisord.conf new file mode 100644 index 000000000000..3320c11b4f4b --- /dev/null +++ b/dockers/docker-stp/supervisord.conf @@ -0,0 +1,36 @@ +[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:stpd] +command=/usr/bin/stpd +priority=3 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:stpmgrd] +command=/usr/bin/stpmgrd +priority=3 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog diff --git a/files/build_templates/stp.service.j2 b/files/build_templates/stp.service.j2 new file mode 100644 index 000000000000..61ba9bda3d5b --- /dev/null +++ b/files/build_templates/stp.service.j2 @@ -0,0 +1,14 @@ +[Unit] +Description=STP container +Requires=updategraph.service swss.service +After=updategraph.service swss.service syncd.service +Before=ntp-config.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 diff --git a/files/image_config/logrotate/logrotate.d/rsyslog b/files/image_config/logrotate/logrotate.d/rsyslog index 76737ba14420..80b02b5126c9 100644 --- a/files/image_config/logrotate/logrotate.d/rsyslog +++ b/files/image_config/logrotate/logrotate.d/rsyslog @@ -27,6 +27,7 @@ /var/log/cron.log /var/log/syslog /var/log/teamd.log +/var/log/stpd.log /var/log/telemetry.log /var/log/quagga/bgpd.log /var/log/quagga/zebra.log diff --git a/files/image_config/rsyslog/rsyslog.d/00-sonic.conf b/files/image_config/rsyslog/rsyslog.d/00-sonic.conf index 455fe89fd2bf..f5409bfd5806 100644 --- a/files/image_config/rsyslog/rsyslog.d/00-sonic.conf +++ b/files/image_config/rsyslog/rsyslog.d/00-sonic.conf @@ -25,3 +25,11 @@ if $msg startswith " telemetry" or ($msg startswith " dialout" )then { /var/log/telemetry.log stop } + +## STPd rules +if $programname contains "stp" then { + if not ($msg contains "STP_SYSLOG") then { + /var/log/stpd.log + stop + } +} diff --git a/rules/docker-stp.mk b/rules/docker-stp.mk new file mode 100644 index 000000000000..8d514283b84a --- /dev/null +++ b/rules/docker-stp.mk @@ -0,0 +1,29 @@ +# Docker image for STP + +DOCKER_STP_STEM = docker-stp +DOCKER_STP = $(DOCKER_STP_STEM).gz +DOCKER_STP_DBG = $(DOCKER_STP_STEM)-$(DBG_IMAGE_MARK).gz + +$(DOCKER_STP)_PATH = $(DOCKERS_PATH)/$(DOCKER_STP_STEM) + +$(DOCKER_STP)_DEPENDS += $(STP) $(SWSS) +$(DOCKER_STP)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS) +$(DOCKER_STP)_DBG_DEPENDS += $(STP) $(SWSS) +$(DOCKER_STP)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES) + +SONIC_DOCKER_IMAGES += $(DOCKER_STP) +SONIC_STRETCH_DOCKERS += $(DOCKER_STP) +SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_STP) + +SONIC_DOCKER_DBG_IMAGES += $(DOCKER_STP_DBG) +SONIC_STRETCH_DBG_DOCKERS += $(DOCKER_STP_DBG) +SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_STP_DBG) + +$(DOCKER_STP)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_STRETCH) + +$(DOCKER_STP)_CONTAINER_NAME = stp +$(DOCKER_STP)_RUN_OPT += --net=host --privileged -t +$(DOCKER_STP)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro +$(DOCKER_STP)_RUN_OPT += -v /host/warmboot:/var/warmboot + +$(DOCKER_STP)_BASE_IMAGE_FILES += stpctl:/usr/bin/stpctl diff --git a/rules/libevent.mk b/rules/libevent.mk new file mode 100644 index 000000000000..4e56d6fcbe15 --- /dev/null +++ b/rules/libevent.mk @@ -0,0 +1,11 @@ +# libevent + +LIBEVENT_VERSION = 2.1.8 + +export LIBEVENT_VERSION + +LIBEVENT = libevent_$(LIBEVENT_VERSION)_amd64.deb +$(LIBEVENT)_DPKGFLAGS += --force-all +$(LIBEVENT)_SRC_PATH = $(SRC_PATH)/libevent +SONIC_MAKE_DEBS += $(LIBEVENT) + diff --git a/rules/stp.mk b/rules/stp.mk new file mode 100644 index 000000000000..f68dba777e02 --- /dev/null +++ b/rules/stp.mk @@ -0,0 +1,18 @@ +# STP package +# +STP_VERSION = 1.0.0 +export STP_VERSION + +STP = stp_$(STP_VERSION)_amd64.deb +$(STP)_SRC_PATH = $(SRC_PATH)/sonic-stp +$(STP)_DEPENDS += $(LIBEVENT) +$(STP)_DEPENDS += $(LIBSWSSCOMMON_DEV) +$(STP)_RDEPENDS += $(LIBSWSSCOMMON) +SONIC_DPKG_DEBS += $(STP) + +STP_DBG = stp-dbg_1.0.0_amd64.deb +$(STP_DBG)_DEPENDS += $(STP) +$(STP_DBG)_RDEPENDS += $(STP) +$(eval $(call add_derived_package,$(STP),$(STP_DBG))) + +export STP diff --git a/rules/swss.mk b/rules/swss.mk index f8044d77fb6a..79b6d7f91f36 100644 --- a/rules/swss.mk +++ b/rules/swss.mk @@ -3,7 +3,7 @@ SWSS = swss_1.0.0_$(CONFIGURED_ARCH).deb $(SWSS)_SRC_PATH = $(SRC_PATH)/sonic-swss $(SWSS)_DEPENDS += $(LIBSAIREDIS_DEV) $(LIBSAIMETADATA_DEV) $(LIBTEAM_DEV) \ - $(LIBTEAMDCT) $(LIBTEAM_UTILS) $(LIBSWSSCOMMON_DEV) + $(LIBTEAMDCT) $(LIBTEAM_UTILS) $(LIBSWSSCOMMON_DEV) $(STP) $(SWSS)_RDEPENDS += $(LIBSAIREDIS) $(LIBSAIMETADATA) $(LIBTEAM) $(LIBSWSSCOMMON) $(PYTHON_SWSSCOMMON) SONIC_DPKG_DEBS += $(SWSS) diff --git a/slave.mk b/slave.mk index 44b903ddf9c9..534f2b2148a2 100644 --- a/slave.mk +++ b/slave.mk @@ -399,7 +399,7 @@ $(SONIC_INSTALL_TARGETS) : $(DEBS_PATH)/%-install : .platform $$(addsuffix -inst # put a lock here because dpkg does not allow installing packages in parallel while true; do if mkdir $(DEBS_PATH)/dpkg_lock &> /dev/null; then - { sudo dpkg -i $(DEBS_PATH)/$* $(LOG) && rm -d $(DEBS_PATH)/dpkg_lock && break; } || { rm -d $(DEBS_PATH)/dpkg_lock && exit 1 ; } + { sudo dpkg -i $($*_DPKGFLAGS) $(DEBS_PATH)/$* $(LOG) && rm -d $(DEBS_PATH)/dpkg_lock && break; } || { rm -d $(DEBS_PATH)/dpkg_lock && exit 1 ; } fi done $(FOOTER) diff --git a/src/libevent/Makefile b/src/libevent/Makefile new file mode 100644 index 000000000000..04ac7578bd39 --- /dev/null +++ b/src/libevent/Makefile @@ -0,0 +1,21 @@ +.ONESHELL: +SHELL = /bin/bash +.SHELLFLAGS += -e + +MAIN_TARGET = libevent_$(LIBEVENT_VERSION)_amd64.deb + +$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : + # Obtaining the libevent + rm -rf ./libevent-$(LIBEVENT_VERSION)-stable + wget -N "https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz" + tar -xzf libevent-$(LIBEVENT_VERSION)-stable.tar.gz + rm -rf libevent-$(LIBEVENT_VERSION)-stable.tar.gz + cp debian libevent-$(LIBEVENT_VERSION)-stable -r + + pushd ./libevent-$(LIBEVENT_VERSION)-stable + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + popd + mv $(MAIN_TARGET) $(DEST)/ + +#$(addprefix $(DEST)/, $(DERIVED_TARGETS)): $(DEST)/% : $(DEST)/$(MAIN_TARGET) + diff --git a/src/libevent/debian/changelog b/src/libevent/debian/changelog new file mode 100644 index 000000000000..470a86850c2d --- /dev/null +++ b/src/libevent/debian/changelog @@ -0,0 +1,5 @@ +sonic (2.1.8) stable; urgency=medium + + * libevent 2.1.8 stable version pulled github + -- LIBEVENT <@broadcom.com> Fri, 26 Apr 2019 12:00:00 -0800 + diff --git a/src/libevent/debian/compat b/src/libevent/debian/compat new file mode 100644 index 000000000000..ec635144f600 --- /dev/null +++ b/src/libevent/debian/compat @@ -0,0 +1 @@ +9 diff --git a/src/libevent/debian/control b/src/libevent/debian/control new file mode 100644 index 000000000000..bfe135fba03d --- /dev/null +++ b/src/libevent/debian/control @@ -0,0 +1,19 @@ +Source: sonic +Maintainer: Broadcom +Section: net +Priority: optional +Build-Depends: dh-exec (>=0.3), debhelper (>= 9), autotools-dev +Standards-Version: 1.0.0 + +Package: libevent +Architecture: any +Depends: ${shlibs:Depends} +Description: This package contains Libevent2.1.8 for SONiC project. + +Package: libevent-dbg +Architecture: any +Section: debug +Priority: extra +Depends: libevent (=${binary:Version}) +Description: debugging symbols for libevent + diff --git a/src/libevent/debian/rules b/src/libevent/debian/rules new file mode 100755 index 000000000000..a781d09adf5c --- /dev/null +++ b/src/libevent/debian/rules @@ -0,0 +1,16 @@ +#!/usr/bin/make -f + +DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/default.mk + +%: + dh $@ --with autotools-dev + +override_dh_auto_configure: + dh_auto_configure -- --disable-samples --disable-libevent-regress + +override_dh_auto_install: + dh_auto_install --destdir=debian/libevent + +override_dh_strip: + dh_strip --dbg-package=libevent-dbg