choose pmtud source address

This commit is contained in:
hide
2021-10-12 23:26:28 +09:00
parent 13330a6f99
commit bcf4b698f6

View File

@ -1632,8 +1632,8 @@ get_tracepath() {
#
do_pmtud() {
if [ $# -ne 4 ]; then
echo "ERROR: do_pmtud <version> <target_addr> <min_mtu>" \
if [ $# -ne 5 ]; then
echo "ERROR: do_pmtud <version> <target_addr> <min_mtu> <src_addr>" \
"<max_mtu>." 1>&2
return 1
fi
@ -1642,7 +1642,7 @@ do_pmtud() {
"6" ) command="ping6 -i 0.2 -W 1"; dfopt="-M do"; header=48 ;;
* ) echo "ERROR: <version> must be 4 or 6." 1>&2; return 9 ;;
esac
if ! $command -c 1 $2 > /dev/null; then
if ! eval $command -c 1 $2 -I $5 > /dev/null; then
echo 0
return 1
fi
@ -1650,6 +1650,7 @@ do_pmtud() {
local target=$2
local min=$3
local max=$4
local src_addr=$5
local mid=$(( ( min + max ) / 2 ))
local result=0
@ -1657,11 +1658,11 @@ do_pmtud() {
echo "$(( min + header ))"
return 0
fi
if $command -c 1 -s $mid $dfopt $target >/dev/null 2>/dev/null
if eval $command -c 1 -s $mid $dfopt $target -I $src_addr >/dev/null 2>/dev/null
then
result=$(do_pmtud "$version" "$target" "$mid" "$max")
result=$(do_pmtud "$version" "$target" "$mid" "$max" "$src_addr")
else
result=$(do_pmtud "$version" "$target" "$min" "$mid")
result=$(do_pmtud "$version" "$target" "$min" "$mid" "$src_addr")
fi
echo "$result"
}
@ -1703,9 +1704,9 @@ cmdset_trace() {
#
cmdset_pmtud() {
if [ $# -ne 6 ]; then
if [ $# -ne 7 ]; then
echo "ERROR: cmdset_pmtud <layer> <version> <target_type>" \
"<target_addr> <ifmtu> <count>." 1>&2
"<target_addr> <ifmtu> <count> <src_addr>." 1>&2
return 1
fi
local layer=$1
@ -1716,10 +1717,11 @@ cmdset_pmtud() {
local min_mtu=56
local max_mtu=$5
local count=$6
local string=" pmtud to $ipv server: $target"
local src_addr=$7
local string=" pmtud to $ipv server: $target, from: $src_addr"
local pmtu_result
pmtu_result=$(do_pmtud "$ver" "$target" "$min_mtu" "$max_mtu")
pmtu_result=$(do_pmtud "$ver" "$target" "$min_mtu" "$max_mtu" "$src_addr")
if [ "$pmtu_result" -eq 0 ]; then
write_json "$layer" "$ipv" "v${ver}pmtu_${type}" "$INFO" "$target" \
unmeasurable "$count"
@ -2921,7 +2923,7 @@ if [ "$v4addr_type" = "private" ] || [ "$v4addr_type" = "grobal" ]; then
if [ "$MODE" = "client" ]; then
# Check path MTU to extarnal IPv4 servers
cmdset_pmtud "$layer" 4 srv "$target" "$ifmtu" "$count" &
cmdset_pmtud "$layer" 4 srv "$target" "$ifmtu" "$count" "$v4addr" &
fi
count=$(( count + 1 ))
@ -2946,10 +2948,16 @@ if [ -n "$v6addrs" ]; then
# Do traceroute to extarnal IPv6 servers
cmdset_trace "$layer" 6 srv "$target" "$count" &
if [ "$MODE" = "client" ]; then
# Check path MTU to extarnal IPv6 servers
cmdset_pmtud "$layer" 6 srv "$target" "$ifmtu" "$count" &
fi
oIFS="$IFS"
IFS=','
for v6addr in $v6addrs; do
if [ "$MODE" = "client" ]; then
# Check path MTU to extarnal IPv6 servers
cmdset_pmtud "$layer" 6 srv "$target" "$ifmtu" "$count" "$v6addr" &
fi
done
IFS="$oIFS"
unset oIFS
count=$(( count + 1 ))
done