diff --git a/mcastmngr/files/common/etc/hotplug.d/iface/mcast.hotplug b/mcastmngr/files/common/etc/hotplug.d/iface/mcast.hotplug index 4345c949b..762a0abbe 100644 --- a/mcastmngr/files/common/etc/hotplug.d/iface/mcast.hotplug +++ b/mcastmngr/files/common/etc/hotplug.d/iface/mcast.hotplug @@ -20,7 +20,12 @@ compare_mcast_proxy_upstream() { for dev in $upstream; do if [ "$l3device" == "$dev" ]; then - ubus call uci commit '{"config":"mcast"}' + running=$(ubus call service list '{"name": "mcast"}' | jsonfilter -e '@.mcast.instances') + if [ -z "${running}" ];then + /etc/init.d/mcast start + else + ubus call uci commit '{"config":"mcast"}' + fi exit fi done diff --git a/mcastmngr/files/linux/lib/mcast/linux.sh b/mcastmngr/files/linux/lib/mcast/linux.sh index 93e5f24e9..43b609a49 100755 --- a/mcastmngr/files/linux/lib/mcast/linux.sh +++ b/mcastmngr/files/linux/lib/mcast/linux.sh @@ -1,6 +1,7 @@ #!/bin/sh . /lib/mcast/common.sh +. /lib/functions/network.sh include /lib/network @@ -95,6 +96,7 @@ config_mcproxy_instance() { local exceptions= local upstreams= local downstreams= + local intf_has_ip= CONFFILE=/var/etc/mcproxy_"$protocol".conf rm -f $CONFFILE @@ -157,7 +159,40 @@ config_mcproxy_instance() { [ -n "$upstreams" ] && [ -n "$downstreams" ] && config_mcproxy_interfaces "$upstreams" "$downstreams" "$exceptions" - PROG_PARAMS="${PROG_PARAMS} -f ${CONFFILE}${PROG_PARAMS_SEPARATOR}" + # In case on proxy, upstreams is a list. Iterating and running the mcproxy + # for each valid upstream interface + for upstream_device in $upstreams; + do + # Read the upstream interface for the upstream device + # upstream device can have multiple logical interfaces like wan and wan6 + # but same l3 device + local upstream_ifaces=$(get_network_of $upstream_device) + + for iface in $upstream_ifaces; + do + if [ "$protocol" == "igmp" ]; then + network_get_ipaddr upstream_ip $iface + if [ ! -z "${upstream_ip}" ]; then + intf_has_ip=1 + break + fi + fi + + if [ "$protocol" == "mld" ]; then + network_get_ipaddr6 upstream_ip $iface + if [ ! -z "${upstream_ip}" ]; then + intf_has_ip=1 + break + fi + fi + done + + if [ -z "${intf_has_ip}" ]; then + continue + fi + + PROG_PARAMS="${PROG_PARAMS} -f ${CONFFILE}${PROG_PARAMS_SEPARATOR}" + done } config_mcproxy() { @@ -203,4 +238,8 @@ configure_mcast() { read_mcast_snooping_params read_mcast_proxy_params config_mcproxy + + if [ -z "${PROG_PARAMS}" ]; then + exit 0 + fi }