Skip to content

Commit

Permalink
brmldproxy: add package
Browse files Browse the repository at this point in the history
Adds the package brmldproxy from https://github.com/T-X/brmldproxy

Signed-off-by: Linus Lüssing <[email protected]>
  • Loading branch information
T-X committed Sep 23, 2023
1 parent 29912ec commit 42b56ae
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 0 deletions.
44 changes: 44 additions & 0 deletions net/brmldproxy/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# SPDX-License-Identifier: MIT
# Copyright (C) 2023 Linus Lüssing <[email protected]>

include $(TOPDIR)/rules.mk

PKG_NAME:=brmldproxy
PKG_RELEASE:=1

PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2023-09-22
PKG_SOURCE_URL=https://github.com/T-X/brmldproxy.git
PKG_SOURCE_VERSION:=a1ef0e6fabbaafa71a864077f4e4d4ac0f01f70a
PKG_MIRROR_HASH:=0a69debd02a4564de512e04d3bc18a9f091f05e0a6bf42b8d8657f5b1117d5cf

PKG_MAINTAINER:=Linus Lüssing <[email protected]>
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))
37 changes: 37 additions & 0 deletions net/brmldproxy/files/etc/hotplug.d/iface/50-brmldproxy
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-License-Identifier: MIT
# Copyright (C) 2023 Linus Lüssing <[email protected]>

. /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
111 changes: 111 additions & 0 deletions net/brmldproxy/files/etc/init.d/brmldproxy
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/bin/sh /etc/rc.common
# SPDX-License-Identifier: MIT
# Copyright (C) 2023 Linus Lüssing <[email protected]>

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
}

0 comments on commit 42b56ae

Please sign in to comment.