mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Fix mptcp script
This commit is contained in:
parent
92fbb3144f
commit
74c76481b9
7 changed files with 141 additions and 114 deletions
|
@ -133,6 +133,13 @@ workflows:
|
|||
- build_x86:
|
||||
requires:
|
||||
- prepare
|
||||
filters:
|
||||
branches:
|
||||
only: /v[0-9]+(\.[0-9]+)*/
|
||||
|
||||
- build_rpi3:
|
||||
requires:
|
||||
- prepare
|
||||
filters:
|
||||
branches:
|
||||
only: /v[0-9]+(\.[0-9]+)*/
|
||||
|
|
23
luci-mod-admin-full/root/etc/hotplug.d/net/00-macvlan → luci-mod-admin-full/root/etc/init.d/macvlan
Normal file → Executable file
23
luci-mod-admin-full/root/etc/hotplug.d/net/00-macvlan → luci-mod-admin-full/root/etc/init.d/macvlan
Normal file → Executable file
|
@ -1,9 +1,7 @@
|
|||
#!/bin/sh
|
||||
# vim: set noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 :
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
config_load network
|
||||
START=15
|
||||
USE_PROCD=1
|
||||
|
||||
_setup_macaddr() {
|
||||
uci -q get "network.$1_dev.macaddr" >/dev/null && return
|
||||
|
@ -48,4 +46,17 @@ _setup_interface() {
|
|||
uci -q set "network.$1.type=macvlan" # legacy
|
||||
uci -q commit network
|
||||
}
|
||||
config_foreach _setup_interface interface
|
||||
|
||||
start_service() {
|
||||
. /lib/functions.sh
|
||||
config_load network
|
||||
config_foreach _setup_interface interface
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger network
|
||||
}
|
8
luci-mod-admin-full/root/etc/uci-defaults/51_macvlan
Executable file
8
luci-mod-admin-full/root/etc/uci-defaults/51_macvlan
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
uci -q batch <<-EOF
|
||||
delete ucitrack.@macvlan[-1]
|
||||
add ucitrack macvlan
|
||||
set ucitrack.@macvlan[-1].init=macvlan
|
||||
add_list ucitrack.@network[-1].affects=macvlan
|
||||
commit ucitrack
|
||||
EOF
|
10
mptcp/files/etc/hotplug.d/iface/30-mptcp
Normal file
10
mptcp/files/etc/hotplug.d/iface/30-mptcp
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
[ "$ACTION" = ifup -o "$ACTION" = ifupdate ] || exit 0
|
||||
[ "$ACTION" = ifupdate -a -z "$IFUPDATE_ADDRESSES" -a -z "$IFUPDATE_DATA" ] && exit 0
|
||||
|
||||
/etc/init.d/mptcp enabled || exit 0
|
||||
|
||||
logger -t mptcp "Reloading mptcp config due to $ACTION of $INTERFACE ($DEVICE)"
|
||||
/etc/init.d/mptcp reload "$INTERFACE" >/dev/null || exit 0
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
#!/bin/sh
|
||||
# vim: set noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 :
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
multipath=
|
||||
mptcp_path_manager=
|
||||
mptcp_schdeduler=
|
||||
congestion=
|
||||
multipath_status=0
|
||||
config_load network
|
||||
config_get multipath globals multipath
|
||||
config_get mptcp_path_manager globals mptcp_path_manager
|
||||
config_get mptcp_scheduler globals mptcp_scheduler
|
||||
config_get congestion globals congestion
|
||||
[ "$multipath" = "enable" ] && multipath_status=1
|
||||
|
||||
# Global MPTCP configuration
|
||||
sysctl -qw net.mptcp.mptcp_enabled="$multipath_status"
|
||||
[ "$multipath_status" = "0" ] && exit 0
|
||||
[ -z "$mptcp_path_manager" ] || sysctl -qw net.mptcp.mptcp_path_manager="$mptcp_path_manager"
|
||||
[ -z "$mptcp_scheduler" ] || sysctl -qw net.mptcp.mptcp_scheduler="$mptcp_scheduler"
|
||||
[ -z "$congestion" ] || sysctl -qw net.ipv4.tcp_congestion_control="$congestion"
|
||||
|
||||
# Configuration by interface
|
||||
_setup_interface() {
|
||||
device=
|
||||
config_get device "$1" ifname
|
||||
[ -z "$device" ] && return 0
|
||||
[ -n "$(config | grep $device)" ] || return 0
|
||||
if_multipath=
|
||||
config_get if_multipath "$1" multipath "off"
|
||||
[ "$if_multipath" = "master" ] && if_multipath="on"
|
||||
multipath "$device" "$if_multipath"
|
||||
}
|
||||
config_foreach _setup_interface interface
|
|
@ -1,69 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Load the multipath config
|
||||
#
|
||||
# Author: Mario Krueger <openwrt at xedp3x.de>
|
||||
# Released under GPL 3 or later
|
||||
|
||||
enable=`uci -q get network.globals.multipath` || exit 0
|
||||
[ "$enable" = "enable" ] || exit 0
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/network.sh
|
||||
|
||||
id=0
|
||||
count=1
|
||||
|
||||
set_default() {
|
||||
local mode
|
||||
local config="$1"
|
||||
count=$(($count+1))
|
||||
local iface
|
||||
config_get iface "$config" ifname
|
||||
id=$count
|
||||
config_get mode "$config" multipath
|
||||
|
||||
mode=`uci -q get network.$config.multipath` || mode='off'
|
||||
[ -n "$(ifconfig | grep $iface)" ] || return 1
|
||||
case "$mode" in
|
||||
"off")
|
||||
multipath $iface off
|
||||
return 1;;
|
||||
"master")
|
||||
mode="on";;
|
||||
"on");;
|
||||
"backup");;
|
||||
"handover");;
|
||||
*)
|
||||
logger -t multipath Wrong multipath value for device $iface
|
||||
return 1;;
|
||||
esac
|
||||
# Update kernel flags
|
||||
multipath $iface $mode
|
||||
# IPv4 Updates:
|
||||
local ipaddr
|
||||
local gateway
|
||||
local network
|
||||
local netmask
|
||||
config_get ipaddr $config ipaddr
|
||||
config_get gateway $config gateway
|
||||
network_get_subnet network $config
|
||||
config_get netmask $config netmask
|
||||
network=`ipcalc.sh $network | sed -n '/NETWORK=/{;s/.*=//;s/ .*//;p;}'`
|
||||
|
||||
[ -n "$gateway" ] || return 1
|
||||
|
||||
ip rule del table $id
|
||||
ip route flush $id
|
||||
ip rule add from $ipaddr table $id
|
||||
ip route replace $network/$netmask dev $iface scope link table $id
|
||||
ip route replace default via $gateway dev $iface table $id
|
||||
ip route flush $id
|
||||
|
||||
[ "$mode" = "master" ] && {
|
||||
ip route replace default via $gateway dev $iface
|
||||
}
|
||||
}
|
||||
|
||||
config_load network
|
||||
config_foreach set_default interface
|
|
@ -4,14 +4,110 @@ START=18
|
|||
|
||||
USE_PROCD=1
|
||||
|
||||
global_multipath_settings() {
|
||||
local multipath mptcp_path_manager mptcp_schdeduler congestion
|
||||
local multipath_status=0
|
||||
config_load network
|
||||
config_get multipath globals multipath
|
||||
config_get mptcp_path_manager globals mptcp_path_manager
|
||||
config_get mptcp_scheduler globals mptcp_scheduler
|
||||
config_get congestion globals congestion
|
||||
[ "$multipath" = "enable" ] && multipath_status=1
|
||||
|
||||
# Global MPTCP configuration
|
||||
sysctl -qw net.mptcp.mptcp_enabled="$multipath_status"
|
||||
[ -z "$mptcp_path_manager" ] || sysctl -qw net.mptcp.mptcp_path_manager="$mptcp_path_manager"
|
||||
[ -z "$mptcp_scheduler" ] || sysctl -qw net.mptcp.mptcp_scheduler="$mptcp_scheduler"
|
||||
[ -z "$congestion" ] || sysctl -qw net.ipv4.tcp_congestion_control="$congestion"
|
||||
}
|
||||
|
||||
interface_multipath_settings() {
|
||||
local mode iface
|
||||
local config="$1"
|
||||
local intf="$2"
|
||||
|
||||
config_get iface "$config" ifname
|
||||
count=$(($count+1))
|
||||
id=$count
|
||||
echo $iface
|
||||
[ -n "$intf" ] && [ "$iface" != "$intf" ] && return 0
|
||||
echo "ok"
|
||||
[ -z "$iface" ] && return 0
|
||||
[ -n "$(ifconfig | grep $iface)" ] || return 0
|
||||
config_get mode "$config" multipath "off"
|
||||
echo "mode $mode"
|
||||
[ "$mode" = "off" ] && {
|
||||
ip rule del table $id > /dev/null 2>&1
|
||||
ip route flush $id > /dev/null 2>&1
|
||||
return 1
|
||||
}
|
||||
|
||||
[ "$mode" = "master" ] && mode="on"
|
||||
multipath "$iface" "$mode"
|
||||
|
||||
# IPv4 Updates:
|
||||
local ipaddr
|
||||
local gateway
|
||||
local network
|
||||
local netmask
|
||||
local proto
|
||||
config_get proto $config proto
|
||||
if [ "$proto" = "static" ]; then
|
||||
config_get ipaddr $config ipaddr
|
||||
config_get gateway $config gateway
|
||||
config_get netmask $config netmask
|
||||
network=`ipcalc.sh $ipaddr $netmask | sed -n '/NETWORK=/{;s/.*=//;s/ .*//;p;}'`
|
||||
else
|
||||
network_get_ipaddr $config ipaddr
|
||||
ipaddr=$(/sbin/ifconfig eth0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}')
|
||||
gateway=$(ip r list dev $config | grep -v default | awk '/proto static/ {print $1}' | tr -d "\n")
|
||||
netmask=$(/sbin/ifconfig eth0 | grep 'Mask' | cut -d: -f2 | awk '{print $1}')
|
||||
__network_ifstatus netmask $config "['ipv4-address'][0]['mask']"
|
||||
network=`ipcalc.sh $ipaddr $netmask | sed -n '/NETWORK=/{;s/.*=//;s/ .*//;p;}'`
|
||||
fi
|
||||
ip rule del table $id > /dev/null 2>&1
|
||||
ip route flush $id > /dev/null 2>&1
|
||||
[ -n "$gateway" ] || return 1
|
||||
ip rule add from $ipaddr table $id
|
||||
ip route replace $network/$netmask dev $iface scope link table $id
|
||||
ip route replace default via $gateway dev $iface table $id
|
||||
ip route flush $id
|
||||
|
||||
[ "$mode" = "master" ] && {
|
||||
ip route replace default via $gateway dev $iface
|
||||
}
|
||||
}
|
||||
|
||||
load_interfaces() {
|
||||
config_get ifname "$1" ifname
|
||||
config_get multipath "$1" multipath "off"
|
||||
[ "$multipath" != "off" ] && interface=" ${ifname} ${interfaces}"
|
||||
}
|
||||
|
||||
start_service() {
|
||||
/sbin/hotplug-call net
|
||||
local intf=$1
|
||||
local id count
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/network.sh
|
||||
global_multipath_settings
|
||||
config_load network
|
||||
config_foreach interface_multipath_settings interface $intf
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
start
|
||||
rc_procd start_service "$@"
|
||||
return 0
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
local interfaces
|
||||
procd_add_reload_trigger network
|
||||
config_load network
|
||||
config_foreach load_interfaces interface
|
||||
|
||||
[ -n "${interfaces}" ] && {
|
||||
for n in $interfaces ; do
|
||||
procd_add_interface_trigger "interface.*" $n /etc/init.d/mptcp reload $n
|
||||
done
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue