selftests: mptcp: add mptcp getsockopt test cases

Add a test program that retrieves the three info types:
1. mptcp meta information
2. tcp info for subflow
3. subflow endpoint addresses

For all three rudimentary checks are added.

1. Meta information checks that the logical mptcp
   sequence numbers advance as expected, based on the bytes read
   (init seq + bytes_received/sent) and the connection state
   (after close, we should exect 1 extra byte due to FIN).

2. TCP info checks the number of bytes sent/received vs.
   sums of read/write syscall return values.

3. Subflow endpoint addresses are checked vs. getsockname/getpeername

Tests for forward compatibility (0-initialisation of output-only
fields in mptcp_subflow_data structure) are added as well.

Co-developed-by: Matthieu Baerts <>
Signed-off-by: Matthieu Baerts <>
Signed-off-by: Florian Westphal <>
Signed-off-by: Mat Martineau <>
Signed-off-by: David S. Miller <>
4 files changed