From nobody Thu Apr 18 23:42:17 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6C5EC54EBE for ; Thu, 12 Jan 2023 18:14:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240312AbjALSOn (ORCPT ); Thu, 12 Jan 2023 13:14:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240521AbjALSNt (ORCPT ); Thu, 12 Jan 2023 13:13:49 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CB7A6DBAE for ; Thu, 12 Jan 2023 09:43:18 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id i17-20020a05600c355100b003d99434b1cfso15732319wmq.1 for ; Thu, 12 Jan 2023 09:43:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=8YUfEdizU6etVNTRXoI4GW0/pb7ruC4LypASoGIVwPU=; b=2KtC7802s32bVsm7NZjN7KH4JundRVEoKhT7MLX3ExFrG8IJ4+v3cCKL/BOb6NeuAr WflCfYzguxCXWVA84P4+arDan1X86BYFIMJc8Y37BZtvt/1ck7WxQwvtJAZwNSkBkY+N Ao2M2KztoSLHYoEPIuX8nTrP8drcderZ0PMpldAK8AiU6Xoz9UxEYf+yVxocKa7zwcI5 xefZ9mwdftJ4KjE38zxYWn8GLitnxJjyHexF+ZI+6mKgAdUpokoIhNTVwt01pCC4sOBC XxUxhiu5SQl/tKVWAkiI6k5Xm6azWV1eUWUvOpCV7ln/SeqgZ4w/uH+8R9+wyRCb3DS3 noig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8YUfEdizU6etVNTRXoI4GW0/pb7ruC4LypASoGIVwPU=; b=7xKR81MUzLCXD/f0zOHKPxx6DaJbZy6tf1WxLIsEJSB9fP480ej2Lqy/4G5fBsOFFK Tz1tVU+5VBH99xT4egn8397fzpnaWjWf1HX7Rrdrt/T1fsPrpUsH91V5IBk9cKJh2MUM RCWmYiXFIpwJsHkLA1zj0AD6VBdsiy22Cs+UXtP9iDHZia50vkLMwnyQrewEb7RSlHNS ssSr3e68nTBAFm9Pdo/KQi1eaAf+kQpCCtepwEe/c+5iJL98X1WVQFstw53elVn/LsjN H3op2dpXXUKCweOXO0K+wwS0VLE33XtXpWuSbNqpT0ZA8amjk8XATKYDOMqDBo9lYb8C 615w== X-Gm-Message-State: AFqh2koIuEn2A8HSbTjH+kcQ4r7zbfl1i8Ky06fWJsscF3+63hvjffX9 jmyfRc0mDjNQ/xRp5X49aU4ygA== X-Google-Smtp-Source: AMrXdXvK/Dxj0h2KI8ZmmNzOHGYhNVCFb4CLn9xyRam5mqbJmKWsmKzga/swbRi3y8zBS1sJHNoECg== X-Received: by 2002:a05:600c:c87:b0:3d9:73fb:8aaa with SMTP id fj7-20020a05600c0c8700b003d973fb8aaamr46696670wmb.8.1673545396847; Thu, 12 Jan 2023 09:43:16 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id hg9-20020a05600c538900b003cfa622a18asm26448769wmb.3.2023.01.12.09.43.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 09:43:16 -0800 (PST) From: Matthieu Baerts Date: Thu, 12 Jan 2023 18:42:51 +0100 Subject: [PATCH net 1/3] mptcp: explicitly specify sock family at subflow creation time MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230112-upstream-net-20230112-netlink-v4-v6-v1-1-6a8363a221d2@tessares.net> References: <20230112-upstream-net-20230112-netlink-v4-v6-v1-0-6a8363a221d2@tessares.net> In-Reply-To: <20230112-upstream-net-20230112-netlink-v4-v6-v1-0-6a8363a221d2@tessares.net> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Kishen Maloor , Florian Westphal , Shuah Khan Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Paolo Abeni , Mat Martineau , Matthieu Baerts , stable@vger.kernel.org X-Mailer: b4 0.11.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3907; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=s+3xVgukLGyOe4wr8E0yNyqO1BWR4F9rZ7m7xbrXwhc=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBjwEayyEL2TZPccGTRXgPHRC1HAS9t3XYCkU15kPTM hAQuVZSJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY8BGsgAKCRD2t4JPQmmgcy48D/ 9INvcrgJwYWWJjoPXs3GnIhV9aEsw999RC4xYkwhfyvmT5af/I4pDPHMyCWBNf+u3N2iJnVMnSoLK6 omjUZ8KvNuhlK8RJ178lcVztmvyYpVL+17/zoeArxUH+w1Hmr4cqHGpv8rGC/9we34lmQ3zWBgECmd a/aDROtQYsnfBu/FIavm64IzA3g5ouCfUAy4WAVDy5PfHe3OVGfQ4ftaZM61TCo/3AvZwF9k19MIx7 imwoUl9YY7g6PGf8Sm65Non2oe5C12DXIlxSA1h3uAKGKoTsdE2Qtpk00yZykK68kN1rwZA9ivUuXn eE2OYIjs/RNDPMwBbwNlafJsLt523vDgIJyE/+eeqYOZftWuF6b4SBxMpCVBHOCdERDE/6NN9aA0V3 SXFsGGD+ravF6uD/uAtMnV/bHf3Dc3rDKALgtdfbf9mWdgKV/oxuVFzruIK3ARyVQilefKpYlwMnbl h5Twxa6KnBGr11FMnX8/Cpr6Dst54q8JvhftvLSOnGc+8ZuHuiKFcMczOOHh5fGatQI/StezvT9sC2 uBOBuI3umttX8BqL/lkD4eI9OkZpL7GEGZCaozGnqOcRNyWuriGWXdMWoh0d09Mns8DtkyJTLKoL4I BiLiqqt6Cg9RcWaMEVUb0LOs1+a0nz2HuUgdLAcf4ItdD+0wffRxfn5RtqVg== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Abeni Let the caller specify the to-be-created subflow family. For a given MPTCP socket created with the AF_INET6 family, the current userspace PM can already ask the kernel to create subflows in v4 and v6. If "plain" IPv4 addresses are passed to the kernel, they are automatically mapped in v6 addresses "by accident". This can be problematic because the userspace will need to pass different addresses, now the v4-mapped-v6 addresses to destroy this new subflow. On the other hand, if the MPTCP socket has been created with the AF_INET family, the command to create a subflow in v6 will be accepted but the result will not be the one as expected as new subflow will be created in IPv4 using part of the v6 addresses passed to the kernel: not creating the expected subflow then. No functional change intended for the in-kernel PM where an explicit enforcement is currently in place. This arbitrary enforcement will be leveraged by other patches in a future version. Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establ= ishment") Cc: stable@vger.kernel.org Co-developed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 2 +- net/mptcp/protocol.h | 3 ++- net/mptcp/subflow.c | 9 +++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index b7ad030dfe89..8cd6cc67c2c5 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -98,7 +98,7 @@ static int __mptcp_socket_create(struct mptcp_sock *msk) struct socket *ssock; int err; =20 - err =3D mptcp_subflow_create_socket(sk, &ssock); + err =3D mptcp_subflow_create_socket(sk, sk->sk_family, &ssock); if (err) return err; =20 diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index a0d1658ce59e..a9e0355744b6 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -641,7 +641,8 @@ bool mptcp_addresses_equal(const struct mptcp_addr_info= *a, /* called with sk socket lock held */ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info = *loc, const struct mptcp_addr_info *remote); -int mptcp_subflow_create_socket(struct sock *sk, struct socket **new_sock); +int mptcp_subflow_create_socket(struct sock *sk, unsigned short family, + struct socket **new_sock); void mptcp_info2sockaddr(const struct mptcp_addr_info *info, struct sockaddr_storage *addr, unsigned short family); diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index bd387d4b5a38..ec54413fb31f 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -1547,7 +1547,7 @@ int __mptcp_subflow_connect(struct sock *sk, const st= ruct mptcp_addr_info *loc, if (!mptcp_is_fully_established(sk)) goto err_out; =20 - err =3D mptcp_subflow_create_socket(sk, &sf); + err =3D mptcp_subflow_create_socket(sk, loc->family, &sf); if (err) goto err_out; =20 @@ -1660,7 +1660,9 @@ static void mptcp_subflow_ops_undo_override(struct so= ck *ssk) #endif ssk->sk_prot =3D &tcp_prot; } -int mptcp_subflow_create_socket(struct sock *sk, struct socket **new_sock) + +int mptcp_subflow_create_socket(struct sock *sk, unsigned short family, + struct socket **new_sock) { struct mptcp_subflow_context *subflow; struct net *net =3D sock_net(sk); @@ -1673,8 +1675,7 @@ int mptcp_subflow_create_socket(struct sock *sk, stru= ct socket **new_sock) if (unlikely(!sk->sk_socket)) return -EINVAL; =20 - err =3D sock_create_kern(net, sk->sk_family, SOCK_STREAM, IPPROTO_TCP, - &sf); + err =3D sock_create_kern(net, family, SOCK_STREAM, IPPROTO_TCP, &sf); if (err) return err; =20 --=20 2.37.2 From nobody Thu Apr 18 23:42:17 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37900C54EBE for ; Thu, 12 Jan 2023 18:14:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240347AbjALSO4 (ORCPT ); Thu, 12 Jan 2023 13:14:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240537AbjALSNv (ORCPT ); Thu, 12 Jan 2023 13:13:51 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 598836DBB4 for ; Thu, 12 Jan 2023 09:43:19 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id ay40so13739594wmb.2 for ; Thu, 12 Jan 2023 09:43:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=QiTuEY+XxNm3ybPyz+48mvw3MWfXIDkBz9A8P0bhXlA=; b=rL9Hw8uromb1tmWzaFdNP0RzZSeHuZEMFaPHO43kBsrbPhytZcZXbwkVpCK/GlLAAD MikurqYTuwb7Ce3QhPz3HOVomK+gvH2o11VbPnrpq7ddeV98W0WdoCU61W0U5uyS/w7p lrSadqajmthZah+VMgp6uWvyFgSl0kdCmuUWDfmdfv/pkAGwUt+ySJhAhhjxgbstwsej QfZ4+DskUsK60jm4SbGETMSsXC2VJ+MnQ1dqyoZvsatqiLP/eOinSKSWWXAqkDY0R4UK cPQIdSfaMKHGGjKz7OGqSEHJIHtpKURasIu0i/i/TDE2ga3o6c9TO3vXUJmu6urDgkVe QkZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QiTuEY+XxNm3ybPyz+48mvw3MWfXIDkBz9A8P0bhXlA=; b=gatgc4OZSLcnBqyWqHnZH70YBtVG7XxsosRy0KK9Co14qBk4GNWCQOuTMLJnYG/RO9 4oeaQA6n6O34q+HmalXDULUeRy52/7T8r8etU2yFV4oAVc4pQGOrSXVepZ0iZg6Siw82 3bo7L5a0lHZ7IVijYi/QI1l4H8KnY/bSHW6nRt8oYfMnXFPaemhHRdAbAO+qA5qMgn8I apbGNyq7o4McAsvpQc5qMlbt4v3rJyvk7e/+gpBsWrXHTNsnYKRc8nkgxYxo+Yl5nivZ W3taqyCYODseAfGgRzB73bLJaReskHEErl0IjsAZMoNzM+NLCfZ1CgyJeHh+aSwjAuPw iu4g== X-Gm-Message-State: AFqh2kpYYXoRcFe95zhcyMCo0mM7dww+oRm4sYv3LXzsP8wyP3F0ctf1 WRZ2Z9iTiXCdx8y9sSd1KowsTg== X-Google-Smtp-Source: AMrXdXuXok4BEMzyXnGeDPxwcjgXMFMJ+rRZQrQPRKGsR9tBWnbGCYJPiJVzTNxy7mkFNs+MI9mq7w== X-Received: by 2002:a05:600c:5119:b0:3da:79f:8953 with SMTP id o25-20020a05600c511900b003da079f8953mr5774861wms.41.1673545397855; Thu, 12 Jan 2023 09:43:17 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id hg9-20020a05600c538900b003cfa622a18asm26448769wmb.3.2023.01.12.09.43.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 09:43:17 -0800 (PST) From: Matthieu Baerts Date: Thu, 12 Jan 2023 18:42:52 +0100 Subject: [PATCH net 2/3] mptcp: netlink: respect v4/v6-only sockets MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230112-upstream-net-20230112-netlink-v4-v6-v1-2-6a8363a221d2@tessares.net> References: <20230112-upstream-net-20230112-netlink-v4-v6-v1-0-6a8363a221d2@tessares.net> In-Reply-To: <20230112-upstream-net-20230112-netlink-v4-v6-v1-0-6a8363a221d2@tessares.net> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Kishen Maloor , Florian Westphal , Shuah Khan Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Paolo Abeni , Mat Martineau , Matthieu Baerts , stable@vger.kernel.org X-Mailer: b4 0.11.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4111; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=e19zv1aFHhB9nt3VCW/8O5Inf4FqFwI97vxJoTjVzvA=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBjwEayt2N4UkguuURJPSqJpm5I3q5acpoa3IF9e41e NnK2xM2JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY8BGsgAKCRD2t4JPQmmgc9qNEA CiHnvCqlld9a8saTmqmnZls7uZM1pDORqxzuHNfyEtGzDrK7FVB/aOsmW4OgllDM+Q+iPndQ5NZT/5 TzG+cMAXhi+1BbsOQlPLGwEpdZyWPrQJvNyd4PW/OEqc8PV0daIhLFT2JpgsWENuWeITuX1FkQgyHL aGttAFCxZOmCNawH37GRCO5dnc7kf8bbPgdEvo0BQF4JJ1101p0RdSY+qfhqB+eT+kYDVzIpY64evq D0F/+3HKgGJzmr2aeg8okDDpxkt4FhEVbPu4BBkI7rM7WcHVX5YhYsmI88HHXEl8RWSFdP6jD/lOhM HpWGAxjjRlmsxn+CRtM0kmut2EelP77cRuDlmA7u5mMqDSXMlA72qGc729kMDBF9abSY6rRZVC+ZMm VLeGsF0t6bdLYgLfEhlcyf3o0s7zmB8m8+4HqDBQfwDpyhbvzik/2YfrmLeDg6Zwjq5h+ri6hPb9Fd 7Yte7aekugwVEKuarRZ7l60wytz+EYkkOa/NySTfB93V5FIPjsJawstmh/LSqrxs3+qQROqe8bo2i/ 7oQLdJQ7FSnL4iCFySgLs9va/XiApuk2zd9jpvwgl4M1J1oFDH7B0WjQfLu0JS0CbirLoTSYtfX/lT LxDI8kICPTQ/v31KbZhOgBO+O1Ou0T3lhDXpzJ/ap2CTZ4Urop47yLdqvWhA== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If an MPTCP socket has been created with AF_INET6 and the IPV6_V6ONLY option has been set, the userspace PM would allow creating subflows using IPv4 addresses, e.g. mapped in v6. The kernel side of userspace PM will also accept creating subflows with local and remote addresses having different families. Depending on the subflow socket's family, different behaviours are expected: - If AF_INET is forced with a v6 address, the kernel will take the last byte of the IP and try to connect to that: a new subflow is created but to a non expected address. - If AF_INET6 is forced with a v4 address, the kernel will try to connect to a v4 address (v4-mapped-v6). A -EBADF error from the connect() part is then expected. It is then required to check the given families can be accepted. This is done by using a new helper for addresses family matching, taking care of IPv4 vs IPv4-mapped-IPv6 addresses. This helper will be re-used later by the in-kernel path-manager to use mixed IPv4 and IPv6 addresses. While at it, a clear error message is now reported if there are some conflicts with the families that have been passed by the userspace. Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establ= ishment") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts --- net/mptcp/pm.c | 25 +++++++++++++++++++++++++ net/mptcp/pm_userspace.c | 7 +++++++ net/mptcp/protocol.h | 3 +++ 3 files changed, 35 insertions(+) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 45e2a48397b9..70f0ced3ca86 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -420,6 +420,31 @@ void mptcp_pm_subflow_chk_stale(const struct mptcp_soc= k *msk, struct sock *ssk) } } =20 +/* if sk is ipv4 or ipv6_only allows only same-family local and remote add= resses, + * otherwise allow any matching local/remote pair + */ +bool mptcp_pm_addr_families_match(const struct sock *sk, + const struct mptcp_addr_info *loc, + const struct mptcp_addr_info *rem) +{ + bool mptcp_is_v4 =3D sk->sk_family =3D=3D AF_INET; + +#if IS_ENABLED(CONFIG_MPTCP_IPV6) + bool loc_is_v4 =3D loc->family =3D=3D AF_INET || ipv6_addr_v4mapped(&loc-= >addr6); + bool rem_is_v4 =3D rem->family =3D=3D AF_INET || ipv6_addr_v4mapped(&rem-= >addr6); + + if (mptcp_is_v4) + return loc_is_v4 && rem_is_v4; + + if (ipv6_only_sock(sk)) + return !loc_is_v4 && !rem_is_v4; + + return loc_is_v4 =3D=3D rem_is_v4; +#else + return mptcp_is_v4 && loc->family =3D=3D AF_INET && rem->family =3D=3D AF= _INET; +#endif +} + void mptcp_pm_data_reset(struct mptcp_sock *msk) { u8 pm_type =3D mptcp_get_pm_type(sock_net((struct sock *)msk)); diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 65dcc55a8ad8..ea6ad9da7493 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -294,6 +294,13 @@ int mptcp_nl_cmd_sf_create(struct sk_buff *skb, struct= genl_info *info) } =20 sk =3D (struct sock *)msk; + + if (!mptcp_pm_addr_families_match(sk, &addr_l, &addr_r)) { + GENL_SET_ERR_MSG(info, "families mismatch"); + err =3D -EINVAL; + goto create_err; + } + lock_sock(sk); =20 err =3D __mptcp_subflow_connect(sk, &addr_l, &addr_r); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index a9e0355744b6..601469249da8 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -777,6 +777,9 @@ int mptcp_pm_parse_addr(struct nlattr *attr, struct gen= l_info *info, int mptcp_pm_parse_entry(struct nlattr *attr, struct genl_info *info, bool require_family, struct mptcp_pm_addr_entry *entry); +bool mptcp_pm_addr_families_match(const struct sock *sk, + const struct mptcp_addr_info *loc, + const struct mptcp_addr_info *rem); void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock = *ssk); void mptcp_pm_nl_subflow_chk_stale(const struct mptcp_sock *msk, struct so= ck *ssk); void mptcp_pm_new_connection(struct mptcp_sock *msk, const struct sock *ss= k, int server_side); --=20 2.37.2 From nobody Thu Apr 18 23:42:17 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FDC6C61DB3 for ; Thu, 12 Jan 2023 18:15:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240367AbjALSPC (ORCPT ); Thu, 12 Jan 2023 13:15:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240558AbjALSN4 (ORCPT ); Thu, 12 Jan 2023 13:13:56 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8F516DBBD for ; Thu, 12 Jan 2023 09:43:20 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id c4-20020a1c3504000000b003d9e2f72093so12318938wma.1 for ; Thu, 12 Jan 2023 09:43:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=3e5PBlGJNiXnH3XwFb6/nJ5M/bSXc0/rRRFPQw8A51M=; b=zQXXh8ieB1e2x1HIq9SMzCtwStEEFHMtKWzpbnXpd/2CDancPQSwJjAnn3tJuNHSQz cw52GdKy2buAYmJ67ykJTuE9AdUYvTIvnveJRELMXxX5eUdHdmgsx68kD5caVrRd+YYm BN52TiyqaQ5Oa+9HkstlrEcup1mdv02RCfMv0p8zpLK+6tAd2qCYr2XkokPD3U9NDOLJ xOZ2U3ftJuEuKpm2zTX/est7NFdkW+ZuGc6En9WzO5l9tQ3ohmY+Mq7D5EsL/Up/Tyb1 DAIjm7ijZQMk2DicW3ZwFCmVtp+H8WoMJuhx3tGUGd/DbgqnRLM5iEsxNXQwel/I2FLy G4bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3e5PBlGJNiXnH3XwFb6/nJ5M/bSXc0/rRRFPQw8A51M=; b=PI/c52sUOvmm0n43o31VybNQAoElnSwVNIMgm5sCra4CBO9jJuRIzznE/drygEIZW0 rs96Jddb/VbAqU5f0RSw1OoT3SPzHLW6TYcfOn7sITFeXHXzbX5qlKH7Hsm8pMpAfVdz 1He52/PIYXEB7g/kL2TklSUn+t1AA7fbnEEU6MfcnoGVwrm3ycUZabMIzFIbx9ESjp/n TIBPWtpUJfPwcntk3v6DmFoeTJYvK7rQaMA6cvkRwMBg1MD/N/DgNMkXC3ev68ZLQSg2 1fjPuirz6U7kCO00+ym70RJXz8xEgNHbCUlEH8Q7f9mgPCEprpqiBrqX9HxXcIc62WnN 7Gnw== X-Gm-Message-State: AFqh2koUVrDzZj1pyTLmpv7eDfH0nyWI4ovKuRBWQu5hedjMkpqfkqtC 4bMmMj3o2EedNkbrqq+I8TuCHA== X-Google-Smtp-Source: AMrXdXvsmad4+iB2Sb/Sj//efn71Od0my1o0QKk8x4Q6YxNY4qhjSBwlePQg5j6h89T1z1GdCI98dw== X-Received: by 2002:a05:600c:3b87:b0:3d2:813:138a with SMTP id n7-20020a05600c3b8700b003d20813138amr59967266wms.35.1673545398942; Thu, 12 Jan 2023 09:43:18 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id hg9-20020a05600c538900b003cfa622a18asm26448769wmb.3.2023.01.12.09.43.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 09:43:18 -0800 (PST) From: Matthieu Baerts Date: Thu, 12 Jan 2023 18:42:53 +0100 Subject: [PATCH net 3/3] selftests: mptcp: userspace: validate v4-v6 subflows mix MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230112-upstream-net-20230112-netlink-v4-v6-v1-3-6a8363a221d2@tessares.net> References: <20230112-upstream-net-20230112-netlink-v4-v6-v1-0-6a8363a221d2@tessares.net> In-Reply-To: <20230112-upstream-net-20230112-netlink-v4-v6-v1-0-6a8363a221d2@tessares.net> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Kishen Maloor , Florian Westphal , Shuah Khan Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Paolo Abeni , Mat Martineau , Matthieu Baerts , stable@vger.kernel.org X-Mailer: b4 0.11.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3020; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=wMA47rRwNHClCs5+kkPqR8S9uOx26T8C//wUolPsOEs=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBjwEayQrKg1fBLIH/Ag9LK+jbOuR/y6ESuubk4Qg62 Xu6uf2qJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY8BGsgAKCRD2t4JPQmmgc1/ND/ 4v+GObwwQJ0B5N50mp9+s+fUPH6lM5J8yQ2LrA9D0KBmeCLBYcZnQgoNAMSWDLuLg9+AIYHvvlyDzy rPO4l+UZpFnbKYIUfKZPpXpF4pvIJAcjjl7lCJzNCerjJbmPWvEULd5a97uOxMqECScgfurVYrfPMb oOsBJFJO7CHwzavV3vqRc2ZpxYrKVhNCrnakBqeyCMu+zUpCImV7fcjCRHXBlvcpFNAiX2D232dgVR aSzBjHXWzTFX1gXjPX2altHxIPYsCRIko4EkrxUOVspn49+418BaNCjS4YRxEDH/Ye6jE5TWRouVuE hMo6BOZuYv4K8W9E+IuBuAHy38JFI1MKmHlD8MrAMWeH5CAwgSHUVKrNrkfd9XTpZyWG6eWFBUjd0b vy/P3W/nRU2UwXHNApC3fpgn6kJpNPAIuyC8zjHHs68XJt51696qiiQoZWpuBidFAZ6dTr8EPuRCT4 y3J0Xq/9bevMAk6uBldNrFMnMWx11tKeZapRGkoEGeIDkfxz4AwkggwKLWGuRD7W523yGpvsoWDPvX akmNFsOwK53zOjAaQERrFf7oAo8hmyvJzb6FcCfFotBpOct7wnS1X41sXp9g94BN/63CJd4JMLlj0i 31/aftWgNI74VaaxXTATynQPz3Yw3g9DD3s86hAnsIW4pxXEQrYhbEQigSng== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org MPTCP protocol supports having subflows in both IPv4 and IPv6. In Linux, it is possible to have that if the MPTCP socket has been created with AF_INET6 family without the IPV6_V6ONLY option. Here, a new IPv4 subflow is being added to the initial IPv6 connection, then being removed using Netlink commands. Cc: stable@vger.kernel.org # v5.19+ Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts --- tools/testing/selftests/net/mptcp/userspace_pm.sh | 47 +++++++++++++++++++= ++++ 1 file changed, 47 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/test= ing/selftests/net/mptcp/userspace_pm.sh index a29deb9fa024..ab2d581f28a1 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -752,6 +752,52 @@ test_subflows() "$server4_token" > /dev/null 2>&1 } =20 +test_subflows_v4_v6_mix() +{ + # Attempt to add a listener at 10.0.2.1: + ip netns exec "$ns1" ./pm_nl_ctl listen 10.0.2.1\ + $app6_port > /dev/null 2>&1 & + local listener_pid=3D$! + + # ADD_ADDR4 from server to client machine reusing the subflow port on + # the established v6 connection + :>"$client_evts" + ip netns exec "$ns1" ./pm_nl_ctl ann 10.0.2.1 token "$server6_token" id\ + $server_addr_id dev ns1eth2 > /dev/null 2>&1 + stdbuf -o0 -e0 printf "ADD_ADDR4 id:%d 10.0.2.1 (ns1) =3D> ns2, reuse por= t\t\t" $server_addr_id + sleep 0.5 + verify_announce_event "$client_evts" "$ANNOUNCED" "$client6_token" "10.0.= 2.1"\ + "$server_addr_id" "$app6_port" + + # CREATE_SUBFLOW from client to server machine + :>"$client_evts" + ip netns exec "$ns2" ./pm_nl_ctl csf lip 10.0.2.2 lid 23 rip 10.0.2.1 rpo= rt\ + $app6_port token "$client6_token" > /dev/null 2>&1 + sleep 0.5 + verify_subflow_events "$client_evts" "$SUB_ESTABLISHED" "$client6_token"\ + "$AF_INET" "10.0.2.2" "10.0.2.1" "$app6_port" "23"\ + "$server_addr_id" "ns2" "ns1" + + # Delete the listener from the server ns, if one was created + kill_wait $listener_pid + + sport=3D$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' = "$client_evts") + + # DESTROY_SUBFLOW from client to server machine + :>"$client_evts" + ip netns exec "$ns2" ./pm_nl_ctl dsf lip 10.0.2.2 lport "$sport" rip 10.0= .2.1 rport\ + $app6_port token "$client6_token" > /dev/null 2>&1 + sleep 0.5 + verify_subflow_events "$client_evts" "$SUB_CLOSED" "$client6_token" \ + "$AF_INET" "10.0.2.2" "10.0.2.1" "$app6_port" "23"\ + "$server_addr_id" "ns2" "ns1" + + # RM_ADDR from server to client machine + ip netns exec "$ns1" ./pm_nl_ctl rem id $server_addr_id token\ + "$server6_token" > /dev/null 2>&1 + sleep 0.5 +} + test_prio() { local count @@ -861,6 +907,7 @@ make_connection "v6" test_announce test_remove test_subflows +test_subflows_v4_v6_mix test_prio test_listener =20 --=20 2.37.2