diff mbox series

[mptcp-next,4/6] mptcp: sockopt: add missing getsockopt() options

Message ID 20230707-mptcp-unify-sockopt-issue-353-v1-4-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, 35 lines checked
matttbe/build fail Build error with: -Werror
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
Some socket options had a support for the "set" part but not the "get"
one:

 - IP_FREEBIND
 - IP_TRANSPARENT
 - IPV6_V6ONLY
 - IPV6_TRANSPARENT
 - IPV6_FREEBIND

Thanks to the previous commit, we can easily support them.

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

Patch

diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
index 673bcf8a97f0..f0007fa7a0a8 100644
--- a/net/mptcp/sockopt.c
+++ b/net/mptcp/sockopt.c
@@ -1367,6 +1367,8 @@  static int mptcp_getsockopt_v4(struct mptcp_sock *msk, int optname,
 			       char __user *optval, int __user *optlen)
 {
 	switch (optname) {
+	case IP_FREEBIND:
+	case IP_TRANSPARENT:
 	case IP_TOS:
 		return mptcp_getsockopt_msk(msk, SOL_IP, optname, optval, optlen);
 	}
@@ -1374,6 +1376,19 @@  static int mptcp_getsockopt_v4(struct mptcp_sock *msk, int optname,
 	return -EOPNOTSUPP;
 }
 
+static int mptcp_getsockopt_v6(struct mptcp_sock *msk, int optname,
+			       char __user *optval, int __user *optlen)
+{
+	switch (optname) {
+	case IPV6_V6ONLY:
+	case IPV6_TRANSPARENT:
+	case IPV6_FREEBIND:
+		return mptcp_getsockopt_msk(msk, SOL_IPV6, optname, optval, optlen);
+	}
+
+	return -EOPNOTSUPP;
+}
+
 static int mptcp_getsockopt_sol_mptcp(struct mptcp_sock *msk, int optname,
 				      char __user *optval, int __user *optlen)
 {
@@ -1413,6 +1428,8 @@  int mptcp_getsockopt(struct sock *sk, int level, int optname,
 
 	if (level == SOL_IP)
 		return mptcp_getsockopt_v4(msk, optname, optval, option);
+	if (level == SOL_IPV6)
+		return mptcp_getsockopt_v6(msk, optname, optval, option);
 	if (level == SOL_TCP)
 		return mptcp_getsockopt_sol_tcp(msk, optname, optval, option);
 	if (level == SOL_MPTCP)