Skip to contentSkip to conversation

fixes for "map v4 address to v6"

PATCH In review Geliang Tang 4 participants 11 messages Feb 7, 2024 – Feb 14, 2024

Subsystems (3)
lore
Share & tools
lore

Geliang Tang

author reviewer
#0 lore raw

v3 cover fixes for "map v4 address to v6"

From: Geliang Tang <[email protected]>

v3:
- add a new argument addr for mptcp_lib_evts_get_info, instead of a new helper mptcp_lib_evts_get_info_with_addr

v2:
- update selftests as Mat suggested.

Geliang Tang (2):
mptcp: map v4 address to v6 when destroying subflow
selftests: mptcp: rm subflow with v4/v4mapped addr

 net/mptcp/pm_userspace.c                      | 10 +++++++
 .../testing/selftests/net/mptcp/mptcp_join.sh | 28 +++++++++++--------
 .../testing/selftests/net/mptcp/mptcp_lib.sh  |  7 +++--
 3 files changed, 31 insertions(+), 14 deletions(-)
Signature · 1 line
2.40.1
author reviewer
#1 lore raw

PATCH v3 1/2 mptcp: map v4 address to v6 when destroying subflow

From: Geliang Tang <[email protected]>

Address family of server side mismatches with that of client side, like in "userspace pm add & remove address" test:

    userspace_pm_add_addr $ns1 10.0.2.1 10
    userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $SUB_ESTABLISHED

That's because on the server side, the family is set to AF_INET6 and the v4 address is mapped in a v6 one.

This patch fixes this issue. 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")
---
 net/mptcp/pm_userspace.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
net/mptcp/pm_userspace.c +10 -0
index e582b3b2d174..b40a69649fe1 100644
@@ -495,6 +495,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;
Signature · 1 line
2.40.1
author reviewer
#2 lore raw

PATCH v3 2/2 selftests: mptcp: rm subflow with v4/v4mapped addr

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Now both a v4 address and a v4-mapped address are supported when destroying a userspace pm subflow, this patch adds a second subflow to "userspace pm add & remove address" test, and two subflows could be removed two different ways, one with the v4mapped and one with v4.

Fixes 48d73f609dcc ("selftests: mptcp: update userspace pm addr tests")
---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 28 +++++++++++--------
 .../testing/selftests/net/mptcp/mptcp_lib.sh  |  7 +++--
 2 files changed, 21 insertions(+), 14 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +16 -12
index c07386e21e0a..e68b1bc2c2e4 100755
@@ -3333,16 +3333,17 @@ userspace_pm_rm_sf()
 {
 	local evts=$evts_ns1
 	local t=${3:-1}
-	local ip=4
+	local ip
 	local tk da dp sp
 	local cnt
 
 	[ "$1" == "$ns2" ] && evts=$evts_ns2
-	if mptcp_lib_is_v6 $2; then ip=6; fi
+	[ -n "$(mptcp_lib_evts_get_info "saddr4" "$evts" $t)" ] && ip=4
+	[ -n "$(mptcp_lib_evts_get_info "saddr6" "$evts" $t)" ] && ip=6
 	tk=$(mptcp_lib_evts_get_info token "$evts")
-	da=$(mptcp_lib_evts_get_info "daddr$ip" "$evts" $t)
-	dp=$(mptcp_lib_evts_get_info dport "$evts" $t)
-	sp=$(mptcp_lib_evts_get_info sport "$evts" $t)
+	da=$(mptcp_lib_evts_get_info "daddr$ip" "$evts" $t $2)
+	dp=$(mptcp_lib_evts_get_info dport "$evts" $t $2)
+	sp=$(mptcp_lib_evts_get_info sport "$evts" $t $2)
 
 	cnt=$(rm_sf_count ${1})
 	ip netns exec $1 ./pm_nl_ctl dsf lip $2 lport $sp \
@@ -3429,20 +3430,23 @@ userspace_tests()
 	if reset_with_events "userspace pm add & remove address" &&
 	   continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
 		set_userspace_pm $ns1
-		pm_nl_set_limits $ns2 1 1
+		pm_nl_set_limits $ns2 2 2
 		speed=5 \
 			run_tests $ns1 $ns2 10.0.1.1 &
 		local tests_pid=$!
 		wait_mpj $ns1
 		userspace_pm_add_addr $ns1 10.0.2.1 10
-		chk_join_nr 1 1 1
-		chk_add_nr 1 1
-		chk_mptcp_info subflows 1 subflows 1
-		chk_subflows_total 2 2
-		chk_mptcp_info add_addr_signal 1 add_addr_accepted 1
+		userspace_pm_add_addr $ns1 10.0.3.1 20
+		chk_join_nr 2 2 2
+		chk_add_nr 2 2
+		chk_mptcp_info subflows 2 subflows 2
+		chk_subflows_total 3 3
+		chk_mptcp_info add_addr_signal 2 add_addr_accepted 2
 		userspace_pm_rm_addr $ns1 10
 		userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $SUB_ESTABLISHED
-		chk_rm_nr 1 1 invert
+		userspace_pm_rm_addr $ns1 20
+		userspace_pm_rm_sf $ns1 10.0.3.1 $SUB_ESTABLISHED
+		chk_rm_nr 2 2 invert
 		chk_mptcp_info subflows 0 subflows 0
 		chk_subflows_total 1 1
 		kill_events_pids
tools/testing/selftests/net/mptcp/mptcp_lib.sh +5 -2
index 3a2abae5993e..69001d2a8dab 100644
@@ -213,9 +213,12 @@ mptcp_lib_get_info_value() {
 	grep "${2}" | sed -n 's/.*\('"${1}"':\)\([0-9a-f:.]*\).*$/\2/p;q'
 }
 
-# $1: info name ; $2: evts_ns ; $3: event type
+# $1: info name ; $2: evts_ns ; $3: event type; $4: addr
 mptcp_lib_evts_get_info() {
-	mptcp_lib_get_info_value "${1}" "^type:${3:-1}," < "${2}"
+	local addr=${4:-""}
+
+	cat "${2}" | grep "${addr}" |
+	mptcp_lib_get_info_value "${1}" "^type:${3:-1},"
 }
 
 # $1: PID
Signature · 1 line
2.40.1
#3 lore raw

Re: selftests: mptcp: rm subflow with v4/v4mapped addr: Tests Results

Hi Geliang,

Thank you for your modifications, that's great!

Our CI (GitHub Action) did some validations and here is its report:

- KVM Validation: normal:
- Success! ✅:
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/7808971609

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/d954c612ab76

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-normal

For 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)

#4 lore raw

Re: selftests: mptcp: rm subflow with v4/v4mapped addr: Tests Results

In reply to Geliang Tang

Hi Geliang,

Thank you for your modifications, that's great!

Our CI (Cirrus) did some validations with a debug kernel and here is its report:

- KVM Validation: debug (except selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5682143834144768
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5682143834144768/summary/summary.txt

- KVM Validation: debug (only selftest_mptcp_join):
- Unstable: 1 failed test(s): selftest_mptcp_join 🔴:
- Task: https://cirrus-ci.com/task/5119193880723456
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5119193880723456/summary/summary.txt

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/d954c612ab76

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-debug

For 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)

#5 lore raw

Re: selftests: mptcp: rm subflow with v4/v4mapped addr: Tests Results

In reply to Geliang Tang

Hi Geliang,

Thank you for your modifications, that's great!

Our CI (GitHub Action) did some validations and here is its report:

- KVM Validation: normal:
- Success! ✅:
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/7895424329

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/9b8ecb217a79

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-normal

For 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)

#6 lore raw

Re: selftests: mptcp: rm subflow with v4/v4mapped addr: Tests Results

In reply to Geliang Tang

Hi Geliang,

Thank you for your modifications, that's great!

Our CI (Cirrus) did some validations with a debug kernel and here is its report:

- KVM Validation: debug (except selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5714999662870528
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5714999662870528/summary/summary.txt

- KVM Validation: debug (only selftest_mptcp_join):
- Unstable: 1 failed test(s): selftest_mptcp_join 🔴:
- Task: https://cirrus-ci.com/task/5152049709449216
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5152049709449216/summary/summary.txt

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/9b8ecb217a79

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-debug

For 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)

maintainer
#7 lore raw

Re: [PATCH mptcp-next v3 2/2] selftests: mptcp: rm subflow with v4/v4mapped addr

In reply to Geliang Tang

Hi Geliang,

Quoted 6 lines · Geliang Tang

From: Geliang Tang <[email protected]>

Now both a v4 address and a v4-mapped address are supported when destroying a userspace pm subflow, this patch adds a second subflow to "userspace pm add & remove address" test, and two subflows could be removed two different ways, one with the v4mapped and one with v4.

Thank you for validating this.

Quoted 6 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +0 -0
index 3a2abae5993e..69001d2a8dab 100644
@@ -213,9 +213,12 @@ mptcp_lib_get_info_value() {
 	grep "${2}" | sed -n 's/.*\('"${1}"':\)\([0-9a-f:.]*\).*$/\2/p;q'

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_get_info_value() { · line 221

Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +5 -2
 }
 
-# $1: info name ; $2: evts_ns ; $3: event type
+# $1: info name ; $2: evts_ns ; $3: event type; $4: addr
 mptcp_lib_evts_get_info() {
-	mptcp_lib_get_info_value "${1}" "^type:${3:-1}," < "${2}"
+	local addr=${4:-""}
+
+	cat "${2}" | grep "${addr}" |
+	mptcp_lib_get_info_value "${1}" "^type:${3:-1},"

When modifying shell scripts, please make sure 'shellcheck' is happy with the modifications you did.

Quoted 8 lines
$ shellcheck -x mptcp_lib.sh

In mptcp_lib.sh line 220:

        cat "${2}" | grep "${addr}" |
            ^----^ SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.

For more information:
https://www.shellcheck.net/wiki/SC2002 -- Useless cat. Consider 'cmd < file...

I then did this modification when applying the patch:

Quoted 9 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +0 -1
index 69001d2a8dab..3777d66fc56d 100644
@@ -213,12 +213,9 @@ mptcp_lib_get_info_value() {
        grep "${2}" | sed -n 's/.*\('"${1}"':\)\([0-9a-f:.]*\).*$/\2/p;q'
 }
 
-# $1: info name ; $2: evts_ns ; $3: event type; $4: addr

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_get_info_value() { · line 221

Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +2 -4
+# $1: info name ; $2: evts_ns ; [$3: event type; [$4: addr]]
 mptcp_lib_evts_get_info() {
-       local addr=${4:-""}
-
-       cat "${2}" | grep "${addr}" |
-       mptcp_lib_get_info_value "${1}" "^type:${3:-1},"
+       grep "${4:-}" "${2}" | mptcp_lib_get_info_value "${1}" "^type:${3:-1},"
 }
 
 # $1: PID

Note that it is not strictly needed to add ':-' in '${4:-}' (we don't use 'set -u'), but it clearly shows the argument is optional.

I also edited the comment above the declaration of the function to reflect that.

About 'shellcheck', please note that for the moment, not all scripts are shellcheck compliant, only 'mptcp_join.sh', 'mptcp_lib.sh' and 'userspace_pm.sh'. For the others, it would be great if at the least the new code is shellcheck compliant. I don't think it is needed to modify the existing ones, they are not often modified and they work. (Except maybe if there are some other big modifications needed.)

Also, some checks can be ignored with '# shellcheck disable=XXXX' directive if needed:

https://www.shellcheck.net/wiki/Ignore

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
author reviewer
#8 lore raw

Re: [PATCH mptcp-next v3 2/2] selftests: mptcp: rm subflow with v4/v4mapped addr

Hi Matt,

Quoted 20 lines · Matthieu Baerts

Hi Geliang,

Quoted 6 lines · Geliang Tang

From: Geliang Tang <[email protected]>

Now both a v4 address and a v4-mapped address are supported when destroying a userspace pm subflow, this patch adds a second subflow to "userspace pm add & remove address" test, and two subflows could be removed two different ways, one with the v4mapped and one with v4.

Thank you for validating this.

Quoted 8 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +0 -0
index 3a2abae5993e..69001d2a8dab 100644
@@ -213,9 +213,12 @@ mptcp_lib_get_info_value() {
 	grep "${2}" | sed -n 's/.*\('"${1}"':\)\([0-9a-f:.]*\).*$/\2/p;q'
 }
 
Quoted 11 lines

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_get_info_value() { · line 221

Quoted 8 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +5 -2
-# $1: info name ; $2: evts_ns ; $3: event type
+# $1: info name ; $2: evts_ns ; $3: event type; $4: addr
 mptcp_lib_evts_get_info() {
-	mptcp_lib_get_info_value "${1}" "^type:${3:-1}," < "${2}"
+	local addr=${4:-""}
+
+	cat "${2}" | grep "${addr}" |
+	mptcp_lib_get_info_value "${1}" "^type:${3:-1},"

When modifying shell scripts, please make sure 'shellcheck' is happy with the modifications you did.

Sure, I'll use shellcheck to check my script modifications next time.

Quoted 11 lines
Quoted 9 lines
$ shellcheck -x mptcp_lib.sh

In mptcp_lib.sh line 220:

        cat "${2}" | grep "${addr}" |
            ^----^ SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.

For more information:
https://www.shellcheck.net/wiki/SC2002 -- Useless cat. Consider 'cmd < file...

I then did this modification when applying the patch:

Thanks a lot.

-Geliang

Quoted 43 lines
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +0 -1
index 69001d2a8dab..3777d66fc56d 100644
@@ -213,12 +213,9 @@ mptcp_lib_get_info_value() {
        grep "${2}" | sed -n 's/.*\('"${1}"':\)\([0-9a-f:.]*\).*$/\2/p;q'
 }
 
-# $1: info name ; $2: evts_ns ; $3: event type; $4: addr

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_get_info_value() { · line 221

Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +2 -4
+# $1: info name ; $2: evts_ns ; [$3: event type; [$4: addr]]
 mptcp_lib_evts_get_info() {
-       local addr=${4:-""}
-
-       cat "${2}" | grep "${addr}" |
-       mptcp_lib_get_info_value "${1}" "^type:${3:-1},"
+       grep "${4:-}" "${2}" | mptcp_lib_get_info_value "${1}" "^type:${3:-1},"
 }
 
 # $1: PID

Note that it is not strictly needed to add ':-' in '${4:-}' (we don't use 'set -u'), but it clearly shows the argument is optional.

I also edited the comment above the declaration of the function to reflect that.

About 'shellcheck', please note that for the moment, not all scripts are shellcheck compliant, only 'mptcp_join.sh', 'mptcp_lib.sh' and 'userspace_pm.sh'. For the others, it would be great if at the least the new code is shellcheck compliant. I don't think it is needed to modify the existing ones, they are not often modified and they work. (Except maybe if there are some other big modifications needed.)

Also, some checks can be ignored with '# shellcheck disable=XXXX' directive if needed:

https://www.shellcheck.net/wiki/Ignore

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
maintainer Reviewed-by on the v3 series
#9 lore raw
In reply to Geliang Tang
Quoted 5 lines · Geliang Tang

From: Geliang Tang <[email protected]>

v3:
- add a new argument addr for mptcp_lib_evts_get_info, instead of a new helper mptcp_lib_evts_get_info_with_addr

v3 looks good to me, thanks Geliang.

Quoted 18 lines

v2:
- update selftests as Mat suggested.

Geliang Tang (2):
mptcp: map v4 address to v6 when destroying subflow
selftests: mptcp: rm subflow with v4/v4mapped addr

net/mptcp/pm_userspace.c                      | 10 +++++++
.../testing/selftests/net/mptcp/mptcp_join.sh | 28 +++++++++++--------
.../testing/selftests/net/mptcp/mptcp_lib.sh  |  7 +++--
3 files changed, 31 insertions(+), 14 deletions(-)
Signature · 1 line
2.40.1
maintainer
#10 lore raw
In reply to Geliang Tang

Hi Geliang, Mat,

Quoted 6 lines · Geliang Tang

From: Geliang Tang <[email protected]>

v3:
- add a new argument addr for mptcp_lib_evts_get_info, instead of a new helper mptcp_lib_evts_get_info_with_addr

Quoted 6 lines

v2:
- update selftests as Mat suggested.

Geliang Tang (2):
mptcp: map v4 address to v6 when destroying subflow
selftests: mptcp: rm subflow with v4/v4mapped addr

Thank you for the patches and the reviews!

Now in our tree (fixes for -net), with Mat and my RvB tags, and the modification I mentioned in patch 2/2.

New patches for t/upstream-net and t/upstream:
- cc6b8f6f3d24: mptcp: map v4 address to v6 when destroying subflow
- bbc429327d25: selftests: mptcp: rm subflow with v4/v4mapped addr
- Results: 0675fccde951..abfdc616f556 (export-net)
- Results: f63a9c1dbbaa..ce1856db2249 (export)

Tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export-net/20240214T102432
https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20240214T102432

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.