The existing interface selection/detection code was incomprehensible at worst and convoluted at best. The uci config file suggested it understood an external ipv6 interface but in reality the init script took no notice. Re-work it so it is at least comprehendible and takes notice of ipv6 interface details if specified. Update the hotplug script to use the same interface selection/detection code as the init script and take note of ipv6 interface selection, only restarting miniupnpd on interface up events and only if that interface isn't already known (for that ip class) by miniupnpd. For me this has solved numerous 'flaky' startup problems, especially with regard to ipv6. Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
46 lines
1.3 KiB
Text
46 lines
1.3 KiB
Text
/etc/init.d/miniupnpd enabled || exit 0
|
|
|
|
# If miniupnpd is not running:
|
|
# - check on _any_ event (event updates may contribute to network_find_wan*)
|
|
|
|
# If miniupnpd _is_ running:
|
|
# - check only on ifup (otherwise lease updates etc would cause
|
|
# miniupnpd state loss)
|
|
|
|
. /lib/functions/procd.sh
|
|
|
|
[ "$ACTION" != "ifup" ] && procd_running "miniupnpd" "*" && exit 0
|
|
|
|
tmpconf="/var/etc/miniupnpd.conf"
|
|
external_iface=$(uci get upnpd.config.external_iface)
|
|
external_iface6=$(uci get upnpd.config.external_iface6)
|
|
external_zone=$(uci get upnpd.config.external_zone)
|
|
|
|
. /lib/functions/network.sh
|
|
|
|
if [ -n "$external_iface" ] ; then
|
|
network_get_device ifname "$external_iface"
|
|
else
|
|
if [ -n "$external_zone" ] ; then
|
|
ifname=$(fw3 -q zone "$external_zone" 2>/dev/null | head -1)
|
|
else
|
|
network_find_wan external_iface && \
|
|
network_get_device ifname "$external_iface"
|
|
fi
|
|
fi
|
|
if [ -n "$external_iface6" ] ; then
|
|
network_get_device ifname6 "$external_iface6"
|
|
else
|
|
if [ -n "$external_zone" ] ; then
|
|
ifname6=$(fw3 -q zone "$external_zone" 2>/dev/null | head -1)
|
|
else
|
|
network_find_wan6 external_iface6 && \
|
|
network_get_device ifname6 "$external_iface6"
|
|
fi
|
|
fi
|
|
|
|
[ "$DEVICE" != "$ifname" ] && [ "$DEVICE" != "$ifname6" ] && exit 0
|
|
|
|
grep -q "^ext_ifname=$ifname" "$tmpconf" && grep -q "^ext_ifname6=$ifname6" "$tmpconf" && exit 0
|
|
|
|
/etc/init.d/miniupnpd restart
|