mptcp: sockopt: fix missing get options
Subsystems (2)
Matthieu Baerts (NGI0)
maintainercover mptcp: sockopt: fix missing get options
When adding a socket option support in MPTCP, both the get and set parts are supposed to be implemented.
A few socket options had the 'set' part implemented, but not the 'get' part, while everything was in place to expose it, just the last step was missing. It looks like this was not intentional, and the 'get' support should have been present from the beginning, hence the 'Fixes' tags.
---
Matthieu Baerts (NGI0) (2):
mptcp: sockopt: fix getting IPV6_V6ONLY
mptcp: sockopt: fix getting freebind & transparent
net/mptcp/sockopt.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
---
base-commit: b084c48057bbf45fbedc06d7a9d4ec417992fb1e
change-id: 20250303-mptcp-sockopt-missing-get-356e26dc6955
Best regards,
Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>
Matthieu Baerts (NGI0)
maintainerPATCH 1/2 mptcp: sockopt: fix getting IPV6_V6ONLY
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.
--- net/mptcp/sockopt.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
net/mptcp/sockopt.c +16 -0
@@ -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 )
Signature · 1 line
2.47.1
Matthieu Baerts (NGI0)
maintainerPATCH 2/2 mptcp: sockopt: fix getting freebind & transparent
In reply to Matthieu Baerts (NGI0)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.
--- net/mptcp/sockopt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
net/mptcp/sockopt.c +12 -0
@@ -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 ;
Signature · 1 line
2.47.1
Hi Matthieu,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Unstable: 1 failed test(s): selftest_mptcp_connect 🔴
- KVM Validation: debug: Unstable: 1 failed test(s): packetdrill_mp_join 🔴
- KVM Validation: btf-normal (only bpftest_all): Unstable: 1 failed test(s): bpftest_test_progs-cpuv4_mptcp 🔴
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/13653022673
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/c0b81bfd0e61
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=940005
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Hi Matthieu,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Unstable: 1 failed test(s): selftest_mptcp_connect 🔴
- KVM Validation: debug: Unstable: 1 failed test(s): selftest_mptcp_connect - Critical: Global Timeout ❌
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/13653022673
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/c0b81bfd0e61
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=940005
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Quoted 14 lines · On Tue, 4 Mar 2025, Matthieu Baerts (NGI0) wrote:
When adding a socket option support in MPTCP, both the get and set parts are supposed to be implemented.
A few socket options had the 'set' part implemented, but not the 'get' part, while everything was in place to expose it, just the last step was missing. It looks like this was not intentional, and the 'get' support should have been present from the beginning, hence the 'Fixes' tags.
Signed-off-by Matthieu Baerts (NGI0) <[email protected]>---
Matthieu Baerts (NGI0) (2):
mptcp: sockopt: fix gettingIPV6_V6ONLY
mptcp: sockopt: fix getting freebind & transparent
Quoted 5 lines
net/mptcp/sockopt.c| 28 ++++++++++++++++++++++++++++1 file changed, 28 insertions(+)---
base-commit:b084c48057bbf45fbedc06d7a9d4ec417992fb1e
change-id: 20250303-mptcp-sockopt-missing-get-356e26dc6955
Hi Matthieu -
The series looks good to me:
Matthieu Baerts
maintainerHi Mat,
Quoted 22 lines · Mat Martineau
Quoted 14 lines · On Tue, 4 Mar 2025, Matthieu Baerts (NGI0) wrote:
When adding a socket option support in MPTCP, both the get and set parts are supposed to be implemented.
A few socket options had the 'set' part implemented, but not the 'get' part, while everything was in place to expose it, just the last step was missing. It looks like this was not intentional, and the 'get' support should have been present from the beginning, hence the 'Fixes' tags.
Signed-off-by Matthieu Baerts (NGI0) <[email protected]>---
Matthieu Baerts (NGI0) (2):
mptcp: sockopt: fix gettingIPV6_V6ONLY
mptcp: sockopt: fix getting freebind & transparentQuoted 5 lines
net/mptcp/sockopt.c| 28 ++++++++++++++++++++++++++++1 file changed, 28 insertions(+)---
base-commit:b084c48057bbf45fbedc06d7a9d4ec417992fb1e
change-id: 20250303-mptcp-sockopt-missing-get-356e26dc6955
Quoted 5 lines
Hi Matthieu -
The series looks good to me:
Reviewed-by Mat Martineau <[email protected]>
Thank you for the review!
Now in our tree (fixes for -net):
New patches for t/upstream-net and t/upstream:
- f5b862898d83: mptcp: sockopt: fix getting IPV6_V6ONLY
- 7e0ad93236c1: mptcp: sockopt: fix getting freebind & transparent
- Results: 74ce8fb51c46..f1d6b77be72d (export-net)
- Results: 0a1c12618a04..318c86579343 (export)
Tests are now in progress:
- export-net:
https://github.com/multipath-tcp/mptcp_net-next/commit/585fa1467b894289fe3c3ad009b203d1de00ad9a/checks
- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/4a4388014f7c410b33a39aac85c1ca6fe1b4907d/checks
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.