Skip to content

Commit 83f0c10

Browse files
Florian Westphaldavem330
authored andcommitted
net: use mptcp setsockopt function for SOL_SOCKET on mptcp sockets
setsockopt(mptcp_fd, SOL_SOCKET, ...)... appears to work (returns 0), but it has no effect -- this is because the MPTCP layer never has a chance to copy the settings to the subflow socket. Skip the generic handling for the mptcp case and instead call the mptcp specific handler instead for SOL_SOCKET too. Next patch adds more specific handling for SOL_SOCKET to mptcp. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f551e2f commit 83f0c10

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎net/mptcp/protocol.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,9 @@ static int mptcp_setsockopt(struct sock *sk, int level, int optname,
16091609

16101610
pr_debug("msk=%p", msk);
16111611

1612+
if (level == SOL_SOCKET)
1613+
return sock_setsockopt(sk->sk_socket, level, optname, optval, optlen);
1614+
16121615
/* @@ the meaning of setsockopt() when the socket is connected and
16131616
* there are multiple subflows is not yet defined. It is up to the
16141617
* MPTCP-level socket to configure the subflows until the subflow

‎net/socket.c‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2080,6 +2080,17 @@ SYSCALL_DEFINE4(recv, int, fd, void __user *, ubuf, size_t, size,
20802080
return __sys_recvfrom(fd, ubuf, size, flags, NULL, NULL);
20812081
}
20822082

2083+
static bool sock_use_custom_sol_socket(const struct socket *sock)
2084+
{
2085+
const struct sock *sk = sock->sk;
2086+
2087+
/* Use sock->ops->setsockopt() for MPTCP */
2088+
return IS_ENABLED(CONFIG_MPTCP) &&
2089+
sk->sk_protocol == IPPROTO_MPTCP &&
2090+
sk->sk_type == SOCK_STREAM &&
2091+
(sk->sk_family == AF_INET || sk->sk_family == AF_INET6);
2092+
}
2093+
20832094
/*
20842095
* Set a socket option. Because we don't know the option lengths we have
20852096
* to pass the user mode parameter for the protocols to sort out.
@@ -2118,7 +2129,7 @@ static int __sys_setsockopt(int fd, int level, int optname,
21182129
optval = (char __user __force *)kernel_optval;
21192130
}
21202131

2121-
if (level == SOL_SOCKET)
2132+
if (level == SOL_SOCKET && !sock_use_custom_sol_socket(sock))
21222133
err =
21232134
sock_setsockopt(sock, level, optname, optval,
21242135
optlen);

0 commit comments

Comments
 (0)