From 17c8f0b7c80859e4d2a02d8481b2ba52dbd2dc23 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Thu, 2 May 2024 20:50:05 +0200 Subject: [PATCH] multipath command doesn't check if all is ok when only requesting interface mode --- mptcp/files/usr/bin/multipath | 42 +++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/mptcp/files/usr/bin/multipath b/mptcp/files/usr/bin/multipath index 90f648a67..40cca3ab2 100755 --- a/mptcp/files/usr/bin/multipath +++ b/mptcp/files/usr/bin/multipath @@ -131,31 +131,35 @@ if [ -f /proc/sys/net/mptcp/mptcp_enabled ]; then printf "0x%02x" $(($(($IFF^$(($IFF&$IFF_MASK))))|$FLAG)) > $FLAG_PATH else - # Remove not needed if* interfaces in MPTCP - endpoint="$(ip mptcp endpoint show)" - [ -n "$endpoint" ] && oldintfs=$(echo "${endpoint}" | grep "dev if" | awk '{ print $3 }') - [ -n "$oldintfs" ] && { - for oldintf in $oldintfs; do - ip mptcp endpoint delete id $oldintf 2>&1 >/dev/null - done - } endpoint="$(ip mptcp endpoint show)" + if [ -n "$TYPE" ]; then + # Remove not needed if* interfaces in MPTCP + [ -n "$endpoint" ] && oldintfs=$(echo "${endpoint}" | grep "dev if" | awk '{ print $3 }') + [ -n "$oldintfs" ] && { + for oldintf in $oldintfs; do + ip mptcp endpoint delete id $oldintf 2>&1 >/dev/null + done + endpoint="$(ip mptcp endpoint show)" + } + fi if [ -n "$endpoint" ]; then ID=$(echo "${endpoint}" | sort | grep "dev $DEVICE " | awk '{print $3}') IFF=$(echo "${endpoint}" | sort | grep -m 1 -E "dev $DEVICE " | awk '{print $4; exit}') fi - #IP=$(ip a show $DEVICE | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p') - if [ -f /usr/bin/jsonfilter ]; then - IP=$(ip -j a show $DEVICE scope global | jsonfilter -e '@[0].addr_info[*].local') - elif [ -f /usr/bin/jq ]; then - IP=$(ip -j a show $DEVICE scope global | jq -r '.[0].addr_info[].local') - else - echo "jsonfilter or jq are required" - exit 1 + if [ -n "$TYPE" ]; then + #IP=$(ip a show $DEVICE | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p') + if [ -f /usr/bin/jsonfilter ]; then + IP=$(ip -j a show $DEVICE scope global | jsonfilter -e '@[0].addr_info[*].local') + elif [ -f /usr/bin/jq ]; then + IP=$(ip -j a show $DEVICE scope global | jq -r '.[0].addr_info[].local') + else + echo "jsonfilter or jq are required" + exit 1 + fi + [ -z "$ID" ] && [ -n "$IP" ] && [ -n "$endpoint" ] && ID=$(echo "${endpoint}" show | grep "$IP " | awk '{print $3}') + [ -n "$endpoint" ] && RMID=$(echo "${endpoint}" | grep '::ffff' | awk '{ print $3 }') + [ -n "$RMID" ] && ip mptcp endpoint delete id $RMID 2>&1 >/dev/null fi - [ -z "$ID" ] && [ -n "$IP" ] && [ -n "$endpoint" ] && ID=$(echo "${endpoint}" show | grep "$IP " | awk '{print $3}') - [ -n "$endpoint" ] && RMID=$(echo "${endpoint}" | grep '::ffff' | awk '{ print $3 }') - [ -n "$RMID" ] && ip mptcp endpoint delete id $RMID 2>&1 >/dev/null case $TYPE in "off") [ -n "$ID" ] && {