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

Support IPv6 for MPTCP

This commit is contained in:
Ycarus 2018-10-26 16:52:11 +02:00
parent d30b6452dd
commit 623f0133a0
3 changed files with 100 additions and 21 deletions

36
ipcalc/Makefile Normal file
View file

@ -0,0 +1,36 @@
#
# Copyright (C) 2018 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=ipcalc
PKG_RELEASE:=1
PKG_SOURCE_URL:=https://github.com/nmav/ipcalc.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=e9f88461f2585575d12fc95f5eeb9996b863f5af
PKG_MAINTAINER:=Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
PKG_LICENSE:=GPL-2.0
include $(INCLUDE_DIR)/package.mk
MAKE_FLAGS += USE_GEOIP=no USE_MAXMIND=no
define Package/ipcalc
SECTION:=net
CATEGORY:=Network
MAINTAINER:=Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
TITLE:=Modern tool to assist in network address calculations for IPv4 and IPv6.
endef
define Package/ipcalc/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ipcalc $(1)/usr/sbin/ipcalc
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

View file

@ -20,8 +20,8 @@ include $(INCLUDE_DIR)/package.mk
define Package/mptcp
SECTION:=net
CATEGORY:=Network
TITLE:=Multipath TCP configuration scrips
DEPENDS:=+ip +iptables +ethtool
TITLE:=Multipath TCP configuration scripts
DEPENDS:=+ip +iptables +ethtool +ipcalc
KCONFIG:=\
CONFIG_MPTCP=y \
CONFIG_MPTCP_BINDER=y \

View file

@ -77,31 +77,74 @@ interface_multipath_settings() {
gateway=$(ip -4 r list dev $iface | grep -v default | awk '/proto static/ {print $1}' | tr -d "\n")
[ -z "$gateway" ] && gateway=$(uci -q get "network.$config.gateway")
[ -z "$gateway" ] && gateway=$(ubus call network.interface.$config status | jsonfilter -q -e '@.route[0].nexthop' | tr -d "\n")
[ -z "$gateway" ] && gateway=$(ubus call network.interface.$config status | jsonfilter -q -e '@.inactive.route[0].nexthop' | tr -d "\n")
[ -z "$gateway" ] && gateway=$(ubus call network.interface.${config}_4 status 2>/dev/null | jsonfilter -q -e '@.inactive.route[0].nexthop' | tr -d "\n")
[ -z "$gateway" ] || [ "$( valid_subnet4 $gateway)" = "ok" ] && gateway=$(ubus call network.interface.$config status | jsonfilter -q -e '@.inactive.route[0].nexthop' | tr -d "\n")
[ -z "$gateway" ] || [ "$( valid_subnet4 $gateway)" = "ok" ] && gateway=$(ubus call network.interface.${config}_4 status 2>/dev/null | jsonfilter -q -e '@.inactive.route[0].nexthop' | tr -d "\n")
netmask=$(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f2 | tr -d "\n")
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
[ -n "$network" ] || 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
if [ -n "$gateway" ] && [ -n "$network" ]; then
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
config_get mode "$config" multipath "off"
local enabled
config_get enabled "$config" auto "1"
[ "$mode" = "master" ] && {
ip route replace default via $gateway dev $iface
}
[ "$mode" = "off" ] && {
ifconfig $iface txqueuelen 90 > /dev/null 2>&1
} || {
ifconfig $iface txqueuelen 10000 > /dev/null 2>&1
}
config_get mode "$config" multipath "off"
local enabled
config_get enabled "$config" auto "1"
[ "$mode" = "master" ] && {
ip route replace default via $gateway dev $iface
}
[ "$mode" = "off" ] && {
ifconfig $iface txqueuelen 90 > /dev/null 2>&1
} || {
ifconfig $iface txqueuelen 10000 > /dev/null 2>&1
}
fi
if [ "$(sysctl -n net.ipv6.conf.all.disable_ipv6 | tr -d '\n')" != "1" ]; then
# IPv6 Updates:
local ip6addr
local ipaddr6
local gateway6
local network6
local netmask6
config_get ipaddr6 $config ip6addr
config_get gateway6 $config ip6gw
ip6addr=`echo $ip6addr | cut -d/ -f1`
netmask6=`ipcalc $ipaddr6 | sed -n '/PREFIX=/{;s/.*=//;s/ .*//;p;}'`
network6=`ipcalc $ip6addr | sed -n '/NETWORK=/{;s/.*=//;s/ .*//;p;}'`
if [ -z "$ip6addr" ] || [ -z "$network6" ]; then
ip6addr=$(ip -6 addr show dev $iface | grep -v 'scope link' | grep inet6 | awk '{print $2}' | cut -d/ -f1 | tr -d "\n")
gateway6=$(ip -6 r list dev $iface | grep -v default | awk '/proto static/ {print $1}' | tr -d "\n")
[ -z "$gateway6" ] && gateway6=$(uci -q get "network.$config.ip6gw")
[ -z "$gateway6" ] && gateway6=$(ubus call network.interface.$config status | jsonfilter -q -e '@.route[0].nexthop' | tr -d "\n")
[ -z "$gateway6" ] || [ "$( valid_subnet6 $gateway6)" = "ok" ] && gateway6=$(ubus call network.interface.$config status | jsonfilter -q -e '@.inactive.route[0].nexthop' | tr -d "\n")
[ -z "$gateway6" ] || [ "$( valid_subnet6 $gateway6)" = "ok" ] && gateway6=$(ubus call network.interface.${config}_6 status 2>/dev/null | jsonfilter -q -e '@.inactive.route[0].nexthop' | tr -d "\n")
netmask6=$(ip -6 addr show dev $iface | grep -v 'scope link' | grep inet6 | awk '{print $2}' | cut -d/ -f2 | tr -d "\n")
network6=`ipcalc $ip6addr | sed -n '/NETWORK=/{;s/.*=//;s/ .*//;p;}'`
fi
ip -6 rule del table 6$id > /dev/null 2>&1
ip -6 route flush 6$id > /dev/null 2>&1
if [ -n "$gateway6" ] && [ -n "$network6" ]; then
ip -6 rule add from $ip6addr table 6$id
ip -6 route replace $network6/$netmask6 dev $iface scope link table 6$id
ip -6 route replace default via $gateway6 dev $iface table 6$id
ip -6 route flush 6$id
config_get mode "$config" multipath "off"
local enabled
config_get enabled "$config" auto "1"
[ "$mode" = "master" ] && {
ip -6 route replace default via $gateway6 dev $iface
}
[ "$mode" = "off" ] && {
ifconfig $iface txqueuelen 90 > /dev/null 2>&1
} || {
ifconfig $iface txqueuelen 10000 > /dev/null 2>&1
}
fi
fi
}
load_interfaces() {