Browse Source

Merge pull request #13748 from aaronjg/mwan3-owner-procd

mwan3: fix mwan3 'use'
lilik-openwrt-22.03
Florian Eckert 4 years ago
committed by GitHub
parent
commit
33df7bbda8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 27 additions and 18 deletions
  1. +1
    -1
      net/mwan3/Makefile
  2. +5
    -0
      net/mwan3/files/etc/init.d/mwan3
  3. +3
    -0
      net/mwan3/files/lib/mwan3/common.sh
  4. +0
    -3
      net/mwan3/files/lib/mwan3/mwan3.sh
  5. +2
    -2
      net/mwan3/files/usr/libexec/rpcd/mwan3
  6. +2
    -2
      net/mwan3/files/usr/sbin/mwan3
  7. +8
    -8
      net/mwan3/files/usr/sbin/mwan3rtmon
  8. +6
    -2
      net/mwan3/files/usr/sbin/mwan3track

+ 1
- 1
net/mwan3/Makefile View File

@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=mwan3 PKG_NAME:=mwan3
PKG_VERSION:=2.10.0
PKG_VERSION:=2.10.1
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de> PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>
PKG_LICENSE:=GPL-2.0 PKG_LICENSE:=GPL-2.0


+ 5
- 0
net/mwan3/files/etc/init.d/mwan3 View File

@ -111,6 +111,11 @@ stop_service() {
mwan3_unlock "command" "mwan3" mwan3_unlock "command" "mwan3"
} }
reload_service() {
stop
start
}
service_triggers() { service_triggers() {
procd_add_reload_trigger 'mwan3' procd_add_reload_trigger 'mwan3'
} }

+ 3
- 0
net/mwan3/files/lib/mwan3/common.sh View File

@ -23,6 +23,9 @@ MMX_UNREACHABLE=""
MM_UNREACHABLE="" MM_UNREACHABLE=""
MAX_SLEEP=$(((1<<31)-1)) MAX_SLEEP=$(((1<<31)-1))
command -v ip6tables > /dev/null
NO_IPV6=$?
LOG() LOG()
{ {
local facility=$1; shift local facility=$1; shift


+ 0
- 3
net/mwan3/files/lib/mwan3/mwan3.sh View File

@ -24,9 +24,6 @@ IPv4_REGEX="((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[0
DEFAULT_LOWEST_METRIC=256 DEFAULT_LOWEST_METRIC=256
command -v ip6tables > /dev/null
NO_IPV6=$?
mwan3_push_update() mwan3_push_update()
{ {
# helper function to build an update string to pass on to # helper function to build an update string to pass on to


+ 2
- 2
net/mwan3/files/usr/libexec/rpcd/mwan3 View File

@ -5,8 +5,6 @@
. /usr/share/libubox/jshn.sh . /usr/share/libubox/jshn.sh
. /lib/mwan3/common.sh . /lib/mwan3/common.sh
MWAN3TRACK_STATUS_DIR="/var/run/mwan3track"
IPS="ipset" IPS="ipset"
IPT4="iptables -t mangle -w" IPT4="iptables -t mangle -w"
IPT6="ip6tables -t mangle -w" IPT6="ip6tables -t mangle -w"
@ -22,6 +20,7 @@ report_connected_v4() {
} }
report_connected_v6() { report_connected_v6() {
[ $NO_IPV6 -ne 0 ] && return
local address local address
if [ -n "$($IPT6 -S mwan3_connected 2> /dev/null)" ]; then if [ -n "$($IPT6 -S mwan3_connected 2> /dev/null)" ]; then
@ -60,6 +59,7 @@ report_policies_v4() {
} }
report_policies_v6() { report_policies_v6() {
[ $NO_IPV6 -ne 0 ] && return
local policy local policy
for policy in $($IPT6 -S | awk '{print $2}' | grep mwan3_policy_ | sort -u); do for policy in $($IPT6 -S | awk '{print $2}' | grep mwan3_policy_ | sort -u); do


+ 2
- 2
net/mwan3/files/usr/sbin/mwan3 View File

@ -123,7 +123,7 @@ restart() {
/etc/init.d/mwan3 start /etc/init.d/mwan3 start
} }
wrap() {
use() {
# Run a command with the device, src_ip and fwmark set to avoid processing by mwan3 # Run a command with the device, src_ip and fwmark set to avoid processing by mwan3
# firewall rules # firewall rules
@ -132,7 +132,7 @@ wrap() {
config_load mwan3 config_load mwan3
interface=$1 ; shift interface=$1 ; shift
[ -z "$*" ] && echo "no command specified for mwan3 wrap" && return
[ -z "$*" ] && echo "no command specified for mwan3 use" && return
network_get_device device $interface network_get_device device $interface
[ -z "$device" ] && echo "could not find device for $interface" && return [ -z "$device" ] && echo "could not find device for $interface" && return


+ 8
- 8
net/mwan3/files/usr/sbin/mwan3rtmon View File

@ -74,7 +74,7 @@ mwan3_rtmon_route_handle()
route_line=${1##"Deleted "} route_line=${1##"Deleted "}
route_family=$2 route_family=$2
config_get_boolean source_routing globals source_routing 0
config_get_bool source_routing globals source_routing 0
[ $source_routing -eq 0 ] && unset source_routing [ $source_routing -eq 0 ] && unset source_routing
if [ "$route_line" = "$1" ]; then if [ "$route_line" = "$1" ]; then
@ -107,22 +107,22 @@ mwan3_rtmon_route_handle()
local iface=$1 local iface=$1
tbl=$($IP route list table $tid 2>/dev/null)$'\n' tbl=$($IP route list table $tid 2>/dev/null)$'\n'
if [ "$(cat /var/run/mwan3track/$iface/STATUS)" != "online" ]; then
LOG debug "interface $iface is offline - skipping $route_line";
if [ -n "$iface" ] && [ "$(mwan3_get_mwan3track_status $iface)" != "active" ]; then
LOG debug "interface $iface is disabled - skipping '$route_line'";
return return
fi fi
# check that action needs to be performed. May not need to take action if we # check that action needs to be performed. May not need to take action if we
# got a delete event, but table was already flushed # got a delete event, but table was already flushed
if [ $action = "del" ] && [ -n "${tbl##*$route_line$'\n'*}" ]; then if [ $action = "del" ] && [ -n "${tbl##*$route_line$'\n'*}" ]; then
LOG debug "skipping already deleted route table $tid - skipping $route_line"
LOG debug "skipping already deleted route table $tid - skipping '$route_line'"
return return
fi fi
network_get_device device "$iface" network_get_device device "$iface"
LOG debug "adjusting route $device: $IP route $action table $tid $route_line"
LOG debug "adjusting route $device: '$IP route $action table $tid $route_line'"
$IP route "$action" table $tid $route_line || $IP route "$action" table $tid $route_line ||
LOG warn "failed: $IP route $action table $tid $route_line"
LOG warn "failed: '$IP route $action table $tid $route_line'"
} }
handle_route_cb(){ handle_route_cb(){
local iface=$1 local iface=$1
@ -163,9 +163,9 @@ main()
sh -c "echo \$\$; exec $IP monitor route" | { sh -c "echo \$\$; exec $IP monitor route" | {
read -r monitor_pid read -r monitor_pid
trap_with_arg func_trap "$monitor_pid" SIGINT SIGTERM SIGKILL trap_with_arg func_trap "$monitor_pid" SIGINT SIGTERM SIGKILL
while read -r line; do
while IFS='' read -r line; do
[ -z "${line##*table*}" ] && continue [ -z "${line##*table*}" ] && continue
LOG debug "handling route update $family $line"
LOG debug "handling route update $family '$line'"
mwan3_lock "service" "mwan3rtmon" mwan3_lock "service" "mwan3rtmon"
mwan3_rtmon_route_handle "$line" "$family" mwan3_rtmon_route_handle "$line" "$family"
mwan3_unlock "service" "mwan3rtmon" mwan3_unlock "service" "mwan3rtmon"


+ 6
- 2
net/mwan3/files/usr/sbin/mwan3track View File

@ -345,8 +345,12 @@ main() {
get_uptime > $MWAN3TRACK_STATUS_DIR/$INTERFACE/TIME get_uptime > $MWAN3TRACK_STATUS_DIR/$INTERFACE/TIME
host_up_count=0 host_up_count=0
sleep "${sleep_time}" &
wait
if [ "${IFDOWN_EVENT}" -ne 0 ] && [ "${IFUP_EVENT}" -ne 0 ]; then
sleep "${sleep_time}" &
SLEEP_PID=$!
wait
unset SLEEP_PID
fi
if [ "${IFDOWN_EVENT}" -eq 1 ]; then if [ "${IFDOWN_EVENT}" -eq 1 ]; then
LOG debug "Register ifdown event on interface ${INTERFACE} (${DEVICE})" LOG debug "Register ifdown event on interface ${INTERFACE} (${DEVICE})"


Loading…
Cancel
Save