diff mbox series

[mptcp-net,2/2] selftests: mptcp: userspace PM support for MP_PRIO signals

Message ID 20220622175547.289717-3-kishen.maloor@intel.com (mailing list archive)
State Superseded, archived
Headers show
Series mptcp: support MP_PRIO signals with userspace PMs | expand

Checks

Context Check Description
matttbe/build success Build and static analysis OK
matttbe/checkpatch warning total: 0 errors, 1 warnings, 0 checks, 84 lines checked
matttbe/KVM_Validation__normal success Success! ✅
matttbe/KVM_Validation__debug warning Unstable: 3 failed test(s): packetdrill_add_addr selftest_diag selftest_mptcp_join

Commit Message

Kishen Maloor June 22, 2022, 5:55 p.m. UTC
This change updates the testing sample (pm_nl_ctl) to take a
connection token as an optional param for the MPTCP_PM_CMD_SET_FLAGS
command. This is used to test the userspace PM code path for issuing
MP_PRIO signals over a connection for the specified address ID.

E.g. ./pm_nl_ctl set id 0 flags backup token 823274047

userspace_pm.sh has new selftests which exercise this command.

Fixes: 259a834fadda ("selftests: mptcp: functional tests for the userspace PM type")
Signed-off-by: Kishen Maloor <kishen.maloor@intel.com>
---
 tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 19 ++++++++++--
 .../selftests/net/mptcp/userspace_pm.sh       | 31 +++++++++++++++++++
 2 files changed, 48 insertions(+), 2 deletions(-)

Comments

MPTCP CI June 22, 2022, 8:03 p.m. UTC | #1
Hi Kishen,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal:
  - Success! ✅:
  - Task: https://cirrus-ci.com/task/5802668730875904
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/5802668730875904/summary/summary.txt

- KVM Validation: debug:
  - Unstable: 3 failed test(s): packetdrill_add_addr selftest_diag selftest_mptcp_join 
Mat Martineau June 22, 2022, 10:48 p.m. UTC | #2
On Wed, 22 Jun 2022, Kishen Maloor wrote:

> This change updates the testing sample (pm_nl_ctl) to take a
> connection token as an optional param for the MPTCP_PM_CMD_SET_FLAGS
> command. This is used to test the userspace PM code path for issuing
> MP_PRIO signals over a connection for the specified address ID.
>
> E.g. ./pm_nl_ctl set id 0 flags backup token 823274047
>
> userspace_pm.sh has new selftests which exercise this command.
>
> Fixes: 259a834fadda ("selftests: mptcp: functional tests for the userspace PM type")
> Signed-off-by: Kishen Maloor <kishen.maloor@intel.com>
> ---
> tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 19 ++++++++++--
> .../selftests/net/mptcp/userspace_pm.sh       | 31 +++++++++++++++++++
> 2 files changed, 48 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
> index 4dd87bb9ee91..0512d64b1d11 100644
> --- a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
> +++ b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
> @@ -39,7 +39,7 @@ static void syntax(char *argv[])
> 	fprintf(stderr, "\tdsf lip <local-ip> lport <local-port> rip <remote-ip> rport <remote-port> token <token>\n");
> 	fprintf(stderr, "\tdel <id> [<ip>]\n");
> 	fprintf(stderr, "\tget <id>\n");
> -	fprintf(stderr, "\tset [<ip>] [id <nr>] flags [no]backup|[no]fullmesh [port <nr>]\n");
> +	fprintf(stderr, "\tset [<ip>] [id <nr>] flags [no]backup|[no]fullmesh [port <nr>] [token <token>]\n");
> 	fprintf(stderr, "\tflush\n");
> 	fprintf(stderr, "\tdump\n");
> 	fprintf(stderr, "\tlimits [<rcv addr max> <subflow max>]\n");
> @@ -1279,6 +1279,7 @@ int set_flags(int fd, int pm_family, int argc, char *argv[])
> 	struct rtattr *rta, *nest;
> 	struct nlmsghdr *nh;
> 	u_int32_t flags = 0;
> +	u_int32_t token = 0;
> 	u_int16_t family;
> 	int nest_start;
> 	int use_id = 0;
> @@ -1339,7 +1340,13 @@ int set_flags(int fd, int pm_family, int argc, char *argv[])
> 		error(1, 0, " missing flags keyword");
>
> 	for (; arg < argc; arg++) {
> -		if (!strcmp(argv[arg], "flags")) {
> +		if (!strcmp(argv[arg], "token")) {
> +			if (++arg >= argc)
> +				error(1, 0, " missing token value");
> +
> +			/* token */
> +			token = atoi(argv[arg]);
> +		} else if (!strcmp(argv[arg], "flags")) {
> 			char *tok, *str;
>
> 			/* flags */
> @@ -1384,6 +1391,14 @@ int set_flags(int fd, int pm_family, int argc, char *argv[])
> 	}
> 	nest->rta_len = off - nest_start;
>
> +	if (token) {
> +		rta = (void *)(data + off);
> +		rta->rta_type = MPTCP_PM_ATTR_TOKEN;
> +		rta->rta_len = RTA_LENGTH(4);
> +		memcpy(RTA_DATA(rta), &token, 4);
> +		off += NLMSG_ALIGN(rta->rta_len);
> +	}
> +
> 	do_nl_req(fd, nh, off, 0);
> 	return 0;
> }
> diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh
> index d586bc5ffe01..387f5774d541 100755
> --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh
> +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh
> @@ -776,10 +776,41 @@ test_subflows()
> 	rm -f "$evts"
> }
>
> +test_prio()
> +{
> +	local count
> +
> +	# Send MP_PRIO signal from client to server machine
> +	ip netns exec "$ns2" ./pm_nl_ctl set id 0 flags backup token "$client4_token"

This test did pass for me with a debug kernel in a desktop VM.

Considering the occasional failures we have when running other tests on 
debug kernels in CI, and the delays inserted elsewhere in this script, I 
think there should be a "sleep 0.5" here to make sure the MIBs have time 
to update.

- Mat


> +
> +	# Check TX
> +	stdbuf -o0 -e0 printf "MP_PRIO TX                                                 \t"
> +	count=$(ip netns exec "$ns2" nstat -as | grep MPTcpExtMPPrioTx | awk '{print $2}')
> +	[ -z "$count" ] && count=0
> +	if [ $count != 1 ]; then
> +		stdbuf -o0 -e0 printf "[FAIL]\n"
> +		exit 1
> +	else
> +		stdbuf -o0 -e0 printf "[OK]\n"
> +	fi
> +
> +	# Check RX
> +	stdbuf -o0 -e0 printf "MP_PRIO RX                                                 \t"
> +	count=$(ip netns exec "$ns1" nstat -as | grep MPTcpExtMPPrioRx | awk '{print $2}')
> +	[ -z "$count" ] && count=0
> +	if [ $count != 1 ]; then
> +		stdbuf -o0 -e0 printf "[FAIL]\n"
> +		exit 1
> +	else
> +		stdbuf -o0 -e0 printf "[OK]\n"
> +	fi
> +}
> +
> make_connection
> make_connection "v6"
> test_announce
> test_remove
> test_subflows
> +test_prio
>
> exit 0
> -- 
> 2.31.1
>
>
>

--
Mat Martineau
Intel
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
index 4dd87bb9ee91..0512d64b1d11 100644
--- a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
+++ b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
@@ -39,7 +39,7 @@  static void syntax(char *argv[])
 	fprintf(stderr, "\tdsf lip <local-ip> lport <local-port> rip <remote-ip> rport <remote-port> token <token>\n");
 	fprintf(stderr, "\tdel <id> [<ip>]\n");
 	fprintf(stderr, "\tget <id>\n");
-	fprintf(stderr, "\tset [<ip>] [id <nr>] flags [no]backup|[no]fullmesh [port <nr>]\n");
+	fprintf(stderr, "\tset [<ip>] [id <nr>] flags [no]backup|[no]fullmesh [port <nr>] [token <token>]\n");
 	fprintf(stderr, "\tflush\n");
 	fprintf(stderr, "\tdump\n");
 	fprintf(stderr, "\tlimits [<rcv addr max> <subflow max>]\n");
@@ -1279,6 +1279,7 @@  int set_flags(int fd, int pm_family, int argc, char *argv[])
 	struct rtattr *rta, *nest;
 	struct nlmsghdr *nh;
 	u_int32_t flags = 0;
+	u_int32_t token = 0;
 	u_int16_t family;
 	int nest_start;
 	int use_id = 0;
@@ -1339,7 +1340,13 @@  int set_flags(int fd, int pm_family, int argc, char *argv[])
 		error(1, 0, " missing flags keyword");
 
 	for (; arg < argc; arg++) {
-		if (!strcmp(argv[arg], "flags")) {
+		if (!strcmp(argv[arg], "token")) {
+			if (++arg >= argc)
+				error(1, 0, " missing token value");
+
+			/* token */
+			token = atoi(argv[arg]);
+		} else if (!strcmp(argv[arg], "flags")) {
 			char *tok, *str;
 
 			/* flags */
@@ -1384,6 +1391,14 @@  int set_flags(int fd, int pm_family, int argc, char *argv[])
 	}
 	nest->rta_len = off - nest_start;
 
+	if (token) {
+		rta = (void *)(data + off);
+		rta->rta_type = MPTCP_PM_ATTR_TOKEN;
+		rta->rta_len = RTA_LENGTH(4);
+		memcpy(RTA_DATA(rta), &token, 4);
+		off += NLMSG_ALIGN(rta->rta_len);
+	}
+
 	do_nl_req(fd, nh, off, 0);
 	return 0;
 }
diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh
index d586bc5ffe01..387f5774d541 100755
--- a/tools/testing/selftests/net/mptcp/userspace_pm.sh
+++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh
@@ -776,10 +776,41 @@  test_subflows()
 	rm -f "$evts"
 }
 
+test_prio()
+{
+	local count
+
+	# Send MP_PRIO signal from client to server machine
+	ip netns exec "$ns2" ./pm_nl_ctl set id 0 flags backup token "$client4_token"
+
+	# Check TX
+	stdbuf -o0 -e0 printf "MP_PRIO TX                                                 \t"
+	count=$(ip netns exec "$ns2" nstat -as | grep MPTcpExtMPPrioTx | awk '{print $2}')
+	[ -z "$count" ] && count=0
+	if [ $count != 1 ]; then
+		stdbuf -o0 -e0 printf "[FAIL]\n"
+		exit 1
+	else
+		stdbuf -o0 -e0 printf "[OK]\n"
+	fi
+
+	# Check RX
+	stdbuf -o0 -e0 printf "MP_PRIO RX                                                 \t"
+	count=$(ip netns exec "$ns1" nstat -as | grep MPTcpExtMPPrioRx | awk '{print $2}')
+	[ -z "$count" ] && count=0
+	if [ $count != 1 ]; then
+		stdbuf -o0 -e0 printf "[FAIL]\n"
+		exit 1
+	else
+		stdbuf -o0 -e0 printf "[OK]\n"
+	fi
+}
+
 make_connection
 make_connection "v6"
 test_announce
 test_remove
 test_subflows
+test_prio
 
 exit 0