Skip to content

Commit b102523

Browse files
matttbemjmartineau
authored andcommitted
scripts: get debug info for bug reports
This is a simple script that is here to get debug info. It will be helpful to get more details in case of issues with MPTCP in general, not specific to mptcpd or mptcpize then. The script is basic, supporting /bin/sh with a minimum of dependences. It should be used with '--collect' or '--reproduce', as shown by the help menu. Please note that a lot of efforts have been done recently to improve the documentation on mptcp.dev website, on the kernel side, and on IPRoute side. Thanks to that, this script can be small, focussing on this small set of commands for the moment. It can always be improved later on. The idea is to place it here in mptcpd, to have it somewhere, and ideally already installed on some machines, in /usr/libexec dir, ready to be used without having to install it. Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
1 parent 5eea3f4 commit b102523

File tree

2 files changed

+131
-0
lines changed

2 files changed

+131
-0
lines changed

scripts/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
## Copyright (c) 2018, 2019, Intel Corporation
44

55
dist_noinst_SCRIPTS = check-permissions
6+
7+
dist_libexec_SCRIPTS = mptcp-get-debug

scripts/mptcp-get-debug

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#! /bin/sh
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
#
4+
# Copyright (c) 2024, Matthieu Baerts
5+
6+
SCRIPT="$(basename "${0}")"
7+
VERSION="1"
8+
PID_IP=
9+
10+
EQ="========================================"
11+
12+
title() {
13+
printf "\n%s\n%s\n%s\n" "${EQ}" "${*}" "${EQ}"
14+
}
15+
16+
stdout() {
17+
printf "\n%s\n" "${*}"
18+
}
19+
20+
stderr() {
21+
stdout "${@}" >&2
22+
}
23+
24+
cmd() {
25+
title "${*}"
26+
"${@}" 2>&1
27+
}
28+
29+
start_ip_mptcp_monitor() {
30+
title "ip mptcp monitor: start"
31+
ip mptcp monitor 2>&1 & # not using cmd to get the right PID
32+
PID_IP=$!
33+
34+
sleep 0.1 2>/dev/null || sleep 1
35+
36+
for _ in $(seq 20); do
37+
out="$(ss -f netlink -H "src = rtnl:${PID_IP}" 2>/dev/null)" || break
38+
[ "$(echo "${out}" | wc -l)" != 0 ] && return 0
39+
40+
sleep 0.1 2>/dev/null || break
41+
done
42+
43+
if [ ! -d "/proc/${PID_IP}" ]; then
44+
stdout "ip monitor has been killed"
45+
return 1
46+
fi
47+
}
48+
49+
stop_ip_mptcp_monitor() {
50+
title "ip mptcp monitor: stop"
51+
52+
if [ -n "${PID_IP}" ] && [ -d "/proc/${PID_IP}" ]; then
53+
kill "${PID_IP}"
54+
fi
55+
}
56+
57+
collect_data_pre() {
58+
stdout "${SCRIPT}: version ${VERSION}"
59+
60+
if [ "$(id -u)" != 0 ]; then
61+
stderr "This script is not executed as root, not all info can be collected."
62+
stderr "Press Enter to continue, Ctrl+C to stop"
63+
read -r _
64+
fi
65+
66+
cmd sysctl net.mptcp
67+
cmd ip mptcp endpoint show
68+
cmd ip mptcp limits show
69+
}
70+
71+
collect_data_post() {
72+
cmd ss -ManiH
73+
cmd nstat
74+
}
75+
76+
collect_data() {
77+
collect_data_pre
78+
collect_data_post
79+
}
80+
81+
collect_data_repro() {
82+
collect_data_pre
83+
84+
cmd ss -ManiH
85+
nstat -n 2>&1
86+
start_ip_mptcp_monitor
87+
88+
stderr "Please reproduce the issue now, then press the Enter key when it is done."
89+
read -r _
90+
91+
collect_data_post
92+
stop_ip_mptcp_monitor
93+
}
94+
95+
version() {
96+
printf "%s: version %s\n" "${SCRIPT}" ${VERSION}
97+
}
98+
99+
usage() {
100+
version
101+
printf "\n"
102+
printf " -c | --collect Collect info and exit.\n"
103+
printf " -r | --reproduce Collect info, start monitor, wait for user and exit.\n"
104+
printf " -h | --help Show this and exit.\n"
105+
printf " -v | --version Show the version and exit.\n"
106+
printf "\n"
107+
printf "Please check https://mptcp.dev website for more info.\n"
108+
}
109+
110+
case "${1}" in
111+
"-c" | "--collect")
112+
collect_data
113+
;;
114+
"-r" | "--reproduce")
115+
collect_data_repro
116+
;;
117+
"-h" | "--help")
118+
usage
119+
;;
120+
"-v" | "--version")
121+
version
122+
;;
123+
*)
124+
usage >&2
125+
exit 1
126+
;;
127+
esac
128+
129+
exit 0

0 commit comments

Comments
 (0)