mptcp: add the subflow-retries limit
v2 cover mptcp: add the subflow-retries limit
This adds the new subflow-retries limit of the in-kernel path manager to "ip mptcp limits", and shows it in "ss -Mi", as Matt suggested on the kernel series:
https://lore.kernel.org/mptcp/[email protected]/
Patch 1 adds the new attribute and the new mptcp_info field to the copied uapi headers. It is only needed until the iproute2 maintainers update the headers, once the kernel part is merged.
Patch 2 adds "subflow_retries" to "ip mptcp limits set" and "show", and to the man page.
Patch 3 shows the limit in "ss -Mi". If the split of ss.c lands first, I will rebase it:
https://lore.kernel.org/[email protected]
Tested in a VM with the kernel series applied: show, set, a partial set keeping the other limits, JSON output, the maximum (127 accepted, 128 refused by the kernel), and "ss -Mi" with the limit at 127, 5 and 0. With an older kernel, nothing new is shown, and setting the limit is accepted but ignored by the kernel.
The fix for "pm_netlink.sh -i" with this ip will be in v16 of the kernel series.
Changes in v2: show the limit in ss, as Matt asked, with the new mptcp_info field in patch 1; and the iproute2-mptcp prefix.
v1: https://lore.kernel.org/mptcp/[email protected]/
I used an LLM to help write and review these patches. I checked and tested every change myself.
Anil Kaushik (3):
uapi: mptcp: add the subflow-retries limit
mptcp: limits: add subflow_retries
ss: mptcp: show the subflow-retries limit
include/uapi/linux/mptcp.h | 2 +- include/uapi/linux/mptcp_pm.h | 1 + ip/ipmptcp.c | 21 ++++++++++++++++++++- man/man8/ip-mptcp.8 | 10 ++++++++++ misc/ss.c | 3 +++ 5 files changed, 35 insertions(+), 2 deletions(-)
base-commit: 87cb3f4198507331b9308689d4a726d17db63dd3
Signature · 1 line
2.25.1
PATCH v2 1/3 uapi: mptcp: add the subflow-retries limit
Add the new netlink attribute and the new mptcp_info field from the kernel series adding the subflow-retries limit to the in-kernel path manager. They are used by patches 2 and 3.
This should be replaced by the usual header update from the iproute2 maintainers once the kernel part is merged.
--- include/uapi/linux/mptcp.h | 2 +- include/uapi/linux/mptcp_pm.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
include/uapi/linux/mptcp.h +1 -1
@@ -70,7 +70,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;
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 };
base-commit: 87cb3f4198507331b9308689d4a726d17db63dd3
Signature · 1 line
2.25.1
PATCH v2 2/3 mptcp: limits: add subflow_retries
In reply to Anil KaushikThe in-kernel path manager can re-create a subflow closed after a retransmission or keepalive timeout. The new subflow-retries limit sets the number of SYN retries of such subflow, like the TCP_SYNCNT socket
option: 127 by default, also the maximum, and 0 to not re-create it.
Add it to "ip mptcp limits set" and show it in "ip mptcp limits show" when the kernel reports it:
# ip mptcp limits set subflow_retries 5 # ip mptcp limits show add_addr_accepted 0 subflows 2 subflow_retries 5
The new keyword is matched exactly, so "subflow" still means "subflows".
--- ip/ipmptcp.c | 21 ++++++++++++++++++++- man/man8/ip-mptcp.8 | 10 ++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-)
ip/ipmptcp.c +20 -1
@@ -30,6 +30,7 @@ static void usage(void)" ip mptcp endpoint show [ id ID ]\n" " ip mptcp endpoint flush\n" " ip mptcp limits set [ subflows NR ] [ add_addr_accepted NR ]\n" +" [ subflow_retries NR ]\n" " ip mptcp limits show\n" " ip mptcp monitor\n" "FLAG-LIST := [ FLAG-LIST ] FLAG\n"
@@ -362,9 +363,11 @@ static int mptcp_addr_flush(int argc, char **argv)static int mptcp_parse_limit (int argc,char **argv,struct nlmsghdr *n) {bool set_rcv_add_addrs = false; +bool set_retries = false;bool set_subflows = false;__u32 rcv_add_addrs =0 ;__u32 subflows =0 ; +__u32 retries =0 ;while (argc >0 ) {if (matches (*argv,"subflows" ) ==0 ) {
@@ -379,6 +382,12 @@ static int mptcp_parse_limit(int argc, char **argv, struct nlmsghdr *n)if (get_u32 (&rcv_add_addrs, *argv,0 ))invarg ("invalid add_addr_accepted\n" , *argv); set_rcv_add_addrs = true; + }else if (strcmp (*argv,"subflow_retries" ) ==0 ) { +NEXT_ARG (); + +if (get_u32 (&retries, *argv,0 )) +invarg ("invalid subflow_retries\n" , *argv); + set_retries = true; }else {invarg ("unknown limit" , *argv); }
@@ -390,7 +399,10 @@ static int mptcp_parse_limit(int argc, char **argv, struct nlmsghdr *n) rcv_add_addrs);if (set_subflows)addattr32 (n,MPTCP_BUFLEN ,MPTCP_PM_ATTR_SUBFLOWS , subflows); -return set_rcv_add_addrs || set_subflows; +if (set_retries) +addattr32 (n,MPTCP_BUFLEN ,MPTCP_PM_ATTR_SUBFLOW_RETRIES , + retries); +return set_rcv_add_addrs || set_subflows || set_retries; }static int print_mptcp_limit (struct nlmsghdr *n,void *arg)
@@ -424,6 +436,13 @@ static int print_mptcp_limit(struct nlmsghdr *n, void *arg)print_uint (PRINT_ANY ,"subflows" ,"subflows %d " , val); } +if (tb[MPTCP_PM_ATTR_SUBFLOW_RETRIES ]) { + val =rta_getattr_u32 (tb[MPTCP_PM_ATTR_SUBFLOW_RETRIES ]); + +print_uint (PRINT_ANY ,"subflow_retries" ,"subflow_retries %d " , + val); + } +print_nl ();close_json_object ();
man/man8/ip-mptcp.8 +10 -0
@@ -92,6 +92,9 @@ ip-mptcp \- MPTCP path manager configuration .RB "[ " .B add_addr_accepted .IR ADD_ADDR_ACCEPTED_NR " ]" +.RB "[ " +.B subflow_retries +.IR SUBFLOW_RETRIES_NR " ]" .ti -8 .BR "ip mptcp limits show"
@@ -268,6 +271,13 @@ In both cases the .IR SUBFLOW_NR limit is enforced. +.TP +.IR SUBFLOW_RETRIES_NR +specifies the number of SYN retries used when the in-kernel path manager +re-creates a subflow closed after a retransmission or keepalive timeout, +like the TCP_SYNCNT socket option. The default and maximum value is 127, +about 4 hours with the default RTO settings. 0 disables the re-creation. + .sp .PP .B monitor
Signature · 1 line
2.25.1
PATCH v2 3/3 ss: mptcp: show the subflow-retries limit
In reply to Anil KaushikThe kernel series adding the subflow-retries limit to the in-kernel path manager also reports it in mptcp_info, in a byte that was reserved before. Show it in "ss -Mi" when it is set, like the other fields:
# ss -Mi ESTAB 0 0 127.0.0.1:33586 127.0.0.1:10000 subflows_max:2 ... subflows_total:1 limit_subflow_retries:127 ...
Older kernels leave this byte at 0, so nothing more is shown with them, as when the retry is disabled.
--- misc/ss.c | 3 +++ 1 file changed, 3 insertions(+)
misc/ss.c +3 -0
@@ -3203,6 +3203,9 @@ static void mptcp_stats_print(struct mptcp_info *s)out (" subflows_total:%u" , s->mptcpi_subflows_total);if (s->mptcpi_endp_laminar_max)out (" endp_laminar_max:%u" , s->mptcpi_endp_laminar_max); +if (s->mptcpi_limit_subflow_retries) +out (" limit_subflow_retries:%u" , + s->mptcpi_limit_subflow_retries);if (s->mptcpi_last_data_sent)out (" last_data_sent:%u" , s->mptcpi_last_data_sent);if (s->mptcpi_last_data_recv)
Signature · 1 line
2.25.1