[PATCH mptcp-net 2/3] selftests: mptcp: pm: ensure unknown flags are ignored

Matthieu Baerts (NGI0) posted 3 patches 2 months, 1 week ago
[PATCH mptcp-net 2/3] selftests: mptcp: pm: ensure unknown flags are ignored
Posted by Matthieu Baerts (NGI0) 2 months, 1 week ago
This validates the previous commit: the userspace can set unknown flags
-- the 7th bit is currently unused -- without errors, but only the
supported ones are printed in the endpoints dumps.

The 'Fixes' tag here below is the same as the one from the previous
commit: this patch here is not fixing anything wrong in the selftests,
but it validates the previous fix for an issue introduced by this commit
ID.

Fixes: 01cacb00b35c ("mptcp: add netlink-based PM")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 tools/testing/selftests/net/mptcp/pm_netlink.sh |  4 ++++
 tools/testing/selftests/net/mptcp/pm_nl_ctl.c   | 11 +++++++++++
 2 files changed, 15 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh
index ec6a87588191..123d9d7a0278 100755
--- a/tools/testing/selftests/net/mptcp/pm_netlink.sh
+++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh
@@ -192,6 +192,10 @@ check "show_endpoints" \
 flush_endpoint
 check "show_endpoints" "" "flush addrs"
 
+add_endpoint 10.0.1.1 flags unknown
+check "show_endpoints" "$(format_endpoints "1,10.0.1.1")" "ignore unknown flags"
+flush_endpoint
+
 set_limits 9 1 2>/dev/null
 check "get_limits" "${default_limits}" "rcv addrs above hard limit"
 
diff --git a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
index 65b374232ff5..99eecccbf0c8 100644
--- a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
+++ b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
@@ -24,6 +24,8 @@
 #define IPPROTO_MPTCP 262
 #endif
 
+#define MPTCP_PM_ADDR_FLAG_UNKNOWN _BITUL(7)
+
 static void syntax(char *argv[])
 {
 	fprintf(stderr, "%s add|ann|rem|csf|dsf|get|set|del|flush|dump|events|listen|accept [<args>]\n", argv[0]);
@@ -836,6 +838,8 @@ int add_addr(int fd, int pm_family, int argc, char *argv[])
 					flags |= MPTCP_PM_ADDR_FLAG_BACKUP;
 				else if (!strcmp(tok, "fullmesh"))
 					flags |= MPTCP_PM_ADDR_FLAG_FULLMESH;
+				else if (!strcmp(tok, "unknown"))
+					flags |= MPTCP_PM_ADDR_FLAG_UNKNOWN;
 				else
 					error(1, errno,
 					      "unknown flag %s", argv[arg]);
@@ -1048,6 +1052,13 @@ static void print_addr(struct rtattr *attrs, int len)
 					printf(",");
 			}
 
+			if (flags & MPTCP_PM_ADDR_FLAG_UNKNOWN) {
+				printf("unknown");
+				flags &= ~MPTCP_PM_ADDR_FLAG_UNKNOWN;
+				if (flags)
+					printf(",");
+			}
+
 			/* bump unknown flags, if any */
 			if (flags)
 				printf("0x%x", flags);

-- 
2.51.0
Re: [PATCH mptcp-net 2/3] selftests: mptcp: pm: ensure unknown flags are ignored
Posted by Mat Martineau 2 months, 1 week ago
On Wed, 26 Nov 2025, Matthieu Baerts (NGI0) wrote:

> This validates the previous commit: the userspace can set unknown flags
> -- the 7th bit is currently unused -- without errors, but only the
> supported ones are printed in the endpoints dumps.
>
> The 'Fixes' tag here below is the same as the one from the previous
> commit: this patch here is not fixing anything wrong in the selftests,
> but it validates the previous fix for an issue introduced by this commit
> ID.
>
> Fixes: 01cacb00b35c ("mptcp: add netlink-based PM")
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> ---
> tools/testing/selftests/net/mptcp/pm_netlink.sh |  4 ++++
> tools/testing/selftests/net/mptcp/pm_nl_ctl.c   | 11 +++++++++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh
> index ec6a87588191..123d9d7a0278 100755
> --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh
> +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh
> @@ -192,6 +192,10 @@ check "show_endpoints" \
> flush_endpoint
> check "show_endpoints" "" "flush addrs"
>
> +add_endpoint 10.0.1.1 flags unknown
> +check "show_endpoints" "$(format_endpoints "1,10.0.1.1")" "ignore unknown flags"
> +flush_endpoint
> +
> set_limits 9 1 2>/dev/null
> check "get_limits" "${default_limits}" "rcv addrs above hard limit"
>
> diff --git a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
> index 65b374232ff5..99eecccbf0c8 100644
> --- a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
> +++ b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
> @@ -24,6 +24,8 @@
> #define IPPROTO_MPTCP 262
> #endif
>
> +#define MPTCP_PM_ADDR_FLAG_UNKNOWN _BITUL(7)

Given the u8->u32 change in patch 3, I can see why this needs to be 7 for 
this patch to be meaningful for -net.

Can you add a patch 4 that updates this to _BITUL(31) to match up with 
the internal flag representation change?

Thanks,
Mat

> +
> static void syntax(char *argv[])
> {
> 	fprintf(stderr, "%s add|ann|rem|csf|dsf|get|set|del|flush|dump|events|listen|accept [<args>]\n", argv[0]);
> @@ -836,6 +838,8 @@ int add_addr(int fd, int pm_family, int argc, char *argv[])
> 					flags |= MPTCP_PM_ADDR_FLAG_BACKUP;
> 				else if (!strcmp(tok, "fullmesh"))
> 					flags |= MPTCP_PM_ADDR_FLAG_FULLMESH;
> +				else if (!strcmp(tok, "unknown"))
> +					flags |= MPTCP_PM_ADDR_FLAG_UNKNOWN;
> 				else
> 					error(1, errno,
> 					      "unknown flag %s", argv[arg]);
> @@ -1048,6 +1052,13 @@ static void print_addr(struct rtattr *attrs, int len)
> 					printf(",");
> 			}
>
> +			if (flags & MPTCP_PM_ADDR_FLAG_UNKNOWN) {
> +				printf("unknown");
> +				flags &= ~MPTCP_PM_ADDR_FLAG_UNKNOWN;
> +				if (flags)
> +					printf(",");
> +			}
> +
> 			/* bump unknown flags, if any */
> 			if (flags)
> 				printf("0x%x", flags);
>
> -- 
> 2.51.0
>
>
>
Re: [PATCH mptcp-net 2/3] selftests: mptcp: pm: ensure unknown flags are ignored
Posted by Matthieu Baerts 2 months, 1 week ago
Hi Mat,

Thank you for the review!

On 27/11/2025 00:57, Mat Martineau wrote:
> On Wed, 26 Nov 2025, Matthieu Baerts (NGI0) wrote:
> 
>> This validates the previous commit: the userspace can set unknown flags
>> -- the 7th bit is currently unused -- without errors, but only the
>> supported ones are printed in the endpoints dumps.
>>
>> The 'Fixes' tag here below is the same as the one from the previous
>> commit: this patch here is not fixing anything wrong in the selftests,
>> but it validates the previous fix for an issue introduced by this commit
>> ID.

(...)

>> diff --git a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c b/tools/
>> testing/selftests/net/mptcp/pm_nl_ctl.c
>> index 65b374232ff5..99eecccbf0c8 100644
>> --- a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
>> +++ b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
>> @@ -24,6 +24,8 @@
>> #define IPPROTO_MPTCP 262
>> #endif
>>
>> +#define MPTCP_PM_ADDR_FLAG_UNKNOWN _BITUL(7)
> 
> Given the u8->u32 change in patch 3, I can see why this needs to be 7
> for this patch to be meaningful for -net.
> 
> Can you add a patch 4 that updates this to _BITUL(31) to match up with
> the internal flag representation change?

It makes sense, and I was going to do that, but now I'm hesitating: some
CIs will use the latest version of the selftests on older kernels. If
they do that, the test will be less interesting on older kernels.

Maybe that's not an issue? I could move it to 31, or set bits from 6 to
31. Or stay on 7 for the time being?

(I don't think we would add new flags, but if we do, we can also move
this flag to the end later on?)

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.