Skip to content

Commit e53123d

Browse files
committed
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: c9b95a1 ("mptcp: support IPV6_V6ONLY setsockopt") Closes: #550 Reviewed-by: Mat Martineau <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
1 parent 4433885 commit e53123d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

net/mptcp/sockopt.c

+16
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,20 @@ static int mptcp_getsockopt_v4(struct mptcp_sock *msk, int optname,
14301430
return -EOPNOTSUPP;
14311431
}
14321432

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+
14331447
static int mptcp_getsockopt_sol_mptcp(struct mptcp_sock *msk, int optname,
14341448
char __user *optval, int __user *optlen)
14351449
{
@@ -1469,6 +1483,8 @@ int mptcp_getsockopt(struct sock *sk, int level, int optname,
14691483

14701484
if (level == SOL_IP)
14711485
return mptcp_getsockopt_v4(msk, optname, optval, option);
1486+
if (level == SOL_IPV6)
1487+
return mptcp_getsockopt_v6(msk, optname, optval, option);
14721488
if (level == SOL_TCP)
14731489
return mptcp_getsockopt_sol_tcp(msk, optname, optval, option);
14741490
if (level == SOL_MPTCP)

0 commit comments

Comments
 (0)