Skip to content

Commit

Permalink
Flush route cache after route changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ysurac committed Jan 13, 2024
1 parent 4a21f31 commit 52a7f7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mptcp/files/etc/init.d/mptcp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ interface_multipath_settings() {
ip route replace $network/$netmask dev $iface scope link table $id $initcwrwnd 2>&1 >/dev/null
ip route replace default via $gateway dev $iface table $id $initcwrwnd 2>&1 >/dev/null
[ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ] && ip route replace default via $gateway dev $iface metric $id $initcwrwnd 2>&1 >/dev/null
#ip route flush $id
ip route flush cache $id 2>&1 >/dev/null
fi

#config_get mode "$config" multipath ""
Expand Down Expand Up @@ -395,7 +395,7 @@ interface_multipath_settings() {
ip -6 route replace $network6/$netmask6 dev $iface scope link table 6$id $initcwrwnd 2>&1 >/dev/null
ip -6 route replace default via $gateway6 dev $iface table 6$id $initcwrwnd 2>&1 >/dev/null
[ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ] && ip -6 route replace default via $gateway6 dev $iface metric 6$id $initcwrwnd 2>&1 >/dev/null
#ip -6 route flush 6$id 2>&1 >/dev/null
ip -6 route flush cache 6$id 2>&1 >/dev/null
fi

#config_get mode "$config" multipath "off"
Expand Down
8 changes: 8 additions & 0 deletions mptcp/files/usr/share/omr/post-tracking.d/001-post-tracking
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,7 @@ if [ "$multipath_config" = "master" ]; then
config_foreach set_server_default_route server
#config_foreach set_server_default_route6 server
fi
ip route flush cache 2>&1 >/dev/null
fi
if ([ "$default_gw6" != "$OMR_TRACKER_DEVICE_GATEWAY6" ] || [ "$default_gw6" = "" ]) && [ "$OMR_TRACKER_DEVICE_GATEWAY6" != "" ] && [ "$(uci -q get openmptcprouter.settings.master)" != "balancing" ]; then
omrvpn_intf=$(uci -q get "network.omrvpn.device" || echo "tun0")
Expand All @@ -1096,6 +1097,7 @@ if [ "$multipath_config" = "master" ]; then
#config_foreach set_server_default_route server
config_foreach set_server_default_route6 server
fi
ip -6 route flush cache 2>&1 >/dev/null
fi
#if [ "$(uci -q get openmptcprouter.settings.master)" = "balancing" ] && [ "$(ip route show default | grep weight)" = "" ] && [ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ] && [ "$(uci -q get openmptcprouter.settings.vpn)" != "mlvpn" ]; then
if [ "$(uci -q get openmptcprouter.settings.master)" = "balancing" ] && ([ "$(ip route show default | grep weight)" = "" ] || [ "$(ip -6 route show default | grep weight)" = "" ]) && [ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ]; then
Expand Down Expand Up @@ -1157,12 +1159,16 @@ if [ "$multipath_config" = "master" ]; then
}
}
fi
ip route flush cache 2>&1 >/dev/null
ip -6 route flush cache 2>&1 >/dev/null
fi
if [ -n "$OMR_TRACKER_DEVICE_GATEWAY" ] && [ -n "$OMR_TRACKER_DEVICE" ] && [ "$(ip r show table 991337)" != "default via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE " ]; then
ip route replace default via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE table 991337 $initcwrwnd 2>&1 >/dev/null
ip route flush cache 2>&1 >/dev/null
fi
if [ -n "$OMR_TRACKER_DEVICE_GATEWAY6" ] && [ -n "$OMR_TRACKER_DEVICE" ] && [ "$(ip -6 r show table 991337)" != "default via $OMR_TRACKER_DEVICE_GATEWAY6 dev $OMR_TRACKER_DEVICE " ]; then
ip -6 route replace default via $OMR_TRACKER_DEVICE_GATEWAY6 dev $OMR_TRACKER_DEVICE table 991337 $initcwrwnd 2>&1 >/dev/null
ip -6 route flush cache 2>&1 >/dev/null
fi
if ([ -n "$OMR_TRACKER_INTERFACE" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc)" = "" ]) || [ $(($(date +"%s") + $((10 + RANDOM % 31)) - $(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc))) -gt 3600 ] || [ "$(uci -q show openmptcprouter | grep get_config=\'1\')" != "" ] || [ "$(uci -q show openmptcprouter | grep admin_error=\'1\')" != "" ]; then
[ "$(pgrep -f openmptcprouter-vps)" = "" ] && /etc/init.d/openmptcprouter-vps restart >/dev/null 2>&1 &
Expand All @@ -1181,6 +1187,7 @@ if [ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
if [ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY" ] && [ -n "$OMR_TRACKER_DEVICE" ] && [ "$(ip r show dev $OMR_TRACKER_DEVICE | grep default)" = "" ] && [ -n "$OMR_TRACKER_INTERFACE" ] && [ "$(uci -q get network.$OMR_TRACKER_INTERFACE.metric)" != "" ]; then
_log "Interface route not yet set, set route ip r add default via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE metric $(uci -q get network.$OMR_TRACKER_INTERFACE.metric)"
ip r add default via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE metric $(uci -q get network.$OMR_TRACKER_INTERFACE.metric) >/dev/null 2>&1
ip route flush cache 2>&1 >/dev/null
fi
fi
if [ -n "$OMR_TRACKER_DEVICE_IP6" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY6" ]; then
Expand All @@ -1193,6 +1200,7 @@ if [ -n "$OMR_TRACKER_DEVICE_IP6" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY6" ]; th
fi
if [ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY6" ] && [ -n "$OMR_TRACKER_DEVICE" ] && [ "$(ip -6 r show dev $OMR_TRACKER_DEVICE | grep default)" = "" ] && [ -n "$OMR_TRACKER_INTERFACE" ] && [ "$(uci -q get network.$OMR_TRACKER_INTERFACE.metric)" != "" ]; then
ip -6 r replace default via $OMR_TRACKER_DEVICE_GATEWAY6 dev $OMR_TRACKER_DEVICE metric $(uci -q get network.$OMR_TRACKER_INTERFACE.metric) >/dev/null 2>&1
ip -6 route flush cache 2>&1 >/dev/null
fi
fi

Expand Down

0 comments on commit 52a7f7e

Please sign in to comment.