Skip to content

Commit 41089d9

Browse files
Paolo Abenigregkh
Paolo Abeni
authored andcommitted
mptcp: avoid some duplicate code in socket option handling
commit a747626 upstream. 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 <[email protected]> Reviewed-by: Mat Martineau <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Signed-off-by: David S. Miller <[email protected]> Stable-dep-of: bd11dc4 ("mptcp: fix full TCP keep-alive support") Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0af2070 commit 41089d9

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

net/mptcp/sockopt.c

+8-12
Original file line numberDiff line numberDiff line change
@@ -626,13 +626,11 @@ static int mptcp_setsockopt_sol_tcp_cork(struct mptcp_sock *msk, sockptr_t optva
626626
{
627627
struct mptcp_subflow_context *subflow;
628628
struct sock *sk = (struct sock *)msk;
629-
int val;
630-
631-
if (optlen < sizeof(int))
632-
return -EINVAL;
629+
int val, ret;
633630

634-
if (copy_from_sockptr(&val, optval, sizeof(val)))
635-
return -EFAULT;
631+
ret = mptcp_get_int_option(msk, optval, optlen, &val);
632+
if (ret)
633+
return ret;
636634

637635
lock_sock(sk);
638636
sockopt_seq_inc(msk);
@@ -656,13 +654,11 @@ static int mptcp_setsockopt_sol_tcp_nodelay(struct mptcp_sock *msk, sockptr_t op
656654
{
657655
struct mptcp_subflow_context *subflow;
658656
struct sock *sk = (struct sock *)msk;
659-
int val;
660-
661-
if (optlen < sizeof(int))
662-
return -EINVAL;
657+
int val, ret;
663658

664-
if (copy_from_sockptr(&val, optval, sizeof(val)))
665-
return -EFAULT;
659+
ret = mptcp_get_int_option(msk, optval, optlen, &val);
660+
if (ret)
661+
return ret;
666662

667663
lock_sock(sk);
668664
sockopt_seq_inc(msk);

0 commit comments

Comments
 (0)