mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Fix
This commit is contained in:
parent
4418b1e0fb
commit
0d2b2e3e68
6 changed files with 139 additions and 10 deletions
1
luci-mod-admin-full/root/etc/hotplug.d/iface/03-macvlan → luci-mod-admin-full/root/etc/hotplug.d/iface/00-macvlan
Executable file → Normal file
1
luci-mod-admin-full/root/etc/hotplug.d/iface/03-macvlan → luci-mod-admin-full/root/etc/hotplug.d/iface/00-macvlan
Executable file → Normal file
|
@ -37,5 +37,6 @@ _setup_interface() {
|
||||||
_macaddr=$(uci -q get "network.$1.macaddr")
|
_macaddr=$(uci -q get "network.$1.macaddr")
|
||||||
_setup_macaddr "$1" "${_macaddr:-auto$(date +%s)}"
|
_setup_macaddr "$1" "${_macaddr:-auto$(date +%s)}"
|
||||||
uci -q set "network.$1.type=macvlan" # legacy
|
uci -q set "network.$1.type=macvlan" # legacy
|
||||||
|
uci -q commit network
|
||||||
}
|
}
|
||||||
config_foreach _setup_interface interface
|
config_foreach _setup_interface interface
|
42
luci-mod-admin-full/root/etc/hotplug.d/net/00-macvlan
Normal file
42
luci-mod-admin-full/root/etc/hotplug.d/net/00-macvlan
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# vim: set noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 :
|
||||||
|
|
||||||
|
. /lib/functions.sh
|
||||||
|
|
||||||
|
config_load network
|
||||||
|
|
||||||
|
_setup_macaddr() {
|
||||||
|
uci -q get "network.$1_dev.macaddr" >/dev/null && return
|
||||||
|
uci -q set "network.$1_dev.macaddr=$2"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Configuration by interface
|
||||||
|
_setup_interface() {
|
||||||
|
uci -q get "network.$1_dev.ifname" >/dev/null && return
|
||||||
|
|
||||||
|
# do not create macvlan for vlan
|
||||||
|
local _ifname
|
||||||
|
config_get _ifname "$1" ifname
|
||||||
|
case "$_ifname" in
|
||||||
|
eth*.*) return ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
local _type
|
||||||
|
config_get _type "$1" type
|
||||||
|
[ "$_type" = "macvlan" ] || return 0
|
||||||
|
|
||||||
|
uci -q batch <<-EOF
|
||||||
|
set network.$1_dev=device
|
||||||
|
set network.$1_dev.name=$1
|
||||||
|
set network.$1_dev.type=macvlan
|
||||||
|
set network.$1_dev.ifname=eth0
|
||||||
|
set network.$1.ifname=$1
|
||||||
|
set network.$1.defaultroute=0
|
||||||
|
EOF
|
||||||
|
|
||||||
|
_macaddr=$(uci -q get "network.$1.macaddr")
|
||||||
|
_setup_macaddr "$1" "${_macaddr:-auto$(date +%s)}"
|
||||||
|
uci -q set "network.$1.type=macvlan" # legacy
|
||||||
|
uci -q commit network
|
||||||
|
}
|
||||||
|
config_foreach _setup_interface interface
|
|
@ -54,6 +54,7 @@ config_foreach set_default interface
|
||||||
}
|
}
|
||||||
|
|
||||||
mode=`uci -q get network.$INTERFACE.multipath` || mode='off'
|
mode=`uci -q get network.$INTERFACE.multipath` || mode='off'
|
||||||
|
[ -n "$(ifconfig | grep $DEVICE)" ] || exit 0
|
||||||
|
|
||||||
case "$mode" in
|
case "$mode" in
|
||||||
"off")
|
"off")
|
||||||
|
|
2
mptcp/files/etc/hotplug.d/net/03-mptcp
Executable file → Normal file
2
mptcp/files/etc/hotplug.d/net/03-mptcp
Executable file → Normal file
|
@ -27,7 +27,7 @@ _setup_interface() {
|
||||||
device=
|
device=
|
||||||
config_get device "$1" ifname
|
config_get device "$1" ifname
|
||||||
[ -z "$device" ] && return 0
|
[ -z "$device" ] && return 0
|
||||||
|
[ -n "$(config | grep $device)" ] || return 0
|
||||||
if_multipath=
|
if_multipath=
|
||||||
config_get if_multipath "$1" multipath "off"
|
config_get if_multipath "$1" multipath "off"
|
||||||
[ "$if_multipath" = "master" ] && if_multipath="on"
|
[ "$if_multipath" = "master" ] && if_multipath="on"
|
||||||
|
|
89
mptcp/files/etc/hotplug.d/net/30-mptcp
Normal file
89
mptcp/files/etc/hotplug.d/net/30-mptcp
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Load the multipath config
|
||||||
|
#
|
||||||
|
# Author: Mario Krueger <openwrt at xedp3x.de>
|
||||||
|
# Released under GPL 3 or later
|
||||||
|
|
||||||
|
[ "$ACTION" = ifup -o "$ACTION" = ifupdate ] || exit 0
|
||||||
|
|
||||||
|
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
|
||||||
|
[ "$iface" = "$INTERFACE" ] && id=$count
|
||||||
|
config_get mode "$config" multipath
|
||||||
|
[ "$mode" = "master" ] && {
|
||||||
|
local gateway
|
||||||
|
network_get_gateway gateway $config || {
|
||||||
|
logger -t multipath master device $DEVICE has no gateway!
|
||||||
|
#Fallback: use upcomming interface...
|
||||||
|
network_get_gateway gateway $INTERFACE
|
||||||
|
config=$INTERFACE
|
||||||
|
}
|
||||||
|
local iface
|
||||||
|
config_get iface "$config" ifname
|
||||||
|
[ -n "gateway" ] && {
|
||||||
|
ip route replace default via $gateway dev $iface || {
|
||||||
|
#Fallback: use upcomming interface...
|
||||||
|
network_get_gateway gateway $INTERFACE
|
||||||
|
ip route replace default via $gateway dev $INTERFACE
|
||||||
|
logger -t multipath Failed to set default multipath device! Use $INTERFACE as fallback...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config_load network
|
||||||
|
config_foreach set_default interface
|
||||||
|
[ $id = 0 ] && {
|
||||||
|
logger -t multipath device $INTERFACE not found!
|
||||||
|
echo device $INTERFACE not found!
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
mode=`uci -q get network.$INTERFACE.multipath` || mode='off'
|
||||||
|
[ -n "$(ifconfig | grep $DEVICE)" ] || exit 0
|
||||||
|
|
||||||
|
case "$mode" in
|
||||||
|
"off")
|
||||||
|
multipath $DEVICE off
|
||||||
|
exit 0;;
|
||||||
|
"master")
|
||||||
|
mode="on";;
|
||||||
|
"on");;
|
||||||
|
"backup");;
|
||||||
|
"handover");;
|
||||||
|
*)
|
||||||
|
logger -t multipath Wrong multipath value for device $DEVICE
|
||||||
|
exit 1;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Update kernel flags
|
||||||
|
multipath $DEVICE $mode
|
||||||
|
|
||||||
|
# IPv4 Updates:
|
||||||
|
|
||||||
|
network_get_ipaddr ipaddr $INTERFACE
|
||||||
|
network_get_gateway gateway $INTERFACE
|
||||||
|
network_get_subnet network $INTERFACE
|
||||||
|
__network_ifstatus netmask $INTERFACE "['ipv4-address'][0]['mask']"
|
||||||
|
network=`ipcalc.sh $network | sed -n '/NETWORK=/{;s/.*=//;s/ .*//;p;}'`
|
||||||
|
|
||||||
|
ip rule del table $id
|
||||||
|
ip route flush $id
|
||||||
|
ip rule add from $ipaddr table $id
|
||||||
|
ip route add $network/$netmask dev $DEVICE scope link table $id
|
||||||
|
ip route add default via $gateway dev $DEVICE table $id
|
||||||
|
ip route flush $id
|
|
@ -1,21 +1,17 @@
|
||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
START=20
|
START=10
|
||||||
STOP=90
|
|
||||||
|
|
||||||
USE_PROCD=1
|
USE_PROCD=1
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
procd_open_instance
|
hotplug-call net
|
||||||
procd_set_param command hotplug-call net
|
|
||||||
procd_set_param watch network.globals
|
|
||||||
procd_close_instance
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reload_service() {
|
reload_service() {
|
||||||
ubus call network reload
|
start
|
||||||
}
|
}
|
||||||
|
|
||||||
service_running() {
|
service_triggers() {
|
||||||
ubus -t 30 wait_for network
|
procd_add_reload_trigger network
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue