Hi Paolo, Peter,
On 22/10/2019 10:35, Paolo Abeni wrote:
Hi,
On Mon, 2019-10-21 at 16:41 -0700, Peter Krystad wrote:
> Use the address family used when the initial MPTCP socket
> was created when making additional subflow sockets.
>
> squashto: Implement basic path manager
>
> Signed-off-by: Peter Krystad <peter.krystad(a)linux.intel.com>
> ---
> net/mptcp/basic.c | 28 ++++++++++++++++------------
> 1 file changed, 16 insertions(+), 12 deletions(-)
>
> diff --git a/net/mptcp/basic.c b/net/mptcp/basic.c
> index d2fd0560c136..2557cb63fd61 100644
> --- a/net/mptcp/basic.c
> +++ b/net/mptcp/basic.c
> @@ -209,19 +209,23 @@ static void create_subflow_worker(struct work_struct *work)
>
> pernet = net_generic(sock_net((struct sock *)msk), basic_pernet_id);
>
> - if (pernet->has_announce_v4)
> - mptcp_pm_create_subflow(pm->token, pm->remote_id,
> - &pernet->announce_v4_addr);
> -#if IS_ENABLED(CONFIG_IPV6)
> - else if (pernet->has_announce_v6)
> - mptcp_pm_create_subflow6(pm->token, pm->remote_id,
> - &pernet->announce_v6_addr);
> -#endif
> - else if (pm->local_family == AF_INET)
> - mptcp_pm_create_subflow(pm->token, pm->remote_id, NULL);
> + if (msk->family == AF_INET) {
> + if (pernet->has_announce_v4)
> + mptcp_pm_create_subflow(pm->token, pm->remote_id,
> + &pernet->announce_v4_addr);
> + else
> + mptcp_pm_create_subflow(pm->token, pm->remote_id,
> + NULL);
> + }
Here I'm likely a bit lost, but what if the peer sends an ADD_ADDR v4,
and the local msk socket is a v6 (or vice versa)?
On one hand, if the socket is v6 only, it would make sense not to
establish a v4 subflow or announce a v4 IP. Same if the socket is v4 only.
But on the other hand, when an app creates both v4-only and v6-only
sockets (like many webservers do), it is annoying because you cannot
combine v4 and v6. In this case the PM doesn't announce the addresses
for the other family because it will not accept addresses from this
other family. We respect what the app asked but I don't know if we want
to "ignore" v4-only/v6-only for other subflows.
I think checking vs the msk family is possibly not required here
(IIRC
the RFC code, it looks like an MPTCP client could manage correctly
subflows with different inet families - but we need to check/match the
local address family (has_announce_v4/has_announce_v6) vs the remote
address/ADD_ADDR family. Otherwise we could try to connect to a
corrupted/truncated/uncomplete address.
Regarding the code here, I guess we should check for sockets allowing
both v4 and v6. And possibly use the v4 addressed mapped in v6.
Additionally, I think we need to check/match the local additional
address family (has_announce_v4/has_announce_v6) vs the msk family in
announce_addr_worker(), so that the sever always announce addresses
that is able to accept[1].
Yes but only if the socket is v4-only or v6-only.
Thanks,
Paolo
[1] for IPv6 listener such check could be fairly more complex - unbound
listener could accept any ipv4 address, bound ones could check for
ipv4-mapped ipv6 address, etc... I think is better use to the simpler
approach here.
So accept a mix of v4 and v6 later? It would make sense but it will need
to be documented somewhere with a TODO I guess :)
Cheers,
Matt
PS: Paolo: is it OK for you if I apply the first patch of the series?
--
Matthieu Baerts | R&D Engineer
matthieu.baerts(a)tessares.net
Tessares SA | Hybrid Access Solutions
www.tessares.net
1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium