Skip to content

Commit

Permalink
mptcp: avoid some duplicate code in socket option handling
Browse files Browse the repository at this point in the history
The mptcp_get_int_option() helper is needless open-coded in a
couple of places, replace the duplicate code with the helper
call.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Paolo Abeni authored and David S. Miller committed Mar 4, 2024
1 parent 037db6e commit a747626
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions net/mptcp/sockopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,13 +629,11 @@ static int mptcp_setsockopt_sol_tcp_cork(struct mptcp_sock *msk, sockptr_t optva
{
struct mptcp_subflow_context *subflow;
struct sock *sk = (struct sock *)msk;
int val;

if (optlen < sizeof(int))
return -EINVAL;
int val, ret;

if (copy_from_sockptr(&val, optval, sizeof(val)))
return -EFAULT;
ret = mptcp_get_int_option(msk, optval, optlen, &val);
if (ret)
return ret;

lock_sock(sk);
sockopt_seq_inc(msk);
Expand All @@ -659,13 +657,11 @@ static int mptcp_setsockopt_sol_tcp_nodelay(struct mptcp_sock *msk, sockptr_t op
{
struct mptcp_subflow_context *subflow;
struct sock *sk = (struct sock *)msk;
int val;

if (optlen < sizeof(int))
return -EINVAL;
int val, ret;

if (copy_from_sockptr(&val, optval, sizeof(val)))
return -EFAULT;
ret = mptcp_get_int_option(msk, optval, optlen, &val);
if (ret)
return ret;

lock_sock(sk);
sockopt_seq_inc(msk);
Expand Down

0 comments on commit a747626

Please sign in to comment.