1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Fix WAN IPv6 support if WAN IPv4 is also available

This commit is contained in:
Ycarus (Yannick Chabanois) 2021-01-21 11:27:28 +01:00
parent b350af4207
commit bd954b3f78

View file

@ -210,14 +210,14 @@ set_routes_intf6() {
weight=1 weight=1
fi fi
if [ "$multipath_config_route" = "backup" ]; then if [ "$multipath_config_route" = "backup" ]; then
nbintfb=$((nbintfb+1)) nbintfb6=$((nbintfb6+1))
if [ -z "$routesintfbackup6" ]; then if [ -z "$routesintfbackup6" ]; then
routesintfbackup6="nexthop via $interface_gw dev $interface_if weight $weight" routesintfbackup6="nexthop via $interface_gw dev $interface_if weight $weight"
else else
routesintfbackup6="$routesintfbackup6 nexthop via $interface_gw dev $interface_if weight $weight" routesintfbackup6="$routesintfbackup6 nexthop via $interface_gw dev $interface_if weight $weight"
fi fi
else else
nbintf=$((nbintf+1)) nbintf6=$((nbintf6+1))
if [ -z "$routesintf6" ]; then if [ -z "$routesintf6" ]; then
routesintf6="nexthop via $interface_gw dev $interface_if weight $weight" routesintf6="nexthop via $interface_gw dev $interface_if weight $weight"
else else
@ -304,10 +304,10 @@ set_route_balancing6() {
weight=1 weight=1
fi fi
if [ "$multipath_config_route" = "backup" ]; then if [ "$multipath_config_route" = "backup" ]; then
nbintfb=$((nbintfb+1)) nbintfb6=$((nbintfb6+1))
routesbalancingbackup6="$routesbalancingbackup6 nexthop via $interface_gw dev $interface_if weight $weight" routesbalancingbackup6="$routesbalancingbackup6 nexthop via $interface_gw dev $interface_if weight $weight"
else else
nbintf=$((nbintf+1)) nbintf6=$((nbintf6+1))
routesbalancing6="$routesbalancing6 nexthop via $interface_gw dev $interface_if weight $weight" routesbalancing6="$routesbalancing6 nexthop via $interface_gw dev $interface_if weight $weight"
fi fi
fi fi
@ -369,13 +369,13 @@ set_server_all_routes6() {
if [ "$serverip" != "" ] && [ "$OMR_TRACKER_DEVICE_GATEWAY6" != "" ] && [ "$multipath_config_route" != "off" ] && [ "$interface_up" = "true" ]; then if [ "$serverip" != "" ] && [ "$OMR_TRACKER_DEVICE_GATEWAY6" != "" ] && [ "$multipath_config_route" != "off" ] && [ "$interface_up" = "true" ]; then
routesintf="" routesintf=""
routesintfbackup="" routesintfbackup=""
nbintf=0 nbintf6=0
nbintfb=0 nbintfb6=0
config_load network config_load network
config_foreach set_routes_intf interface config_foreach set_routes_intf interface
uintf="$(echo $routesintf | awk '{print $5}')" uintf="$(echo $routesintf | awk '{print $5}')"
uintfb="$(echo $routesintfbackup | awk '{print $5}')" uintfb="$(echo $routesintfbackup | awk '{print $5}')"
if [ -n "$routesintf" ] && ([ "$nbintf" -gt "1" ] && [ "$(ip -6 r show $serverip metric 0 | tr -d '\t' | tr -d '\n')" != "$serverip $routesintf " ]) || ([ "$nbintf" = "1" ] && [ "$(ip -6 r show $serverip metric 0 | grep $uintf)" = "" ]); then if [ -n "$routesintf" ] && ([ "$nbintf6" -gt "1" ] && [ "$(ip -6 r show $serverip metric 0 | tr -d '\t' | tr -d '\n')" != "$serverip $routesintf " ]) || ([ "$nbintf6" = "1" ] && [ "$(ip -6 r show $serverip metric 0 | grep $uintf)" = "" ]); then
while [ "$(ip -6 r show $serverip | grep -v nexthop | sed 's/ //g' | tr -d '\n')" != "$serverip" ] && [ "$(ip -6 r show $serverip | grep -v nexthop | sed 's/ //g' | tr -d '\n')" != "" ]; do while [ "$(ip -6 r show $serverip | grep -v nexthop | sed 's/ //g' | tr -d '\n')" != "$serverip" ] && [ "$(ip -6 r show $serverip | grep -v nexthop | sed 's/ //g' | tr -d '\n')" != "" ]; do
ip -6 r del $serverip ip -6 r del $serverip
done done
@ -383,8 +383,8 @@ set_server_all_routes6() {
ip -6 route replace $serverip scope global $routesintf ip -6 route replace $serverip scope global $routesintf
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "New server route is $(ip -6 r show $serverip metric 0 | tr -d '\t' | tr -d '\n')" [ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "New server route is $(ip -6 r show $serverip metric 0 | tr -d '\t' | tr -d '\n')"
fi fi
if [ -n "$routesintfbackup" ] && ([ "$nbintfb" -gt "1" ] && [ "$(ip -6 r show $serverip metric 999 | tr -d '\t' | tr -d '\n')" != "$serverip $routesintfbackup " ]) || ([ "$nbintfb" = "1" ] && [ "$(ip -6 r show $serverip metric 999 | grep $uintfb)" = "" ]); then if [ -n "$routesintfbackup" ] && ([ "$nbintfb6" -gt "1" ] && [ "$(ip -6 r show $serverip metric 999 | tr -d '\t' | tr -d '\n')" != "$serverip $routesintfbackup " ]) || ([ "$nbintfb6" = "1" ] && [ "$(ip -6 r show $serverip metric 999 | grep $uintfb)" = "" ]); then
[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "Set server $server ($serverip) backup default route $serverip $routesintfbackup nbintfb $nbintfb $OMR_TRACKER_DEVICE" [ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "Set server $server ($serverip) backup default route $serverip $routesintfbackup nbintfb $nbintfb6 $OMR_TRACKER_DEVICE"
ip -6 route replace $serverip scope global metric 999 $routesintfbackup ip -6 route replace $serverip scope global metric 999 $routesintfbackup
fi fi
fi fi
@ -796,6 +796,7 @@ if [ "$multipath_config" = "master" ]; then
routesbalancing="" routesbalancing=""
routesbalancingbackup="" routesbalancingbackup=""
nbintf=0 nbintf=0
nbintf6=0
config_load network config_load network
config_foreach set_route_balancing interface config_foreach set_route_balancing interface
config_foreach set_route_balancing6 interface config_foreach set_route_balancing6 interface
@ -806,7 +807,7 @@ if [ "$multipath_config" = "master" ]; then
} }
} }
[ -n "$routesbalancing6" ] && { [ -n "$routesbalancing6" ] && {
([ "$nbintf" -gt "1" ] && [ "$(ip -6 r show default metric 1 | tr -d '\t' | tr -d '\n')" != "default via $routesbalancing6 " ]) || ([ "$nbintf" = "1" ] && [ "$(ip -6 r show default metric 1 | grep $OMR_TRACKER_DEVICE)" = "" ]) && { ([ "$nbintf6" -gt "1" ] && [ "$(ip -6 r show default metric 1 | tr -d '\t' | tr -d '\n')" != "default via $routesbalancing6 " ]) || ([ "$nbintf6" = "1" ] && [ "$(ip -6 r show default metric 1 | grep $OMR_TRACKER_DEVICE)" = "" ]) && {
_log "Set ip -6 route replace default scope global metric 1 $routesbalancing6" _log "Set ip -6 route replace default scope global metric 1 $routesbalancing6"
ip -6 route replace default scope global metric 1 $routesbalancing6 ip -6 route replace default scope global metric 1 $routesbalancing6
} }
@ -818,7 +819,7 @@ if [ "$multipath_config" = "master" ]; then
} }
} }
[ -n "$routesbalancingbackup6" ] && { [ -n "$routesbalancingbackup6" ] && {
([ "$nbintf" -gt "1" ] && [ "$(ip -6 r show default metric 999 | tr -d '\t' | tr -d '\n')" != "default via $routesbalancingbackup6 " ]) || ([ "$nbintf" = "1" ] && [ "$(ip -6 r show default metric 999 | grep $OMR_TRACKER_DEVICE)" = "" ]) && { ([ "$nbintf6" -gt "1" ] && [ "$(ip -6 r show default metric 999 | tr -d '\t' | tr -d '\n')" != "default via $routesbalancingbackup6 " ]) || ([ "$nbintf6" = "1" ] && [ "$(ip -6 r show default metric 999 | grep $OMR_TRACKER_DEVICE)" = "" ]) && {
_log "Set backup ip -6 route replace default scope global $routesbalancingbackup6" _log "Set backup ip -6 route replace default scope global $routesbalancingbackup6"
ip -6 route replace default scope global metric 999 $routesbalancingbackup6 ip -6 route replace default scope global metric 999 $routesbalancingbackup6
} }