Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mptcp: sockopt: fix getting IPV6_V6ONLY

When adding a socket option support in MPTCP, both the get and set parts
are supposed to be implemented.

IPV6_V6ONLY support for the setsockopt part has been added a while ago,
but it looks like the get part got forgotten. It should have been
present as a way to verify a setting has been set as expected, and not
to act differently from TCP or any other socket types.

Not supporting this getsockopt(IPV6_V6ONLY) blocks some apps which want
to check the default value, before doing extra actions. On Linux, the
default value is 0, but this can be changed with the net.ipv6.bindv6only
sysctl knob. On Windows, it is set to 1 by default. So supporting the
get part, like for all other socket options, is important.

Everything was in place to expose it, just the last step was missing.
Only new code is added to cover this specific getsockopt(), that seems
safe.

Fixes: c9b95a135987 ("mptcp: support IPV6_V6ONLY setsockopt")
Cc: stable@vger.kernel.org
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/550
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250314-net-mptcp-fix-data-stream-corr-sockopt-v1-2-122dbb249db3@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Matthieu Baerts (NGI0) and committed by
Paolo Abeni
8c396337 ddf9c6d9

+16
+16
net/mptcp/sockopt.c
··· 1430 1430 return -EOPNOTSUPP; 1431 1431 } 1432 1432 1433 + static int mptcp_getsockopt_v6(struct mptcp_sock *msk, int optname, 1434 + char __user *optval, int __user *optlen) 1435 + { 1436 + struct sock *sk = (void *)msk; 1437 + 1438 + switch (optname) { 1439 + case IPV6_V6ONLY: 1440 + return mptcp_put_int_option(msk, optval, optlen, 1441 + sk->sk_ipv6only); 1442 + } 1443 + 1444 + return -EOPNOTSUPP; 1445 + } 1446 + 1433 1447 static int mptcp_getsockopt_sol_mptcp(struct mptcp_sock *msk, int optname, 1434 1448 char __user *optval, int __user *optlen) 1435 1449 { ··· 1483 1469 1484 1470 if (level == SOL_IP) 1485 1471 return mptcp_getsockopt_v4(msk, optname, optval, option); 1472 + if (level == SOL_IPV6) 1473 + return mptcp_getsockopt_v6(msk, optname, optval, option); 1486 1474 if (level == SOL_TCP) 1487 1475 return mptcp_getsockopt_sol_tcp(msk, optname, optval, option); 1488 1476 if (level == SOL_MPTCP)