mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-07 12:44:06 +08:00
🏅 Sync 2026-10-10 12:03:15
This commit is contained in:
1 parent
ad68a3cd65
commit
f080de4b89
109 files changed
+72311
-621
No files matched your search
+1
-1
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=mptcp
|
||||
PKG_VERSION:=6.1
|
||||
PKG_RELEASE:=22
|
||||
PKG_RELEASE:=23
|
||||
|
||||
PKG_MAINTAINER:=Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
@@ -653,13 +653,13 @@ interface_multipath_settings() {
|
||||
# every ifup (discussion #4368). 003-up adds the endpoint back in the
|
||||
# configured mode as soon as the recovery is confirmed (issue #4355).
|
||||
logger -t "MPTCP" "$iface tracker state is down, not adding it to MPTCP ($(multipath $iface))"
|
||||
elif ([ "$mode" = "master" ] || [ "$mode" = "on" ]) && [ -z "$(multipath $iface | grep default)" ]; then
|
||||
elif ([ "$mode" = "master" ] || [ "$mode" = "on" ]) && { [ -z "$(multipath $iface | grep default)" ] || ! multipath -i "$iface" "$id"; }; then
|
||||
logger -t "MPTCP" "Set $iface to $mode from $(multipath $iface)"
|
||||
multipath "$iface" "on" "$id"
|
||||
elif ([ "$mode" = "off" ] || [ -z "$mode" ]) && [ -z "$(multipath $iface | grep deactivated)" ]; then
|
||||
logger -t "MPTCP" "Set $iface to $mode from $(multipath $iface)"
|
||||
multipath "$iface" "$mode" "$id"
|
||||
elif [ "$mode" = "backup" ] && [ -z "$(multipath $iface | grep backup)" ]; then
|
||||
elif [ "$mode" = "backup" ] && { [ -z "$(multipath $iface | grep backup)" ] || ! multipath -i "$iface" "$id"; }; then
|
||||
logger -t "MPTCP" "Set $iface to $mode from $(multipath $iface)"
|
||||
multipath "$iface" "$mode" "$id"
|
||||
fi
|
||||
|
||||
@@ -17,6 +17,77 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# From an "ip mptcp endpoint show" listing ($1), set id_used when an endpoint
|
||||
# has the id $2 and id_holder to its device, and dev_ids to the endpoint ids
|
||||
# of device $3. Lines are "ADDR [port P] id ID [FLAGS...] [dev DEV]".
|
||||
endpoint_ids() {
|
||||
local listing="$1" want="$2" dev="$3" ep_line ep_id ep_dev
|
||||
id_used=""
|
||||
id_holder=""
|
||||
dev_ids=""
|
||||
while IFS= read -r ep_line; do
|
||||
ep_id=""
|
||||
ep_dev=""
|
||||
set -- $ep_line
|
||||
while [ "$#" -gt 1 ]; do
|
||||
case "$1" in
|
||||
id) ep_id="$2" ;;
|
||||
dev) ep_dev="$2" ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
[ -n "$ep_id" ] || continue
|
||||
[ "$ep_id" = "$want" ] && {
|
||||
id_used=1
|
||||
id_holder="$ep_dev"
|
||||
}
|
||||
[ -n "$dev" ] && [ "$ep_dev" = "$dev" ] && dev_ids="$dev_ids $ep_id"
|
||||
done <<EOF
|
||||
$listing
|
||||
EOF
|
||||
}
|
||||
|
||||
# Add an endpoint with the flags $@ for each global address ($IP) of $DEVICE.
|
||||
# The explicit id ($ENDPOINT_ID, the WAN's metric) goes to the first address,
|
||||
# the IPv4 one on a dual-stack WAN, the one the VPS pins a WAN by. Each
|
||||
# endpoint needs its own id: with the same one for all, the IPv6 add failed
|
||||
# ("Resource busy") and IPv6 was left out of MPTCP. The next addresses get
|
||||
# id+128 then id+192, above the WAN metrics so that they never take the id
|
||||
# of another WAN, and an address left without one is not added at all: an
|
||||
# id picked by the kernel would be one of those WAN ids.
|
||||
# When another device still holds the id of the first address, it is added
|
||||
# with an id picked by the kernel instead of failing on every tracker check,
|
||||
# and "multipath -i" tells the callers to fix it once the id is free.
|
||||
add_endpoints() {
|
||||
local addr addr_id n=0
|
||||
for addr in $IP; do
|
||||
addr_id=""
|
||||
if [ -n "$ENDPOINT_ID" ]; then
|
||||
case "$n" in
|
||||
0) addr_id="$ENDPOINT_ID" ;;
|
||||
1) addr_id=$((ENDPOINT_ID + 128)) ;;
|
||||
2) addr_id=$((ENDPOINT_ID + 192)) ;;
|
||||
*) addr_id=256 ;;
|
||||
esac
|
||||
endpoint_ids "$endpoint" "$addr_id" "$DEVICE"
|
||||
if [ -n "$id_used" ] && [ "$id_holder" != "$DEVICE" ]; then
|
||||
logger -t "MPTCP" "Endpoint id $addr_id for $addr on $DEVICE is used by ${id_holder:-another endpoint}"
|
||||
addr_id=256
|
||||
fi
|
||||
if [ "$addr_id" -gt 255 ]; then
|
||||
if [ "$n" -gt 0 ]; then
|
||||
logger -t "MPTCP" "No endpoint id left for $addr on $DEVICE, not added to MPTCP"
|
||||
n=$((n + 1))
|
||||
continue
|
||||
fi
|
||||
addr_id=""
|
||||
fi
|
||||
fi
|
||||
ip mptcp endpoint add "$addr" dev "$DEVICE" "$@" ${addr_id:+id "$addr_id"}
|
||||
n=$((n + 1))
|
||||
done
|
||||
}
|
||||
|
||||
case $1 in
|
||||
"-h")
|
||||
echo " Multipath-TCP configuration tool"
|
||||
@@ -34,6 +105,7 @@ case $1 in
|
||||
echo "show MPTCP info: -m"
|
||||
if [ -f /proc/sys/net/mptcp/enabled ]; then
|
||||
echo "verify MPTCP interface: -v device"
|
||||
echo "check the endpoint id of an interface: -i device id"
|
||||
fi
|
||||
echo
|
||||
echo "Flag on the device, to enable/disable MPTCP for this interface. The backup-flag"
|
||||
@@ -44,6 +116,8 @@ case $1 in
|
||||
echo "(0-255) to pass to 'ip mptcp endpoint add ... id <id>' instead of letting the"
|
||||
echo "kernel auto-assign one. Needed for a stable id per WAN across reconnects, e.g."
|
||||
echo "so a peer (VPS) can pin traffic to this WAN via the subflow's remote_id."
|
||||
echo "It goes to the first address of the device, the next ones get id+128 and"
|
||||
echo "id+192 (IPv6 on a dual-stack WAN)."
|
||||
echo
|
||||
exit 0 ;;
|
||||
"-c")
|
||||
@@ -119,6 +193,22 @@ case $1 in
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
"-i")
|
||||
# Exit 1 when the endpoint of device $2 doesn't have the explicit id $3
|
||||
# although no other endpoint holds it, so that recreating it gives that
|
||||
# id back. An endpoint that kept an old id is never fixed by the mode
|
||||
# checks of the callers, and it blocks the WAN that now has this id.
|
||||
[ -f /proc/sys/net/mptcp/enabled ] || exit 0
|
||||
case "$3" in
|
||||
''|*[!0-9]*) exit 0 ;;
|
||||
esac
|
||||
[ "$3" -le 255 ] || exit 0
|
||||
endpoint_ids "$(ip mptcp endpoint show)" "$3" "$2"
|
||||
if [ -z "$dev_ids" ] || [ -n "$id_used" ]; then
|
||||
exit 0
|
||||
fi
|
||||
exit 1
|
||||
;;
|
||||
"")
|
||||
for ifpath in /sys/class/net/*; do
|
||||
$0 ${ifpath##*/}
|
||||
@@ -137,8 +227,6 @@ case "$ENDPOINT_ID" in
|
||||
''|*[!0-9]*) ENDPOINT_ID="" ;;
|
||||
*) [ "$ENDPOINT_ID" -ge 0 ] 2>/dev/null && [ "$ENDPOINT_ID" -le 255 ] 2>/dev/null || ENDPOINT_ID="" ;;
|
||||
esac
|
||||
IDOPT=""
|
||||
[ -n "$ENDPOINT_ID" ] && IDOPT="id $ENDPOINT_ID"
|
||||
#FLAG_PATH=`find /sys/devices/ -path "*/net/$DEVICE/flags"`
|
||||
|
||||
[ -e "/sys/class/net/$DEVICE/" ] || {
|
||||
@@ -253,9 +341,7 @@ EOF
|
||||
ip mptcp endpoint delete id $i >/dev/null 2>&1
|
||||
done
|
||||
}
|
||||
for i in $IP; do
|
||||
ip mptcp endpoint add $i dev $DEVICE subflow fullmesh $IDOPT
|
||||
done
|
||||
add_endpoints subflow fullmesh
|
||||
exit 0;;
|
||||
"signal")
|
||||
[ -z "$IP" ] && {
|
||||
@@ -267,10 +353,8 @@ EOF
|
||||
ip mptcp endpoint delete id $i >/dev/null 2>&1
|
||||
done
|
||||
}
|
||||
for i in $IP; do
|
||||
#ip mptcp endpoint add $i dev $DEVICE signal subflow fullmesh
|
||||
ip mptcp endpoint add $i dev $DEVICE signal $IDOPT
|
||||
done
|
||||
#add_endpoints signal subflow fullmesh
|
||||
add_endpoints signal
|
||||
exit 0;;
|
||||
"backup")
|
||||
[ -z "$IP" ] && {
|
||||
@@ -282,9 +366,7 @@ EOF
|
||||
ip mptcp endpoint delete id $i >/dev/null 2>&1
|
||||
done
|
||||
}
|
||||
for i in $IP; do
|
||||
ip mptcp endpoint add $i dev $DEVICE subflow backup fullmesh $IDOPT
|
||||
done
|
||||
add_endpoints subflow backup fullmesh
|
||||
exit 0;;
|
||||
"")
|
||||
case "$IFF" in
|
||||
|
||||
Reference in new issue
Block a user