brmldproxy: add package

Adds the package brmldproxy from https://github.com/T-X/brmldproxy

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
This commit is contained in:
Linus Lüssing 2023-09-23 21:39:22 +02:00
parent 3d08b0fee8
commit 62ca2ad4a8
4 changed files with 212 additions and 0 deletions

44
net/brmldproxy/Makefile Normal file
View File

@ -0,0 +1,44 @@
# SPDX-License-Identifier: MIT
# Copyright (C) 2023 Linus Lüssing <linus.luessing@c0d3.blue>
include $(TOPDIR)/rules.mk
PKG_NAME:=brmldproxy
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2023-12-31
PKG_SOURCE_URL=https://github.com/T-X/brmldproxy.git
PKG_SOURCE_VERSION:=4d7fdb1a5c6e726b4c1930ad411d5571e09fa2f0
PKG_MIRROR_HASH:=1541eeaf6ae2fb4390448f02c5486da708cfa4d6200be77f884b47a2c86a7d06
PKG_MAINTAINER:=Linus Lüssing <linus.luessing@c0d3.blue>
PKG_LICENSE:=GPL-2.0-or-later
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
define Package/brmldproxy
SECTION:=net
CATEGORY:=Network
TITLE:=Bridge MLD Proxy
DEPENDS:=+tc
endef
define Package/brmldproxy/description
A userspace controlled MLD proxy implementation for a Linux bridge.
The bridge itself will appear as a single multicast listening host
to any MLD querier on a configured proxy port, acting in deputy
for any other multicast listener behind adjacent bridge ports.
This potentially reduces MLD report overhead.
brmldproxy further allows to filter out specific multicast groups
and bridge ports from its combined MLD report.
endef
define Package/brmldproxy/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/brmldproxy $(1)/usr/sbin/
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,brmldproxy))

View File

@ -0,0 +1,20 @@
#config brmldproxy 'lan'
# option disabled '1'
# # The bridge to apply brmldproxy to. Either the
# # bridge interface name or the UCI network interface
# # section name.
# option bridge 'lan'
# # Currently only "ipv6" is supported, optional.
# option family 'ipv6'
# # bridge port to proxy to
# list proxiedport 'wan0'
# # bridge port to proxy from
# list includedport 'lan0'
# # bridge port to exclude from proxying
# list excludedport 'lan1'
# # multicast IP address (range) to exclude from proxying
# list excludefilter 'ff00::/ff0e::'
# list excludefilter 'ff0e::/64'
# # multicast IP address (range) to include in proxying
# # (includes ff0e::123 even though ff0e::/64 was excluded above)
# list includefilter 'ff0e::123'

View File

@ -0,0 +1,37 @@
# SPDX-License-Identifier: MIT
# Copyright (C) 2023 Linus Lüssing <linus.luessing@c0d3.blue>
. /lib/functions.sh
[ -z "$INTERFACE" ] && exit 0
[ "$ACTION" != "ifup" ] && [ "$ACTION" != "ifdown" ] && exit 0
/etc/init.d/brmldproxy enabled || exit 0
brmldproxy_handle() {
local cfg="$1"
local disabled
local bridge
config_get_bool disabled "$cfg" disabled 0
[ "$disabled" -gt 0 ] && return 0
config_get bridge "$cfg" bridge
[ -z "$bridge" ] && return 0
[ "$bridge" != "$INTERFACE" ] && return 0
if [ "$ACTION" = "ifup" ]; then
/etc/init.d/brmldproxy start "$cfg" || return 0
else
/etc/init.d/brmldproxy stop "brmldproxy.$cfg" || return 0
fi
# success, stop
return 1
}
config_load brmldproxy
config_foreach brmldproxy_handle brmldproxy

View File

@ -0,0 +1,111 @@
#!/bin/sh /etc/rc.common
# SPDX-License-Identifier: MIT
# Copyright (C) 2023 Linus Lüssing <linus.luessing@c0d3.blue>
USE_PROCD=1
START=19
STOP=90
brmldproxy_start() {
local cfg="$1"
local namespace="$2"
local disabled
local ifname
local family
local bridge
local includedports
local excludedports
local proxiedports
local includefilters
local excludefilters
config_get_bool disabled "$cfg" disabled 0
[ "$disabled" -gt 0 ] && return 0
config_get bridge "$cfg" "bridge"
config_get family "$cfg" "family"
config_get includedports "$cfg" "includedport"
config_get excludedports "$cfg" "excludedport"
config_get proxiedports "$cfg" "proxiedport"
config_get includefilters "$cfg" "includefilter"
config_get excludefilters "$cfg" "excludefilter"
[ -z "$bridge" ] && {
echo "Error: no bridge specified for $cfg" >&2
return 0
}
. /lib/functions/network.sh
if network_get_device ifname "$bridge" && [ -n "$ifname" ]; then
bridge="$ifname"
fi
[ -n "$excludedports" ] && excludedports=$(echo "$excludedports" | sed 's/[^ ]* */-e &/g')
[ -n "$includedports" ] && includedports=$(echo "$includedports" | sed 's/[^ ]* */-i &/g')
[ -n "$proxiedports" ] && proxiedports=$(echo "$proxiedports" | sed 's/[^ ]* */-p &/g')
[ -n "$includefilters" ] && includefilters=$(echo "$includefilters" | sed 's/[^ ]* */-I &/g')
[ -n "$excludefilters" ] && excludefilters=$(echo "$excludefilters" | sed 's/[^ ]* */-E &/g')
[ -z "$namespace" ] && namespace="brmldproxy"
procd_open_instance "$namespace.$cfg"
procd_set_param command /usr/sbin/brmldproxy
[ "${family}" = "ipv4" ] && procd_append_param command -4
[ "${family}" = "ipv6" ] && procd_append_param command -6
procd_append_param command -b "$bridge"
[ -n "$excludedports" ] && procd_append_param command $excludedports
[ -n "$includedports" ] && procd_append_param command $includedports
[ -n "$proxiedports" ] && procd_append_param command $proxiedports
[ -n "$includefilters" ] && procd_append_param command $includefilters
[ -n "$excludefilters" ] && procd_append_param command $excludefilters
procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
procd_set_param stderr 1
procd_close_instance
}
start_service() {
local cfg="$1"
local namespace="$2"
local instance_found=0
. /lib/functions/network.sh
# no procd boot startup, via hotplug or manual only
[ $PPID -eq 1 ] && return 0
config_cb() {
local type="$1"
local name="$2"
if [ "$type" = "brmldproxy" ]; then
if [ -n "$cfg" -a "$cfg" = "$name" ]; then
instance_found=1
fi
fi
}
config_load brmldproxy
if [ -n "$cfg" ]; then
[ "$instance_found" -gt 0 ] || return
brmldproxy_start "$cfg" "$namespace"
else
config_foreach brmldproxy_start brmldproxy "$namespace"
fi
}
stop_service() {
local cfg="$1"
local namespace="$2"
[ -z "$namespace" ] && namespace="brmldproxy"
}
service_triggers() {
procd_add_reload_trigger brmldproxy
}