Skip to contentSkip to conversation

move to next addr and testcases

PATCH Superseded Geliang Tang 2 participants 6 messages Feb 8, 2021 – Feb 9, 2021

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Geliang Tang

author
#0 lore raw

v2 cover move to next addr and testcases

v2:
- add patch 2 and 3 for removing testcases.
- tag: export/20210207T062839.

Geliang Tang (4):
mptcp: move to next addr when subflow creation fail
selftests: mptcp: add invert argument for chk_rm_nr
selftests: mptcp: set addr id for removing testcases
selftests: mptcp: signal addresses testcases

 net/mptcp/options.c                           |   1 +
 net/mptcp/pm.c                                |  15 +++
 net/mptcp/pm_netlink.c                        |  13 ++-
 net/mptcp/protocol.h                          |   4 +
 .../testing/selftests/net/mptcp/mptcp_join.sh | 105 ++++++++++++++----
 5 files changed, 117 insertions(+), 21 deletions(-)
Signature · 1 line
2.29.2
author
#1 lore raw

PATCH v2 1/4 mptcp: move to next addr when subflow creation fail

When an invalid address was announced, the subflow couldn't be created for this address. Therefore mptcp_pm_nl_subflow_established couldn't be invoked. Then the next addresses in the local address list didn't have a chance to be announced.

This patch invokes the new function mptcp_pm_add_addr_echoed when the address is echoed. In it, use lookup_subflow_by_saddr to check whether this address is in the conn_list. If it isn't, PM schedule the new status MPTCP_PM_NEXT_ADDR to invoke mptcp_pm_nl_next_addr.

In mptcp_pm_nl_next_addr, invoke mptcp_pm_create_subflow_or_signal_addr to deal with the next address in the local address list.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/options.c    |  1 +
 net/mptcp/pm.c         | 15 +++++++++++++++
 net/mptcp/pm_netlink.c | 13 +++++++++++--
 net/mptcp/protocol.h   |  4 ++++
 4 files changed, 31 insertions(+), 2 deletions(-)
net/mptcp/options.c +1 -0
index bb874c5d663a..1c5c99c06951 100644
@@ -1022,6 +1022,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
 			mptcp_pm_add_addr_received(msk, &addr);
 			MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_ADDADDR);
 		} else {
+			mptcp_pm_add_addr_echoed(msk, &addr);
 			mptcp_pm_del_add_timer(msk, &addr);
 			MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_ECHOADD);
 		}
net/mptcp/pm.c +15 -0
index 6fd4b2c1b076..a6d068d801d0 100644
@@ -197,6 +197,21 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk,
 	spin_unlock_bh(&pm->lock);
 }
 
+void mptcp_pm_add_addr_echoed(struct mptcp_sock *msk, struct mptcp_addr_info *addr)
+{
+	struct mptcp_pm_data *pm = &msk->pm;
+
+	pr_debug("msk=%p", msk);
+
+	spin_lock_bh(&pm->lock);
+
+	__mptcp_flush_join_list(msk);
+	if (!lookup_subflow_by_saddr(&msk->conn_list, addr))
+		mptcp_pm_schedule_work(msk, MPTCP_PM_NEXT_ADDR);
+
+	spin_unlock_bh(&pm->lock);
+}
+
 void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk)
 {
 	if (!mptcp_pm_should_add_signal(msk))
net/mptcp/pm_netlink.c +11 -2
index 8e8e35fa4002..d9eaee2037bd 100644
@@ -122,8 +122,8 @@ static void remote_address(const struct sock_common *skc,
 #endif
 }
 
-static bool lookup_subflow_by_saddr(const struct list_head *list,
-				    struct mptcp_addr_info *saddr)
+bool lookup_subflow_by_saddr(const struct list_head *list,
+			     struct mptcp_addr_info *saddr)
 {
 	struct mptcp_subflow_context *subflow;
 	struct mptcp_addr_info cur;
@@ -608,6 +608,11 @@ static void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
 	}
 }
 
+static void mptcp_pm_nl_next_addr(struct mptcp_sock *msk)
+{
+	mptcp_pm_create_subflow_or_signal_addr(msk);
+}
+
 void mptcp_pm_nl_work(struct mptcp_sock *msk)
 {
 	struct mptcp_pm_data *pm = &msk->pm;
@@ -629,6 +634,10 @@ void mptcp_pm_nl_work(struct mptcp_sock *msk)
 		pm->status &= ~BIT(MPTCP_PM_RM_ADDR_RECEIVED);
 		mptcp_pm_nl_rm_addr_received(msk);
 	}
+	if (pm->status & BIT(MPTCP_PM_NEXT_ADDR)) {
+		pm->status &= ~BIT(MPTCP_PM_NEXT_ADDR);
+		mptcp_pm_nl_next_addr(msk);
+	}
 	if (pm->status & BIT(MPTCP_PM_ESTABLISHED)) {
 		pm->status &= ~BIT(MPTCP_PM_ESTABLISHED);
 		mptcp_pm_nl_fully_established(msk);
net/mptcp/protocol.h +4 -0
index de488c3a286e..7ad0dfef36bd 100644
@@ -176,6 +176,7 @@ enum mptcp_pm_status {
 	MPTCP_PM_ADD_ADDR_RECEIVED,
 	MPTCP_PM_ADD_ADDR_SEND_ACK,
 	MPTCP_PM_RM_ADDR_RECEIVED,
+	MPTCP_PM_NEXT_ADDR,
 	MPTCP_PM_ESTABLISHED,
 	MPTCP_PM_ALREADY_ESTABLISHED,	/* persistent status, set after ESTABLISHED event */
 	MPTCP_PM_SUBFLOW_ESTABLISHED,
@@ -659,6 +660,9 @@ void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup);
 int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,
 				 struct mptcp_addr_info *addr,
 				 u8 bkup);
+void mptcp_pm_add_addr_echoed(struct mptcp_sock *msk, struct mptcp_addr_info *addr);
+bool lookup_subflow_by_saddr(const struct list_head *list,
+			     struct mptcp_addr_info *saddr);
 void mptcp_pm_free_anno_list(struct mptcp_sock *msk);
 bool mptcp_pm_sport_in_anno_list(struct mptcp_sock *msk, const struct sock *sk);
 struct mptcp_pm_add_entry *
Signature · 1 line
2.29.2
author
#2 lore raw

PATCH v2 2/4 selftests: mptcp: add invert argument for chk_rm_nr

Some of the removing testcases used two zeros as arguments for chk_rm_nr like this: chk_rm_nr 0 0. This dosen't mean that no RM_ADDR has been sent. It only means that RM_ADDR had been sent in the opposite direction that chk_rm_nr is checking.

This patch added a new argument invert for chk_rm_nr to allow it can check the RM_ADDR from the opposite direction.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 21 ++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +16 -5
index 964db9ed544f..15b71ddee615 100755
@@ -610,11 +610,22 @@ chk_rm_nr()
 {
 	local rm_addr_nr=$1
 	local rm_subflow_nr=$2
+	local invert=${3:-""}
 	local count
 	local dump_stats
+	local addr_ns
+	local subflow_ns
+
+	if [ -z $invert ]; then
+		addr_ns=$ns1
+		subflow_ns=$ns2
+	elif [ $invert = "invert" ]; then
+		addr_ns=$ns2
+		subflow_ns=$ns1
+	fi
 
 	printf "%-39s %s" " " "rm "
-	count=`ip netns exec $ns1 nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'`
+	count=`ip netns exec $addr_ns nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'`
 	[ -z "$count" ] && count=0
 	if [ "$count" != "$rm_addr_nr" ]; then
 		echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr"
@@ -625,7 +636,7 @@ chk_rm_nr()
 	fi
 
 	echo -n " - sf    "
-	count=`ip netns exec $ns2 nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}'`
+	count=`ip netns exec $subflow_ns nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}'`
 	[ -z "$count" ] && count=0
 	if [ "$count" != "$rm_subflow_nr" ]; then
 		echo "[fail] got $count RM_SUBFLOW[s] expected $rm_subflow_nr"
@@ -833,7 +844,7 @@ remove_tests()
 	run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow
 	chk_join_nr "remove single address" 1 1 1
 	chk_add_nr 1 1
-	chk_rm_nr 0 0
+	chk_rm_nr 1 1 invert
 
 	# subflow and signal, remove
 	reset
@@ -945,7 +956,7 @@ ipv6_tests()
 	run_tests $ns1 $ns2 dead:beef:1::1 0 -1 0 slow
 	chk_join_nr "remove single address IPv6" 1 1 1
 	chk_add_nr 1 1
-	chk_rm_nr 0 0
+	chk_rm_nr 1 1 invert
 
 	# subflow and signal IPv6, remove
 	reset
@@ -1088,7 +1099,7 @@ add_addr_ports_tests()
 	run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow
 	chk_join_nr "remove single address with port" 1 1 1
 	chk_add_nr 1 1 1
-	chk_rm_nr 0 0
+	chk_rm_nr 1 1 invert
 
 	# subflow and signal with port, remove
 	reset
Signature · 1 line
2.29.2
author
#3 lore raw

PATCH v2 3/4 selftests: mptcp: set addr id for removing testcases

The removing testcases can only delete the addresses from id 1, this patch added the support for deleting the addresses from any id that user set.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 38 ++++++++++++-------
 1 file changed, 24 insertions(+), 14 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +24 -14
index 15b71ddee615..6782a891b3e7 100755
@@ -284,14 +284,19 @@ do_transfer()
 		let rm_nr_ns1=-addr_nr_ns1
 		if [ $rm_nr_ns1 -lt 8 ]; then
 			counter=1
-			sleep 1
-
-			while [ $counter -le $rm_nr_ns1 ]
-			do
-				ip netns exec ${listener_ns} ./pm_nl_ctl del $counter
+			dump=(`ip netns exec ${listener_ns} ./pm_nl_ctl dump`)
+			if [ ${#dump[@]} -gt 0 ]; then
+				id=${dump[1]}
 				sleep 1
-				let counter+=1
-			done
+
+				while [ $counter -le $rm_nr_ns1 ]
+				do
+					ip netns exec ${listener_ns} ./pm_nl_ctl del $id
+					sleep 1
+					let counter+=1
+					let id+=1
+				done
+			fi
 		else
 			sleep 1
 			ip netns exec ${listener_ns} ./pm_nl_ctl flush
@@ -318,14 +323,19 @@ do_transfer()
 		let rm_nr_ns2=-addr_nr_ns2
 		if [ $rm_nr_ns2 -lt 8 ]; then
 			counter=1
-			sleep 1
-
-			while [ $counter -le $rm_nr_ns2 ]
-			do
-				ip netns exec ${connector_ns} ./pm_nl_ctl del $counter
+			dump=(`ip netns exec ${connector_ns} ./pm_nl_ctl dump`)
+			if [ ${#dump[@]} -gt 0 ]; then
+				id=${dump[1]}
 				sleep 1
-				let counter+=1
-			done
+
+				while [ $counter -le $rm_nr_ns2 ]
+				do
+					ip netns exec ${connector_ns} ./pm_nl_ctl del $id
+					sleep 1
+					let counter+=1
+					let id+=1
+				done
+			fi
 		else
 			sleep 1
 			ip netns exec ${connector_ns} ./pm_nl_ctl flush
Signature · 1 line
2.29.2
author
#4 lore raw

PATCH v2 4/4 selftests: mptcp: signal addresses testcases

This patch added testcases for signalling multi valid and invalid addresses for both signal_address_tests and remove_tests.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_join.sh +46 -0
index 6782a891b3e7..b0af4f8c3b02 100755
@@ -788,6 +788,28 @@ signal_address_tests()
 	run_tests $ns1 $ns2 10.0.1.1
 	chk_join_nr "multiple subflows and signal" 3 3 3
 	chk_add_nr 1 1
+
+	# signal addresses
+	reset
+	ip netns exec $ns1 ./pm_nl_ctl limits 3 3
+	ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal
+	ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal
+	ip netns exec $ns1 ./pm_nl_ctl add 10.0.4.1 flags signal
+	ip netns exec $ns2 ./pm_nl_ctl limits 3 3
+	run_tests $ns1 $ns2 10.0.1.1
+	chk_join_nr "signal addresses" 3 3 3
+	chk_add_nr 3 3
+
+	# signal invalid addresses
+	reset
+	ip netns exec $ns1 ./pm_nl_ctl limits 3 3
+	ip netns exec $ns1 ./pm_nl_ctl add 10.0.12.1 flags signal
+	ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal
+	ip netns exec $ns1 ./pm_nl_ctl add 10.0.14.1 flags signal
+	ip netns exec $ns2 ./pm_nl_ctl limits 3 3
+	run_tests $ns1 $ns2 10.0.1.1
+	chk_join_nr "signal invalid addresses" 1 1 1
+	chk_add_nr 3 3
 }
 
 link_failure_tests()
@@ -879,6 +901,30 @@ remove_tests()
 	chk_add_nr 1 1
 	chk_rm_nr 2 2
 
+	# addresses remove
+	reset
+	ip netns exec $ns1 ./pm_nl_ctl limits 3 3
+	ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal id 250
+	ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal
+	ip netns exec $ns1 ./pm_nl_ctl add 10.0.4.1 flags signal
+	ip netns exec $ns2 ./pm_nl_ctl limits 3 3
+	run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow
+	chk_join_nr "remove addresses" 3 3 3
+	chk_add_nr 3 3
+	chk_rm_nr 3 3 invert
+
+	# invalid addresses remove
+	reset
+	ip netns exec $ns1 ./pm_nl_ctl limits 3 3
+	ip netns exec $ns1 ./pm_nl_ctl add 10.0.12.1 flags signal
+	ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal
+	ip netns exec $ns1 ./pm_nl_ctl add 10.0.14.1 flags signal
+	ip netns exec $ns2 ./pm_nl_ctl limits 3 3
+	run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow
+	chk_join_nr "remove invalid addresses" 1 1 1
+	chk_add_nr 3 3
+	chk_rm_nr 3 1 invert
+
 	# subflows and signal, flush
 	reset
 	ip netns exec $ns1 ./pm_nl_ctl limits 0 3
Signature · 1 line
2.29.2
#5 lore raw

[MPTCP] Re: [MPTCP][PATCH v2 mptcp-next 1/4] mptcp: move to next addr when subflow creation fail

In reply to Geliang Tang
Quoted 40 lines · Geliang Tang

When an invalid address was announced, the subflow couldn't be created for this address. Therefore mptcp_pm_nl_subflow_established couldn't be invoked. Then the next addresses in the local address list didn't have a chance to be announced.

This patch invokes the new function mptcp_pm_add_addr_echoed when the address is echoed. In it, use lookup_subflow_by_saddr to check whether this address is in the conn_list. If it isn't, PM schedule the new status MPTCP_PM_NEXT_ADDR to invoke mptcp_pm_nl_next_addr.

In mptcp_pm_nl_next_addr, invoke mptcp_pm_create_subflow_or_signal_addr to deal with the next address in the local address list.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>

---

net/mptcp/options.c    |  1 +
net/mptcp/pm.c         | 15 +++++++++++++++
net/mptcp/pm_netlink.c | 13 +++++++++++--
net/mptcp/protocol.h   |  4 ++++
4 files changed, 31 insertions(+), 2 deletions(-)
net/mptcp/options.c +1 -0
index bb874c5d663a..1c5c99c06951 100644
@@ -1022,6 +1022,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
 			mptcp_pm_add_addr_received(msk, &addr);
 			MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_ADDADDR);
 		} else {
+			mptcp_pm_add_addr_echoed(msk, &addr);
 			mptcp_pm_del_add_timer(msk, &addr);
 			MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_ECHOADD);
 		}
net/mptcp/pm.c +0 -0
index 6fd4b2c1b076..a6d068d801d0 100644
@@ -197,6 +197,21 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk,
 	spin_unlock_bh(&pm->lock);
 }

net/mptcp/pm.c void mptcp_pm_add_addr_received(struct mptcp_sock *msk, · line 208

Quoted 10 lines
net/mptcp/pm.c +9 -0
 
+void mptcp_pm_add_addr_echoed(struct mptcp_sock *msk, struct mptcp_addr_info *addr)
+{
+	struct mptcp_pm_data *pm = &msk->pm;
+
+	pr_debug("msk=%p", msk);
+
+	spin_lock_bh(&pm->lock);
+
+	__mptcp_flush_join_list(msk);

The msk lock needs to be held to call this and to iterate over msk->conn_list.

Quoted 52 lines
net/mptcp/pm.c +6 -0
+	if (!lookup_subflow_by_saddr(&msk->conn_list, addr))
+		mptcp_pm_schedule_work(msk, MPTCP_PM_NEXT_ADDR);
+
+	spin_unlock_bh(&pm->lock);
+}
+
 void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk)
 {
 	if (!mptcp_pm_should_add_signal(msk))
net/mptcp/pm_netlink.c +11 -2
index 8e8e35fa4002..d9eaee2037bd 100644
@@ -122,8 +122,8 @@ static void remote_address(const struct sock_common *skc,
 #endif
 }
 
-static bool lookup_subflow_by_saddr(const struct list_head *list,
-				    struct mptcp_addr_info *saddr)
+bool lookup_subflow_by_saddr(const struct list_head *list,
+			     struct mptcp_addr_info *saddr)
 {
 	struct mptcp_subflow_context *subflow;
 	struct mptcp_addr_info cur;
@@ -608,6 +608,11 @@ static void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
 	}
 }
 
+static void mptcp_pm_nl_next_addr(struct mptcp_sock *msk)
+{
+	mptcp_pm_create_subflow_or_signal_addr(msk);
+}
+
 void mptcp_pm_nl_work(struct mptcp_sock *msk)
 {
 	struct mptcp_pm_data *pm = &msk->pm;
@@ -629,6 +634,10 @@ void mptcp_pm_nl_work(struct mptcp_sock *msk)
 		pm->status &= ~BIT(MPTCP_PM_RM_ADDR_RECEIVED);
 		mptcp_pm_nl_rm_addr_received(msk);
 	}
+	if (pm->status & BIT(MPTCP_PM_NEXT_ADDR)) {
+		pm->status &= ~BIT(MPTCP_PM_NEXT_ADDR);
+		mptcp_pm_nl_next_addr(msk);
+	}
 	if (pm->status & BIT(MPTCP_PM_ESTABLISHED)) {
 		pm->status &= ~BIT(MPTCP_PM_ESTABLISHED);
 		mptcp_pm_nl_fully_established(msk);
net/mptcp/protocol.h +0 -0
index de488c3a286e..7ad0dfef36bd 100644

net/mptcp/protocol.h enum mptcp_pm_status { · line 179

Quoted 4 lines
net/mptcp/protocol.h +1 -0
@@ -176,6 +176,7 @@ enum mptcp_pm_status {
 	MPTCP_PM_ADD_ADDR_RECEIVED,
 	MPTCP_PM_ADD_ADDR_SEND_ACK,
 	MPTCP_PM_RM_ADDR_RECEIVED,
+	MPTCP_PM_NEXT_ADDR,

It looks like this flag and MPTCP_PM_ESTABLISHED end up doing exactly the same thing. Could just reuse the existing event and calls.

Quoted 12 lines
net/mptcp/protocol.h +3 -0
 	MPTCP_PM_ESTABLISHED,
 	MPTCP_PM_ALREADY_ESTABLISHED,	/* persistent status, set after ESTABLISHED event */
 	MPTCP_PM_SUBFLOW_ESTABLISHED,
@@ -659,6 +660,9 @@ void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup);
 int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,
 				 struct mptcp_addr_info *addr,
 				 u8 bkup);
+void mptcp_pm_add_addr_echoed(struct mptcp_sock *msk, struct mptcp_addr_info *addr);
+bool lookup_subflow_by_saddr(const struct list_head *list,
+			     struct mptcp_addr_info *saddr);
 void mptcp_pm_free_anno_list(struct mptcp_sock *msk);
 bool mptcp_pm_sport_in_anno_list(struct mptcp_sock *msk, const struct sock *sk);
Quoted 3 lines

struct mptcp_pm_add_entry *

Signature · 1 line
2.29.2

--
Mat Martineau
Intel