Skip to content
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

PVST Feature commit #1

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,7 @@
url = https://github.com/Marvell-switching/sonic-platform-arm64.git
[submodule "platform/innovium/sonic-platform-marvell"]
path = platform/innovium/sonic-platform-marvell
url = https://github.com/Marvell-switching/sonic-platform-marvell
url = https://github.com/Marvell-switching/sonic-platform-marvell
[submodule "src/sonic-stp"]
path = src/sonic-stp
url = https://github.com/sonic-net/sonic-stp
38 changes: 38 additions & 0 deletions dockers/docker-stp/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %}
FROM docker-config-engine-bookworm-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}}

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
libjemalloc2 \
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/"]
COPY ["critical_processes", "/etc/supervisor"]

ENTRYPOINT ["/usr/local/bin/supervisord"]
5 changes: 5 additions & 0 deletions dockers/docker-stp/base_image_files/stpctl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

# -t option needed only for shell, not for commands

docker exec -i stp stpctl "$@"
2 changes: 2 additions & 0 deletions dockers/docker-stp/critical_processes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
program:stpd
program:stpmgrd
11 changes: 11 additions & 0 deletions dockers/docker-stp/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/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
36 changes: 36 additions & 0 deletions dockers/docker-stp/supervisord.conf
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions files/build_templates/init_cfg.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
{% do features.append(("eventd","disabled", false, "enabled")) %}
{%- elif include_system_eventd == "y" %}
{% do features.append(("eventd", "enabled", false, "enabled")) %}
{%- if include_stp == "y" %}{% do features.append(("stp", "enabled", false, "enabled")) %}{% endif %}
{%- endif %}
"FEATURE": {
{# delayed field if set, will start the feature systemd .timer unit instead of .service unit #}
Expand Down
19 changes: 19 additions & 0 deletions files/build_templates/stp.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Unit]
Description=STP container
Requires=updategraph.service swss.service
After=updategraph.service swss.service syncd.service
Before=ntp-config.service
BindsTo=sonic.target
After=sonic.target
StartLimitIntervalSec=1200
StartLimitBurst=3

[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
RestartSec=30

[Install]
WantedBy=multi-user.target
1 change: 1 addition & 0 deletions files/image_config/logrotate/rsyslog.j2
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
/var/log/syslog
/var/log/teamd.log
/var/log/telemetry.log
/var/log/stpd.log
/var/log/gnmi.log
/var/log/frr/bgpd.log
/var/log/frr/zebra.log
Expand Down
8 changes: 8 additions & 0 deletions files/image_config/rsyslog/rsyslog.d/00-sonic.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,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
}
}
3 changes: 3 additions & 0 deletions rules/config
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ INCLUDE_GBSYNCD ?= y
# INCLUDE_TEAMD - build docker-teamd for LAG protocol support
INCLUDE_TEAMD ?= y

# INCLUDE_STP - build docker-stp for stp/pvst support
INCLUDE_STP = y

# INCLUDE_ROUTER_ADVERTISER - build docker-router-advertiser for router advertisements support
INCLUDE_ROUTER_ADVERTISER ?= y

Expand Down
31 changes: 31 additions & 0 deletions rules/docker-stp.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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) $(SONIC_RSYSLOG_PLUGIN)
$(DOCKER_STP)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BOOKWORM)_DBG_DEPENDS)
$(DOCKER_STP)_DBG_DEPENDS += $(STP) $(SWSS) $(SONIC_RSYSLOG_PLUGIN)

$(DOCKER_STP)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BOOKWORM)_DBG_IMAGE_PACKAGES)

$(DOCKER_STP)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_BOOKWORM)

ifeq ($(INCLUDE_STP), y)
SONIC_DOCKER_IMAGES += $(DOCKER_STP)
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_STP)

SONIC_DOCKER_DBG_IMAGES += $(DOCKER_STP_DBG)
SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_STP_DBG)
endif

$(DOCKER_STP)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_BOOKWORM)

$(DOCKER_STP)_CONTAINER_NAME = stp
$(DOCKER_STP)_RUN_OPT += -t --cap-add=NET_ADMIN --cap-add=SYS_ADMIN
$(DOCKER_STP)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro

$(DOCKER_STP)_BASE_IMAGE_FILES += stpctl:/usr/bin/stpctl
10 changes: 10 additions & 0 deletions rules/libevent.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 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)
18 changes: 18 additions & 0 deletions rules/sonic-stp.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# STP package
#
STP_VERSION = 1.0.0
export STP_VERSION

STP = stp_$(STP_VERSION)_$(CONFIGURED_ARCH).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_$(STP_VERSION)_$(CONFIGURED_ARCH).deb
$(STP_DBG)_DEPENDS += $(STP)
$(STP_DBG)_RDEPENDS += $(STP)
$(eval $(call add_derived_package,$(STP),$(STP_DBG)))

export STP
2 changes: 1 addition & 1 deletion rules/swss.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SWSS = swss_1.0.0_$(CONFIGURED_ARCH).deb
$(SWSS)_SRC_PATH = $(SRC_PATH)/sonic-swss
$(SWSS)_DEPENDS += $(LIBSAIREDIS_DEV) $(LIBSAIMETADATA_DEV) $(LIBTEAM_DEV) \
$(LIBTEAMDCTL) $(LIBTEAM_UTILS) $(LIBSWSSCOMMON_DEV) \
$(LIBSAIVS) $(LIBSAIVS_DEV) \
$(LIBSAIVS) $(LIBSAIVS_DEV) $(STP)\
$(PROTOBUF) $(PROTOBUF_LITE) $(PROTOBUF_DEV) $(LIB_SONIC_DASH_API)
$(SWSS)_UNINSTALLS = $(LIBSAIVS_DEV)

Expand Down
4 changes: 3 additions & 1 deletion slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ $(info "BLDENV" : "$(BLDENV)")
$(info "VS_PREPARE_MEM" : "$(VS_PREPARE_MEM)")
$(info "INCLUDE_MGMT_FRAMEWORK" : "$(INCLUDE_MGMT_FRAMEWORK)")
$(info "INCLUDE_ICCPD" : "$(INCLUDE_ICCPD)")
$(info "INCLUDE_STP" : "$(INCLUDE_STP)")
$(info "INCLUDE_SYSTEM_TELEMETRY" : "$(INCLUDE_SYSTEM_TELEMETRY)")
$(info "INCLUDE_SYSTEM_GNMI" : "$(INCLUDE_SYSTEM_GNMI)")
$(info "INCLUDE_SYSTEM_EVENTD" : "$(INCLUDE_SYSTEM_EVENTD)")
Expand Down Expand Up @@ -867,7 +868,7 @@ $(SONIC_INSTALL_DEBS) : $(DEBS_PATH)/%-install : .platform $$(addsuffix -install
# put a lock here because dpkg does not allow installing packages in parallel
if mkdir $(DEBS_PATH)/dpkg_lock &> /dev/null; then
ifneq ($(CROSS_BUILD_ENVIRON),y)
{ sudo DEBIAN_FRONTEND=noninteractive dpkg -i $(DEBS_PATH)/$* $(LOG) && rm -d $(DEBS_PATH)/dpkg_lock && break; } || { set +e; rm -d $(DEBS_PATH)/dpkg_lock; sudo lsof /var/lib/dpkg/lock-frontend; ps aux; exit 1 ; }
{ sudo DEBIAN_FRONTEND=noninteractive dpkg -i $($*_DPKGFLAGS) $(DEBS_PATH)/$* $(LOG) && rm -d $(DEBS_PATH)/dpkg_lock && break; } || { set +e; rm -d $(DEBS_PATH)/dpkg_lock; sudo lsof /var/lib/dpkg/lock-frontend; ps aux; exit 1 ; }
else
# Relocate debian packages python libraries to the cross python virtual env location
{ sudo DEBIAN_FRONTEND=noninteractive dpkg -i $(if $(findstring $(LINUX_HEADERS),$*),--force-depends) $(DEBS_PATH)/$* $(LOG) && \
Expand Down Expand Up @@ -1445,6 +1446,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
export include_dhcp_server="$(INCLUDE_DHCP_SERVER)"
export include_mgmt_framework="$(INCLUDE_MGMT_FRAMEWORK)"
export include_iccpd="$(INCLUDE_ICCPD)"
export include_stpd="$(INCLUDE_STP)"
export pddf_support="$(PDDF_SUPPORT)"
export include_pde="$(INCLUDE_PDE)"
export shutdown_bgp_on_start="$(SHUTDOWN_BGP_ON_START)"
Expand Down
20 changes: 20 additions & 0 deletions src/libevent/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.ONESHELL:
SHELL = /bin/bash
.SHELLFLAGS += -e

MAIN_TARGET = libevent_$(LIBEVENT_VERSION)_$(CONFIGURED_ARCH).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)
4 changes: 4 additions & 0 deletions src/libevent/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
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
1 change: 1 addition & 0 deletions src/libevent/debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7
18 changes: 18 additions & 0 deletions src/libevent/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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
16 changes: 16 additions & 0 deletions src/libevent/debian/rules
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/sonic-build-hooks/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DEPENDS := $(shell find scripts hooks debian -type f)
$(SONIC_BUILD_HOOKS_TARGET): $(DEPENDS)
@rm -rf $(BUILDINFO_DIR)/$(SONIC_BUILD_HOOKS) $(TMP_DIR)
@mkdir -p $(DEBIAN_DIR) $(SCRIPTS_PATH) $(HOOKS_PATH) $(SYMBOL_LINK_PATH) $(TRUSTED_GPG_PATH) $(BUILDINFO_DIR)
@chmod 0775 $(DEBIAN_DIR)
@chmod 00775 $(DEBIAN_DIR)
@cp debian/* $(DEBIAN_DIR)/
@cp scripts/* $(SCRIPTS_PATH)/
@cp hooks/* $(HOOKS_PATH)/
Expand Down
1 change: 1 addition & 0 deletions src/sonic-stp
Submodule sonic-stp added at 455e86