[PATCH mptcp-net v3 32/32] Squash to "selftests: mptcp: add MPTCP_FULL_INFO testcase"

Matthieu Baerts posted 32 patches 2 years, 8 months ago
Maintainers: Matthieu Baerts <matthieu.baerts@tessares.net>, Mat Martineau <martineau@kernel.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Shuah Khan <shuah@kernel.org>, Davide Caratti <dcaratti@redhat.com>, Christoph Paasch <cpaasch@apple.com>, Florian Westphal <fw@strlen.de>, Dmytro Shytyi <dmytro@shytyi.net>, Menglong Dong <imagedong@tencent.com>, Geliang Tang <geliang.tang@suse.com>, Kishen Maloor <kishen.maloor@intel.com>
[PATCH mptcp-net v3 32/32] Squash to "selftests: mptcp: add MPTCP_FULL_INFO testcase"
Posted by Matthieu Baerts 2 years, 8 months ago
Relax the expected returned sizes from a getsockopt(MPTCP_FULL_INFO):
the sizes should be positive and the user one should be the min between
the one given by the userspace and the one from the kernelspace.

By doing that, we support new fields added on the userspace or the
kernelspace sides.

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
v3:
  - new patch (the mentioned patch has been sent and applied while the
    v2 was still in review)
---
 tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
index de897f77e174..5994a078a65d 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
@@ -519,10 +519,12 @@ static void do_getsockopt_mptcp_full_info(struct so_state *s, int fd)
 	}
 
 	assert(olen <= data_size);
-	assert(mfi.size_tcpinfo_user == mfi.size_tcpinfo_kernel);
-	assert(mfi.size_tcpinfo_user == sizeof(struct tcp_info));
-	assert(mfi.size_sfinfo_user == mfi.size_sfinfo_kernel);
-	assert(mfi.size_sfinfo_user == sizeof(struct mptcp_subflow_info));
+	assert(mfi.size_tcpinfo_kernel > 0);
+	assert(mfi.size_tcpinfo_user ==
+	       MIN(mfi.size_tcpinfo_kernel, sizeof(struct tcp_info)));
+	assert(mfi.size_sfinfo_kernel > 0);
+	assert(mfi.size_sfinfo_user ==
+	       MIN(mfi.size_sfinfo_kernel, sizeof(struct mptcp_subflow_info)));
 	assert(mfi.num_subflows == 1);
 
 	/* Tolerate future extension to mptcp_info struct and running newer

-- 
2.39.2