From patchwork Tue Mar 4 11:32:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 14000524 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F148E1FE471 for ; Tue, 4 Mar 2025 11:32:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741087979; cv=none; b=f50+AWO8XQUBguJDzMaw+R+v1yQW2RnwQJ7b2qZd/1IMEGo3I/p3+USAT4k4rBnKuHluObKPz0/8Ju9bRwloPAtrvIEvWCuXXLc3NlbhSKjn1r0JTBWveafOvvMjkjZkmU8KPazPzpkwWyT0LXDf0AWACBBZOTabjVuxbLbfcsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741087979; c=relaxed/simple; bh=HipJrqHq24SCCyVfi6a1v0iUFY+Inc2jmVllzWiZahg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jDnjQJ9iWehXoh5oVAP9EI6NyILHNUkcfV6egpHPWzJrp/5/adXSFomJYvILFK+u2VHmAiW4iky7ul2IcclWOJ1rBAVLlaGfL74SMgG2f+RgnVE1wtGzXy9SNkyBw8Kw3lXTTW6EJkHG3f20L5KccdDxOfSIXnCFcjae42eLjQI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=htnKMh9/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="htnKMh9/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F01C1C4CEEB; Tue, 4 Mar 2025 11:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741087978; bh=HipJrqHq24SCCyVfi6a1v0iUFY+Inc2jmVllzWiZahg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=htnKMh9/MgU7EE016/kPVz7dF1q6ebARh2O0+cKaYjWb37FCoKs3lXt950nQOND1q yr8d228+t4B/jV1LzKVB5N8xfAqGx3k6PmD4b3itO9m19MGBzKyI/SHp7Kb9gGenNX Es+RNi/HHj7ubac6BEarv4Zwn2P6TZn1fdfnidypVgUGQtl7r2fiPNbzZTza29OfY5 5vdFslB9B2POl3ll+lMVxd2k2Y1tGajpEb3LDdDkXex5D82mrpmMUJ1/WjxjveGzXh fW0pQDJ5iGN2mVWCOxs62JGTR+6LGlwdfS0j/rhM7PQh9YRbzZ2FDdw6YhrfIuPVuK Bl2tnRSFGFHZw== From: "Matthieu Baerts (NGI0)" Date: Tue, 04 Mar 2025 12:32:50 +0100 Subject: [PATCH mptcp-net 1/2] mptcp: sockopt: fix getting IPV6_V6ONLY Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250304-mptcp-sockopt-missing-get-v1-1-6d306d0384be@kernel.org> References: <20250304-mptcp-sockopt-missing-get-v1-0-6d306d0384be@kernel.org> In-Reply-To: <20250304-mptcp-sockopt-missing-get-v1-0-6d306d0384be@kernel.org> To: mptcp@lists.linux.dev Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2345; i=matttbe@kernel.org; h=from:subject:message-id; bh=HipJrqHq24SCCyVfi6a1v0iUFY+Inc2jmVllzWiZahg=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnxuTo0t5V+GaL9h27uKsExBWbQKWaZyOf0bWp5 lYv2egfV8yJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ8bk6AAKCRD2t4JPQmmg c7RjEADtoMowI4uuohr3PjinR8PCugIwP5SeC6hAUzkf/VL2t7sVffn6oyoDz/ecIBEVLYDmI4Q zkHCmHlO23BQ4CgJs+w06LbyNi5QKcktklSu4VT0paTJlbVXfTJ5eZ7x48s6Rf+s2CaritOU68R aCCpx8kDmvrZFYtiW9965DU0XxAPLXwIwd8ynZnQ0z5tfES1g2dxVbjHMrqdXVxPBH+TYbVjNHH Uen13BiwD2Fh6iLZJNQ/bPpIL37vBZ+DHkjtjTp0btfVoZjADN1u4SgTKhBKL+wIiyb7cwCPPi7 OYB2jlN9fbZp5sqnzsyBLlB/ApeNqpiCPU4wQdtbQppSwyYQsTDJ9f35ROLcQaYCwDG1zc9SIpi gnr7AfuUiaCfrAwk4WxkGCy676lGbX08s/cYSJiOjzho3XG+JcLqlI9CSbUDVMDkm0BOde1/9Ix StMcuuseMJGFghNQOeXPFt74qdnB715yMM57f13tsqmeVcnd8ECSMaL3FXL3a7nct7t7VMBvIUv 4sJ03D53USH93+wNvBtpIfO2JZZqrDFGgV2X/gA97BOeTWZbqhhO+lN/QP/V0AEiipCjMlkn0Wo XMkDWSkiZSx3KBCA172c1pG1RbH3Dr+woiHP4XARXbQVKPN6nvOY4gyFJB6zSL8OaOYgK/yuCTm xCvPgNawQAdHfMw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 When adding a socket option support in MPTCP, both the get and set parts are supposed to be implemented. IPV6_V6ONLY support for the setsockopt part has been added a while ago, but it looks like the get part got forgotten. It should have been present as a way to verify a setting has been set as expected, and not to act differently from TCP or any other socket types. Not supporting this getsockopt(IPV6_V6ONLY) blocks some apps which want to check the default value, before doing extra actions. On Linux, the default value is 0, but this can be changed with the net.ipv6.bindv6only sysctl knob. On Windows, it is set to 1 by default. So supporting the get part, like for all other socket options, is important. Everything was in place to expose it, just the last step was missing. Only new code is added to cover this specific getsockopt(), that seems safe. Fixes: c9b95a135987 ("mptcp: support IPV6_V6ONLY setsockopt") Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/550 Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/sockopt.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index 505445a9598fafa1cde6d8f4a1a8635c3e778051..4b99eb796855e4578d14df90f9d1cc3f1cd5b8c7 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -1430,6 +1430,20 @@ 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) +{ + struct sock *sk = (void *)msk; + + switch (optname) { + case IPV6_V6ONLY: + return mptcp_put_int_option(msk, optval, optlen, + sk->sk_ipv6only); + } + + return -EOPNOTSUPP; +} + static int mptcp_getsockopt_sol_mptcp(struct mptcp_sock *msk, int optname, char __user *optval, int __user *optlen) { @@ -1469,6 +1483,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) From patchwork Tue Mar 4 11:32:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 14000525 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA2301FE471 for ; Tue, 4 Mar 2025 11:32:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741087980; cv=none; b=l+EdmpvubbrzmIaI79lbFf8wt/mn3ecoATjnHtYTxEvgVwKMMNCtPP3cofRQynDILE0v6i/IDkRZck99ZZ17ZdZ4LCv5SkdvMEwqOWwRgT9zkvfyMbKaC3uGRASkc1H8EhfCa1Be6GfPNY9b3ShVAf6FH5pdxwX5B35PfBM3V5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741087980; c=relaxed/simple; bh=c5CSyTdy3BzyhnKO8OTXVMvkGGEH2UUJtieRDrgTp/s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nv68dT29h+v4vrXzAyULR912O9QM/iG03VAV+1+YAOV2JpqjbSs9qzjHTV9/OpU0EfX0oS1loYowXtWK+7mqkps63toRHpWhtah+21fw2XjNKjwX7aXeIoMoAvrSGGVK79UJ5fnF24UhycS6sJVyzlETF4hedJDHJPhz6C2wclo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g5ilMtUo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="g5ilMtUo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA0D2C4CEE5; Tue, 4 Mar 2025 11:32:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741087979; bh=c5CSyTdy3BzyhnKO8OTXVMvkGGEH2UUJtieRDrgTp/s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=g5ilMtUoPHXar6SLk5AIg+/aSNay/IkdFPHzPgG53lQsRDTan9W//yU0mOyZvKbxF ygq/7+wjwFUQzkzC70sAw5bN+5G/taRtNfP/F7ECfi/86iMY1DeZJah5fZA/enRCXe DBBH3jYyLNmCYoMU5H4qFxrlEDB+wnliFwQFcdkds9/pOeulP90FU/LtUiYKXNcxSN 1BNRtpJB+22mAjmh9SOFgrjeXSpmyW3ol8FrMjTaTCqBAj+jvFEP90cnj2ylqrlTIt QXH8fpXjlbNq8swQqkhndEWM8Hv8B/bZHemWH5sdByeUdFWeK4XUzZ0QxpkOr51Axm Z3zrg2vRTuFpw== From: "Matthieu Baerts (NGI0)" Date: Tue, 04 Mar 2025 12:32:51 +0100 Subject: [PATCH mptcp-net 2/2] mptcp: sockopt: fix getting freebind & transparent Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250304-mptcp-sockopt-missing-get-v1-2-6d306d0384be@kernel.org> References: <20250304-mptcp-sockopt-missing-get-v1-0-6d306d0384be@kernel.org> In-Reply-To: <20250304-mptcp-sockopt-missing-get-v1-0-6d306d0384be@kernel.org> To: mptcp@lists.linux.dev Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2046; i=matttbe@kernel.org; h=from:subject:message-id; bh=c5CSyTdy3BzyhnKO8OTXVMvkGGEH2UUJtieRDrgTp/s=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnxuTokaWm2AyOJrMVHJcV47K78Ofkoq8h5OPQE liZ5yoTZHyJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ8bk6AAKCRD2t4JPQmmg cxKyEADHo57A9jl2LcKqACUHKxOEC0HZ2nWjw6cBGaDlgMXSxcgFJzGB0EEB4b8V2+2/1q/hpjn LddB/0YwYRr2waV+3Ru4r87ov3ZAPxS/0JTS8WFqKrn162AS5vEzyhg54rITrDHzaHf8zoH9Fy+ +aSUNNDN7w/xygBNouZOI8NDWNKM79aYCeLu3FaLAjjTxZyESiWEkNtl42Y8lsBxU4LYsf8htP7 om7kYXpFAQ7SVN+V2KyxBTEnqd2Rwd4kB+KgYd3Ab3UC8dbDCXEI7X4CmAnAd0C82Feht8D22AG exDzPxzRKVmW3WBRhCyC81aJiu9h6kyzZ0pUgJIlUIBhsqwgovzWOmJ3kC8ep2bYjJgOiI/QY4T Pwt7+SLI1WJyEoXo0riCDQVJUPueG/kQtFVx8a4hGXHcs1u8juSSf16WhbQoXet79kYBa7DZ9Bg xnSM5aV4oaDjzwldlzW+1HgzxYOPpBzKa1JbWgNzDuajNsWzvVDGSdupFPYm3aYDjSxi2Ky+CdM HgWrC8xSevKEoZJ0RMXiWw411nrkmlrUpb3YBhd7XaMDbARoHvJHKjhhee8ZnF5horz61oHEhP/ Q2NQ7EmPI0KgbNLH8Aqt+dZcJLkatrCWUmCcBIt3v6AE7Snk4G3j5SaUNMpI0esOSt0dHkU6mz+ +A45L5MgP+QKPSQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 When adding a socket option support in MPTCP, both the get and set parts are supposed to be implemented. IP(V6)_FREEBIND and IP(V6)_TRANSPARENT support for the setsockopt part has been added a while ago, but it looks like the get part got forgotten. It should have been present as a way to verify a setting has been set as expected, and not to act differently from TCP or any other socket types. Everything was in place to expose it, just the last step was missing. Only new code is added to cover these specific getsockopt(), that seems safe. Fixes: c9406a23c116 ("mptcp: sockopt: add SOL_IP freebind & transparent options") Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/sockopt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index 4b99eb796855e4578d14df90f9d1cc3f1cd5b8c7..3caa0a9d3b3885ce6399570f2d98a2e8f103638d 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -1419,6 +1419,12 @@ static int mptcp_getsockopt_v4(struct mptcp_sock *msk, int optname, switch (optname) { case IP_TOS: return mptcp_put_int_option(msk, optval, optlen, READ_ONCE(inet_sk(sk)->tos)); + case IP_FREEBIND: + return mptcp_put_int_option(msk, optval, optlen, + inet_test_bit(FREEBIND, sk)); + case IP_TRANSPARENT: + return mptcp_put_int_option(msk, optval, optlen, + inet_test_bit(TRANSPARENT, sk)); case IP_BIND_ADDRESS_NO_PORT: return mptcp_put_int_option(msk, optval, optlen, inet_test_bit(BIND_ADDRESS_NO_PORT, sk)); @@ -1439,6 +1445,12 @@ static int mptcp_getsockopt_v6(struct mptcp_sock *msk, int optname, case IPV6_V6ONLY: return mptcp_put_int_option(msk, optval, optlen, sk->sk_ipv6only); + case IPV6_TRANSPARENT: + return mptcp_put_int_option(msk, optval, optlen, + inet_test_bit(TRANSPARENT, sk)); + case IPV6_FREEBIND: + return mptcp_put_int_option(msk, optval, optlen, + inet_test_bit(FREEBIND, sk)); } return -EOPNOTSUPP;