[PATCH mptcp-next v7 05/24] mptcp: map v4 address to v6 when destroying subflow

Geliang Tang posted 24 patches 8 months, 1 week ago
There is a newer version of this series
[PATCH mptcp-next v7 05/24] mptcp: map v4 address to v6 when destroying subflow
Posted by Geliang Tang 8 months, 1 week ago
In mptcp_pm_nl_subflow_destroy_doit(), before checking local address
family with remote address family, map an IPv4 address to an IPv6 address
if the pair is a v4-mapped address.

Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establishment")
Signed-off-by: Geliang Tang <geliang.tang@linux.dev>
---
 net/mptcp/pm_userspace.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index c592536b9889..9df643373c39 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -499,6 +499,16 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info
 		goto destroy_err;
 	}
 
+#if IS_ENABLED(CONFIG_MPTCP_IPV6)
+	if (addr_l.family == AF_INET && ipv6_addr_v4mapped(&addr_r.addr6)) {
+		ipv6_addr_set_v4mapped(addr_l.addr.s_addr, &addr_l.addr6);
+		addr_l.family = AF_INET6;
+	}
+	if (addr_r.family == AF_INET && ipv6_addr_v4mapped(&addr_l.addr6)) {
+		ipv6_addr_set_v4mapped(addr_r.addr.s_addr, &addr_r.addr6);
+		addr_r.family = AF_INET6;
+	}
+#endif
 	if (addr_l.family != addr_r.family) {
 		GENL_SET_ERR_MSG(info, "address families do not match");
 		err = -EINVAL;
-- 
2.39.2
Re: [PATCH mptcp-next v7 05/24] mptcp: map v4 address to v6 when destroying subflow
Posted by Mat Martineau 8 months ago
On Sat, 30 Dec 2023, Geliang Tang wrote:

> In mptcp_pm_nl_subflow_destroy_doit(), before checking local address
> family with remote address family, map an IPv4 address to an IPv6 address
> if the pair is a v4-mapped address.
>

Hi Geliang -

The code looks good, thanks. For the commit message, can you add some more 
detail about the problem that is being fixed? Is there a github issue to 
link?

- Mat

> Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establishment")
> Signed-off-by: Geliang Tang <geliang.tang@linux.dev>
> ---
> net/mptcp/pm_userspace.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
> index c592536b9889..9df643373c39 100644
> --- a/net/mptcp/pm_userspace.c
> +++ b/net/mptcp/pm_userspace.c
> @@ -499,6 +499,16 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info
> 		goto destroy_err;
> 	}
>
> +#if IS_ENABLED(CONFIG_MPTCP_IPV6)
> +	if (addr_l.family == AF_INET && ipv6_addr_v4mapped(&addr_r.addr6)) {
> +		ipv6_addr_set_v4mapped(addr_l.addr.s_addr, &addr_l.addr6);
> +		addr_l.family = AF_INET6;
> +	}
> +	if (addr_r.family == AF_INET && ipv6_addr_v4mapped(&addr_l.addr6)) {
> +		ipv6_addr_set_v4mapped(addr_r.addr.s_addr, &addr_r.addr6);
> +		addr_r.family = AF_INET6;
> +	}
> +#endif
> 	if (addr_l.family != addr_r.family) {
> 		GENL_SET_ERR_MSG(info, "address families do not match");
> 		err = -EINVAL;
> -- 
> 2.39.2
>
>
>