Skip to content

Commit

Permalink
Replicate dropmon netlink defs to allow compilation on older Linux di…
Browse files Browse the repository at this point in the history
…stributions. And remove the kernel version test that was gating this before.
  • Loading branch information
sflow committed Jan 10, 2023
1 parent d0e0e9b commit b730e77
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/Linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ ifndef REDHAT
endif

# learn kernel version
KVER=$(shell ./kernelVersion.sh)
KERNEL54PLUS=$(shell if test $(KVER) -ge 5004000; then echo "yes"; else echo "no"; fi)
# KVER=$(shell ./kernelVersion.sh)
# KERNEL54PLUS=$(shell if test $(KVER) -ge 5004000; then echo "yes"; else echo "no"; fi)

HSFLOWD_CONF=scripts/hsflowd.conf
HSFLOWD_INITSCRIPT=scripts/hsflowd
Expand Down Expand Up @@ -46,10 +46,7 @@ FEATURES_DENTOS= DENT PSAMPLE SYSTEMD DROPMON
FEATURES_EOS= EAPI
FEATURES_OS10= OS10 DBUS SYSTEMD
FEATURES_OPX= OPX DBUS SYSTEMD
FEATURES_SONIC= SONIC PSAMPLE DOCKER
ifeq ($(KERNEL54PLUS),yes)
FEATURES_SONIC += DROPMON
endif
FEATURES_SONIC= SONIC PSAMPLE DOCKER DROPMON
FEATURES_XEN= XEN OVS
FEATURES_HOST= NFLOG PCAP TCP DOCKER KVM OVS DBUS SYSTEMD PSAMPLE DENT DROPMON

Expand Down
44 changes: 44 additions & 0 deletions src/Linux/mod_dropmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,50 @@ extern "C" {
#define DROPMON_GENL_NAME "NET_DM"
#endif

#define HSP_REPLICATE_DROPMON_DEFS 1
#ifdef HSP_REPLICATE_DROPMON_DEFS
/* Replicate the definitions we need from net_dropmon.h here,
so we can compile on an older OS if necessary. This assumes
that the kernel will only ever add to these, and never
change them.
*/

/* net_dm_addr */
#define NET_DM_ATTR_UNSPEC 0
#define NET_DM_ATTR_ALERT_MODE 1 /* u8 */
#define NET_DM_ATTR_PC 2 /* u64 */
#define NET_DM_ATTR_SYMBOL 3 /* string */
#define NET_DM_ATTR_IN_PORT 4 /* nested */
#define NET_DM_ATTR_TIMESTAMP 5 /* u64 */
#define NET_DM_ATTR_PROTO 6 /* u16 */
#define NET_DM_ATTR_PAYLOAD 7 /* binary */
#define NET_DM_ATTR_PAD 8
#define NET_DM_ATTR_TRUNC_LEN 9 /* u32 */
#define NET_DM_ATTR_ORIG_LEN 10 /* u32 */
#define NET_DM_ATTR_QUEUE_LEN 11 /* u32 */
#define NET_DM_ATTR_STATS 12 /* nested */
#define NET_DM_ATTR_HW_STATS 13 /* nested */
#define NET_DM_ATTR_ORIGIN 14 /* u16 */
#define NET_DM_ATTR_HW_TRAP_GROUP_NAME 15 /* string */
#define NET_DM_ATTR_HW_TRAP_NAME 16 /* string */
#define NET_DM_ATTR_HW_ENTRIES 17 /* nested */
#define NET_DM_ATTR_HW_ENTRY 18 /* nested */
#define NET_DM_ATTR_HW_TRAP_COUNT 19 /* u32 */
#define NET_DM_ATTR_SW_DROPS 20 /* flag */
#define NET_DM_ATTR_HW_DROPS 21 /* flag */
#define NET_DM_ATTR_MAX NET_DM_ATTR_HW_DROPS

/* net_dm_alert_mode */
#define NET_DM_ALERT_MODE_SUMMARY 0
#define NET_DM_ALERT_MODE_PACKET 1

/* net_dm_attr_port */
#define NET_DM_ATTR_PORT_NETDEV_IFINDEX 0 /* u32 */
#define NET_DM_ATTR_PORT_NETDEV_NAME 1 /* string */
#define NET_DM_ATTR_PORT_MAX NET_DM_ATTR_PORT_NETDEV_NAME

#endif /* HSP_REPLICATE_DROPMON_DEFS */

#define HSP_DROPMON_READNL_RCV_BUF 8192
#define HSP_DROPMON_READNL_BATCH 100
#define HSP_DROPMON_RCVBUF 8000000
Expand Down

0 comments on commit b730e77

Please sign in to comment.