mptcp: pm: in-kernel: retry subflows closed after an error
Subsystems (5)
v16 cover mptcp: pm: in-kernel: retry subflows closed after an error
A subflow closed after an error is never re-created, even once the path is back (#440).
When TCP gives up on an established subflow we created, after a retransmission or keepalive timeout, the in-kernel PM now creates a new one to the same addresses, while another subflow can still send data. Its SYN retries space out the attempts. Their number is set by a new limit, subflow-retries, like TCP_SYNCNT: the maximum, 127, by default, about 4 hours, and 0 disables it.
Patch 1 fixes a selftest tool issue seen with the new test. Patch 2 checks the existing limits with the netlink policy. Patches 3 and 4 add the new limit, patch 5 the retry, patches 6 and 7 the selftests.
I used an LLM to help write and review the code, the tests and the commit messages of this series. I checked and tested every change myself.
Limit: as documented, the new subflow is a single connection attempt, so an ICMP error received during the outage ends it at its first SYN. The retry then mostly helps when the path drops the packets silently. Such errors could be handled as soft ones for these SYNs later, if useful. The peer must also have room for the new subflow: if it only receives data, it can still count the old one, and with its subflows limit reached, it rejects the new one, which is not retried.
Known issue: in about 1 run in 20, more often on debug kernels, the first new test fails. Once the path is back, the re-created subflow joins, but the server resets it right away with an MP_RST, after DSSNotMatching, and the PAWS counters are high on both sides. It looks like an existing issue on the receive path, triggered by the two-way transfer with losses rather than by the retry itself, but I have not found the cause yet: it does not show up with tcpdump or tracepoints running. I did not see it in the 9 runs of the new tests on v16, but that is too few to say it is gone. Any hint is welcome.
Changes in v16: in patch 6, "pm_netlink.sh -i" also checks the subflow-retries limit when ip supports it, with the iproute2 patches [1], and then expects it in the "ip mptcp limits" output, so it no longer fails with them; with an older ip or kernel, these checks are skipped as before. The shared mptcp_lib_pm_nl_set_limits() helper now takes the new limit as an optional value, instead of a helper only in pm_netlink.sh. And the patches are rebased on the current export branch.
[1] https://lore.kernel.org/mptcp/[email protected]/
Changes in v15: new patch 2, so all the limits are checked with the netlink policy, as Matthieu asked on v7, which I had missed; and the first two new tests only lower tcp_retries2 while a path is blocked, and the first one restores it on errors (netdev Sashiko); no export for the new getter; and the doc says a peer that only receives data can reject the new subflow.
Changes in v14, after the netdev Sashiko review of v13: the slot of a closed additional subflow is kept for the new one, so a join from the peer cannot take it in between; the join counters are checked before the transfer is killed, since that can send MP_RST, counted with -C; if the new subflow cannot be created, the PM tries the next endpoints, with a new test; and the commit message and mptcp.rst wording is fixed. The netlink spec patch still only adds the attribute, which the next patch uses, as asked on v4.
Changes in v13, after the sashiko.dev and netdev Sashiko reviews of v12:
all the re-created subflows not fully established are closed again when no other subflow can send data, not only the ones still connecting, since one waiting for the 4th ACK could keep the connection open forever; to fix the race reported on v11 instead, __mptcp_close_ssk() checks fully_established again under the ssk lock, and keeps a subflow that got fully established in between, so the change cleaning the msk backlog without MPTCP_CF_PUSH is gone; the commit message and the doc say that a re-created subflow keeps its place in the subflows limit, so an endpoint not used yet is only tried if the limit allows one more subflow; and the tests wait for the netlink events before stopping the listener, plus small test and wording fixes. If trying an endpoint not used yet first is preferred, I can change it.
Changes in v12, after the netdev Sashiko review of v11: when no other subflow can send data, only the re-created subflows still connecting are closed, a joined one is fully established soon; a subflow in CLOSE_WAIT no longer keeps them open either; the doc says the initial subflow is not re-created if the peer does not accept joins to its initial address; small test fixes; and the patches are rebased on the current export branch.
Changes in v11, after the Sashiko review of v10: a subflow is only re-created while another subflow can send data, so the close timeout works as before, and all the code re-arming or stopping it is gone; the re-created subflows not established yet are closed from the worker, or when the MPTCP socket is shut down or closed, never while iterating on the subflows; the path-back test is gone, and the third test checks the only subflow is not re-created.
Changes in v10, after the Sashiko review of v9: when the close timeout expires, the connection is kept if a re-created subflow connected in the meantime, since an active join does not stop the timer; the re-created subflows still connecting are closed once the msk is no longer established and no other subflow is left; a new test lets the path come back before the close timeout; and the patches are rebased on the current export branch, without the Assisted-by tag, removed upstream.
Changes in v9, after the Sashiko reviews of v8 and more checks: every timeout is retried, whatever ICMP error TCP reports for it, and only resets, local aborts and MPTCP protocol errors are excluded; if no other subflow can send data, the close timeout still applies, the new subflow no longer keeps the connection open for all its SYN retries; the re-created subflows closed with the msk have their data in the msk backlog cleaned, since they can get established in between; the doc says this is a single connection attempt, ended by an ICMP error, and that 0 disables it; the close test blocks both paths, and its server reads all the data first; the tests read the counters before blocking a path; and a new test checks the close timeout with only one subflow.
Changes in v8, after the Sashiko reviews of v7 and Matthieu's comments:
the default number of SYN retries is the maximum, 127; the re-created subflows still connecting are closed before the write shutdown disconnects them; the doc is more precise; and a separate test closes the connection while a subflow is being re-created.
Changes in v7, after the netdev Sashiko reviews of v5 and v6, and Abdul's tests: only a path error, a retransmission or keepalive timeout, makes the PM re-create a subflow, not a reset, so a peer cannot make it loop; the flags are bools under the msk socket lock; mptcp.rst documents tcp_retries2 and the keepalive needed by a subflow that only receives data; and small fixes in the tests.
Changes in v6, after the Sashiko reviews (netdev Sashiko on v4, which also applied to v5, and sashiko.dev on v5): only subflows that were established are re-created, so the PM still moves on to the next endpoints as before; removed remote addresses and the local ID 0 are handled too; the policy checks the maximum value, so the parse_limit() patch is gone; and the test uses the net/lib.sh helpers. Details in each patch.
v15: https://lore.kernel.org/mptcp/[email protected]/
v14: https://lore.kernel.org/mptcp/[email protected]/
v13: https://lore.kernel.org/mptcp/[email protected]/
v12: https://lore.kernel.org/mptcp/[email protected]/
v11: https://lore.kernel.org/mptcp/[email protected]/
v10: https://lore.kernel.org/mptcp/[email protected]/
v9: https://lore.kernel.org/mptcp/[email protected]/
v8: https://lore.kernel.org/mptcp/[email protected]/
v7: https://lore.kernel.org/mptcp/[email protected]/
v6: https://lore.kernel.org/mptcp/[email protected]/
v5: https://lore.kernel.org/mptcp/[email protected]/
v4: https://lore.kernel.org/mptcp/[email protected]/
v3: https://lore.kernel.org/mptcp/[email protected]/
v2: https://lore.kernel.org/mptcp/[email protected]/
v1: https://lore.kernel.org/mptcp/[email protected]/
Anil Kaushik (7):
selftests: mptcp: connect: retry write() on EAGAIN
mptcp: pm: in-kernel: check the limits with the netlink policy
netlink: specs: mptcp: add the subflow-retries attribute
mptcp: pm: in-kernel: add the subflow-retries limit
mptcp: pm: in-kernel: retry subflows closed after an error
selftests: mptcp: pm_nl_ctl: support the subflow-retries limit
selftests: mptcp: join: validate subflow retry after link failure
Documentation/netlink/specs/mptcp_pm.yaml | 17 + Documentation/networking/mptcp.rst | 26 ++ include/uapi/linux/mptcp.h | 2 +- include/uapi/linux/mptcp_pm.h | 1 + net/mptcp/mptcp_pm_gen.c | 18 +- net/mptcp/mptcp_pm_gen.h | 4 +- net/mptcp/pm.c | 50 +++ net/mptcp/pm_kernel.c | 218 +++++++-- net/mptcp/protocol.c | 77 +++- net/mptcp/protocol.h | 52 +++ net/mptcp/sockopt.c | 2 + .../selftests/net/mptcp/mptcp_connect.c | 18 + .../testing/selftests/net/mptcp/mptcp_join.sh | 420 +++++++++++++++++- .../testing/selftests/net/mptcp/mptcp_lib.sh | 8 +- .../testing/selftests/net/mptcp/pm_netlink.sh | 59 ++- tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 34 +- 16 files changed, 941 insertions(+), 65 deletions(-)
base-commit: 85e5bb627afc7749558bb522d64e1163b87f0913
Signature · 1 line
2.25.1
PATCH v16 1/7 selftests: mptcp: connect: retry write() on EAGAIN
mptcp_connect treats any write() error as fatal. But write() can fail with EAGAIN even after poll() said the socket was writable: the MPTCP send buffer shrinks when a subflow is closed.
The tool then exits and the transfer fails on both sides. Instead, go back to poll() and wait for more space. If a poll timeout is set, still fail after as many 1 ms retries as the timeout in ms: poll() does not check every cause of EAGAIN.
--- .../selftests/net/mptcp/mptcp_connect.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_connect.c +18 -0
@@ -651,6 +651,7 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd, .events = POLLIN | POLLOUT, };unsigned int total_wlen =0 , total_rlen =0 ; +int eagain_cnt =0 ;set_nonblock (peerfd, true);
@@ -725,6 +726,22 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd, bw =do_rnd_write (peerfd, winfo->buf + winfo->off, winfo->len);if (bw <0 ) { +/* POLLOUT does not guarantee that +* the next write will not block: +* the MPTCP send buffer can shrink +* in between, e.g. when a subflow +* is closed. Wait for more space, +* but not forever if a poll timeout +* is set: poll() does not check +* every cause of EAGAIN. +*/ +if (errno ==EAGAIN && + (poll_timeout <0 || + ++eagain_cnt <= poll_timeout)) { +usleep (1000 ); +continue ; + } +/* expected reset, continue to read */ if (cfg_rcv_trunc && (errno == ECONNRESET ||
@@ -737,6 +754,7 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd,return 111 ; } + eagain_cnt =0 ; winfo->off += bw; winfo->len -= bw; total_wlen += bw;
Signature · 1 line
2.25.1
PATCH v16 2/7 mptcp: pm: in-kernel: check the limits with the netlink policy
In reply to Anil KaushikThe maximum of the rcv-add-addrs and subflows limits is checked by parse_limit(). The netlink policy can do that: add the maximum to the spec, and drop this helper. The next limit will do the same.
The maximum is unchanged, but a value above it now gets ERANGE from the policy, instead of EINVAL.
The uapi header is not changed. The generated files are updated with ynl-regen.
--- Documentation/netlink/specs/mptcp_pm.yaml | 4 +++ net/mptcp/mptcp_pm_gen.c | 8 ++--- net/mptcp/pm_kernel.c | 39 +++++------------------ 3 files changed, 16 insertions(+), 35 deletions(-)
Documentation/netlink/specs/mptcp_pm.yaml +4 -0
@@ -183,9 +183,13 @@ attribute-sets: - name: rcv-add-addrs type: u32 + checks: + max: 64 - name: subflows type: u32 + checks: + max: 64 - name: token type: u32
net/mptcp/mptcp_pm_gen.c +4 -4
@@ -45,14 +45,14 @@ const struct nla_policy mptcp_pm_flush_addrs_nl_policy[MPTCP_PM_ENDPOINT_ADDR +/* MPTCP_PM_CMD_SET_LIMITS - do */ const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS +1 ] = { - [MPTCP_PM_ATTR_RCV_ADD_ADDRS ] = { .type =NLA_U32 , }, - [MPTCP_PM_ATTR_SUBFLOWS ] = { .type =NLA_U32 , }, + [MPTCP_PM_ATTR_RCV_ADD_ADDRS ] =NLA_POLICY_MAX (NLA_U32 ,64 ), + [MPTCP_PM_ATTR_SUBFLOWS ] =NLA_POLICY_MAX (NLA_U32 ,64 ), };/* MPTCP_PM_CMD_GET_LIMITS - do */ const struct nla_policy mptcp_pm_get_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS +1 ] = { - [MPTCP_PM_ATTR_RCV_ADD_ADDRS ] = { .type =NLA_U32 , }, - [MPTCP_PM_ATTR_SUBFLOWS ] = { .type =NLA_U32 , }, + [MPTCP_PM_ATTR_RCV_ADD_ADDRS ] =NLA_POLICY_MAX (NLA_U32 ,64 ), + [MPTCP_PM_ATTR_SUBFLOWS ] =NLA_POLICY_MAX (NLA_U32 ,64 ), };/* MPTCP_PM_CMD_SET_FLAGS - do */
net/mptcp/pm_kernel.c +8 -31
@@ -30,7 +30,6 @@ struct pm_nl_pernet { };#define MPTCP_PM_ADDR_MAX 8 -#define MPTCP_PM_SUBFLOWS_MAX 64static struct pm_nl_pernet *pm_nl_get_pernet (const struct net *net) {
@@ -1402,46 +1401,24 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg,return msg->len; } -static int parse_limit (struct genl_info *info,int id,unsigned int *limit) -{ -struct nlattr *attr = info->attrs[id]; - -if (!attr) -return 0 ; - - *limit =nla_get_u32 (attr); -if (*limit >MPTCP_PM_SUBFLOWS_MAX ) { -NL_SET_ERR_MSG_ATTR_FMT (info->extack, attr, -"limit greater than maximum (%u)" , -MPTCP_PM_SUBFLOWS_MAX ); -return -EINVAL ; - } -return 0 ; -} -int mptcp_pm_nl_set_limits_doit (struct sk_buff *skb,struct genl_info *info) {struct pm_nl_pernet *pernet =genl_info_pm_nl (info); +struct nlattr **attrs = info->attrs;unsigned int rcv_addrs, subflows; -int ret; +/* the maximums are checked by the policy */ spin_lock_bh (&pernet->lock); - rcv_addrs = pernet->limit_add_addr_accepted; - ret =parse_limit (info,MPTCP_PM_ATTR_RCV_ADD_ADDRS , &rcv_addrs); -if (ret) - goto unlock; - - subflows = pernet->limit_extra_subflows; - ret =parse_limit (info,MPTCP_PM_ATTR_SUBFLOWS , &subflows); -if (ret) - goto unlock; + rcv_addrs =nla_get_u32_default (attrs[MPTCP_PM_ATTR_RCV_ADD_ADDRS ], + pernet->limit_add_addr_accepted); + subflows =nla_get_u32_default (attrs[MPTCP_PM_ATTR_SUBFLOWS ], + pernet->limit_extra_subflows);WRITE_ONCE (pernet->limit_add_addr_accepted, rcv_addrs);WRITE_ONCE (pernet->limit_extra_subflows, subflows); - -unlock:spin_unlock_bh (&pernet->lock); -return ret; + +return 0 ; }int mptcp_pm_nl_get_limits_doit (struct sk_buff *skb,struct genl_info *info)
Signature · 1 line
2.25.1
PATCH v16 3/7 netlink: specs: mptcp: add the subflow-retries attribute
In reply to Anil KaushikIt will be used by the in-kernel PM to set the number of SYN retransmissions of a subflow re-created after a timeout, with the other
limits: add it to the set-limits and get-limits commands.
The uapi header and the generated files are updated with ynl-regen.
--- Documentation/netlink/specs/mptcp_pm.yaml | 13 +++++++++++++ include/uapi/linux/mptcp_pm.h | 1 + net/mptcp/mptcp_pm_gen.c | 10 ++++++---- net/mptcp/mptcp_pm_gen.h | 4 ++-- 4 files changed, 22 insertions(+), 6 deletions(-)
Documentation/netlink/specs/mptcp_pm.yaml +13 -0
@@ -200,6 +200,16 @@ attribute-sets: name: addr-remote type: nest nested-attributes: address + - + name: subflow-retries + type: u32 + checks: + max: 127 + doc: | + SYN retries of a subflow re-created after a timeout, like the + TCP_SYNCNT socket option, so with tcp_syn_linear_timeouts on top. + The default is the maximum, MAX_TCP_SYNCNT (127), about 4 hours + with the default RTO settings. 0 to not re-create it. - name: event-attr enum-name: mptcp-event-attr
@@ -331,6 +341,7 @@ operations: attributes: - rcv-add-addrs - subflows + - subflow-retries - name: get-limits doc: Get protocol limits
@@ -341,10 +352,12 @@ operations: attributes: - rcv-add-addrs - subflows + - subflow-retries reply: attributes: - rcv-add-addrs - subflows + - subflow-retries - name: set-flags doc: Change endpoint flags
include/uapi/linux/mptcp_pm.h +1 -0
@@ -102,6 +102,7 @@ enum {MPTCP_PM_ATTR_TOKEN ,MPTCP_PM_ATTR_LOC_ID ,MPTCP_PM_ATTR_ADDR_REMOTE , +MPTCP_PM_ATTR_SUBFLOW_RETRIES , __MPTCP_ATTR_AFTER_LAST };
net/mptcp/mptcp_pm_gen.c +6 -4
@@ -44,15 +44,17 @@ const struct nla_policy mptcp_pm_flush_addrs_nl_policy[MPTCP_PM_ENDPOINT_ADDR + };/* MPTCP_PM_CMD_SET_LIMITS - do */ -const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS +1 ] = { +const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOW_RETRIES +1 ] = { [MPTCP_PM_ATTR_RCV_ADD_ADDRS ] =NLA_POLICY_MAX (NLA_U32 ,64 ), [MPTCP_PM_ATTR_SUBFLOWS ] =NLA_POLICY_MAX (NLA_U32 ,64 ), + [MPTCP_PM_ATTR_SUBFLOW_RETRIES ] =NLA_POLICY_MAX (NLA_U32 ,127 ), };/* MPTCP_PM_CMD_GET_LIMITS - do */ -const struct nla_policy mptcp_pm_get_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS +1 ] = { +const struct nla_policy mptcp_pm_get_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOW_RETRIES +1 ] = { [MPTCP_PM_ATTR_RCV_ADD_ADDRS ] =NLA_POLICY_MAX (NLA_U32 ,64 ), [MPTCP_PM_ATTR_SUBFLOWS ] =NLA_POLICY_MAX (NLA_U32 ,64 ), + [MPTCP_PM_ATTR_SUBFLOW_RETRIES ] =NLA_POLICY_MAX (NLA_U32 ,127 ), };/* MPTCP_PM_CMD_SET_FLAGS - do */
@@ -127,7 +129,7 @@ const struct genl_ops mptcp_pm_nl_ops[11] = { .validate = GENL_DONT_VALIDATE_STRICT, .doit = mptcp_pm_nl_set_limits_doit, .policy = mptcp_pm_set_limits_nl_policy, - .maxattr = MPTCP_PM_ATTR_SUBFLOWS, + .maxattr = MPTCP_PM_ATTR_SUBFLOW_RETRIES, .flags = GENL_UNS_ADMIN_PERM, }, {
@@ -135,7 +137,7 @@ const struct genl_ops mptcp_pm_nl_ops[11] = { .validate = GENL_DONT_VALIDATE_STRICT, .doit = mptcp_pm_nl_get_limits_doit, .policy = mptcp_pm_get_limits_nl_policy, - .maxattr = MPTCP_PM_ATTR_SUBFLOWS, + .maxattr = MPTCP_PM_ATTR_SUBFLOW_RETRIES, }, { .cmd = MPTCP_PM_CMD_SET_FLAGS,
net/mptcp/mptcp_pm_gen.h +2 -2
@@ -23,9 +23,9 @@ extern const struct nla_policy mptcp_pm_get_addr_nl_policy[MPTCP_PM_ATTR_TOKEN +extern const struct nla_policy mptcp_pm_flush_addrs_nl_policy[MPTCP_PM_ENDPOINT_ADDR +1 ]; -extern const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS +1 ]; +extern const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOW_RETRIES +1 ]; -extern const struct nla_policy mptcp_pm_get_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS +1 ]; +extern const struct nla_policy mptcp_pm_get_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOW_RETRIES +1 ];extern const struct nla_policy mptcp_pm_set_flags_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE +1 ];
Signature · 1 line
2.25.1
PATCH v16 4/7 mptcp: pm: in-kernel: add the subflow-retries limit
In reply to Anil KaushikA new limit for the in-kernel PM, set and read with the other limits:
the number of SYN retries of a subflow re-created after a timeout, like the TCP_SYNCNT socket option. The default is the maximum, MAX_TCP_SYNCNT (127), about 4 hours, and 0 to not re-create it. The netlink policy checks this maximum value.
It is also exposed in struct mptcp_info, in place of the reserved field.
The next patch uses it.
--- include/uapi/linux/mptcp.h | 2 +- net/mptcp/pm_kernel.c | 19 ++++++++++++++++++- net/mptcp/protocol.h | 1 + net/mptcp/sockopt.c | 2 ++ 4 files changed, 22 insertions(+), 2 deletions(-)
include/uapi/linux/mptcp.h +1 -1
@@ -72,7 +72,7 @@ struct mptcp_info {__u8 mptcpi_subflows_total;__u8 mptcpi_endp_laminar_max;__u8 mptcpi_endp_fullmesh_max; -__u8 reserved; +__u8 mptcpi_limit_subflow_retries;__u32 mptcpi_last_data_sent;__u32 mptcpi_last_data_recv;__u32 mptcpi_last_ack_recv;
net/mptcp/pm_kernel.c +18 -1
@@ -25,6 +25,7 @@ struct pm_nl_pernet {u8 endp_fullmesh_max;u8 limit_add_addr_accepted;u8 limit_extra_subflows; +u8 limit_subflow_retries;u8 next_id;DECLARE_BITMAP (id_bitmap,MPTCP_PM_MAX_ADDR_ID +1 ); };
@@ -95,6 +96,13 @@ u8 mptcp_pm_get_limit_extra_subflows(const struct mptcp_sock *msk) }EXPORT_SYMBOL_GPL (mptcp_pm_get_limit_extra_subflows); +u8 mptcp_pm_get_limit_subflow_retries (const struct mptcp_sock *msk) +{ +struct pm_nl_pernet *pernet =pm_nl_get_pernet_from_msk (msk); + +return READ_ONCE (pernet->limit_subflow_retries); +} +static bool has_subflow_daddr (const struct mptcp_sock *msk,const struct mptcp_addr_info *daddr) {
@@ -1404,8 +1412,8 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg,int mptcp_pm_nl_set_limits_doit (struct sk_buff *skb,struct genl_info *info) {struct pm_nl_pernet *pernet =genl_info_pm_nl (info); +unsigned int rcv_addrs, subflows, retries;struct nlattr **attrs = info->attrs; -unsigned int rcv_addrs, subflows;/* the maximums are checked by the policy */ spin_lock_bh (&pernet->lock);
@@ -1413,9 +1421,12 @@ int mptcp_pm_nl_set_limits_doit(struct sk_buff *skb, struct genl_info *info) pernet->limit_add_addr_accepted); subflows =nla_get_u32_default (attrs[MPTCP_PM_ATTR_SUBFLOWS ], pernet->limit_extra_subflows); + retries =nla_get_u32_default (attrs[MPTCP_PM_ATTR_SUBFLOW_RETRIES ], + pernet->limit_subflow_retries);WRITE_ONCE (pernet->limit_add_addr_accepted, rcv_addrs);WRITE_ONCE (pernet->limit_extra_subflows, subflows); +WRITE_ONCE (pernet->limit_subflow_retries, retries);spin_unlock_bh (&pernet->lock);return 0 ;
@@ -1444,6 +1455,10 @@ int mptcp_pm_nl_get_limits_doit(struct sk_buff *skb, struct genl_info *info) READ_ONCE(pernet->limit_extra_subflows))) goto fail; +if (nla_put_u32 (msg,MPTCP_PM_ATTR_SUBFLOW_RETRIES , +READ_ONCE (pernet->limit_subflow_retries))) + goto fail; +genlmsg_end (msg, reply);return genlmsg_reply (msg, info);
@@ -1598,6 +1613,8 @@ static int __net_init pm_nl_init_net(struct net *net)/* Cit. 2 subflows ought to be enough for anybody. */ pernet->limit_extra_subflows =2 ; +/* the maximum: about 4 hours with the default RTOs */ + pernet->limit_subflow_retries =MAX_TCP_SYNCNT ; pernet->next_id =1 ;spin_lock_init (&pernet->lock);
net/mptcp/protocol.h +1 -0
@@ -1280,6 +1280,7 @@ u8 mptcp_pm_get_endp_laminar_max(const struct mptcp_sock *msk);u8 mptcp_pm_get_endp_fullmesh_max (const struct mptcp_sock *msk);u8 mptcp_pm_get_limit_add_addr_accepted (const struct mptcp_sock *msk);u8 mptcp_pm_get_limit_extra_subflows (const struct mptcp_sock *msk); +u8 mptcp_pm_get_limit_subflow_retries (const struct mptcp_sock *msk);/* called under PM lock */ static inline void __mptcp_pm_close_subflow (struct mptcp_sock *msk)
net/mptcp/sockopt.c +2 -0
@@ -1075,6 +1075,8 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info)mptcp_pm_get_endp_laminar_max (msk); info->mptcpi_endp_fullmesh_max =mptcp_pm_get_endp_fullmesh_max (msk); + info->mptcpi_limit_subflow_retries = +mptcp_pm_get_limit_subflow_retries (msk); }if (__mptcp_check_fallback (msk))
Signature · 1 line
2.25.1
PATCH v16 5/7 mptcp: pm: in-kernel: retry subflows closed after an error
In reply to Anil KaushikWith the in-kernel PM, a subflow closed after an error, e.g. a timeout when a path silently drops packets, is never re-created, even once the path works again. For example, with a main link and a backup link, connections move to the backup after an outage but never come back.
When TCP gives up on an established subflow created by this side, after a retransmission or keepalive timeout, whatever ICMP error was received from the path before, the PM now creates a new one with the same addresses. Its SYN retries, set like TCP_SYNCNT by the subflow-retries limit, space out the attempts. This is a single connection attempt: an ICMP error, or a local error when connecting, ends it, and it is not retried again. It is also closed if the MPTCP socket is closed in the meantime. This is only done while the connection is established and another subflow can send data: otherwise the connection is closed after the close timeout, as before. The re-created subflows not fully established yet are closed when no other subflow can send data anymore, when the connection is no longer established, e.g. after a DATA_FIN from the peer, or when the MPTCP socket is shut down for writing or closed, unless they got fully established in between. A closed one gets an MPTCP_EVENT_SUB_CLOSED event while the MPTCP socket is established, like a join that fails. Once it is established, it is handled like any other subflow. Re-creating the initial subflow uses one of the additional subflows allowed by the limits.
A subflow reset by the peer, or by anything on the path, is not
re-created: the path works, and re-creating it right away could loop. A subflow that never got established is not re-created either: the PM keeps trying the next endpoints, as before. A re-created subflow takes the place of the closed one in the subflows limit: while it is connecting, an endpoint not used yet is only tried if the limit allows one more subflow, or if the new subflow cannot be created. Subflows aborted locally, also by MPTCP, or using an address that has been removed are not retried.
TCP only closes a subflow after a retransmission timeout set by tcp_retries2, about 15 minutes by default. A subflow that only receives data never gets an error: the application has to enable TCP keepalive on the MPTCP socket, which MPTCP applies to all the subflows. Both are documented in mptcp.rst. So is the case of a peer that only receives
data: it can still count the old subflow, and if its subflows limit is then reached, it rejects the new one, which is not retried.
--- Documentation/networking/mptcp.rst | 26 +++++ net/mptcp/pm.c | 50 +++++++++ net/mptcp/pm_kernel.c | 160 +++++++++++++++++++++++++++++ net/mptcp/protocol.c | 77 +++++++++++++- net/mptcp/protocol.h | 51 +++++++++ 5 files changed, 363 insertions(+), 1 deletion(-)
Documentation/networking/mptcp.rst +26 -0
@@ -73,6 +73,32 @@ To be able to use multiple IP addresses on a host to create multiple *subflows* addresses can be used. This can be configured with ``ip mptcp endpoint`` for example. +When TCP gives up on an established subflow created by this host, after a +retransmission or keepalive timeout, the in-kernel path manager creates it +again, with the ``subflow-retries`` limit as its number of SYN retries, like +``TCP_SYNCNT``: 127 by default, about 4 hours, and 0 to not re-create it. This +is done for the additional subflows, and for the initial one on the client side: +the new subflow then takes one of the additional subflows allowed by the +``subflows`` limit. It keeps this place while it is being created again: an +endpoint not used yet is only tried if the ``subflows`` limit allows one more +subflow, or if the new one cannot be created. The initial one is not created +again if the peer does not accept joins to its initial address. This is a single +connection attempt: an ICMP error, or a local error when connecting, ends it, +and it is not created again. This is only done while the connection is +established and another subflow can send data: otherwise the connection is +closed after ``close_timeout``, as before, and the subflows being re-created are +closed too, as they are once the connection is no longer established, e.g. after +a DATA_FIN from the peer. A subflow reset by the peer, or by anything on the +path, is not created again either. TCP only gives up on a subflow after a +retransmission timeout set by ``tcp_retries2``, about 15 minutes by default: +shorter outages are handled by TCP itself. A subflow that only receives data +does not notice that its path stopped working: the application should then +enable TCP keepalive on the MPTCP socket (``SO_KEEPALIVE``, ``TCP_KEEPIDLE``, +``TCP_KEEPINTVL`` and ``TCP_KEEPCNT``), which MPTCP applies to all its subflows. +The peer must also have room for the new subflow: if it only receives data, it +can still count the old one, and if this reached its ``subflows`` limit, it +rejects the new one, which is not created again. + Packet Scheduler ----------------
net/mptcp/pm.c +50 -0
68 lines not on this page · raw message
net/mptcp/pm_kernel.c +160 -0
166 lines not on this page · raw message
net/mptcp/protocol.c +76 -1
138 lines not on this page · raw message
net/mptcp/protocol.h +51 -0
75 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v16 6/7 selftests: mptcp: pm_nl_ctl: support the subflow-retries limit
In reply to Anil Kaushik'pm_nl_ctl limits' can now set the subflow-retries limit with a third value, and shows it when the kernel supports it. The shared mptcp_lib_pm_nl_set_limits() helper takes it as an optional value too, for both ip and pm_nl_ctl: the existing callers are not changed.
pm_netlink.sh checks its default value, that a value above the maximum is refused, that it can be set, and that it is kept when only the other limits are set. With "-i", this is done with "ip mptcp" when it supports this limit, and the expected "ip mptcp limits" output includes it then. With an older kernel or an older ip, these checks are skipped.
--- .../testing/selftests/net/mptcp/mptcp_lib.sh | 8 ++- .../testing/selftests/net/mptcp/pm_netlink.sh | 59 +++++++++++++++++-- tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 34 ++++++++--- 3 files changed, 88 insertions(+), 13 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_lib.sh +6 -2
@@ -689,15 +689,19 @@ mptcp_lib_pm_nl_get_endpoint() { fi } +# $1: ns, $2: rcv addrs, $3: subflows, [ $4: subflow retries ] mptcp_lib_pm_nl_set_limits() { local ns=${1} local addrs=${2} local subflows=${3} + local retries=${4} if mptcp_lib_is_ip_mptcp; then - ip -n "${ns}" mptcp limits set add_addr_accepted "${addrs}" subflows "${subflows}" + ip -n "${ns}" mptcp limits set add_addr_accepted "${addrs}" subflows "${subflows}" \ + ${retries:+subflow_retries "${retries}"} else - ip netns exec "${ns}" ./pm_nl_ctl limits "${addrs}" "${subflows}" + ip netns exec "${ns}" ./pm_nl_ctl limits "${addrs}" "${subflows}" \ + ${retries:+"${retries}"} fi }
tools/testing/selftests/net/mptcp/pm_netlink.sh +55 -4
92 lines not on this page · raw message
tools/testing/selftests/net/mptcp/pm_nl_ctl.c +27 -7
@@ -39,7 +39,7 @@ static void syntax(char *argv[])fprintf (stderr,"\tset [<ip>] [id <nr>] flags [no]backup|[no]fullmesh [port <nr>] [token <token>] [rip <ip>] [rport <port>]\n" );fprintf (stderr,"\tflush\n" );fprintf (stderr,"\tdump\n" ); -fprintf (stderr,"\tlimits [<rcv addr max> <subflow max>]\n" ); +fprintf (stderr,"\tlimits [<rcv addr max> <subflow max> [<retry>]]\n" );fprintf (stderr,"\tevents\n" );fprintf (stderr,"\tlisten <local-ip> <local-port>\n" );exit (0 );
@@ -1217,6 +1217,7 @@ int flush_addrs(int fd, int pm_family, int argc, char *argv[])static void print_limits (struct nlmsghdr *nh,int pm_family,int total_len) {struct rtattr *attrs; +const char *name;uint32_t max;for (;NLMSG_OK (nh, total_len); nh =NLMSG_NEXT (nh, total_len)) {
@@ -1235,13 +1236,22 @@ static void print_limits(struct nlmsghdr *nh, int pm_family, int total_len)while (RTA_OK (attrs, len)) {int type = attrs->rta_type; -if (type !=MPTCP_PM_ATTR_RCV_ADD_ADDRS && - type !=MPTCP_PM_ATTR_SUBFLOWS ) +switch (type) { +case MPTCP_PM_ATTR_RCV_ADD_ADDRS : + name ="accept" ; +break ; +case MPTCP_PM_ATTR_SUBFLOWS : + name ="subflows" ; +break ; +case MPTCP_PM_ATTR_SUBFLOW_RETRIES : + name ="subflow_retries" ; +break ; +default : goto next; + }memcpy (&max,RTA_DATA (attrs),4 ); -printf ("%s %u\n" , type ==MPTCP_PM_ATTR_SUBFLOWS ? -"subflows" :"accept" , max); +printf ("%s %u\n" , name, max); next: attrs =RTA_NEXT (attrs, len);
@@ -1254,15 +1264,17 @@ int get_set_limits(int fd, int pm_family, int argc, char *argv[])char data[NLMSG_ALIGN (sizeof (struct nlmsghdr )) +NLMSG_ALIGN (sizeof (struct genlmsghdr )) +1024 ]; -uint32_t rcv_addr =0 , subflows =0 ; +uint32_t rcv_addr =0 , subflows =0 , retries =0 ;int cmd, len =sizeof (data);struct nlmsghdr *nh;int off =0 ;/* limit */ -if (argc ==4 ) { +if (argc ==4 || argc ==5 ) { rcv_addr =atoi (argv[2 ]); subflows =atoi (argv[3 ]); +if (argc ==5 ) + retries =atoi (argv[4 ]); cmd =MPTCP_PM_CMD_SET_LIMITS ; }else { cmd =MPTCP_PM_CMD_GET_LIMITS ;
@@ -1287,6 +1299,14 @@ int get_set_limits(int fd, int pm_family, int argc, char *argv[])memcpy (RTA_DATA (rta), &subflows,4 ); off +=NLMSG_ALIGN (rta->rta_len); +if (argc ==5 ) { + rta = (void *)(data + off); + rta->rta_type =MPTCP_PM_ATTR_SUBFLOW_RETRIES ; + rta->rta_len =RTA_LENGTH (4 ); +memcpy (RTA_DATA (rta), &retries,4 ); + off +=NLMSG_ALIGN (rta->rta_len); + } +/* do not expect a reply */ len =0 ; }
Signature · 1 line
2.25.1
PATCH v16 7/7 selftests: mptcp: join: validate subflow retry after link failure
In reply to Anil KaushikTest the subflow-retries limit, with its default value, and a long connection in the background: drop the packets the client sends from the additional subflow address with netfilter, without bringing the link down, until the subflow is closed and re-created. Let them through again once the SYN of the new subflow has been retransmitted more times than tcp_syn_retries allows, and check the subflow comes back from the same address. Then do the same with the initial subflow.
A second test closes the connection while a subflow is being re-created, and checks the netlink events. Only the client sends data: the server reads it all first, in sendfile mode, and keeps its side open. The client gets a big MPTCP send buffer compared to its subflows, and both paths are blocked: the data left in it is never sent, nor the DATA_FIN, so only the close of the MPTCP socket can stop the subflow being re-created. Only the client is closed: it has nothing left to read, so the connection is not closed with a fastclose, which would reset all the subflows anyway. The check is skipped if a fastclose happens. The big files used for the long connection are emptied at the end.
A third test checks the only subflow is not re-created: there is no other subflow to send data.
A fourth test removes the address of the additional subflow while its packets are dropped: the subflow times out, the new one cannot be created, bind() fails, and the PM uses the next endpoint instead.
The tests are skipped if pm_nl_ctl does not show the new limit, or if the filter chain cannot be created.
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 420 +++++++++++++++++- 1 file changed, 412 insertions(+), 8 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +412 -8
@@ -52,6 +52,7 @@ nr_blank=6 # These var are used only in some tests, make sure they are not already set unset FAILING_LINKS unset test_linkfail +unset server_in unset addr_nr_ns1 unset addr_nr_ns2 unset cestab_ns1
@@ -1038,7 +1039,12 @@ do_transfer() fi extra_srv_args="$extra_args $extra_srv_args" - if [ "$test_linkfail" -gt 1 ];then + if [ -n "${server_in}" ]; then + # the server reads all the data from the client before sending + # this file: it does not block on its input + extra_srv_args="$extra_srv_args -m sendfile" + listener_in="${server_in}" + elif [ "$test_linkfail" -gt 1 ]; then listener_in="${sinfail}" fi ip netns exec ${listener_ns} \
@@ -1135,9 +1141,9 @@ run_tests() cinfail=$(mktemp) fi make_file "$cinfail" "client" $size - # create the input file for the failure test when - # the first failure test run - elif [ "$test_linkfail" -ne 0 ] && [ -z "$cinfail" ]; then + # create the input file for the failure test, when + # it is missing or has been emptied + elif [ "$test_linkfail" -ne 0 ] && [ ! -s "$cinfail" ]; then # the client file must be considerably larger # of the maximum expected cwin value, or the # link utilization will be not predicable
@@ -1146,23 +1152,27 @@ run_tests() size=$((size*8192)) size=$((size + ( RANDOM % 8192) )) - cinfail=$(mktemp) + if [ -z "$cinfail" ]; then + cinfail=$(mktemp) + fi make_file "$cinfail" "client" $size fi - if [ "$test_linkfail" -gt 2 ]; then + if [ "$test_linkfail" -gt 2 ] && [ -z "${server_in}" ]; then size=$test_linkfail if [ -z "$sinfail" ]; then sinfail=$(mktemp) fi make_file "$sinfail" "server" $size - elif [ "$test_linkfail" -eq 2 ] && [ -z "$sinfail" ]; then + elif [ "$test_linkfail" -eq 2 ] && [ ! -s "$sinfail" ]; then size=$((RANDOM%16)) size=$((size+1)) size=$((size*2048)) - sinfail=$(mktemp) + if [ -z "$sinfail" ]; then + sinfail=$(mktemp) + fi make_file "$sinfail" "server" $size fi
@@ -2151,6 +2161,210 @@ wait_attempt_fail() return 1 } +# $1: timeout in seconds ; $2: ns ; $3: counter ; $4: increment, 1 by default +wait_counter_inc() +{ + slowwait_for_counter "${1}" "${4:-1}" \ + mptcp_lib_get_counter "${2}" "${3}" >/dev/null +} + +# $1: timeout ; $2: ns ; $3: counter ; $4: value to reach +wait_counter_ge() +{ + slowwait "${1}" until_counter_is ">= ${4}" \ + mptcp_lib_get_counter "${2}" "${3}" >/dev/null +} + +# $1: client address ; prints the local address and port of its subflow +sf_from() +{ + ip netns exec $ns2 ss -tnH state established src "${1}" | + awk '{ print $3; exit }' +} + +# the client got the 4th ACK of the MP_JOIN +sf_fully_established() +{ + ip netns exec $ns2 ss -tniH state established src "${1}" | + grep -q "tcp-ulp-mptcp flags:[A-Za-z]*e" +} + +has_subflow_retries() +{ + ip netns exec $ns2 ./pm_nl_ctl limits | grep -q "^subflow_retries" +} + +# the client packets are dropped with rules in this chain +init_nft_filter() +{ + init_nftables + if ! ip netns exec $ns2 nft list chain ip filter OUTPUT \ + &>/dev/null; then + mark_as_skipped "unable to set the filter rules" + return 1 + fi +} + +# $1: client address +nft_drop_from() +{ + ip netns exec $ns2 nft add rule ip filter OUTPUT ip saddr "${1}" drop +} + +# $1: client address to block +# +# The link stays up, but the client packets from this address are dropped: +# the subflow using it is closed after a few retransmissions, and re-created. +# The packets go through again once the SYN has been retransmitted more times +# than tcp_syn_retries allows: the new subflow still connects thanks to the +# subflow-retries limit. +sf_retry_after_block() +{ + local before ack_rx syn_tx + + before=$(sf_from "${1}") + + print_check "subflow from ${1}" + if [ -z "${before}" ]; then + fail_test "no established subflow from ${1} before the block" + return + fi + + # read before the block: the subflow can be re-created right after it + syn_tx=$(mptcp_lib_get_counter $ns2 "MPTcpExtMPJoinSynTx") + # a short timeout only while the path is blocked: it is per netns, so + # keep this window short, the other path could time out on losses + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=3 + if ! nft_drop_from "${1}"; then + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=15 + fail_test "unable to drop the packets from ${1}" + return + fi + if ! wait_counter_ge "${timeout_poll}" $ns2 "MPTcpExtMPJoinSynTx" \ + $((syn_tx + 1)); then + ip netns exec $ns2 nft flush chain ip filter OUTPUT + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=15 + fail_test "subflow from ${1} not re-created" + return + fi + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=15 + # tcp_syn_retries=1: one more retransmission than allowed + if ! wait_counter_inc "${timeout_poll}" \ + $ns2 "TcpExtTCPSynRetrans" 2; then + ip netns exec $ns2 nft flush chain ip filter OUTPUT + fail_test "SYN from ${1} not retransmitted enough" + return + fi + # read before the flush: the next SYN can be sent right after it + ack_rx=$(mptcp_lib_get_counter $ns1 "MPTcpExtMPJoinAckRx") + ip netns exec $ns2 nft flush chain ip filter OUTPUT + + if ! wait_counter_ge "${timeout_poll}" $ns1 "MPTcpExtMPJoinAckRx" \ + $((ack_rx + 1)); then + fail_test "re-created subflow from ${1} not established" + return + fi + + # before a close, which would close it too if not fully established + if ! slowwait "${timeout_poll}" sf_fully_established "${1}"; then + fail_test "no fully established subflow from ${1}" + else + print_ok + fi +} + +# $1: ns ; prints the number of MP_FASTCLOSE sent and received +fastclose_nr() +{ + local tx rx + + tx=$(mptcp_lib_get_counter "${1}" "MPTcpExtMPFastcloseTx") + rx=$(mptcp_lib_get_counter "${1}" "MPTcpExtMPFastcloseRx") + echo $((${tx:-0} + ${rx:-0})) +} + +no_sf_connecting() +{ + ! ip netns exec $ns2 ss -tnH state syn-sent | grep -q . +} + +# The client has nothing left to read: it closes the connection without a +# fastclose, which would reset all the subflows anyway. +kill_client() +{ + local pid + + for pid in $(ip netns pids $ns2); do + if [ "$(cat "/proc/${pid}/comm" 2>/dev/null)" = mptcp_connect ] + then + kill "${pid}" 2>/dev/null + fi + done +} + +# $1: why the subflow is not being re-created before the close, if it is not +# $2: number of MP_FASTCLOSE before the close +chk_no_sf_connecting() +{ + local closed + + print_check "no subflow connecting after close" + if [ -n "${1}" ]; then + fail_test "${1}" + return + fi + + # closed with the MPTCP socket + slowwait "${timeout_poll}" no_sf_connecting + closed=$? + if [ "$(fastclose_nr $ns2)" -gt "${2}" ]; then + print_skip "closed with a fastclose, resetting all the subflows" + elif [ "${closed}" -eq 0 ]; then + print_ok + else + fail_test "subflow still connecting after close" + fi +} + +# Slow links with short queues: the transfer lasts the whole test on any +# machine, and the blocked subflow always has data in flight. +sf_retry_init() +{ + local i + + # link 4: the next endpoint of the "creation error" test + for i in 1 3 4; do + tc -n $ns1 qdisc add dev ns1eth$i root netem \ + rate 4mbit limit 30 delay 1ms + tc -n $ns2 qdisc add dev ns2eth$i root netem \ + rate 4mbit limit 30 delay 1ms + done + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=3 + ip netns exec $ns2 sysctl -q net.ipv4.tcp_syn_retries=1 + ip netns exec $ns2 sysctl -q net.ipv4.tcp_syn_linear_timeouts=0 + pm_nl_set_limits $ns1 0 4 + pm_nl_set_limits $ns2 0 2 + pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow + # created here, not in the background job, for cleanup() + if [ -z "$cinfail" ]; then + cinfail=$(mktemp) + fi + if [ -z "$sinfail" ]; then + sinfail=$(mktemp) + fi +} + +sf_retry_cleanup() +{ + ip netns exec $ns2 nft flush chain ip filter OUTPUT + # big files: empty them, the next tests write their own content + : > "$cinfail" + : > "$sinfail" + : > "$cinsent" + : > "$cout" + : > "$sout" +} + set_userspace_pm() { local ns=$1
@@ -2585,6 +2799,196 @@ link_failure_tests() chk_stale_nr $ns2 1 -1 2 chk_link_usage $ns2 ns2eth3 $cinsent 50 fi + + # subflows closed after a silent link failure, then re-created: the + # additional one, then the initial one + if reset_with_events "subflow retry after link failure" && + continue_if has_subflow_retries && init_nft_filter; then + sf_retry_init + # lowered by sf_retry_after_block() while a path is blocked + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=15 + # killed at the end: the timeout only stops a stuck test + { timeout_test=600 test_linkfail=131072 \ + run_tests $ns1 $ns2 10.0.1.1 & } 2>/dev/null + local tests_pid=$! + + # the 128 MB files are created first, that can take a while + if wait_counter_ge $((timeout_poll * 4)) \ + $ns1 "MPTcpExtMPJoinAckRx" 1; then + sf_retry_after_block 10.0.3.2 + sf_retry_after_block 10.0.1.2 + else + print_check "additional subflow" + fail_test "no additional subflow before the blocks" + fi + # before the kill, which can send MP_RST (checked with -C) + join_syn_tx=3 chk_join_nr 3 3 3 + mptcp_lib_kill_group_wait $tests_pid + # the listener could be stopped before it got the last events + wait_event ns2 MPTCP_LIB_EVENT_SUB_ESTABLISHED 3 + wait_event ns2 MPTCP_LIB_EVENT_SUB_CLOSED 2 + kill_events_pids + + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_ESTABLISHED 3 + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_CLOSED 2 error 2 + sf_retry_cleanup + fi + + # close the connection while a subflow is being re-created + if reset_with_events "subflow retry, close while connecting" && + continue_if has_subflow_retries && init_nft_filter; then + sf_retry_init + # lowered just before the block: both paths are used until then + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=15 + # A big msk send buffer, compared to the subflow ones: when the + # client is closed, some data is not given to any subflow yet, + # so the DATA_FIN, which would also close the subflow being + # re-created, is not sent. The min value is above the max on + # purpose: __mptcp_sync_sndbuf() adds it to the subflow ones. + ip netns exec $ns2 sysctl -q \ + net.ipv4.tcp_wmem="1048576 65536 262144" + # The server reads until the client closes, and sends nothing: + # the client has nothing to read, and the connection stays + # established. The transfer is stopped on purpose, its result + # is not checked. + : > "$sinfail" + { timeout_test=600 test_linkfail=131072 server_in="$sinfail" \ + run_tests $ns1 $ns2 10.0.1.1 >/dev/null & } 2>/dev/null + local tests_pid=$! + + local not_ready="" syn_tx + if ! wait_counter_ge $((timeout_poll * 4)) \ + $ns1 "MPTcpExtMPJoinAckRx" 1; then + not_ready="no additional subflow before the block" + else + # read before the block: the subflow can be re-created + # right after it + syn_tx=$(mptcp_lib_get_counter $ns2 \ + "MPTcpExtMPJoinSynTx") + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=3 + if ! nft_drop_from 10.0.3.2; then + not_ready="unable to drop the packets" + elif ! wait_counter_ge "${timeout_poll}" \ + $ns2 "MPTcpExtMPJoinSynTx" $((syn_tx + 1)); then + not_ready="no subflow re-created before close" + fi + fi + # Block the other path too, so this data is never sent: only + # the close of the MPTCP socket can then stop the subflow being + # re-created. The initial subflow is no longer closed after a + # few retransmissions: that would close it too. + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=15 + if [ -z "${not_ready}" ] && ! nft_drop_from 10.0.1.2; then + not_ready="unable to drop the packets" + fi + local fc_before + fc_before=$(fastclose_nr $ns2) + # before the kill, which can send MP_RST (checked with -C) + join_syn_tx=2 chk_join_nr 1 1 1 + kill_client + chk_no_sf_connecting "${not_ready}" "${fc_before}" + mptcp_lib_kill_group_wait $tests_pid + # the listener could be stopped before it got the last event + wait_event ns2 MPTCP_LIB_EVENT_SUB_CLOSED 2 + kill_events_pids + + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_ESTABLISHED 1 + # the re-created subflow, closed with the MPTCP socket + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_CLOSED 2 error 1 + sf_retry_cleanup + fi + + # the only subflow is not re-created + if reset_with_events "subflow retry, no other subflow" && + continue_if has_subflow_retries && init_nft_filter; then + sf_retry_init + pm_nl_flush_endpoint $ns2 + { timeout_test=600 test_linkfail=131072 \ + run_tests $ns1 $ns2 10.0.1.1 >/dev/null & } 2>/dev/null + local tests_pid=$! + + print_check "not re-created" + if ! wait_counter_ge $((timeout_poll * 4)) \ + $ns1 "MPTcpExtMPCapableACKRX" 1; then + fail_test "connection not established" + elif ! nft_drop_from 10.0.1.2; then + fail_test "unable to drop the packets" + elif ! wait_counter_ge "${timeout_poll}" \ + $ns2 "TcpExtTCPAbortOnTimeout" 1; then + fail_test "subflow not closed" + else + # the worker decides right after it reports the close + wait_event ns2 MPTCP_LIB_EVENT_SUB_CLOSED 1 + sleep 1 + local syn_tx + syn_tx=$(mptcp_lib_get_counter $ns2 \ + "MPTcpExtMPJoinSynTx") + if [ "${syn_tx}" != 0 ]; then + fail_test "subflow re-created" + else + print_ok + fi + fi + # before the kill, which can send MP_RST (checked with -C) + join_syn_tx=0 chk_join_nr 0 0 0 + mptcp_lib_kill_group_wait $tests_pid + kill_events_pids + + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_CLOSED 1 error 1 + sf_retry_cleanup + fi + + # the subflow cannot be re-created: the next endpoint takes its place + if reset_with_events "subflow retry, creation error" && + continue_if has_subflow_retries && init_nft_filter; then + sf_retry_init + pm_nl_set_limits $ns2 0 1 + pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=15 + { timeout_test=600 test_linkfail=131072 \ + run_tests $ns1 $ns2 10.0.1.1 >/dev/null & } 2>/dev/null + local tests_pid=$! + + print_check "next endpoint used" + if ! wait_counter_ge $((timeout_poll * 4)) \ + $ns1 "MPTcpExtMPJoinAckRx" 1; then + fail_test "no additional subflow before the block" + elif [ -z "$(sf_from 10.0.3.2)" ]; then + fail_test "no subflow from 10.0.3.2 before the block" + else + # The subflow times out, then the new one cannot be + # created: its address is gone, bind() fails. + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=3 + if ! nft_drop_from 10.0.3.2; then + fail_test "unable to drop the packets" + elif ! ip -n $ns2 addr del 10.0.3.2/24 dev ns2eth3; then + fail_test "unable to remove 10.0.3.2" + elif ! wait_counter_ge "${timeout_poll}" $ns2 \ + "MPTcpExtMPJoinSynTxBindErr" 1; then + fail_test "subflow from 10.0.3.2 not re-created" + elif ! wait_counter_ge "${timeout_poll}" $ns1 \ + "MPTcpExtMPJoinAckRx" 2; then + fail_test "next endpoint not used" + elif ! slowwait "${timeout_poll}" \ + sf_fully_established 10.0.4.2; then + fail_test "10.0.4.2 not fully established" + else + print_ok + fi + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=15 + fi + # before the kill, which can send MP_RST (checked with -C) + join_syn_tx=2 join_bind_err=1 chk_join_nr 2 2 2 + mptcp_lib_kill_group_wait $tests_pid + # the listener could be stopped before it got the last events + wait_event ns2 MPTCP_LIB_EVENT_SUB_ESTABLISHED 2 + wait_event ns2 MPTCP_LIB_EVENT_SUB_CLOSED 1 + kill_events_pids + + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_ESTABLISHED 2 + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_CLOSED 1 error 1 + sf_retry_cleanup + fi } add_addr_timeout_tests()
Signature · 1 line
2.25.1
Hi Anil,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Perf: Unstable: 6 failed test(s): regression:sched-bbr regression:sched-clientlim regression:sched-mem-pressure regression:sched-rmem(3) regression:sched-weak-secondary validation:sched-loss ⚠️ (105 new outliers to review)
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/44971784636
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/cc174cbf3118
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1218365
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)