* [MPTCP] Re: [PATCH mptcp] mptcp: provide subflow aware release function
@ 2021-02-15 15:44 Paolo Abeni
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Abeni @ 2021-02-15 15:44 UTC (permalink / raw)
To: mptcp
[-- Attachment #1: Type: text/plain, Size: 3074 bytes --]
On Mon, 2021-02-15 at 16:36 +0100, Florian Westphal wrote:
> mptcp re-used inet(6)_release, so the subflow sockets are ignored.
> Need to invoke ip(v6)_mc_drop_socket function to ensure mcast join
> resources get free'd.
>
> Fixes: 717e79c867ca5 ("mptcp: Add setsockopt()/getsockopt() socket operations")
> Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/110
> Signed-off-by: Florian Westphal <fw(a)strlen.de>
> ---
> net/mptcp/protocol.c | 55 ++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 53 insertions(+), 2 deletions(-)
>
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 19faa43be2f8..d811f60a867b 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -11,6 +11,7 @@
> #include <linux/netdevice.h>
> #include <linux/sched/signal.h>
> #include <linux/atomic.h>
> +#include <linux/igmp.h>
> #include <net/sock.h>
> #include <net/inet_common.h>
> #include <net/inet_hashtables.h>
> @@ -19,6 +20,7 @@
> #include <net/tcp_states.h>
> #if IS_ENABLED(CONFIG_MPTCP_IPV6)
> #include <net/transp_v6.h>
> +#include <net/addrconf.h>
> #endif
> #include <net/mptcp.h>
> #include <net/xfrm.h>
> @@ -3388,10 +3390,34 @@ static __poll_t mptcp_poll(struct file *file, struct socket *sock,
> return mask;
> }
>
> +static int mptcp_release(struct socket *sock)
> +{
> + struct mptcp_subflow_context *subflow;
> + struct sock *sk = sock->sk;
> + struct mptcp_sock *msk;
> +
> + if (!sk)
> + return 0;
> +
> + lock_sock(sk);
> +
> + msk = mptcp_sk(sk);
> +
> + mptcp_for_each_subflow(msk, subflow) {
> + struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
> +
> + ip_mc_drop_socket(ssk);
> + }
> +
> + release_sock(sk);
> +
> + return inet_release(sock);
> +}
> +
> static const struct proto_ops mptcp_stream_ops = {
> .family = PF_INET,
> .owner = THIS_MODULE,
> - .release = inet_release,
> + .release = mptcp_release,
> .bind = mptcp_bind,
> .connect = mptcp_stream_connect,
> .socketpair = sock_no_socketpair,
> @@ -3489,10 +3515,35 @@ void __init mptcp_proto_init(void)
> }
>
> #if IS_ENABLED(CONFIG_MPTCP_IPV6)
> +static int mptcp6_release(struct socket *sock)
> +{
> + struct mptcp_subflow_context *subflow;
> + struct mptcp_sock *msk;
> + struct sock *sk = sock->sk;
> +
> + if (!sk)
> + return 0;
> +
> + lock_sock(sk);
> +
> + msk = mptcp_sk(sk);
> +
> + mptcp_for_each_subflow(msk, subflow) {
> + struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
> +
> + ip_mc_drop_socket(ssk);
> + ipv6_sock_mc_close(ssk);
> + ipv6_sock_ac_close(ssk);
> + }
> +
> + release_sock(sk);
> + return inet6_release(sock);
> +}
> +
> static const struct proto_ops mptcp_v6_stream_ops = {
> .family = PF_INET6,
> .owner = THIS_MODULE,
> - .release = inet6_release,
> + .release = mptcp6_release,
> .bind = mptcp_bind,
> .connect = mptcp_stream_connect,
> .socketpair = sock_no_socketpair,
Nice, LGTM. Thanks Florian!
/P
^ permalink raw reply [flat|nested] 2+ messages in thread
* [MPTCP] Re: [PATCH mptcp] mptcp: provide subflow aware release function
@ 2021-02-15 19:16 Matthieu Baerts
0 siblings, 0 replies; 2+ messages in thread
From: Matthieu Baerts @ 2021-02-15 19:16 UTC (permalink / raw)
To: mptcp
[-- Attachment #1: Type: text/plain, Size: 754 bytes --]
Hi Florian, Paolo,
On 15/02/2021 16:36, Florian Westphal wrote:
> mptcp re-used inet(6)_release, so the subflow sockets are ignored.
> Need to invoke ip(v6)_mc_drop_socket function to ensure mcast join
> resources get free'd.
>
> Fixes: 717e79c867ca5 ("mptcp: Add setsockopt()/getsockopt() socket operations")
> Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/110
> Signed-off-by: Florian Westphal <fw(a)strlen.de>
Thank you for the patch and the review!
Just applied in our tree with Paolo's ACK:
- aee946a79980: mptcp: provide subflow aware release function
- Results: 1de5e73fbb6c..9344b5c5d36e
Tests + export are in progress!
Cheers,
Matt
--
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-15 19:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-15 15:44 [MPTCP] Re: [PATCH mptcp] mptcp: provide subflow aware release function Paolo Abeni
2021-02-15 19:16 Matthieu Baerts
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.