Skip to content

Commit be532c0

Browse files
vadymhlushko-mlnxskbarista
authored andcommitted
[sflow + dropmon] added the ENABLE_SFLOW_DROPMON build flag. Added patches for sflow repo. (sonic-net#10370)
* [sflow + dropmon] added INCLUDE_SFLOW_DROPMON flag, added patches for hsflowd *Added a capability of monitoring dropped packets for the sFlow daemon in order to improve network - monitoring, diagnostic, and troubleshooting. The drop monitor service allows the sFlow daemon to export another type of sample - dropped packets as Discard samples alongside Counter samples and Packet Flow samples. Signed-off-by: Vadym Hlushko <[email protected]>
1 parent 67308b0 commit be532c0

7 files changed

+246
-1
lines changed

rules/config

+3
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ INCLUDE_ICCPD = n
131131
# INCLUDE_SFLOW - build docker-sflow for sFlow support
132132
INCLUDE_SFLOW = y
133133

134+
# ENABLE_SFLOW_DROPMON - support of drop packets monitoring feature for sFlow deamon
135+
ENABLE_SFLOW_DROPMON = n
136+
134137
# INCLUDE_MGMT_FRAMEWORK - build docker-sonic-mgmt-framework for CLI and REST server support
135138
INCLUDE_MGMT_FRAMEWORK = y
136139

rules/sflow.mk

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# host-sflow package
22

3-
HSFLOWD_VERSION = 2.0.34
3+
HSFLOWD_VERSION = 2.0.35
44
HSFLOWD_SUBVERSION = 1
5+
6+
export ENABLE_SFLOW_DROPMON
57
export HSFLOWD_VERSION HSFLOWD_SUBVERSION
68

79
HSFLOWD = hsflowd_$(HSFLOWD_VERSION)-$(HSFLOWD_SUBVERSION)_$(CONFIGURED_ARCH).deb

slave.mk

+1
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ $(info "INCLUDE_SYSTEM_TELEMETRY" : "$(INCLUDE_SYSTEM_TELEMETRY)")
328328
$(info "ENABLE_HOST_SERVICE_ON_START" : "$(ENABLE_HOST_SERVICE_ON_START)")
329329
$(info "INCLUDE_RESTAPI" : "$(INCLUDE_RESTAPI)")
330330
$(info "INCLUDE_SFLOW" : "$(INCLUDE_SFLOW)")
331+
$(info "ENABLE_SFLOW_DROPMON" : "$(ENABLE_SFLOW_DROPMON)")
331332
$(info "INCLUDE_NAT" : "$(INCLUDE_NAT)")
332333
$(info "INCLUDE_DHCP_RELAY" : "$(INCLUDE_DHCP_RELAY)")
333334
$(info "INCLUDE_P4RT" : "$(INCLUDE_P4RT)")

src/sflow/hsflowd/Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
1616
stg init
1717
stg import -s ../patch/series
1818

19+
if [[ $(ENABLE_SFLOW_DROPMON) == y ]]; then
20+
stg repair
21+
stg import -s ../patch/dropmon/series
22+
fi
23+
1924
mkdir -p debian
2025
cp -r DEBIAN_build/* debian
2126
chmod u+x debian/rules
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
From 6ad3a8ef0339041a800a41dac96370c11b72d814 Mon Sep 17 00:00:00 2001
2+
From: Vadym Hlushko <[email protected]>
3+
Date: Fri, 4 Feb 2022 15:11:48 +0000
4+
Subject: [PATCH] [dropmon] workaround - created local copy of <linux/net_dropmon.h>
5+
TDB: this patch will be removed when we update docker-sflow to bullseye kernel.
6+
7+
Signed-off-by: Vadym Hlushko <[email protected]>
8+
---
9+
src/Linux/mod_dropmon.c | 2 +-
10+
src/Linux/my_dropmon.h | 132 ++++++++++++++++++++++++++++++++++++++++
11+
2 files changed, 133 insertions(+), 1 deletion(-)
12+
create mode 100644 src/Linux/my_dropmon.h
13+
14+
diff --git a/src/Linux/mod_dropmon.c b/src/Linux/mod_dropmon.c
15+
index 6b8ec6d..a37b157 100644
16+
--- a/src/Linux/mod_dropmon.c
17+
+++ b/src/Linux/mod_dropmon.c
18+
@@ -7,12 +7,12 @@ extern "C" {
19+
#endif
20+
21+
#include "hsflowd.h"
22+
+#include "my_dropmon.h"
23+
#include <asm/types.h>
24+
#include <sys/socket.h>
25+
#include <linux/types.h>
26+
#include <linux/netlink.h>
27+
#include <linux/genetlink.h>
28+
-#include <linux/net_dropmon.h>
29+
#include <net/if.h>
30+
#include <fnmatch.h>
31+
32+
diff --git a/src/Linux/my_dropmon.h b/src/Linux/my_dropmon.h
33+
new file mode 100644
34+
index 0000000..66048cc
35+
--- /dev/null
36+
+++ b/src/Linux/my_dropmon.h
37+
@@ -0,0 +1,132 @@
38+
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
39+
+#ifndef __NET_DROPMON_H
40+
+#define __NET_DROPMON_H
41+
+
42+
+#include <linux/types.h>
43+
+#include <linux/netlink.h>
44+
+
45+
+struct net_dm_drop_point {
46+
+ __u8 pc[8];
47+
+ __u32 count;
48+
+};
49+
+
50+
+#define is_drop_point_hw(x) do {\
51+
+ int ____i, ____j;\
52+
+ for (____i = 0; ____i < 8; i ____i++)\
53+
+ ____j |= x[____i];\
54+
+ ____j;\
55+
+} while (0)
56+
+
57+
+#define NET_DM_CFG_VERSION 0
58+
+#define NET_DM_CFG_ALERT_COUNT 1
59+
+#define NET_DM_CFG_ALERT_DELAY 2
60+
+#define NET_DM_CFG_MAX 3
61+
+
62+
+struct net_dm_config_entry {
63+
+ __u32 type;
64+
+ __u64 data __attribute__((aligned(8)));
65+
+};
66+
+
67+
+struct net_dm_config_msg {
68+
+ __u32 entries;
69+
+ struct net_dm_config_entry options[0];
70+
+};
71+
+
72+
+struct net_dm_alert_msg {
73+
+ __u32 entries;
74+
+ struct net_dm_drop_point points[0];
75+
+};
76+
+
77+
+struct net_dm_user_msg {
78+
+ union {
79+
+ struct net_dm_config_msg user;
80+
+ struct net_dm_alert_msg alert;
81+
+ } u;
82+
+};
83+
+
84+
+
85+
+/* These are the netlink message types for this protocol */
86+
+
87+
+enum {
88+
+ NET_DM_CMD_UNSPEC = 0,
89+
+ NET_DM_CMD_ALERT,
90+
+ NET_DM_CMD_CONFIG,
91+
+ NET_DM_CMD_START,
92+
+ NET_DM_CMD_STOP,
93+
+ NET_DM_CMD_PACKET_ALERT,
94+
+ NET_DM_CMD_CONFIG_GET,
95+
+ NET_DM_CMD_CONFIG_NEW,
96+
+ NET_DM_CMD_STATS_GET,
97+
+ NET_DM_CMD_STATS_NEW,
98+
+ _NET_DM_CMD_MAX,
99+
+};
100+
+
101+
+#define NET_DM_CMD_MAX (_NET_DM_CMD_MAX - 1)
102+
+
103+
+/*
104+
+ * Our group identifiers
105+
+ */
106+
+#define NET_DM_GRP_ALERT 1
107+
+
108+
+enum net_dm_attr {
109+
+ NET_DM_ATTR_UNSPEC,
110+
+
111+
+ NET_DM_ATTR_ALERT_MODE, /* u8 */
112+
+ NET_DM_ATTR_PC, /* u64 */
113+
+ NET_DM_ATTR_SYMBOL, /* string */
114+
+ NET_DM_ATTR_IN_PORT, /* nested */
115+
+ NET_DM_ATTR_TIMESTAMP, /* u64 */
116+
+ NET_DM_ATTR_PROTO, /* u16 */
117+
+ NET_DM_ATTR_PAYLOAD, /* binary */
118+
+ NET_DM_ATTR_PAD,
119+
+ NET_DM_ATTR_TRUNC_LEN, /* u32 */
120+
+ NET_DM_ATTR_ORIG_LEN, /* u32 */
121+
+ NET_DM_ATTR_QUEUE_LEN, /* u32 */
122+
+ NET_DM_ATTR_STATS, /* nested */
123+
+ NET_DM_ATTR_HW_STATS, /* nested */
124+
+ NET_DM_ATTR_ORIGIN, /* u16 */
125+
+ NET_DM_ATTR_HW_TRAP_GROUP_NAME, /* string */
126+
+ NET_DM_ATTR_HW_TRAP_NAME, /* string */
127+
+ NET_DM_ATTR_HW_ENTRIES, /* nested */
128+
+ NET_DM_ATTR_HW_ENTRY, /* nested */
129+
+ NET_DM_ATTR_HW_TRAP_COUNT, /* u32 */
130+
+ NET_DM_ATTR_SW_DROPS, /* flag */
131+
+ NET_DM_ATTR_HW_DROPS, /* flag */
132+
+ NET_DM_ATTR_FLOW_ACTION_COOKIE, /* binary */
133+
+
134+
+ __NET_DM_ATTR_MAX,
135+
+ NET_DM_ATTR_MAX = __NET_DM_ATTR_MAX - 1
136+
+};
137+
+
138+
+/**
139+
+ * enum net_dm_alert_mode - Alert mode.
140+
+ * @NET_DM_ALERT_MODE_SUMMARY: A summary of recent drops is sent to user space.
141+
+ * @NET_DM_ALERT_MODE_PACKET: Each dropped packet is sent to user space along
142+
+ * with metadata.
143+
+ */
144+
+enum net_dm_alert_mode {
145+
+ NET_DM_ALERT_MODE_SUMMARY,
146+
+ NET_DM_ALERT_MODE_PACKET,
147+
+};
148+
+
149+
+enum {
150+
+ NET_DM_ATTR_PORT_NETDEV_IFINDEX, /* u32 */
151+
+ NET_DM_ATTR_PORT_NETDEV_NAME, /* string */
152+
+
153+
+ __NET_DM_ATTR_PORT_MAX,
154+
+ NET_DM_ATTR_PORT_MAX = __NET_DM_ATTR_PORT_MAX - 1
155+
+};
156+
+
157+
+enum {
158+
+ NET_DM_ATTR_STATS_DROPPED, /* u64 */
159+
+
160+
+ __NET_DM_ATTR_STATS_MAX,
161+
+ NET_DM_ATTR_STATS_MAX = __NET_DM_ATTR_STATS_MAX - 1
162+
+};
163+
+
164+
+enum net_dm_origin {
165+
+ NET_DM_ORIGIN_SW,
166+
+ NET_DM_ORIGIN_HW,
167+
+};
168+
+
169+
+#endif
170+
--
171+
2.17.1
172+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
From 4bdd892662c08a396066ba6a1c55eac3f8aa0a5f Mon Sep 17 00:00:00 2001
2+
From: Vadym Hlushko <[email protected]>
3+
Date: Tue, 25 Jan 2022 12:59:40 +0000
4+
Subject: [PATCH] [sflow] enabled drop monitor support for SONiC
5+
6+
Signed-off-by: Vadym Hlushko <[email protected]>
7+
---
8+
src/Linux/Makefile | 2 +-
9+
src/Linux/hsflowd.c | 8 ++++++++
10+
src/Linux/scripts/hsflowd.conf.sonic | 2 ++
11+
3 files changed, 11 insertions(+), 1 deletion(-)
12+
13+
diff --git a/src/Linux/Makefile b/src/Linux/Makefile
14+
index 8128cf2..cf538e7 100644
15+
--- a/src/Linux/Makefile
16+
+++ b/src/Linux/Makefile
17+
@@ -34,7 +34,7 @@ FEATURES_DENT= DENT PSAMPLE SYSTEMD DROPMON
18+
FEATURES_EOS= EAPI
19+
FEATURES_OS10= OS10 DBUS SYSTEMD
20+
FEATURES_OPX= OPX DBUS SYSTEMD
21+
-FEATURES_SONIC= SONIC PSAMPLE DOCKER
22+
+FEATURES_SONIC= SONIC PSAMPLE DOCKER DROPMON
23+
FEATURES_XEN= XEN OVS
24+
FEATURES_HOST= NFLOG PCAP TCP DOCKER KVM OVS DBUS SYSTEMD
25+
26+
diff --git a/src/Linux/hsflowd.c b/src/Linux/hsflowd.c
27+
index 5d94e79..25031d1 100644
28+
--- a/src/Linux/hsflowd.c
29+
+++ b/src/Linux/hsflowd.c
30+
@@ -1877,6 +1877,14 @@ extern "C" {
31+
sp->psample.ingress = YES;
32+
sp->psample.egress = NO;
33+
sp->psample.group = 1;
34+
+ // drop-monitor support
35+
+ myLog(LOG_INFO, "drop-monitor support for SONiC");
36+
+ sp->dropmon.dropmon = YES;
37+
+ sp->dropmon.group = 1;
38+
+ sp->dropmon.start = NO;
39+
+ sp->dropmon.limit = 1000;
40+
+ sp->dropmon.sw = NO;
41+
+ sp->dropmon.hw = YES;
42+
#endif /* HSP_LOAD_SONIC */
43+
44+
#ifdef HSP_LOAD_XEN
45+
diff --git a/src/Linux/scripts/hsflowd.conf.sonic b/src/Linux/scripts/hsflowd.conf.sonic
46+
index e675730..fb52a54 100644
47+
--- a/src/Linux/scripts/hsflowd.conf.sonic
48+
+++ b/src/Linux/scripts/hsflowd.conf.sonic
49+
@@ -4,6 +4,8 @@
50+
sflow {
51+
# sonic {} loaded automatically
52+
# psample {} loaded automatically
53+
+ # packet drop monitoring:
54+
+ dropmon { group=1 start=on limit=1000 sw=off hw=on }
55+
# ====== detect new interfaces ======
56+
refreshAdaptors=60
57+
# ====== Agent IP selection ======
58+
--
59+
2.17.1
60+
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
0001-dropmon-workaround-created-local-copy-of-linux-net_dropmon.patch
2+
0001-sflow-enabled-drop-monitor-support-for-SONiC.patch

0 commit comments

Comments
 (0)