switch-fabric: add package that handles switch-fabric features

* add support for port mirroring
* lagcp will be housed within this package aswell in future

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2021-08-16 11:43:28 +02:00
parent cf8c89d9e1
commit 179d1b5770
5 changed files with 122 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=switch-fabric
PKG_RELEASE:=1
PKG_LICENSE:=BSD-3-Clause
PKG_MAINTAINER:=John Crispin <john@phrozen.org>
include $(INCLUDE_DIR)/package.mk
define Package/switch-fabric
SECTION:=ucentral
CATEGORY:=uCentral
TITLE:=switch-fabric
endef
define Package/switch-fabric/description
Allow configuring HW specific switch fabric features.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Compile/Default
endef
Build/Compile = $(Build/Compile/Default)
define Package/switch-fabric/install
$(CP) ./files/* $(1)
endef
$(eval $(call BuildPackage,switch-fabric))

View File

@@ -0,0 +1,19 @@
#!/bin/sh /etc/rc.common
START=90
USE_PROCD=1
PROG=/usr/libexec/switch.sh
reload_service() {
restart
}
service_triggers() {
procd_add_reload_trigger switch
}
start_service() {
procd_open_instance
procd_set_param command "$PROG"
procd_close_instance
}

View File

@@ -0,0 +1,23 @@
#!/bin/sh
. /lib/functions.sh
port_mirror() {
for lan in $(ls -d /sys/class/net/lan* | cut -dn -f3 |sort -n); do
tc qdisc del dev lan$lan clsact
done
monitor=$(uci get switch.mirror.monitor)
analysis=$(uci get switch.mirror.analysis)
[ -n "$monitor" -a -n "$analysis" ] || return
ifconfig $analysis up
for port in $monitor; do
tc qdisc add dev $port clsact
tc filter add dev $port ingress matchall skip_sw action mirred egress mirror dev $analysis
tc filter add dev $port egress matchall skip_sw action mirred egress mirror dev $analysis
done
}
port_mirror

View File

@@ -0,0 +1,46 @@
{
"uuid": 2,
"switch": {
"port-mirror": {
"monitor-ports": [ "WAN2" ],
"analysis-port": "WAN3"
}
},
"interfaces": [
{
"name": "WAN",
"role": "upstream",
"services": [ "lldp", "ssh" ],
"ethernet": [
{
"select-ports": [
"WAN*"
]
}
],
"ipv4": {
"addressing": "dynamic"
}
}
],
"metrics": {
"statistics": {
"interval": 120,
"types": [ "ssids", "lldp", "clients" ]
},
"health": {
"interval": 120
}
},
"services": {
"lldp": {
"describe": "uCentral",
"location": "universe"
},
"ssh": {
"port": 22
}
}
}