Skip to content

Commit

Permalink
gluon-statistics-mcast: adding initial package
Browse files Browse the repository at this point in the history
This package collects disected statistics on multicast
and management traffic and provides them via respondd in
"statistics-extended". Such information can be helpful
for further development and comparison of mesh routing
protocols and troubleshooting network issues.

The statistics gathered disect into batman-adv
packets as well. Statistics are collected both on client
bridge ports and br-client as well as mesh interfaces.

This introduces a performance penalty but tries to
keep the impact on unicast traffic small.

Note that respondd replies are rather large
(several UDP datagrams, even when LZMA compressed).
Therefore you might want to use slower intervals for
querying respondd "statistics-extended".

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
  • Loading branch information
T-X committed Jan 18, 2022
1 parent c16eb43 commit 06d95f2
Show file tree
Hide file tree
Showing 7 changed files with 1,285 additions and 0 deletions.
33 changes: 33 additions & 0 deletions package/gluon-statistics-mcast/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=gluon-statistics-mcast
PKG_VERSION:=1

include ../gluon.mk

define Package/gluon-statistics-mcast
TITLE:=Gluon Statistics for Multicast Traffic
DEPENDS:= +bpfcountd +libgluonutil
endef

define Package/gluon-statistics-mcast/description
This package collects disected statistics on multicast
and management traffic and provides them via respondd in
"statistics-extended". Such information can be helpful
for further development and comparison of mesh routing
protocols and troubleshooting network issues.

The statistics gathered disect into batman-adv
packets as well. Statistics are collected both on client
bridge ports and br-client as well as mesh interfaces.

This introduces a performance penalty but tries to
keep the impact on unicast traffic small.

Note that respondd replies are rather large
(several UDP datagrams, even when LZMA compressed).
Therefore you might want to use slower intervals for
querying respondd "statistics-extended".
endef

$(eval $(call BuildPackageGluon,gluon-statistics-mcast))
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
case "$INTERFACE" in
"client"|\
"mmfd")
;;
*)
exit 0
;;
esac

BPFCOUNTD_RUN="/var/run/bpfcountd"
mkdir -p "${BPFCOUNTD_RUN}/gluon-ifaces"

get_ifup_ifaces() {
local ifaces="$DEVICE"
local brports

if [ -d "/sys/class/net/$DEVICE/bridge/" ]; then
brports="$(ls "/sys/class/net/$DEVICE/brif/")"
[ -n "$brports" ] && ifaces="$(echo -e "${brports}\n${ifaces}")"
fi

echo "$ifaces"
}

get_ifdown_ifaces() {
cat "${BPFCOUNTD_RUN}/gluon-ifaces/$INTERFACE"
}

bpfcountd_start() {
local ifaces="$(get_ifup_ifaces)"
local iface

[ -z "$ifaces" ] && return
[ -f "${BPFCOUNTD_RUN}/gluon-ifaces/$INTERFACE" ] && return
echo "$ifaces" > "${BPFCOUNTD_RUN}/gluon-ifaces/$INTERFACE"

for iface in $ifaces; do
IFNAME="$iface" /lib/gluon/core/mesh/setup.d/40-bpfcountd "clients"
done
}

bpfcountd_stop() {
local ifaces="$(get_ifdown_ifaces)"
local iface

[ -z "$ifaces" ] && return
rm "${BPFCOUNTD_RUN}/gluon-ifaces/$INTERFACE"

for iface in $ifaces; do
IFNAME="$iface" /lib/gluon/core/mesh/teardown.d/40-bpfcountd
done
}

# synchronize reads+writes to /var/run/gluon-ifaces/$INTERFACE
lock /var/lock/gluon_bpfcountd_ifaces.lock

case "$ACTION" in
"ifup")
bpfcountd_start
;;
"ifdown")
bpfcountd_stop
;;
*)
;;
esac

lock -u /var/lock/gluon_bpfcountd_ifaces.lock
Loading

0 comments on commit 06d95f2

Please sign in to comment.