All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH mptcp-next 0/5] mptcp: add SOL_MPTCP getsockopt support
@ 2021-08-11 13:15 Florian Westphal
  2021-08-11 13:15 ` [PATCH mptcp-next 1/5] mptcp: add new mptcp_fill_diag helper Florian Westphal
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: Florian Westphal @ 2021-08-11 13:15 UTC (permalink / raw)
  To: mptcp; +Cc: Florian Westphal

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

-- 
2.31.1


^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: [PATCH mptcp-next 3/5] mptcp: add MPTCP_TCPINFO getsockopt support
@ 2021-08-11 18:26 kernel test robot
  0 siblings, 0 replies; 18+ messages in thread
From: kernel test robot @ 2021-08-11 18:26 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 3942 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210811131523.6339-4-fw@strlen.de>
References: <20210811131523.6339-4-fw@strlen.de>
TO: Florian Westphal <fw@strlen.de>
TO: mptcp(a)lists.linux.dev
CC: Florian Westphal <fw@strlen.de>

Hi Florian,

I love your patch! Perhaps something to improve:

[auto build test WARNING on kselftest/next]
[also build test WARNING on mptcp/export linus/master v5.14-rc5 next-20210811]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Florian-Westphal/mptcp-add-SOL_MPTCP-getsockopt-support/20210811-212510
base:   https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git next
:::::: branch date: 5 hours ago
:::::: commit date: 5 hours ago
config: i386-randconfig-m021-20210811 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
net/mptcp/sockopt.c:759 mptcp_get_subflow_data() warn: check for integer overflow 'len'

vim +/len +759 net/mptcp/sockopt.c

d6a9cf7d54d73f1 Florian Westphal 2021-08-11  728  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  729  static int mptcp_get_subflow_data(struct mptcp_subflow_data *sfd,
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  730  				  char __user *optval, int __user *_u_optlen)
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  731  {
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  732  #define MIN_INFO_OPTLEN_SIZE	16
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  733  	int len, copylen;
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  734  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  735  	if (get_user(len, _u_optlen))
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  736  		return -EFAULT;
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  737  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  738  	if (len <= MIN_INFO_OPTLEN_SIZE)
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  739  		return -EINVAL;
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  740  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  741  	memset(sfd, 0, sizeof(*sfd));
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  742  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  743  	copylen = min_t(unsigned int, len, sizeof(*sfd));
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  744  	if (copy_from_user(sfd, optval, copylen))
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  745  		return -EFAULT;
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  746  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  747  	/* size_subflow_data is u32, but len is signed */
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  748  	if (sfd->size_subflow_data > INT_MAX ||
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  749  	    sfd->size_user > INT_MAX)
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  750  		return -EINVAL;
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  751  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  752  	if (sfd->size_subflow_data < MIN_INFO_OPTLEN_SIZE ||
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  753  	    sfd->size_subflow_data > len)
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  754  		return -EINVAL;
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  755  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  756  	if (sfd->num_subflows || sfd->size_kernel)
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  757  		return -EINVAL;
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  758  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11 @759  	return len - sfd->size_subflow_data;
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  760  }
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  761  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 33490 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2021-08-12 18:42 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-11 13:15 [PATCH mptcp-next 0/5] mptcp: add SOL_MPTCP getsockopt support Florian Westphal
2021-08-11 13:15 ` [PATCH mptcp-next 1/5] mptcp: add new mptcp_fill_diag helper Florian Westphal
2021-08-11 13:15 ` [PATCH mptcp-next 2/5] mptcp: add MPTCP_INFO getsockopt Florian Westphal
2021-08-12 16:46   ` Mat Martineau
2021-08-11 13:15 ` [PATCH mptcp-next 3/5] mptcp: add MPTCP_TCPINFO getsockopt support Florian Westphal
2021-08-12 17:03   ` Mat Martineau
2021-08-12 18:41     ` Florian Westphal
2021-08-11 13:15 ` [PATCH mptcp-next 4/5] mptcp: add MPTCP_SUBFLOW_ADDRS " Florian Westphal
2021-08-11 21:18   ` kernel test robot
2021-08-11 21:18     ` kernel test robot
2021-08-12  3:02   ` kernel test robot
2021-08-12  3:02     ` kernel test robot
2021-08-11 13:15 ` [PATCH mptcp-next 5/5] selftests: mptcp: add mptcp getsockopt test cases Florian Westphal
2021-08-12 11:14   ` Paolo Abeni
2021-08-12 11:28     ` Florian Westphal
2021-08-12 10:58 ` [PATCH mptcp-next 0/5] mptcp: add SOL_MPTCP getsockopt support Paolo Abeni
2021-08-12 11:07   ` Florian Westphal
  -- strict thread matches above, loose matches on Subject: below --
2021-08-11 18:26 [PATCH mptcp-next 3/5] mptcp: add MPTCP_TCPINFO " kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.