forked from sonoble/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sflow]: Build infrastructure changes to support sflow docker and uti…
…lities (sonic-net#3251) Introduce a new "sflow" container (if ENABLE_SFLOW is set). The new docker will include: hsflowd : host-sflow based daemon is the sFlow agent psample : Built from libpsample repository. Useful in debugging sampled packets/groups. sflowtool : Locally dump sflow samples (e.g. with a in-unit collector) In case of SONiC-VS, enable psample & act_sample kernel modules. VS' syncd needs iproute2=4.20.0-2~bpo9+1 & libcap2-bin=1:2.25-1 to support tc-sample tc-syncd is provided as a convenience tool for debugging (e.g. tc-syncd filter show ...)
- Loading branch information
1 parent
ac1d2c1
commit 75104bb
Showing
28 changed files
with
500 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{% 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 \ | ||
dmidecode \ | ||
libmnl0=1.0.4-2 | ||
|
||
{% if docker_sflow_debs.strip() -%} | ||
# Copy locally-built Debian package dependencies | ||
{{ copy_files("debs/", docker_sflow_debs.split(' '), "/debs/") }} | ||
|
||
# Install locally-built Debian packages and implicitly install their dependencies | ||
{{ install_debian_packages(docker_sflow_debs.split(' ')) }} | ||
{%- endif %} | ||
|
||
RUN apt-get clean -y && \ | ||
apt-get autoclean -y && \ | ||
apt-get autoremove -y && \ | ||
rm -rf /debs | ||
|
||
RUN sed -ri '/^DAEMON_ARGS=""/c DAEMON_ARGS="-c /var/log/hsflowd.crash"' /etc/init.d/hsflowd | ||
|
||
COPY ["start.sh", "/usr/bin/"] | ||
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] | ||
|
||
ENTRYPOINT ["/usr/bin/supervisord"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 sflow psample "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 sflow sflowtool "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
rm -f /var/run/rsyslogd.pid | ||
|
||
supervisorctl start rsyslogd | ||
|
||
supervisorctl start sflowmgrd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[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:sflowmgrd] | ||
command=/usr/bin/sflowmgrd | ||
priority=3 | ||
autostart=false | ||
autorestart=false | ||
stdout_logfile=syslog | ||
stderr_logfile=syslog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[Unit] | ||
Description=sFlow container | ||
Requires=swss.service | ||
After=swss.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# docker image for sFlow agent | ||
|
||
DOCKER_SFLOW_STEM = docker-sflow | ||
DOCKER_SFLOW = $(DOCKER_SFLOW_STEM).gz | ||
DOCKER_SFLOW_DBG = $(DOCKER_SFLOW_STEM)-$(DBG_IMAGE_MARK).gz | ||
|
||
$(DOCKER_SFLOW)_PATH = $(DOCKERS_PATH)/$(DOCKER_SFLOW_STEM) | ||
|
||
$(DOCKER_SFLOW)_DEPENDS += $(SWSS) $(REDIS_TOOLS) $(HSFLOWD) $(SFLOWTOOL) $(PSAMPLE) | ||
$(DOCKER_SFLOW)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS) | ||
$(DOCKER_TEAMD)_DBG_DEPENDS += $(SWSS_DBG) $(LIBSWSSCOMMON_DBG) | ||
$(DOCKER_SFLOW)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES) | ||
|
||
$(DOCKER_SFLOW)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_STRETCH) | ||
|
||
SONIC_DOCKER_IMAGES += $(DOCKER_SFLOW) | ||
ifeq ($(ENABLE_SFLOW), y) | ||
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_SFLOW) | ||
SONIC_STRETCH_DOCKERS += $(DOCKER_SFLOW) | ||
endif | ||
|
||
SONIC_DOCKER_DBG_IMAGES += $(DOCKER_SFLOW_DBG) | ||
ifeq ($(ENABLE_SFLOW), y) | ||
SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_SFLOW_DBG) | ||
SONIC_STRETCH_DBG_DOCKERS += $(DOCKER_SFLOW_DBG) | ||
endif | ||
|
||
$(DOCKER_SFLOW)_CONTAINER_NAME = sflow | ||
$(DOCKER_SFLOW)_RUN_OPT += --net=host --privileged -t | ||
$(DOCKER_SFLOW)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro | ||
$(DOCKER_SFLOW)_RUN_OPT += -v /host/warmboot:/var/warmboot | ||
|
||
$(DOCKER_SFLOW)_BASE_IMAGE_FILES += psample:/usr/bin/psample | ||
$(DOCKER_SFLOW)_BASE_IMAGE_FILES += sflowtool:/usr/bin/sflowtool | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# host-sflow package | ||
|
||
HSFLOWD_VERSION = 2.0.21 | ||
HSFLOWD_SUBVERSION = 8 | ||
export HSFLOWD_VERSION HSFLOWD_SUBVERSION | ||
|
||
HSFLOWD = hsflowd_$(HSFLOWD_VERSION)-$(HSFLOWD_SUBVERSION)_$(CONFIGURED_ARCH).deb | ||
$(HSFLOWD)_DEPENDS += $(LIBHIREDIS_DEV) $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) | ||
$(HSFLOWD)_SRC_PATH = $(SRC_PATH)/sflow/hsflowd | ||
|
||
SONIC_MAKE_DEBS += $(HSFLOWD) | ||
SONIC_STRETCH_DEBS += $(HSFLOWD) | ||
|
||
HSFLOWD_DBG = hsflowd-dbg_$(HSFLOWD_VERSION)-$(HSFLOWD_SUBVERSION)_$(CONFIGURED_ARCH).deb | ||
$(HSFLOWD_DBG)_DEPENDS += $(HSFLOWD) | ||
$(HSFLOWD_DBG)_RDEPENDS += $(HSFLOWD) | ||
$(eval $(call add_derived_package,$(HSFLOWD),$(HSFLOWD_DBG))) | ||
|
||
export HSFLOWD HSFLOWD_DBG | ||
|
||
# sflowtool package | ||
|
||
SFLOWTOOL_VERSION = 5.04 | ||
export SFLOWTOOL_VERSION | ||
|
||
SFLOWTOOL = sflowtool_$(SFLOWTOOL_VERSION)_$(CONFIGURED_ARCH).deb | ||
$(SFLOWTOOL)_SRC_PATH = $(SRC_PATH)/sflow/sflowtool | ||
|
||
SONIC_MAKE_DEBS += $(SFLOWTOOL) | ||
SONIC_STRETCH_DEBS += $(SFLOWTOOL) | ||
export SFLOWTOOL | ||
|
||
# psample package | ||
|
||
PSAMPLE_VERSION = 1.1 | ||
PSAMPLE_SUBVERSION = 1 | ||
export PSAMPLE_VERSION PSAMPLE_SUBVERSION | ||
|
||
PSAMPLE = psample_$(PSAMPLE_VERSION)-$(PSAMPLE_SUBVERSION)_$(CONFIGURED_ARCH).deb | ||
$(PSAMPLE)_SRC_PATH = $(SRC_PATH)/sflow/psample | ||
|
||
SONIC_MAKE_DEBS += $(PSAMPLE) | ||
SONIC_STRETCH_DEBS += $(PSAMPLE) | ||
export PSAMPLE | ||
|
||
# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} | ||
# are archived into debug one image to facilitate debugging. | ||
# | ||
DBG_SRC_ARCHIVE += sflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.ONESHELL: | ||
SHELL = /bin/bash | ||
.SHELLFLAGS += -e | ||
|
||
MAIN_TARGET = $(HSFLOWD) | ||
DERIVED_TARGET = $(HSFLOWD_DBG) | ||
|
||
$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : | ||
rm -fr ./host-sflow | ||
git clone https://github.com/sflow/host-sflow | ||
|
||
pushd ./host-sflow | ||
git checkout -b sflow -f 996f5ec | ||
|
||
# Apply patch series | ||
stg init | ||
stg import -s ../patch/series | ||
|
||
mkdir -p debian | ||
cp -r DEBIAN_build/* debian | ||
chmod u+x debian/rules | ||
sed -i -e s/_VERSION_/$(HSFLOWD_VERSION)-$(HSFLOWD_SUBVERSION)/g debian/changelog | ||
|
||
dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --buildinfo-option=-u. --changes-option=-u. | ||
|
||
mv $(DERIVED_TARGET) $* $(DEST)/ | ||
popd | ||
|
||
$(addprefix $(DEST)/, $(DERIVED_TARGET)): $(DEST)/% : $(DEST)/$(MAIN_TARGET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
diff -ruN a/src/Linux/linux/psample.h b/src/Linux/linux/psample.h | ||
--- a/src/Linux/linux/psample.h 1969-12-31 16:00:00.000000000 -0800 | ||
+++ b/src/Linux/linux/psample.h 2019-07-20 08:45:58.715748881 -0700 | ||
@@ -0,0 +1,35 @@ | ||
+#ifndef __UAPI_PSAMPLE_H | ||
+#define __UAPI_PSAMPLE_H | ||
+ | ||
+enum { | ||
+ /* sampled packet metadata */ | ||
+ PSAMPLE_ATTR_IIFINDEX, | ||
+ PSAMPLE_ATTR_OIFINDEX, | ||
+ PSAMPLE_ATTR_ORIGSIZE, | ||
+ PSAMPLE_ATTR_SAMPLE_GROUP, | ||
+ PSAMPLE_ATTR_GROUP_SEQ, | ||
+ PSAMPLE_ATTR_SAMPLE_RATE, | ||
+ PSAMPLE_ATTR_DATA, | ||
+ | ||
+ /* commands attributes */ | ||
+ PSAMPLE_ATTR_GROUP_REFCOUNT, | ||
+ | ||
+ __PSAMPLE_ATTR_MAX | ||
+}; | ||
+ | ||
+enum psample_command { | ||
+ PSAMPLE_CMD_SAMPLE, | ||
+ PSAMPLE_CMD_GET_GROUP, | ||
+ PSAMPLE_CMD_NEW_GROUP, | ||
+ PSAMPLE_CMD_DEL_GROUP, | ||
+}; | ||
+ | ||
+/* Can be overridden at runtime by module option */ | ||
+#define PSAMPLE_ATTR_MAX (__PSAMPLE_ATTR_MAX - 1) | ||
+ | ||
+#define PSAMPLE_NL_MCGRP_CONFIG_NAME "config" | ||
+#define PSAMPLE_NL_MCGRP_SAMPLE_NAME "packets" | ||
+#define PSAMPLE_GENL_NAME "psample" | ||
+#define PSAMPLE_GENL_VERSION 1 | ||
+ | ||
+#endif |
Oops, something went wrong.