Skip to content

Commit

Permalink
mptcp: sockopt: make 'tcp_fastopen_connect' generic
Browse files Browse the repository at this point in the history
There are other socket options that need to act only on the first
subflow, e.g. all TCP_FASTOPEN* socket options.

This is similar to the getsockopt version.

In the next commit, this new mptcp_setsockopt_first_sf_only() helper is
used by other another option.

Reviewed-by: Mat Martineau <[email protected]>
Signed-off-by: Matthieu Baerts <[email protected]>
Signed-off-by: Mat Martineau <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
  • Loading branch information
matttbe authored and Paolo Abeni committed Oct 25, 2022
1 parent 818a260 commit d3d4290
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions net/mptcp/sockopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,17 +769,17 @@ static int mptcp_setsockopt_sol_tcp_defer(struct mptcp_sock *msk, sockptr_t optv
return tcp_setsockopt(listener->sk, SOL_TCP, TCP_DEFER_ACCEPT, optval, optlen);
}

static int mptcp_setsockopt_sol_tcp_fastopen_connect(struct mptcp_sock *msk, sockptr_t optval,
unsigned int optlen)
static int mptcp_setsockopt_first_sf_only(struct mptcp_sock *msk, int level, int optname,
sockptr_t optval, unsigned int optlen)
{
struct socket *sock;

/* Limit to first subflow */
/* Limit to first subflow, before the connection establishment */
sock = __mptcp_nmpc_socket(msk);
if (!sock)
return -EINVAL;

return tcp_setsockopt(sock->sk, SOL_TCP, TCP_FASTOPEN_CONNECT, optval, optlen);
return tcp_setsockopt(sock->sk, level, optname, optval, optlen);
}

static int mptcp_setsockopt_sol_tcp(struct mptcp_sock *msk, int optname,
Expand Down Expand Up @@ -811,7 +811,8 @@ static int mptcp_setsockopt_sol_tcp(struct mptcp_sock *msk, int optname,
case TCP_DEFER_ACCEPT:
return mptcp_setsockopt_sol_tcp_defer(msk, optval, optlen);
case TCP_FASTOPEN_CONNECT:
return mptcp_setsockopt_sol_tcp_fastopen_connect(msk, optval, optlen);
return mptcp_setsockopt_first_sf_only(msk, SOL_TCP, optname,
optval, optlen);
}

return -EOPNOTSUPP;
Expand Down

0 comments on commit d3d4290

Please sign in to comment.