mbox series

[mptcp-next,0/5] mptcp: add SOL_MPTCP getsockopt support

Message ID 20210811131523.6339-1-fw@strlen.de (mailing list archive)
Headers show
Series mptcp: add SOL_MPTCP getsockopt support | expand

Message

Florian Westphal Aug. 11, 2021, 1:15 p.m. UTC
This adds the MPTCP_INFO, MPTCP_TCPINFO and MPTCP_SUBFLOW_ADDRS
mptcp getsockopt optnames.

MPTCP_INFO exposes the mptcp_info struct as an alternative to the
existing netlink diag interface.

MPTCP_TCPINFO exposes the tcp_info struct.
Unlike SOL_TCP/TCP_INFO, this returns one struct for each active
subflow.

MPTCP_SUBFLOW_ADDRS allows userspace to discover the ip addresses/ports
used by the local and remote endpoints, one for each active tcp subflow.

MPTCP_TCPINFO and MPTCP_SUBFLOW_ADDRS share the same meta-header that
needs to be pre-filled by userspace with the size of the data structures
it expects.  This is done to allow extension of the involved structs
later on, without breaking backwards compatibility.

The meta-structure can also be used to discover the required space
to obtain all information, as kernel will fill in the number of
active subflows even if there is not enough room for the requested info
itself.

More information is available in the individual patches.
Last patch adds test cases for the three optnames.

Florian Westphal (5):
  mptcp: add new mptcp_fill_diag helper
  mptcp: add MPTCP_INFO getsockopt
  mptcp: add MPTCP_TCPINFO getsockopt support
  mptcp: add MPTCP_SUBFLOW_ADDRS getsockopt support
  selftests: mptcp: add mptcp getsockopt test cases

 include/linux/socket.h                        |   1 +
 include/net/mptcp.h                           |   4 +
 include/uapi/linux/mptcp.h                    |  29 +
 net/mptcp/mptcp_diag.c                        |  26 +-
 net/mptcp/sockopt.c                           | 258 +++++++++
 tools/testing/selftests/net/mptcp/Makefile    |   4 +-
 .../selftests/net/mptcp/mptcp_sockopt.c       | 545 ++++++++++++++++++
 .../selftests/net/mptcp/mptcp_sockopt.sh      |  31 +-
 8 files changed, 869 insertions(+), 29 deletions(-)
 create mode 100644 tools/testing/selftests/net/mptcp/mptcp_sockopt.c

Comments

Paolo Abeni Aug. 12, 2021, 10:58 a.m. UTC | #1
Hello Florian,
On Wed, 2021-08-11 at 15:15 +0200, Florian Westphal wrote:
> This adds the MPTCP_INFO, MPTCP_TCPINFO and MPTCP_SUBFLOW_ADDRS
> mptcp getsockopt optnames.
> 
> MPTCP_INFO exposes the mptcp_info struct as an alternative to the
> existing netlink diag interface.
> 
> MPTCP_TCPINFO exposes the tcp_info struct.
> Unlike SOL_TCP/TCP_INFO, this returns one struct for each active
> subflow.
> 
> MPTCP_SUBFLOW_ADDRS allows userspace to discover the ip addresses/ports
> used by the local and remote endpoints, one for each active tcp subflow.
> 
> MPTCP_TCPINFO and MPTCP_SUBFLOW_ADDRS share the same meta-header that
> needs to be pre-filled by userspace with the size of the data structures
> it expects.  This is done to allow extension of the involved structs
> later on, without breaking backwards compatibility.
> 
> The meta-structure can also be used to discover the required space
> to obtain all information, as kernel will fill in the number of
> active subflows even if there is not enough room for the requested info
> itself.
> 
> More information is available in the individual patches.
> Last patch adds test cases for the three optnames.
> 
> Florian Westphal (5):
>   mptcp: add new mptcp_fill_diag helper
>   mptcp: add MPTCP_INFO getsockopt
>   mptcp: add MPTCP_TCPINFO getsockopt support
>   mptcp: add MPTCP_SUBFLOW_ADDRS getsockopt support
>   selftests: mptcp: add mptcp getsockopt test cases
> 
>  include/linux/socket.h                        |   1 +
>  include/net/mptcp.h                           |   4 +
>  include/uapi/linux/mptcp.h                    |  29 +
>  net/mptcp/mptcp_diag.c                        |  26 +-
>  net/mptcp/sockopt.c                           | 258 +++++++++
>  tools/testing/selftests/net/mptcp/Makefile    |   4 +-
>  .../selftests/net/mptcp/mptcp_sockopt.c       | 545 ++++++++++++++++++
>  .../selftests/net/mptcp/mptcp_sockopt.sh      |  31 +-
>  8 files changed, 869 insertions(+), 29 deletions(-)
>  create mode 100644 tools/testing/selftests/net/mptcp/mptcp_sockopt.c

The patches LGTM! I have just a couple of minor curiosity. 

In some helper the argument that carries the option length from user
space is named '_u_optlen', any special reason for that? Encoding the
argument attribute into the user name looks really win32 style from the
early 2000, afaik ;))) [no offense intended!!!]

I don't see how the mptcp_subflow_addrs is going to change/increase the
size with time... do you have some possible ideas/guess?

Anyhow,

Acked-by: Paolo Abeni <pabeni@redhat.com>
Florian Westphal Aug. 12, 2021, 11:07 a.m. UTC | #2
Paolo Abeni <pabeni@redhat.com> wrote:
> >  8 files changed, 869 insertions(+), 29 deletions(-)
> >  create mode 100644 tools/testing/selftests/net/mptcp/mptcp_sockopt.c
> 
> The patches LGTM! I have just a couple of minor curiosity. 
> 
> In some helper the argument that carries the option length from user
> space is named '_u_optlen', any special reason for that? Encoding the
> argument attribute into the user name looks really win32 style from the
> early 2000, afaik ;))) [no offense intended!!!]

Ok, I'll rename it to 'int __user *optlen' in v2.

> I don't see how the mptcp_subflow_addrs is going to change/increase the
> size with time... do you have some possible ideas/guess?

No idea. IPv8?  I added struct sockaddr_storage into the union so it will
hopefully be enough but who knows, this API might well live on for decades
and I'd rather have a small back door that allows to increase this if
needed.