diff mbox series

[mptcp-next,1/6] mptcp: sockopt: move tcp_inq code to a dedicated function

Message ID 20230707-mptcp-unify-sockopt-issue-353-v1-1-693e15c06646@tessares.net (mailing list archive)
State Changes Requested
Delegated to: Paolo Abeni
Headers show
Series mptcp: sockopt: uniform code to get/set values | expand

Checks

Context Check Description
matttbe/checkpatch success total: 0 errors, 0 warnings, 0 checks, 47 lines checked
matttbe/build success Build and static analysis OK
matttbe/KVM_Validation__normal__except_selftest_mptcp_join_ success Success! ✅
matttbe/KVM_Validation__debug__only_selftest_mptcp_join_ success Success! ✅
matttbe/KVM_Validation__debug__except_selftest_mptcp_join_ success Success! ✅
matttbe/KVM_Validation__normal__only_selftest_mptcp_join_ success Success! ✅

Commit Message

Matthieu Baerts July 7, 2023, 4 p.m. UTC
Similar to what we have with the other TCP socket options where each of
them are in a dedicated function.

It is clearer like that.

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 net/mptcp/sockopt.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
index 63f7a09335c5..a46a00bf0f08 100644
--- a/net/mptcp/sockopt.c
+++ b/net/mptcp/sockopt.c
@@ -577,6 +577,25 @@  static bool mptcp_supported_sockopt(int level, int optname)
 	return false;
 }
 
+static int mptcp_setsockopt_sol_tcp_inq(struct mptcp_sock *msk, sockptr_t optval,
+					unsigned int optlen)
+{
+	struct sock *sk = (struct sock *)msk;
+	int ret, val;
+
+	ret = mptcp_get_int_option(msk, optval, optlen, &val);
+	if (ret)
+		return ret;
+	if (val < 0 || val > 1)
+		return -EINVAL;
+
+	lock_sock(sk);
+	msk->recvmsg_inq = !!val;
+	release_sock(sk);
+
+	return 0;
+}
+
 static int mptcp_setsockopt_sol_tcp_congestion(struct mptcp_sock *msk, sockptr_t optval,
 					       unsigned int optlen)
 {
@@ -784,21 +803,9 @@  static int mptcp_setsockopt_first_sf_only(struct mptcp_sock *msk, int level, int
 static int mptcp_setsockopt_sol_tcp(struct mptcp_sock *msk, int optname,
 				    sockptr_t optval, unsigned int optlen)
 {
-	struct sock *sk = (void *)msk;
-	int ret, val;
-
 	switch (optname) {
 	case TCP_INQ:
-		ret = mptcp_get_int_option(msk, optval, optlen, &val);
-		if (ret)
-			return ret;
-		if (val < 0 || val > 1)
-			return -EINVAL;
-
-		lock_sock(sk);
-		msk->recvmsg_inq = !!val;
-		release_sock(sk);
-		return 0;
+		return mptcp_setsockopt_sol_tcp_inq(msk, optval, optlen);
 	case TCP_ULP:
 		return -EOPNOTSUPP;
 	case TCP_CONGESTION: