diff --git a/rules/config b/rules/config index 0fdbc2b59e..dc973cbd12 100644 --- a/rules/config +++ b/rules/config @@ -131,6 +131,9 @@ INCLUDE_ICCPD = n # INCLUDE_SFLOW - build docker-sflow for sFlow support INCLUDE_SFLOW = y +# ENABLE_SFLOW_DROPMON - support of drop packets monitoring feature for sFlow deamon +ENABLE_SFLOW_DROPMON = n + # INCLUDE_MGMT_FRAMEWORK - build docker-sonic-mgmt-framework for CLI and REST server support INCLUDE_MGMT_FRAMEWORK = y diff --git a/rules/sflow.mk b/rules/sflow.mk index 1942a91065..78b917535b 100644 --- a/rules/sflow.mk +++ b/rules/sflow.mk @@ -1,7 +1,9 @@ # host-sflow package -HSFLOWD_VERSION = 2.0.34 +HSFLOWD_VERSION = 2.0.35 HSFLOWD_SUBVERSION = 1 + +export ENABLE_SFLOW_DROPMON export HSFLOWD_VERSION HSFLOWD_SUBVERSION HSFLOWD = hsflowd_$(HSFLOWD_VERSION)-$(HSFLOWD_SUBVERSION)_$(CONFIGURED_ARCH).deb diff --git a/slave.mk b/slave.mk index 092c515475..79e8fa7eb2 100644 --- a/slave.mk +++ b/slave.mk @@ -328,6 +328,7 @@ $(info "INCLUDE_SYSTEM_TELEMETRY" : "$(INCLUDE_SYSTEM_TELEMETRY)") $(info "ENABLE_HOST_SERVICE_ON_START" : "$(ENABLE_HOST_SERVICE_ON_START)") $(info "INCLUDE_RESTAPI" : "$(INCLUDE_RESTAPI)") $(info "INCLUDE_SFLOW" : "$(INCLUDE_SFLOW)") +$(info "ENABLE_SFLOW_DROPMON" : "$(ENABLE_SFLOW_DROPMON)") $(info "INCLUDE_NAT" : "$(INCLUDE_NAT)") $(info "INCLUDE_DHCP_RELAY" : "$(INCLUDE_DHCP_RELAY)") $(info "INCLUDE_P4RT" : "$(INCLUDE_P4RT)") diff --git a/src/sflow/hsflowd/Makefile b/src/sflow/hsflowd/Makefile index e29dbcc199..d4312b30c2 100644 --- a/src/sflow/hsflowd/Makefile +++ b/src/sflow/hsflowd/Makefile @@ -16,6 +16,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg init stg import -s ../patch/series + if [[ $(ENABLE_SFLOW_DROPMON) == y ]]; then + stg repair + stg import -s ../patch/dropmon/series + fi + mkdir -p debian cp -r DEBIAN_build/* debian chmod u+x debian/rules diff --git a/src/sflow/hsflowd/patch/dropmon/0001-dropmon-workaround-created-local-copy-of-linux-net_dropmon.patch b/src/sflow/hsflowd/patch/dropmon/0001-dropmon-workaround-created-local-copy-of-linux-net_dropmon.patch new file mode 100644 index 0000000000..80a2a20aa8 --- /dev/null +++ b/src/sflow/hsflowd/patch/dropmon/0001-dropmon-workaround-created-local-copy-of-linux-net_dropmon.patch @@ -0,0 +1,172 @@ +From 6ad3a8ef0339041a800a41dac96370c11b72d814 Mon Sep 17 00:00:00 2001 +From: Vadym Hlushko +Date: Fri, 4 Feb 2022 15:11:48 +0000 +Subject: [PATCH] [dropmon] workaround - created local copy of +TDB: this patch will be removed when we update docker-sflow to bullseye kernel. + +Signed-off-by: Vadym Hlushko +--- + src/Linux/mod_dropmon.c | 2 +- + src/Linux/my_dropmon.h | 132 ++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 133 insertions(+), 1 deletion(-) + create mode 100644 src/Linux/my_dropmon.h + +diff --git a/src/Linux/mod_dropmon.c b/src/Linux/mod_dropmon.c +index 6b8ec6d..a37b157 100644 +--- a/src/Linux/mod_dropmon.c ++++ b/src/Linux/mod_dropmon.c +@@ -7,12 +7,12 @@ extern "C" { + #endif + + #include "hsflowd.h" ++#include "my_dropmon.h" + #include + #include + #include + #include + #include +-#include + #include + #include + +diff --git a/src/Linux/my_dropmon.h b/src/Linux/my_dropmon.h +new file mode 100644 +index 0000000..66048cc +--- /dev/null ++++ b/src/Linux/my_dropmon.h +@@ -0,0 +1,132 @@ ++/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ ++#ifndef __NET_DROPMON_H ++#define __NET_DROPMON_H ++ ++#include ++#include ++ ++struct net_dm_drop_point { ++ __u8 pc[8]; ++ __u32 count; ++}; ++ ++#define is_drop_point_hw(x) do {\ ++ int ____i, ____j;\ ++ for (____i = 0; ____i < 8; i ____i++)\ ++ ____j |= x[____i];\ ++ ____j;\ ++} while (0) ++ ++#define NET_DM_CFG_VERSION 0 ++#define NET_DM_CFG_ALERT_COUNT 1 ++#define NET_DM_CFG_ALERT_DELAY 2 ++#define NET_DM_CFG_MAX 3 ++ ++struct net_dm_config_entry { ++ __u32 type; ++ __u64 data __attribute__((aligned(8))); ++}; ++ ++struct net_dm_config_msg { ++ __u32 entries; ++ struct net_dm_config_entry options[0]; ++}; ++ ++struct net_dm_alert_msg { ++ __u32 entries; ++ struct net_dm_drop_point points[0]; ++}; ++ ++struct net_dm_user_msg { ++ union { ++ struct net_dm_config_msg user; ++ struct net_dm_alert_msg alert; ++ } u; ++}; ++ ++ ++/* These are the netlink message types for this protocol */ ++ ++enum { ++ NET_DM_CMD_UNSPEC = 0, ++ NET_DM_CMD_ALERT, ++ NET_DM_CMD_CONFIG, ++ NET_DM_CMD_START, ++ NET_DM_CMD_STOP, ++ NET_DM_CMD_PACKET_ALERT, ++ NET_DM_CMD_CONFIG_GET, ++ NET_DM_CMD_CONFIG_NEW, ++ NET_DM_CMD_STATS_GET, ++ NET_DM_CMD_STATS_NEW, ++ _NET_DM_CMD_MAX, ++}; ++ ++#define NET_DM_CMD_MAX (_NET_DM_CMD_MAX - 1) ++ ++/* ++ * Our group identifiers ++ */ ++#define NET_DM_GRP_ALERT 1 ++ ++enum net_dm_attr { ++ NET_DM_ATTR_UNSPEC, ++ ++ NET_DM_ATTR_ALERT_MODE, /* u8 */ ++ NET_DM_ATTR_PC, /* u64 */ ++ NET_DM_ATTR_SYMBOL, /* string */ ++ NET_DM_ATTR_IN_PORT, /* nested */ ++ NET_DM_ATTR_TIMESTAMP, /* u64 */ ++ NET_DM_ATTR_PROTO, /* u16 */ ++ NET_DM_ATTR_PAYLOAD, /* binary */ ++ NET_DM_ATTR_PAD, ++ NET_DM_ATTR_TRUNC_LEN, /* u32 */ ++ NET_DM_ATTR_ORIG_LEN, /* u32 */ ++ NET_DM_ATTR_QUEUE_LEN, /* u32 */ ++ NET_DM_ATTR_STATS, /* nested */ ++ NET_DM_ATTR_HW_STATS, /* nested */ ++ NET_DM_ATTR_ORIGIN, /* u16 */ ++ NET_DM_ATTR_HW_TRAP_GROUP_NAME, /* string */ ++ NET_DM_ATTR_HW_TRAP_NAME, /* string */ ++ NET_DM_ATTR_HW_ENTRIES, /* nested */ ++ NET_DM_ATTR_HW_ENTRY, /* nested */ ++ NET_DM_ATTR_HW_TRAP_COUNT, /* u32 */ ++ NET_DM_ATTR_SW_DROPS, /* flag */ ++ NET_DM_ATTR_HW_DROPS, /* flag */ ++ NET_DM_ATTR_FLOW_ACTION_COOKIE, /* binary */ ++ ++ __NET_DM_ATTR_MAX, ++ NET_DM_ATTR_MAX = __NET_DM_ATTR_MAX - 1 ++}; ++ ++/** ++ * enum net_dm_alert_mode - Alert mode. ++ * @NET_DM_ALERT_MODE_SUMMARY: A summary of recent drops is sent to user space. ++ * @NET_DM_ALERT_MODE_PACKET: Each dropped packet is sent to user space along ++ * with metadata. ++ */ ++enum net_dm_alert_mode { ++ NET_DM_ALERT_MODE_SUMMARY, ++ NET_DM_ALERT_MODE_PACKET, ++}; ++ ++enum { ++ NET_DM_ATTR_PORT_NETDEV_IFINDEX, /* u32 */ ++ NET_DM_ATTR_PORT_NETDEV_NAME, /* string */ ++ ++ __NET_DM_ATTR_PORT_MAX, ++ NET_DM_ATTR_PORT_MAX = __NET_DM_ATTR_PORT_MAX - 1 ++}; ++ ++enum { ++ NET_DM_ATTR_STATS_DROPPED, /* u64 */ ++ ++ __NET_DM_ATTR_STATS_MAX, ++ NET_DM_ATTR_STATS_MAX = __NET_DM_ATTR_STATS_MAX - 1 ++}; ++ ++enum net_dm_origin { ++ NET_DM_ORIGIN_SW, ++ NET_DM_ORIGIN_HW, ++}; ++ ++#endif +-- +2.17.1 + diff --git a/src/sflow/hsflowd/patch/dropmon/0001-sflow-enabled-drop-monitor-support-for-SONiC.patch b/src/sflow/hsflowd/patch/dropmon/0001-sflow-enabled-drop-monitor-support-for-SONiC.patch new file mode 100644 index 0000000000..7a3561fd7d --- /dev/null +++ b/src/sflow/hsflowd/patch/dropmon/0001-sflow-enabled-drop-monitor-support-for-SONiC.patch @@ -0,0 +1,60 @@ +From 4bdd892662c08a396066ba6a1c55eac3f8aa0a5f Mon Sep 17 00:00:00 2001 +From: Vadym Hlushko +Date: Tue, 25 Jan 2022 12:59:40 +0000 +Subject: [PATCH] [sflow] enabled drop monitor support for SONiC + +Signed-off-by: Vadym Hlushko +--- + src/Linux/Makefile | 2 +- + src/Linux/hsflowd.c | 8 ++++++++ + src/Linux/scripts/hsflowd.conf.sonic | 2 ++ + 3 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/src/Linux/Makefile b/src/Linux/Makefile +index 8128cf2..cf538e7 100644 +--- a/src/Linux/Makefile ++++ b/src/Linux/Makefile +@@ -34,7 +34,7 @@ FEATURES_DENT= DENT PSAMPLE SYSTEMD DROPMON + FEATURES_EOS= EAPI + FEATURES_OS10= OS10 DBUS SYSTEMD + FEATURES_OPX= OPX DBUS SYSTEMD +-FEATURES_SONIC= SONIC PSAMPLE DOCKER ++FEATURES_SONIC= SONIC PSAMPLE DOCKER DROPMON + FEATURES_XEN= XEN OVS + FEATURES_HOST= NFLOG PCAP TCP DOCKER KVM OVS DBUS SYSTEMD + +diff --git a/src/Linux/hsflowd.c b/src/Linux/hsflowd.c +index 5d94e79..25031d1 100644 +--- a/src/Linux/hsflowd.c ++++ b/src/Linux/hsflowd.c +@@ -1877,6 +1877,14 @@ extern "C" { + sp->psample.ingress = YES; + sp->psample.egress = NO; + sp->psample.group = 1; ++ // drop-monitor support ++ myLog(LOG_INFO, "drop-monitor support for SONiC"); ++ sp->dropmon.dropmon = YES; ++ sp->dropmon.group = 1; ++ sp->dropmon.start = NO; ++ sp->dropmon.limit = 1000; ++ sp->dropmon.sw = NO; ++ sp->dropmon.hw = YES; + #endif /* HSP_LOAD_SONIC */ + + #ifdef HSP_LOAD_XEN +diff --git a/src/Linux/scripts/hsflowd.conf.sonic b/src/Linux/scripts/hsflowd.conf.sonic +index e675730..fb52a54 100644 +--- a/src/Linux/scripts/hsflowd.conf.sonic ++++ b/src/Linux/scripts/hsflowd.conf.sonic +@@ -4,6 +4,8 @@ + sflow { + # sonic {} loaded automatically + # psample {} loaded automatically ++ # packet drop monitoring: ++ dropmon { group=1 start=on limit=1000 sw=off hw=on } + # ====== detect new interfaces ====== + refreshAdaptors=60 + # ====== Agent IP selection ====== +-- +2.17.1 + diff --git a/src/sflow/hsflowd/patch/dropmon/series b/src/sflow/hsflowd/patch/dropmon/series new file mode 100644 index 0000000000..1a4bb1772a --- /dev/null +++ b/src/sflow/hsflowd/patch/dropmon/series @@ -0,0 +1,2 @@ +0001-dropmon-workaround-created-local-copy-of-linux-net_dropmon.patch +0001-sflow-enabled-drop-monitor-support-for-SONiC.patch \ No newline at end of file