Skip to contentSkip to conversation

mptcp: MIB counters for sent MP_JOIN

PATCH Superseded Matthieu Baerts (NGI0) 3 participants 6 messages Jul 26, 2024 – Jul 29, 2024

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Matthieu Baerts (NGI0)

author maintainer
#0 lore raw

cover mptcp: MIB counters for sent MP_JOIN

Recently, a few issues have been discovered around the creation of additional subflows. Without these counters, it was difficult to point out the reason why some subflows were not created as expected.

All error paths from __mptcp_subflow_connect() are covered.

These new counters are also verified in the MPTCP Join selftest.

---
Matthieu Baerts (NGI0) (2):
mptcp: MIB counters for sent MP_JOIN
selftests: mptcp: join: validate MPJ SYN TX MIB counters

 net/mptcp/mib.c                                 |  5 ++
 net/mptcp/mib.h                                 |  5 ++
 net/mptcp/subflow.c                             | 24 ++++++++--
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 63 +++++++++++++++++++++++++
 4 files changed, 93 insertions(+), 4 deletions(-)

---
base-commit: a9a9b3b154d187864b73eb0e86a0ff737d79a10a
change-id: 20240724-mptcp-join-tx-mib-84e21ea4b236

Best regards,

Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>
author maintainer
#1 lore raw

PATCH 1/2 mptcp: MIB counters for sent MP_JOIN

Recently, a few issues have been discovered around the creation of additional subflows. Without these counters, it was difficult to point out the reason why some subflows were not created as expected.

These counters should have been added earlier, because there is no other simple ways to extract such information from the kernel, and understand why subflows have not been created.

While at it, some pr_debug() have been added, just in case the errno needs to be printed.

---
 net/mptcp/mib.c     |  5 +++++
 net/mptcp/mib.h     |  5 +++++
 net/mptcp/subflow.c | 24 ++++++++++++++++++++----
 3 files changed, 30 insertions(+), 4 deletions(-)
net/mptcp/mib.c +5 -0
index 7884217f33eb..a0b1152c32f1 100644
@@ -25,6 +25,11 @@ static const struct snmp_mib mptcp_snmp_list[] = {
 	SNMP_MIB_ITEM("MPJoinSynAckHMacFailure", MPTCP_MIB_JOINSYNACKMAC),
 	SNMP_MIB_ITEM("MPJoinAckRx", MPTCP_MIB_JOINACKRX),
 	SNMP_MIB_ITEM("MPJoinAckHMacFailure", MPTCP_MIB_JOINACKMAC),
+	SNMP_MIB_ITEM("MPJoinSynTx", MPTCP_MIB_JOINSYNTX),
+	SNMP_MIB_ITEM("MPJoinSynTxFEstabErr", MPTCP_MIB_JOINSYNTXFULLYESTAB),
+	SNMP_MIB_ITEM("MPJoinSynTxCreatSkErr", MPTCP_MIB_JOINSYNTXCREATESOCK),
+	SNMP_MIB_ITEM("MPJoinSynTxBindErr", MPTCP_MIB_JOINSYNTXBIND),
+	SNMP_MIB_ITEM("MPJoinSynTxConnectErr", MPTCP_MIB_JOINSYNTXCONNECT),
 	SNMP_MIB_ITEM("DSSNotMatching", MPTCP_MIB_DSSNOMATCH),
 	SNMP_MIB_ITEM("InfiniteMapTx", MPTCP_MIB_INFINITEMAPTX),
 	SNMP_MIB_ITEM("InfiniteMapRx", MPTCP_MIB_INFINITEMAPRX),
net/mptcp/mib.h +5 -0
index 66aa67f49d03..ccb3a30e835a 100644
@@ -20,6 +20,11 @@ enum linux_mptcp_mib_field {
 	MPTCP_MIB_JOINSYNACKMAC,	/* HMAC was wrong on SYN/ACK + MP_JOIN */
 	MPTCP_MIB_JOINACKRX,		/* Received an ACK + MP_JOIN */
 	MPTCP_MIB_JOINACKMAC,		/* HMAC was wrong on ACK + MP_JOIN */
+	MPTCP_MIB_JOINSYNTX,		/* Sending a SYN + MP_JOIN */
+	MPTCP_MIB_JOINSYNTXFULLYESTAB,	/* Not in fully established when sending a SYN + MP_JOIN */
+	MPTCP_MIB_JOINSYNTXCREATESOCK,	/* Not able to create a socket when sending a SYN + MP_JOIN */
+	MPTCP_MIB_JOINSYNTXBIND,	/* Not able to bind() the address when sending a SYN + MP_JOIN */
+	MPTCP_MIB_JOINSYNTXCONNECT,	/* Not able to connect() when sending a SYN + MP_JOIN */
 	MPTCP_MIB_DSSNOMATCH,		/* Received a new mapping that did not match the previous one */
 	MPTCP_MIB_INFINITEMAPTX,	/* Sent an infinite mapping */
 	MPTCP_MIB_INFINITEMAPRX,	/* Received an infinite mapping */
net/mptcp/subflow.c +20 -4
index a21c712350c3..d305c0f53a09 100644
@@ -1577,12 +1577,18 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc,
 	int ifindex;
 	u8 flags;
 
-	if (!mptcp_is_fully_established(sk))
+	if (!mptcp_is_fully_established(sk)) {
+		MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_JOINSYNTXFULLYESTAB);
 		goto err_out;
+	}
 
 	err = mptcp_subflow_create_socket(sk, loc->family, &sf);
-	if (err)
+	if (err) {
+		MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_JOINSYNTXCREATESOCK);
+		pr_debug("msk=%p local=%d remote:%d create sock error: %d\n",
+			 msk, local_id, remote_id, err);
 		goto err_out;
+	}
 
 	ssk = sf->sk;
 	subflow = mptcp_subflow_ctx(ssk);
@@ -1608,8 +1614,12 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc,
 #endif
 	ssk->sk_bound_dev_if = ifindex;
 	err = kernel_bind(sf, (struct sockaddr *)&addr, addrlen);
-	if (err)
+	if (err) {
+		MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_JOINSYNTXBIND);
+		pr_debug("msk=%p local=%d remote:%d bind error: %d\n",
+			 msk, local_id, remote_id, err);
 		goto failed;
+	}
 
 	mptcp_crypto_key_sha(subflow->remote_key, &remote_token, NULL);
 	pr_debug("msk=%p remote_token=%u local_id=%d remote_id=%d", msk,
@@ -1624,8 +1634,14 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc,
 	sock_hold(ssk);
 	list_add_tail(&subflow->node, &msk->conn_list);
 	err = kernel_connect(sf, (struct sockaddr *)&addr, addrlen, O_NONBLOCK);
-	if (err && err != -EINPROGRESS)
+	if (err && err != -EINPROGRESS) {
+		MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_JOINSYNTXCONNECT);
+		pr_debug("msk=%p local=%d remote:%d connect error: %d\n",
+			 msk, local_id, remote_id, err);
 		goto failed_unlink;
+	}
+
+	MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_JOINSYNTX);
 
 	/* discard the subflow socket */
 	mptcp_sock_graft(ssk, sk->sk_socket);
Signature · 1 line
2.45.2
reviewer
#2 lore raw

Hi Matt,

Quoted 27 lines · On Fri, 2024-07-26 at 19:48 +0200, Matthieu Baerts (NGI0) wrote:

Recently, a few issues have been discovered around the creation of additional subflows. Without these counters, it was difficult to point
out the reason why some subflows were not created as expected.

These counters should have been added earlier, because there is no other
simple ways to extract such information from the kernel, and understand
why subflows have not been created.

While at it, some pr_debug() have been added, just in case the errno needs to be printed.

---
 net/mptcp/mib.c     |  5 +++++ net/mptcp/mib.h     |  5 +++++ net/mptcp/subflow.c | 24 ++++++++++++++++++++----

 3 files changed, 30 insertions(+), 4 deletions(-)
net/mptcp/mib.c +0 -0
index 7884217f33eb..a0b1152c32f1 100644

net/mptcp/mib.c static const struct snmp_mib mptcp_snmp_list[] = { · line 31

Quoted 7 lines
net/mptcp/mib.c +2 -0
@@ -25,6 +25,11 @@ static const struct snmp_mib mptcp_snmp_list[] = {
  	SNMP_MIB_ITEM("MPJoinSynAckHMacFailure",
 MPTCP_MIB_JOINSYNACKMAC),
  	SNMP_MIB_ITEM("MPJoinAckRx", MPTCP_MIB_JOINACKRX),
  	SNMP_MIB_ITEM("MPJoinAckHMacFailure", MPTCP_MIB_JOINACKMAC),
+	SNMP_MIB_ITEM("MPJoinSynTx", MPTCP_MIB_JOINSYNTX),
+	SNMP_MIB_ITEM("MPJoinSynTxFEstabErr",
 MPTCP_MIB_JOINSYNTXFULLYESTAB),

It's better to keep the "Err" postfix to reduce ambiguity:

MPTCP_MIB_JOINSYNTXFULLYESTAB_ERR or MPTCP_MIB_JOINSYNTXFULLYESTABERR.

Quoted 6 lines
net/mptcp/mib.c +2 -0
+	SNMP_MIB_ITEM("MPJoinSynTxCreatSkErr",
 MPTCP_MIB_JOINSYNTXCREATESOCK),
+	SNMP_MIB_ITEM("MPJoinSynTxBindErr",

MPTCP_MIB_JOINSYNTXBIND),

net/mptcp/mib.c +1 -0
+	SNMP_MIB_ITEM("MPJoinSynTxConnectErr",

MPTCP_MIB_JOINSYNTXCONNECT),

Same these three.

Thanks,
-Geliang

Quoted 99 lines

  SNMP_MIB_ITEM("DSSNotMatching", MPTCP_MIB_DSSNOMATCH), SNMP_MIB_ITEM("InfiniteMapTx", MPTCP_MIB_INFINITEMAPTX), SNMP_MIB_ITEM("InfiniteMapRx", MPTCP_MIB_INFINITEMAPRX),

net/mptcp/mib.h +0 -0
index 66aa67f49d03..ccb3a30e835a 100644
@@ -20,6 +20,11 @@ enum linux_mptcp_mib_field {

  MPTCP_MIB_JOINSYNACKMAC, /* HMAC was wrong on SYN/ACK
+ MP_JOIN */
  MPTCP_MIB_JOINACKRX, /* Received an ACK + MP_JOIN
*/
  MPTCP_MIB_JOINACKMAC, /* HMAC was wrong on ACK +
MP_JOIN */

net/mptcp/mib.h +1 -0
+	MPTCP_MIB_JOINSYNTX,		/* Sending a SYN + MP_JOIN

*/

net/mptcp/mib.h +1 -0
+	MPTCP_MIB_JOINSYNTXFULLYESTAB,	/* Not in fully established

when sending a SYN + MP_JOIN */

net/mptcp/mib.h +1 -0
+	MPTCP_MIB_JOINSYNTXCREATESOCK,	/* Not able to create a

socket when sending a SYN + MP_JOIN */

net/mptcp/mib.h +1 -0
+	MPTCP_MIB_JOINSYNTXBIND,	/* Not able to bind() the

address when sending a SYN + MP_JOIN */

net/mptcp/mib.h +1 -0
+	MPTCP_MIB_JOINSYNTXCONNECT,	/* Not able to connect()

when sending a SYN + MP_JOIN */
  MPTCP_MIB_DSSNOMATCH, /* Received a new mapping
that did not match the previous one */
  MPTCP_MIB_INFINITEMAPTX, /* Sent an infinite mapping
*/
  MPTCP_MIB_INFINITEMAPRX, /* Received an infinite
mapping */

net/mptcp/subflow.c +0 -0
index a21c712350c3..d305c0f53a09 100644
@@ -1577,12 +1577,18 @@ int __mptcp_subflow_connect(struct sock *sk,
 const struct mptcp_addr_info *loc,
  	int ifindex;
  	u8 flags;

net/mptcp/subflow.c +2 -1
-	if (!mptcp_is_fully_established(sk))
+	if (!mptcp_is_fully_established(sk)) {
+		MPTCP_INC_STATS(sock_net(sk),

MPTCP_MIB_JOINSYNTXFULLYESTAB);
  goto err_out;

net/mptcp/subflow.c +1 -0
+	}


  err = mptcp_subflow_create_socket(sk, loc->family, &sf);

net/mptcp/subflow.c +2 -1
-	if (err)
+	if (err) {
+		MPTCP_INC_STATS(sock_net(sk),

MPTCP_MIB_JOINSYNTXCREATESOCK);

net/mptcp/subflow.c +1 -0
+		pr_debug("msk=%p local=%d remote:%d create sock

error: %d\n",

net/mptcp/subflow.c +1 -0
+			 msk, local_id, remote_id, err);

  goto err_out;

net/mptcp/subflow.c +1 -0
+	}


  ssk = sf->sk;
  subflow = mptcp_subflow_ctx(ssk);

net/mptcp/subflow.c +5 -1
@@ -1608,8 +1614,12 @@ int __mptcp_subflow_connect(struct sock *sk,
 const struct mptcp_addr_info *loc,
  #endif
  	ssk->sk_bound_dev_if = ifindex;
  	err = kernel_bind(sf, (struct sockaddr *)&addr, addrlen);
-	if (err)
+	if (err) {
+		MPTCP_INC_STATS(sock_net(sk),
 MPTCP_MIB_JOINSYNTXBIND);
+		pr_debug("msk=%p local=%d remote:%d bind error:
 %d\n",
+			 msk, local_id, remote_id, err);
  		goto failed;
+	}


  mptcp_crypto_key_sha(subflow->remote_key, &remote_token, NULL);
  pr_debug("msk=%p remote_token=%u local_id=%d remote_id=%d", msk,

net/mptcp/subflow.c +4 -1
@@ -1624,8 +1634,14 @@ int __mptcp_subflow_connect(struct sock *sk,
 const struct mptcp_addr_info *loc,
  	sock_hold(ssk);
  	list_add_tail(&subflow->node, &msk->conn_list);
  	err = kernel_connect(sf, (struct sockaddr *)&addr, addrlen,
 O_NONBLOCK);
-	if (err && err != -EINPROGRESS)
+	if (err && err != -EINPROGRESS) {
+		MPTCP_INC_STATS(sock_net(sk),
 MPTCP_MIB_JOINSYNTXCONNECT);
+		pr_debug("msk=%p local=%d remote:%d connect error:
 %d\n",
+			 msk, local_id, remote_id, err);

  goto failed_unlink;

net/mptcp/subflow.c +3 -0
+	}
+
+	MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_JOINSYNTX);


  /* discard the subflow socket */
  mptcp_sock_graft(ssk, sk->sk_socket);

author maintainer
#3 lore raw

Hi Geliang,

Quoted 40 lines · Geliang Tang

Hi Matt,

Quoted 27 lines · On Fri, 2024-07-26 at 19:48 +0200, Matthieu Baerts (NGI0) wrote:

Recently, a few issues have been discovered around the creation of additional subflows. Without these counters, it was difficult to point
out the reason why some subflows were not created as expected.

These counters should have been added earlier, because there is no other
simple ways to extract such information from the kernel, and understand
why subflows have not been created.

While at it, some pr_debug() have been added, just in case the errno needs to be printed.

---
 net/mptcp/mib.c     |  5 +++++ net/mptcp/mib.h     |  5 +++++ net/mptcp/subflow.c | 24 ++++++++++++++++++++----

 3 files changed, 30 insertions(+), 4 deletions(-)
net/mptcp/mib.c +0 -0
index 7884217f33eb..a0b1152c32f1 100644

net/mptcp/mib.c static const struct snmp_mib mptcp_snmp_list[] = { · line 31

Quoted 7 lines
net/mptcp/mib.c +2 -0
@@ -25,6 +25,11 @@ static const struct snmp_mib mptcp_snmp_list[] = {
  	SNMP_MIB_ITEM("MPJoinSynAckHMacFailure",
 MPTCP_MIB_JOINSYNACKMAC),
  	SNMP_MIB_ITEM("MPJoinAckRx", MPTCP_MIB_JOINACKRX),
  	SNMP_MIB_ITEM("MPJoinAckHMacFailure", MPTCP_MIB_JOINACKMAC),
+	SNMP_MIB_ITEM("MPJoinSynTx", MPTCP_MIB_JOINSYNTX),
+	SNMP_MIB_ITEM("MPJoinSynTxFEstabErr",
 MPTCP_MIB_JOINSYNTXFULLYESTAB),

It's better to keep the "Err" postfix to reduce ambiguity:

Quoted 1 line

MPTCP_MIB_JOINSYNTXFULLYESTAB_ERR or MPTCP_MIB_JOINSYNTXFULLYESTABERR.

I agree. I didn't do that because the names were already long enough, they are only used in one place, and we didn't do that for the "HMAC Failure" ones.

Or maybe I reuse a similar name to the ones exposed to the userspace?

MPTCP_MIB_JOINSYNTXFESTABERR
MPTCP_MIB_JOINSYNTXCREATSKERR
MPTCP_MIB_JOINSYNTXBINDERR
MPTCP_MIB_JOINSYNTXCONNECTERR

I can send a v2 with that.

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
author maintainer
#4 lore raw

PATCH 2/2 selftests: mptcp: join: validate MPJ SYN TX MIB counters

In reply to Matthieu Baerts (NGI0)

A few new MIB counters have been added. They are being validated here.

Most of the time, there are no errors, but sometimes, more MPJ SYN are queued compared to the numbers that are received.

Only one test has an error, the one to connect to a broadcast IP address.

---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 63 +++++++++++++++++++++++++
 1 file changed, 63 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_join.sh +63 -0
index fbb0174145ad..c1f1ebd2340c 100755
@@ -1372,6 +1372,66 @@ chk_join_nr()
 	fi
 }
 
+chk_join_tx_nr()
+{
+	local syn_nr=$1
+	local festab=$2
+	local create=$3
+	local bind=$4
+	local connect=$5
+	local count
+
+	print_check "syn TX"
+	count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtMPJoinSynTx")
+	if [ -z "$count" ]; then
+		print_skip
+	elif [ "$count" != "$syn_nr" ]; then
+		fail_test "got $count JOIN[s] syn TX expected $syn_nr"
+	else
+		print_ok
+	fi
+
+	print_check "syn TX Fully Estab Error"
+	count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtMPJoinSynTxFEstabErr")
+	if [ -z "$count" ]; then
+		print_skip
+	elif [ "$count" != "$festab" ]; then
+		fail_test "got $count JOIN[s] syn TX Fully Estab Error expected $festab"
+	else
+		print_ok
+	fi
+
+	print_check "syn TX Create Socket Error"
+	count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtMPJoinSynTxCreatSkErr")
+	if [ -z "$count" ]; then
+		print_skip
+	elif [ "$count" != "$create" ]; then
+		fail_test "got $count JOIN[s] syn TX Create Socket Error expected $create"
+	else
+		print_ok
+	fi
+
+	print_check "syn TX Bind Error"
+	count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtMPJoinSynTxBindErr")
+	if [ -z "$count" ]; then
+		print_skip
+	elif [ "$count" != "$bind" ]; then
+		fail_test "got $count JOIN[s] syn TX Bind Error expected $bind"
+	else
+		print_ok
+	fi
+
+	print_check "syn TX Connect Error"
+	count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtMPJoinSynTxConnectErr")
+	if [ -z "$count" ]; then
+		print_skip
+	elif [ "$count" != "$connect" ]; then
+		fail_test "got $count JOIN[s] syn TX Connect Error expected $connect"
+	else
+		print_ok
+	fi
+}
+
 # a negative value for 'stale_max' means no upper bound:
 # for bidirectional transfer, if one peer sleep for a while
 # - as these tests do - we can have a quite high number of
@@ -1907,6 +1967,7 @@ subflows_error_tests()
 		speed=slow \
 			run_tests $ns1 $ns2 10.0.1.1
 		chk_join_nr 0 0 0
+		chk_join_tx_nr 0 0 0 0 0
 	fi
 
 	# multiple subflows, with subflow creation error
@@ -1919,6 +1980,7 @@ subflows_error_tests()
 		speed=slow \
 			run_tests $ns1 $ns2 10.0.1.1
 		chk_join_nr 1 1 1
+		chk_join_tx_nr 2 0 0 0 0
 	fi
 
 	# multiple subflows, with subflow timeout on MPJ
@@ -2306,6 +2368,7 @@ remove_tests()
 		addr_nr_ns1=-3 speed=10 \
 			run_tests $ns1 $ns2 10.0.1.1
 		chk_join_nr 1 1 1
+		chk_join_tx_nr 2 0 0 0 1
 		chk_add_nr 3 3
 		chk_rm_nr 3 1 invert
 		chk_rst_nr 0 0
Signature · 1 line
2.45.2
#5 lore raw
In reply to Matthieu Baerts (NGI0)

Hi Matthieu,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal: Success! ✅
- KVM Validation: debug: Success! ✅
- KVM Validation: btf (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/10115560325

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/6a77ba3f17f2
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=874150

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-normal

For 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)