Browse Source

net/mwan3: add/remove src_ip from routing table

Add or remove local_source ip also if mwan3 is stopped or started

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
lilik-openwrt-22.03
Florian Eckert 7 years ago
parent
commit
2d9dfa3b1b
1 changed files with 26 additions and 2 deletions
  1. +26
    -2
      net/mwan3/files/usr/sbin/mwan3

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

@ -118,7 +118,7 @@ status()
start() start()
{ {
local enabled
local enabled src_ip local_source
config_load mwan3 config_load mwan3
config_get_bool enabled globals 'enabled' 0 config_get_bool enabled globals 'enabled' 0
@ -127,12 +127,30 @@ start()
exit 0 exit 0
} }
config_get local_source globals local_source 'none'
[ "${local_source}" = "none" ] || {
src_ip=$(uci_get_state mwan3 globals src_ip)
[ "${src_ip}" != "" ] && {
ip route del default via "${src_ip}" dev lo 1>/dev/null 2>&1
ip addr del "${src_ip}/32" dev lo 1>/dev/null 2>&1
}
network_get_ipaddr src_ip "${local_source}"
if [ "${src_ip}" = "" ]; then
$LOG warn "Unable to set source ip for own initiated traffic (${local_source})"
else
ip addr add "${src_ip}/32" dev lo
ip route add default via "${src_ip}" dev lo
uci_toggle_state mwan3 globals src_ip "${src_ip}"
fi
}
config_foreach ifup interface config_foreach ifup interface
} }
stop() stop()
{ {
local ipset route rule table IP IPT pid
local ipset route rule table IP IPT pid src_ip
for pid in $(pgrep -f "mwan3track"); do for pid in $(pgrep -f "mwan3track"); do
kill -TERM "$pid" > /dev/null 2>&1 kill -TERM "$pid" > /dev/null 2>&1
@ -178,6 +196,12 @@ stop()
mwan3_lock_clean mwan3_lock_clean
rm -rf $MWAN3_STATUS_DIR $MWAN3TRACK_STATUS_DIR rm -rf $MWAN3_STATUS_DIR $MWAN3TRACK_STATUS_DIR
src_ip=$(uci_get_state mwan3 globals src_ip)
[ "${src_ip}" = "" ] || {
ip route del default via "${src_ip}" dev lo 1>/dev/null 2>&1
ip addr del "${src_ip}/32" dev lo 1>/dev/null 2>&1
}
} }
restart() { restart() {


Loading…
Cancel
Save