OpenWrt/LEDE Project

  • Status Unconfirmed
  • Percent Complete
    0%
  • Task Type Bug Report
  • Category Base system
  • Assigned To No-one
  • Operating System All
  • Severity Low
  • Priority Very Low
  • Reported Version Trunk
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: OpenWrt/LEDE Project
Opened by howl - 26.11.2018

FS#1972 - omcproxy doesn't start at boot if enabled, works ok when started manually

Supply the following if possible:
- Device problem occurs on: Any you want.
- Software versions of OpenWrt/LEDE release, packages, etc.: OpenWrt 18.06.1 and omcproxy 2017-02-14-1fe6f48f-4
- Steps to reproduce: Enable omcproxy and restart router, omcproxy doesn’t brings up

I have configured properly omcproxy, works fine starting it manually with “service omcproxy start”, no problems at all. The issue is when booting up the device the startup script exits with 0 because the PROXIES variable is empty because no interfaces are ready when the script starts. Commenting Line number 117:” [ -n “$PROXIES” ] || return 0” makes it work as it should. The network triggers seems to make it start when the interfaces are ready.

Also in lines number 89 and 100 the proto specified for the firewall rules are any, but it’s more correct udp.

Will report in omcproxy github too.

howl commented on 28.11.2018 22:03

Using the hint I provided makes procd saying that omcproxy crashed 6 times in a row because the respaw, despite it then works because it gets started again because the trigger I decided to make a new init script so, I have done a new omcproxy init script heavily bassed in the igmpproxy one:

#!/bin/sh /etc/rc.common
# Copyright (C) 2018 OpenWrt.org

START=99
USE_PROCD=1
PROG=/usr/sbin/omcproxy

# Uncomment to enable verbosity 
#OPTIONS="-v" 

omcproxy_add_proxy() {
	local proxy scope uplink downlinks device up

	config_get scope $1 scope
	config_get uplink $1 uplink
	config_get downlinks $1 downlink

	[ -n "$uplink" ] || return

	local status="$(ubus -S call "network.interface.$uplink" status)"
	[ -n "$status" ] || return

	json_load "$status"
	json_get_var device l3_device
	json_get_var up up

	[ -n "$device" -a "$up" = "1" ] || {
		procd_append_param error "$uplink is not up"
		return;
	}

	proxy="$device"

	for downlink in $downlinks; do
		local status="$(ubus -S call "network.interface.$downlink" status)"
		[ -n "$status" ] || return

		json_load "$status"
		json_get_var device l3_device
		json_get_var up up

		[ -n "$device" -a "$up" = "1" ] || {
			procd_append_param error "$downlink is not up"
			continue;
		}

		proxy="$proxy,$device"

		# Disable in-kernel querier while ours is active, default is 1.
		[ -f /sys/class/net/$device/bridge/multicast_querier ] && \
			echo 0 > /sys/class/net/$device/bridge/multicast_querier
	done

	[ -n "$proxy" ] || return 0
	[ -n "$scope" ] && proxy="$proxy,scope=$scope"

	proxies="$proxies $proxy"
}

omcproxy_add_network_triggers() {
	local uplink downlinks

	config_get uplink $1 uplink
	config_get downlinks $1 downlink

	procd_add_interface_trigger "interface.*" $uplink /etc/init.d/omcproxy reload
	for downlink in $downlinks; do
		procd_add_interface_trigger "interface.*" $downlink /etc/init.d/omcproxy reload
	done
}

omcproxy_add_firewall_rules() {
	local uplink downlinks

	config_get uplink $1 uplink
	config_get downlinks $1 downlink

	upzone=$(fw3 -q network $uplink 2>/dev/null)
	[ -n "$upzone" ] || return 0

	json_add_object ""
	json_add_string type rule
	json_add_string src "$upzone"
	json_add_string family ipv4
	json_add_string proto igmp
	json_add_string target ACCEPT
	json_close_object

	json_add_object ""
	json_add_string type rule
	json_add_string family ipv6
	json_add_string src "$upzone"
	json_add_string proto icmp
	json_add_string src_ip fe80::/10
	json_add_array icmp_type
		json_add_string "" 130/0
		json_add_string "" 131/0
		json_add_string "" 132/0
		json_add_string "" 143/0
	json_close_array
	json_add_string target ACCEPT
	json_close_object

	for downlink in $downlinks; do
		downzone=$(fw3 -q network $downlink 2>/dev/null)
		[ -n "$downzone" ] || continue

		json_add_object ""
		json_add_string type rule
		json_add_string src "$upzone"
		json_add_string dest "$downzone"
		json_add_string family ipv4
		json_add_string proto udp
		json_add_string dest_ip "224.0.0.0/4"
		json_add_string target ACCEPT
		json_close_object

		json_add_object ""
		json_add_string type rule
		json_add_string src "$upzone"
		json_add_string dest "$downzone"
		json_add_string family ipv6
		json_add_string proto udp
		json_add_string dest_ip "ff00::/8"
		json_add_string target ACCEPT
		json_close_object
	done
}

service_triggers() {
	procd_add_reload_trigger "omcproxy"
	config_foreach omcproxy_add_network_triggers proxy
}

start_service() {
	proxies=""
	config_load omcproxy

	config_foreach omcproxy_add_proxy proxy
	[ -n "$proxies" ] || return 0

	procd_open_instance
	procd_set_param command $PROG
	[ -n "$OPTIONS" ] && procd_append_param command $OPTIONS
	procd_append_param command $proxies
	procd_set_param respawn

	procd_open_data

	json_add_array firewall
	config_foreach omcproxy_add_firewall_rules proxy
	json_close_array

	procd_close_data

	procd_close_instance

	# Increase maximum IPv4 group memberships per socket, default is 100.
	echo 128 > /proc/sys/net/ipv4/igmp_max_memberships
}

service_started() {
	procd_set_config_changed firewall
}

stop_service() {
	procd_set_config_changed firewall
}

If someone could review it and if it could be used in omcproxy package, go ahead, I put the OpenWrt.org copyright because as I said it only was a simple adoption and adjust of the igmpproxy init script logic to the way omcproxy config is.

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing