Skip to content

Commit c451410

Browse files
committed
Merge branch 'mptcp-fixes'
Matthieu Baerts says: ==================== mptcp: fixes for v6.5 Here is a first batch of fixes for v6.5 and older. The fixes are not linked to each others. Patch 1 ensures subflows are unhashed before cleaning the backlog to avoid races. This fixes another recent fix from v6.4. Patch 2 does not rely on implicit state check in mptcp_listen() to avoid races when receiving an MP_FASTCLOSE. A regression from v5.17. The rest fixes issues in the selftests. Patch 3 makes sure errors when setting up the environment are no longer ignored. For v5.17+. Patch 4 uses 'iptables-legacy' if available to be able to run on older kernels. A fix for v5.13 and newer. Patch 5 catches errors when issues are detected with packet marks. Also for v5.13+. Patch 6 uses the correct variable instead of an undefined one. Even if there was no visible impact, it can help to find regressions later. An issue visible in v5.19+. Patch 7 makes sure errors with some sub-tests are reported to have the selftest marked as failed as expected. Also for v5.19+. Patch 8 adds a kernel config that is required to execute MPTCP selftests. It is valid for v5.9+. Patch 9 fixes issues when validating the userspace path-manager with 32-bit arch, an issue affecting v5.19+. ==================== Signed-off-by: Matthieu Baerts <[email protected]>
2 parents 80de809 + 61d9658 commit c451410

File tree

6 files changed

+34
-20
lines changed

6 files changed

+34
-20
lines changed

net/mptcp/protocol.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2909,10 +2909,10 @@ static void mptcp_check_listen_stop(struct sock *sk)
29092909
return;
29102910

29112911
lock_sock_nested(ssk, SINGLE_DEPTH_NESTING);
2912+
tcp_set_state(ssk, TCP_CLOSE);
29122913
mptcp_subflow_queue_clean(sk, ssk);
29132914
inet_csk_listen_stop(ssk);
29142915
mptcp_event_pm_listener(ssk, MPTCP_EVENT_LISTENER_CLOSED);
2915-
tcp_set_state(ssk, TCP_CLOSE);
29162916
release_sock(ssk);
29172917
}
29182918

@@ -3703,6 +3703,11 @@ static int mptcp_listen(struct socket *sock, int backlog)
37033703
pr_debug("msk=%p", msk);
37043704

37053705
lock_sock(sk);
3706+
3707+
err = -EINVAL;
3708+
if (sock->state != SS_UNCONNECTED || sock->type != SOCK_STREAM)
3709+
goto unlock;
3710+
37063711
ssock = __mptcp_nmpc_socket(msk);
37073712
if (IS_ERR(ssock)) {
37083713
err = PTR_ERR(ssock);

tools/testing/selftests/net/mptcp/config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CONFIG_INET_DIAG=m
66
CONFIG_INET_MPTCP_DIAG=m
77
CONFIG_VETH=y
88
CONFIG_NET_SCH_NETEM=m
9+
CONFIG_SYN_COOKIES=y
910
CONFIG_NETFILTER=y
1011
CONFIG_NETFILTER_ADVANCED=y
1112
CONFIG_NETFILTER_NETLINK=m

tools/testing/selftests/net/mptcp/mptcp_connect.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ table inet mangle {
718718
EOF
719719
if [ $? -ne 0 ]; then
720720
echo "SKIP: $msg, could not load nft ruleset"
721+
mptcp_lib_fail_if_expected_feature "nft rules"
721722
return
722723
fi
723724

@@ -733,6 +734,7 @@ EOF
733734
if [ $? -ne 0 ]; then
734735
ip netns exec "$listener_ns" nft flush ruleset
735736
echo "SKIP: $msg, ip $r6flag rule failed"
737+
mptcp_lib_fail_if_expected_feature "ip rule"
736738
return
737739
fi
738740

@@ -741,6 +743,7 @@ EOF
741743
ip netns exec "$listener_ns" nft flush ruleset
742744
ip -net "$listener_ns" $r6flag rule del fwmark 1 lookup 100
743745
echo "SKIP: $msg, ip route add local $local_addr failed"
746+
mptcp_lib_fail_if_expected_feature "ip route"
744747
return
745748
fi
746749

tools/testing/selftests/net/mptcp/mptcp_sockopt.sh

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ ksft_skip=4
1212
timeout_poll=30
1313
timeout_test=$((timeout_poll * 2 + 1))
1414
mptcp_connect=""
15+
iptables="iptables"
16+
ip6tables="ip6tables"
1517

1618
sec=$(date +%s)
1719
rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
@@ -25,7 +27,7 @@ add_mark_rules()
2527
local m=$2
2628

2729
local t
28-
for t in iptables ip6tables; do
30+
for t in ${iptables} ${ip6tables}; do
2931
# just to debug: check we have multiple subflows connection requests
3032
ip netns exec $ns $t -A OUTPUT -p tcp --syn -m mark --mark $m -j ACCEPT
3133

@@ -95,14 +97,14 @@ if [ $? -ne 0 ];then
9597
exit $ksft_skip
9698
fi
9799

98-
iptables -V > /dev/null 2>&1
99-
if [ $? -ne 0 ];then
100+
# Use the legacy version if available to support old kernel versions
101+
if iptables-legacy -V &> /dev/null; then
102+
iptables="iptables-legacy"
103+
ip6tables="ip6tables-legacy"
104+
elif ! iptables -V &> /dev/null; then
100105
echo "SKIP: Could not run all tests without iptables tool"
101106
exit $ksft_skip
102-
fi
103-
104-
ip6tables -V > /dev/null 2>&1
105-
if [ $? -ne 0 ];then
107+
elif ! ip6tables -V &> /dev/null; then
106108
echo "SKIP: Could not run all tests without ip6tables tool"
107109
exit $ksft_skip
108110
fi
@@ -112,10 +114,10 @@ check_mark()
112114
local ns=$1
113115
local af=$2
114116

115-
local tables=iptables
117+
local tables=${iptables}
116118

117119
if [ $af -eq 6 ];then
118-
tables=ip6tables
120+
tables=${ip6tables}
119121
fi
120122

121123
local counters values
@@ -126,6 +128,7 @@ check_mark()
126128
for v in $values; do
127129
if [ $v -ne 0 ]; then
128130
echo "FAIL: got $tables $values in ns $ns , not 0 - not all expected packets marked" 1>&2
131+
ret=1
129132
return 1
130133
fi
131134
done
@@ -225,11 +228,11 @@ do_transfer()
225228
fi
226229

227230
if [ $local_addr = "::" ];then
228-
check_mark $listener_ns 6
229-
check_mark $connector_ns 6
231+
check_mark $listener_ns 6 || retc=1
232+
check_mark $connector_ns 6 || retc=1
230233
else
231-
check_mark $listener_ns 4
232-
check_mark $connector_ns 4
234+
check_mark $listener_ns 4 || retc=1
235+
check_mark $connector_ns 4 || retc=1
233236
fi
234237

235238
check_transfer $cin $sout "file received by server"

tools/testing/selftests/net/mptcp/pm_nl_ctl.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ int dsf(int fd, int pm_family, int argc, char *argv[])
425425
}
426426

427427
/* token */
428-
token = atoi(params[4]);
428+
token = strtoul(params[4], NULL, 10);
429429
rta = (void *)(data + off);
430430
rta->rta_type = MPTCP_PM_ATTR_TOKEN;
431431
rta->rta_len = RTA_LENGTH(4);
@@ -551,7 +551,7 @@ int csf(int fd, int pm_family, int argc, char *argv[])
551551
}
552552

553553
/* token */
554-
token = atoi(params[4]);
554+
token = strtoul(params[4], NULL, 10);
555555
rta = (void *)(data + off);
556556
rta->rta_type = MPTCP_PM_ATTR_TOKEN;
557557
rta->rta_len = RTA_LENGTH(4);
@@ -598,7 +598,7 @@ int remove_addr(int fd, int pm_family, int argc, char *argv[])
598598
if (++arg >= argc)
599599
error(1, 0, " missing token value");
600600

601-
token = atoi(argv[arg]);
601+
token = strtoul(argv[arg], NULL, 10);
602602
rta = (void *)(data + off);
603603
rta->rta_type = MPTCP_PM_ATTR_TOKEN;
604604
rta->rta_len = RTA_LENGTH(4);
@@ -710,7 +710,7 @@ int announce_addr(int fd, int pm_family, int argc, char *argv[])
710710
if (++arg >= argc)
711711
error(1, 0, " missing token value");
712712

713-
token = atoi(argv[arg]);
713+
token = strtoul(argv[arg], NULL, 10);
714714
} else
715715
error(1, 0, "unknown keyword %s", argv[arg]);
716716
}
@@ -1347,7 +1347,7 @@ int set_flags(int fd, int pm_family, int argc, char *argv[])
13471347
error(1, 0, " missing token value");
13481348

13491349
/* token */
1350-
token = atoi(argv[arg]);
1350+
token = strtoul(argv[arg], NULL, 10);
13511351
} else if (!strcmp(argv[arg], "flags")) {
13521352
char *tok, *str;
13531353

tools/testing/selftests/net/mptcp/userspace_pm.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ test_remove()
423423
stdbuf -o0 -e0 printf "[OK]\n"
424424
else
425425
stdbuf -o0 -e0 printf "[FAIL]\n"
426+
exit 1
426427
fi
427428

428429
# RM_ADDR using an invalid addr id should result in no action
@@ -437,6 +438,7 @@ test_remove()
437438
stdbuf -o0 -e0 printf "[OK]\n"
438439
else
439440
stdbuf -o0 -e0 printf "[FAIL]\n"
441+
exit 1
440442
fi
441443

442444
# RM_ADDR from the client to server machine
@@ -848,7 +850,7 @@ test_prio()
848850
local count
849851

850852
# Send MP_PRIO signal from client to server machine
851-
ip netns exec "$ns2" ./pm_nl_ctl set 10.0.1.2 port "$client4_port" flags backup token "$client4_token" rip 10.0.1.1 rport "$server4_port"
853+
ip netns exec "$ns2" ./pm_nl_ctl set 10.0.1.2 port "$client4_port" flags backup token "$client4_token" rip 10.0.1.1 rport "$app4_port"
852854
sleep 0.5
853855

854856
# Check TX

0 commit comments

Comments
 (0)