Skip to contentSkip to conversation

MP_PRIO support

RFC PATCH In review Geliang Tang 2 participants 16 messages Nov 5, 2020 – Nov 19, 2020

Subsystems (3)
lore
Share & tools
lore

Geliang Tang

author
#0 lore raw

cover MP_PRIO support

This patchset implements the MP_PRIO logic according to the following lines in RFC8684:

"""
Another use of the MP_PRIO option is to set the "B" flag on a subflow to cleanly "retire" its use before closing it and removing it with RM_ADDR. """

Geliang Tang (6):
mptcp: add the outgoing MP_PRIO support
mptcp: add the incoming MP_PRIO support
mptcp: add prio_changed flag
mptcp: send out MP_PRIO before RM_ADDR
mptcp: add the mib for MP_PRIO
selftests: mptcp: add MP_PRIO check in chk_rm_nr

 include/net/mptcp.h                           |  1 +
 net/mptcp/mib.c                               |  1 +
 net/mptcp/mib.h                               |  1 +
 net/mptcp/options.c                           | 53 +++++++++++++++++++
 net/mptcp/pm.c                                | 11 ++++
 net/mptcp/pm_netlink.c                        | 32 +++++++++++
 net/mptcp/protocol.c                          |  4 +-
 net/mptcp/protocol.h                          | 14 +++++
 .../testing/selftests/net/mptcp/mptcp_join.sh | 34 ++++++++----
 9 files changed, 139 insertions(+), 12 deletions(-)
Signature · 1 line
2.26.2
author
#1 lore raw

RFC PATCH 1/6 mptcp: add the outgoing MP_PRIO support

This patch added the outgoing MP_PRIO logic:

In mptcp_pm_mp_prio_send_ack, find the related subflow and subsocket according to the input parameter address, then set subflow's send_mp_prio flag to true, and save the input priority value to suflow's prio_bkup. Finally, send out a pure ACK on the related subsocket.

In mptcp_established_options_mp_prio, check whether the subflow's send_mp_prio is set. If it is, this is the packet for send MP_PRIO. So save subflow->prio_bkup value to mptcp_out_options's prio_bkup, and change the option type to OPTION_MPTCP_PRIO.

In mptcp_write_options, sent out the MP_PRIO suboption with mptcp_out_options's prio_bkup value.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 include/net/mptcp.h    |  1 +
 net/mptcp/options.c    | 36 ++++++++++++++++++++++++++++++++++++
 net/mptcp/pm_netlink.c | 30 ++++++++++++++++++++++++++++++
 net/mptcp/protocol.h   |  7 +++++++
 4 files changed, 74 insertions(+)
include/net/mptcp.h +1 -0
index 5694370be3d4..f71259fb04cd 100644
@@ -51,6 +51,7 @@ struct mptcp_out_options {
 	u8 rm_id;
 	u8 join_id;
 	u8 backup;
+	u8 prio_bkup;
 	u32 nonce;
 	u64 thmac;
 	u32 token;
net/mptcp/options.c +36 -0
index f611fbcbd6d0..b74e6ab2d605 100644
@@ -665,6 +665,30 @@ static bool mptcp_established_options_rm_addr(struct sock *sk,
 	return true;
 }
 
+static bool mptcp_established_options_mp_prio(struct sock *sk,
+					      unsigned int *size,
+					      unsigned int remaining,
+					      struct mptcp_out_options *opts)
+{
+	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
+
+	if (!subflow->send_mp_prio)
+		return false;
+
+	if (remaining < TCPOLEN_MPTCP_PRIO)
+		return false;
+
+	subflow->send_mp_prio = 0;
+
+	*size = TCPOLEN_MPTCP_PRIO;
+	opts->suboptions |= OPTION_MPTCP_PRIO;
+	opts->prio_bkup = subflow->prio_bkup;
+
+	pr_debug("prio=%d", opts->prio_bkup);
+
+	return true;
+}
+
 bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
 			       unsigned int *size, unsigned int remaining,
 			       struct mptcp_out_options *opts)
@@ -707,6 +731,12 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
 		ret = true;
 	}
 
+	if (mptcp_established_options_mp_prio(sk, &opt_size, remaining, opts)) {
+		*size += opt_size;
+		remaining -= opt_size;
+		ret = true;
+	}
+
 	return ret;
 }
 
@@ -1138,6 +1168,12 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
 				      0, opts->rm_id);
 	}
 
+	if (OPTION_MPTCP_PRIO & opts->suboptions) {
+		*ptr++ = mptcp_option(MPTCPOPT_MP_PRIO,
+				      TCPOLEN_MPTCP_PRIO,
+				      opts->prio_bkup, TCPOPT_NOP);
+	}
+
 	if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) {
 		*ptr++ = mptcp_option(MPTCPOPT_MP_JOIN,
 				      TCPOLEN_MPTCP_MPJ_SYN,
net/mptcp/pm_netlink.c +30 -0
index 069447424ddb..a243017c4892 100644
@@ -441,6 +441,36 @@ void mptcp_pm_nl_add_addr_send_ack(struct mptcp_sock *msk)
 	}
 }
 
+void mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk,
+			       struct mptcp_addr_info *addr,
+			       u8 prio_bkup)
+{
+	struct mptcp_subflow_context *subflow, *tmp;
+
+	if (list_empty(&msk->conn_list))
+		return;
+
+	list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
+		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
+		struct mptcp_addr_info local;
+
+		local_address((struct sock_common *)ssk, &local);
+		if (!addresses_equal(&local, addr, false))
+			continue;
+
+		subflow->send_mp_prio = 1;
+		subflow->prio_bkup = prio_bkup;
+		spin_unlock_bh(&msk->pm.lock);
+		pr_debug("send ack for mp_prio");
+		lock_sock(ssk);
+		tcp_send_ack(ssk);
+		release_sock(ssk);
+		spin_lock_bh(&msk->pm.lock);
+
+		break;
+	}
+}
+
 void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
 {
 	struct mptcp_subflow_context *subflow, *tmp;
net/mptcp/protocol.h +7 -0
index b01c1fae9d8f..a8ed1de1cb05 100644
@@ -23,6 +23,7 @@
 #define OPTION_MPTCP_ADD_ADDR	BIT(6)
 #define OPTION_MPTCP_ADD_ADDR6	BIT(7)
 #define OPTION_MPTCP_RM_ADDR	BIT(8)
+#define OPTION_MPTCP_PRIO	BIT(9)
 
 /* MPTCP option subtypes */
 #define MPTCPOPT_MP_CAPABLE	0
@@ -59,6 +60,7 @@
 #define TCPOLEN_MPTCP_PORT_LEN		4
 #define TCPOLEN_MPTCP_ADD_ADDR_HMAC	8
 #define TCPOLEN_MPTCP_RM_ADDR_BASE	4
+#define TCPOLEN_MPTCP_PRIO		4
 
 /* MPTCP MP_JOIN flags */
 #define MPTCPOPT_BACKUP		BIT(0)
@@ -362,6 +364,7 @@ struct mptcp_subflow_context {
 		map_valid : 1,
 		mpc_map : 1,
 		backup : 1,
+		send_mp_prio : 1,
 		rx_eof : 1,
 		can_ack : 1,        /* only after processing the remote a key */
 		disposable : 1;	    /* ctx can be free at ulp release time */
@@ -373,6 +376,7 @@ struct mptcp_subflow_context {
 	u8	hmac[MPTCPOPT_HMAC_LEN];
 	u8	local_id;
 	u8	remote_id;
+	u8	prio_bkup;
 
 	struct	sock *tcp_sock;	    /* tcp sk backpointer */
 	struct	sock *conn;	    /* parent mptcp_sock */
@@ -515,6 +519,9 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk,
 				const struct mptcp_addr_info *addr);
 void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk);
 void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id);
+void mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk,
+			       struct mptcp_addr_info *addr,
+			       u8 prio_bkup);
 void mptcp_pm_free_anno_list(struct mptcp_sock *msk);
 struct mptcp_pm_add_entry *
 mptcp_pm_del_add_timer(struct mptcp_sock *msk,
Signature · 1 line
2.26.2
author
#2 lore raw

RFC PATCH 2/6 mptcp: add the incoming MP_PRIO support

This patch added the incoming MP_PRIO logic:

Added a flag named mp_prio in mptcp_options_received, to mark the MP_PRIO is received, and save the priority value to the new prio_bkup field. Then invoke mptcp_pm_mp_prio_received with the receiving subsocket and the prio_bkup value.

In mptcp_pm_mp_prio_received, find the subflow according the subsocket, and change the subflow's backup as the incoming priority value.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/options.c  | 16 ++++++++++++++++
 net/mptcp/pm.c       | 10 ++++++++++
 net/mptcp/protocol.h |  6 ++++++
 3 files changed, 32 insertions(+)
net/mptcp/options.c +16 -0
index b74e6ab2d605..affbadb77faf 100644
@@ -282,6 +282,15 @@ static void mptcp_parse_option(const struct sk_buff *skb,
 		pr_debug("RM_ADDR: id=%d", mp_opt->rm_id);
 		break;
 
+	case MPTCPOPT_MP_PRIO:
+		if (opsize != TCPOLEN_MPTCP_PRIO)
+			break;
+
+		mp_opt->mp_prio = 1;
+		mp_opt->prio_bkup = *ptr++ & MPTCP_PRIO_BKUP;
+		pr_debug("MP_PRIO: prio=%d", mp_opt->prio_bkup);
+		break;
+
 	default:
 		break;
 	}
@@ -302,6 +311,8 @@ void mptcp_get_options(const struct sk_buff *skb,
 	mp_opt->port = 0;
 	mp_opt->rm_addr = 0;
 	mp_opt->dss = 0;
+	mp_opt->mp_prio = 0;
+	mp_opt->prio_bkup = 0;
 
 	length = (th->doff * 4) - sizeof(struct tcphdr);
 	ptr = (const unsigned char *)(th + 1);
@@ -997,6 +1008,11 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
 		mp_opt.rm_addr = 0;
 	}
 
+	if (mp_opt.mp_prio) {
+		mptcp_pm_mp_prio_received(sk, mp_opt.prio_bkup);
+		mp_opt.mp_prio = 0;
+	}
+
 	if (!mp_opt.dss)
 		return;
 
net/mptcp/pm.c +10 -0
index e63e14f4cf2a..a4dc4aa39ad8 100644
@@ -188,6 +188,16 @@ void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id)
 	spin_unlock_bh(&pm->lock);
 }
 
+void mptcp_pm_mp_prio_received(struct sock *sk, u8 prio_bkup)
+{
+	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
+	struct mptcp_sock *msk = mptcp_sk(subflow->conn);
+
+	spin_lock_bh(&msk->pm.lock);
+	subflow->backup = prio_bkup;
+	spin_unlock_bh(&msk->pm.lock);
+}
+
 /* path manager helpers */
 
 bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
net/mptcp/protocol.h +6 -0
index a8ed1de1cb05..871b73046de0 100644
@@ -87,6 +87,9 @@
 #define MPTCP_ADDR_IPVERSION_4	4
 #define MPTCP_ADDR_IPVERSION_6	6
 
+/* MPTCP MP_PRIO flags */
+#define MPTCP_PRIO_BKUP		BIT(0)
+
 /* MPTCP socket flags */
 #define MPTCP_DATA_READY	0
 #define MPTCP_NOSPACE		1
@@ -115,6 +118,7 @@ struct mptcp_options_received {
 		dss : 1,
 		add_addr : 1,
 		rm_addr : 1,
+		mp_prio : 1,
 		family : 4,
 		echo : 1,
 		backup : 1;
@@ -140,6 +144,7 @@ struct mptcp_options_received {
 	};
 	u64	ahmac;
 	u16	port;
+	u8	prio_bkup;
 };
 
 static inline __be32 mptcp_option(u8 subopt, u8 len, u8 nib, u8 field)
@@ -519,6 +524,7 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk,
 				const struct mptcp_addr_info *addr);
 void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk);
 void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id);
+void mptcp_pm_mp_prio_received(struct sock *sk, u8 prio_bkup);
 void mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk,
 			       struct mptcp_addr_info *addr,
 			       u8 prio_bkup);
Signature · 1 line
2.26.2
author
#3 lore raw

RFC PATCH 3/6 mptcp: add prio_changed flag

This patch add a new flag named prio_changed in msk. When we received the MP_PRIO suboption, we set this flag to true.

In mptcp_subflow_get_send, we check whether prio_changed is set. If it is, we pick a new subflow to send data.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/pm.c       | 1 +
 net/mptcp/protocol.c | 4 +++-
 net/mptcp/protocol.h | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)
net/mptcp/pm.c +1 -0
index a4dc4aa39ad8..b6f4f54e6546 100644
@@ -195,6 +195,7 @@ void mptcp_pm_mp_prio_received(struct sock *sk, u8 prio_bkup)
 
 	spin_lock_bh(&msk->pm.lock);
 	subflow->backup = prio_bkup;
+	WRITE_ONCE(msk->prio_changed, true);
 	spin_unlock_bh(&msk->pm.lock);
 }
 
net/mptcp/protocol.c +3 -1
index a6bd06c724d5..7a7561ba9edf 100644
@@ -1133,7 +1133,8 @@ static struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk,
 	/* re-use last subflow, if the burst allow that */
 	if (msk->last_snd && msk->snd_burst > 0 &&
 	    sk_stream_memory_free(msk->last_snd) &&
-	    mptcp_subflow_active(mptcp_subflow_ctx(msk->last_snd))) {
+	    mptcp_subflow_active(mptcp_subflow_ctx(msk->last_snd)) &&
+	    !READ_ONCE(msk->prio_changed)) {
 		mptcp_for_each_subflow(msk, subflow) {
 			ssk =  mptcp_subflow_tcp_sock(subflow);
 			*sndbuf = max(tcp_sk(ssk)->snd_wnd, *sndbuf);
@@ -1180,6 +1181,7 @@ static struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk,
 		msk->last_snd = send_info[0].ssk;
 		msk->snd_burst = min_t(int, MPTCP_SEND_BURST_SIZE,
 				       sk_stream_wspace(msk->last_snd));
+		WRITE_ONCE(msk->prio_changed, false);
 		return msk->last_snd;
 	}
 	return NULL;
net/mptcp/protocol.h +1 -0
index 871b73046de0..c3386a6a7a16 100644
@@ -240,6 +240,7 @@ struct mptcp_sock {
 	bool		rcv_data_fin;
 	bool		snd_data_fin_enable;
 	bool		use_64bit_ack; /* Set when we received a 64-bit DSN */
+	bool		prio_changed;
 	spinlock_t	join_list_lock;
 	struct work_struct work;
 	struct sk_buff  *ooo_last_skb;
Signature · 1 line
2.26.2
author
#4 lore raw

RFC PATCH 4/6 mptcp: send out MP_PRIO before RM_ADDR

Before sending the RM_ADDR suboption, we also send the MP_PRIO suboption to change the related subflow's priority as backup. So here invoke mptcp_pm_mp_prio_send_ack from mptcp_pm_remove_anno_addr to send the MP_PRIO suboption and check whether the subflow's backup value is changed.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/pm_netlink.c | 2 ++
 1 file changed, 2 insertions(+)
net/mptcp/pm_netlink.c +2 -0
index a243017c4892..f80ebd4f6a29 100644
@@ -491,6 +491,7 @@ void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
 		if (msk->pm.rm_id != subflow->remote_id)
 			continue;
 
+		WARN_ON_ONCE(!subflow->backup);
 		spin_unlock_bh(&msk->pm.lock);
 		mptcp_subflow_shutdown(sk, ssk, how);
 		__mptcp_close_ssk(sk, ssk, subflow);
@@ -830,6 +831,7 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk,
 	ret = remove_anno_list_by_saddr(msk, addr);
 	if (ret || force) {
 		spin_lock_bh(&msk->pm.lock);
+		mptcp_pm_mp_prio_send_ack(msk, addr, 1);
 		mptcp_pm_remove_addr(msk, addr->id);
 		spin_unlock_bh(&msk->pm.lock);
 	}
Signature · 1 line
2.26.2
author
#5 lore raw

RFC PATCH 5/6 mptcp: add the mib for MP_PRIO

This patch added the mib for MP_PRIO, named MPTCP_MIB_MPPRIO, for receiving of the MP_PRIO suboption.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/mib.c     | 1 +
 net/mptcp/mib.h     | 1 +
 net/mptcp/options.c | 1 +
 3 files changed, 3 insertions(+)
net/mptcp/mib.c +1 -0
index a8744ad62087..3812c6417c00 100644
@@ -32,6 +32,7 @@ static const struct snmp_mib mptcp_snmp_list[] = {
 	SNMP_MIB_ITEM("PortAdd", MPTCP_MIB_PORTADD),
 	SNMP_MIB_ITEM("RmAddr", MPTCP_MIB_RMADDR),
 	SNMP_MIB_ITEM("RmSubflow", MPTCP_MIB_RMSUBFLOW),
+	SNMP_MIB_ITEM("MPPrio", MPTCP_MIB_MPPRIO),
 	SNMP_MIB_SENTINEL
 };
 
net/mptcp/mib.h +1 -0
index 1b07fc1ad1a0..522b3b191654 100644
@@ -25,6 +25,7 @@ enum linux_mptcp_mib_field {
 	MPTCP_MIB_PORTADD,		/* Received ADD_ADDR with port */
 	MPTCP_MIB_RMADDR,		/* Received RM_ADDR */
 	MPTCP_MIB_RMSUBFLOW,		/* Remove a subflow */
+	MPTCP_MIB_MPPRIO,		/* Received MP_PRIO */
 	__MPTCP_MIB_MAX
 };
 
net/mptcp/options.c +1 -0
index affbadb77faf..c09695dba1e1 100644
@@ -1010,6 +1010,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
 
 	if (mp_opt.mp_prio) {
 		mptcp_pm_mp_prio_received(sk, mp_opt.prio_bkup);
+		MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPPRIO);
 		mp_opt.mp_prio = 0;
 	}
 
Signature · 1 line
2.26.2
author
#6 lore raw

RFC PATCH 6/6 selftests: mptcp: add MP_PRIO check in chk_rm_nr

This patch added the MPTCP_MIB_MPPRIO counter check in chk_rm_nr, since before sending the RM_ADDR suboption, we also send the MP_PRIO suboption to change the related subflow's priority as backup.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 34 +++++++++++++------
 1 file changed, 23 insertions(+), 11 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +23 -11
index f224379ba254..18d488b9c87b 100755
@@ -484,7 +484,8 @@ chk_add_nr()
 chk_rm_nr()
 {
 	local rm_addr_nr=$1
-	local rm_subflow_nr=$2
+	local mp_prio_nr=$2
+	local rm_subflow_nr=$3
 	local count
 	local dump_stats
 
@@ -499,7 +500,18 @@ chk_rm_nr()
 		echo -n "[ ok ]"
 	fi
 
-	echo -n " - sf    "
+	echo -n " - prio  "
+	count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrio | awk '{print $2}'`
+	[ -z "$count" ] && count=0
+	if [ "$count" != "$mp_prio_nr" ]; then
+		echo "[fail] got $count MP_PRIO[s] expected $mp_prio_nr"
+		ret=1
+		dump_stats=1
+	else
+		echo -n "[ ok ]"
+	fi
+
+	echo -n " - sf "
 	count=`ip netns exec $ns2 nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}'`
 	[ -z "$count" ] && count=0
 	if [ "$count" != "$rm_subflow_nr" ]; then
@@ -637,7 +649,7 @@ ip netns exec $ns2 ./pm_nl_ctl limits 0 1
 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
 run_tests $ns1 $ns2 10.0.1.1 0 0 1 slow
 chk_join_nr "remove single subflow" 1 1 1
-chk_rm_nr 1 1
+chk_rm_nr 1 1 1
 
 # multiple subflows, remove
 reset
@@ -647,7 +659,7 @@ ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow
 ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
 run_tests $ns1 $ns2 10.0.1.1 0 0 2 slow
 chk_join_nr "remove multiple subflows" 2 2 2
-chk_rm_nr 2 2
+chk_rm_nr 2 2 2
 
 # single address, remove
 reset
@@ -657,7 +669,7 @@ ip netns exec $ns2 ./pm_nl_ctl limits 1 1
 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 0 0 0
 
 # subflow and signal, remove
 reset
@@ -668,7 +680,7 @@ ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
 run_tests $ns1 $ns2 10.0.1.1 0 1 1 slow
 chk_join_nr "remove subflow and signal" 2 2 2
 chk_add_nr 1 1
-chk_rm_nr 1 1
+chk_rm_nr 1 1 1
 
 # subflows and signal, remove
 reset
@@ -680,7 +692,7 @@ ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow
 run_tests $ns1 $ns2 10.0.1.1 0 1 2 slow
 chk_join_nr "remove subflows and signal" 3 3 3
 chk_add_nr 1 1
-chk_rm_nr 2 2
+chk_rm_nr 2 2 2
 
 # subflow IPv6
 reset
@@ -723,7 +735,7 @@ ip netns exec $ns2 ./pm_nl_ctl limits 1 1
 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 0 0 0
 
 # subflow and signal IPv6, remove
 reset
@@ -734,7 +746,7 @@ ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 flags subflow
 run_tests $ns1 $ns2 dead:beef:1::1 0 1 1 slow
 chk_join_nr "remove subflow and signal IPv6" 2 2 2
 chk_add_nr 1 1
-chk_rm_nr 1 1
+chk_rm_nr 1 1 1
 
 # signal address with port
 reset
@@ -763,7 +775,7 @@ ip netns exec $ns2 ./pm_nl_ctl limits 1 1
 run_tests $ns1 $ns2 10.0.1.1 0 1 0 slow 10100
 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 0 0 0
 
 # subflow and signal with port, remove
 reset
@@ -774,7 +786,7 @@ ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
 run_tests $ns1 $ns2 10.0.1.1 0 1 1 slow 10100
 chk_join_nr "remove subflow and signal with port" 2 2 2
 chk_add_nr 1 1 1
-chk_rm_nr 1 1
+chk_rm_nr 1 1 1
 
 # single subflow, syncookies
 reset_with_cookies
Signature · 1 line
2.26.2
#7 lore raw

[MPTCP] Re: [MPTCP][RFC PATCH mptcp-next 5/6] mptcp: add the mib for MP_PRIO

In reply to Geliang Tang
Quoted 4 lines · Geliang Tang

This patch added the mib for MP_PRIO, named MPTCP_MIB_MPPRIO, for receiving of the MP_PRIO suboption.

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

Hi Geliang & Matt -

Do you think it makes sense to also have a MIB for number of MP_PRIOs sent?

Mat

Quoted 44 lines

---

net/mptcp/mib.c     | 1 +
net/mptcp/mib.h     | 1 +
net/mptcp/options.c | 1 +
3 files changed, 3 insertions(+)
net/mptcp/mib.c +1 -0
index a8744ad62087..3812c6417c00 100644
@@ -32,6 +32,7 @@ static const struct snmp_mib mptcp_snmp_list[] = {
 	SNMP_MIB_ITEM("PortAdd", MPTCP_MIB_PORTADD),
 	SNMP_MIB_ITEM("RmAddr", MPTCP_MIB_RMADDR),
 	SNMP_MIB_ITEM("RmSubflow", MPTCP_MIB_RMSUBFLOW),
+	SNMP_MIB_ITEM("MPPrio", MPTCP_MIB_MPPRIO),
 	SNMP_MIB_SENTINEL
 };
 
net/mptcp/mib.h +1 -0
index 1b07fc1ad1a0..522b3b191654 100644
@@ -25,6 +25,7 @@ enum linux_mptcp_mib_field {
 	MPTCP_MIB_PORTADD,		/* Received ADD_ADDR with port */
 	MPTCP_MIB_RMADDR,		/* Received RM_ADDR */
 	MPTCP_MIB_RMSUBFLOW,		/* Remove a subflow */
+	MPTCP_MIB_MPPRIO,		/* Received MP_PRIO */
 	__MPTCP_MIB_MAX
 };
 
net/mptcp/options.c +1 -0
index affbadb77faf..c09695dba1e1 100644
@@ -1010,6 +1010,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
 
 	if (mp_opt.mp_prio) {
 		mptcp_pm_mp_prio_received(sk, mp_opt.prio_bkup);
+		MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPPRIO);
 		mp_opt.mp_prio = 0;
 	}
 
Signature · 1 line
2.26.2

--
Mat Martineau
Intel

#8 lore raw

[MPTCP] Re: [MPTCP][RFC PATCH mptcp-next 4/6] mptcp: send out MP_PRIO before RM_ADDR

In reply to Geliang Tang
Quoted 5 lines · Geliang Tang

Before sending the RM_ADDR suboption, we also send the MP_PRIO suboption to change the related subflow's priority as backup. So here invoke mptcp_pm_mp_prio_send_ack from mptcp_pm_remove_anno_addr to send the MP_PRIO suboption and check whether the subflow's backup value is changed.

Geliang,

I also think this patch is not needed. The part of RFC 8684 that mentions using the backup flag before a close is assuming a much longer period of time between the ACK that changes priority and the REMOVE_ADDR. It will be up to the path manager to coordinate the timing on that.

Thanks,

Mat

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

---
net/mptcp/pm_netlink.c | 2 ++

1 file changed, 2 insertions(+)
net/mptcp/pm_netlink.c +2 -0
index a243017c4892..f80ebd4f6a29 100644
@@ -491,6 +491,7 @@ void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
 		if (msk->pm.rm_id != subflow->remote_id)
 			continue;
 
+		WARN_ON_ONCE(!subflow->backup);
 		spin_unlock_bh(&msk->pm.lock);
 		mptcp_subflow_shutdown(sk, ssk, how);
 		__mptcp_close_ssk(sk, ssk, subflow);
@@ -830,6 +831,7 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk,
 	ret = remove_anno_list_by_saddr(msk, addr);
 	if (ret || force) {
 		spin_lock_bh(&msk->pm.lock);
+		mptcp_pm_mp_prio_send_ack(msk, addr, 1);
 		mptcp_pm_remove_addr(msk, addr->id);
 		spin_unlock_bh(&msk->pm.lock);
 	}
Signature · 4 lines
2.26.2
_______________________________________________
mptcp mailing list -- mptcp(a)lists.01.org
To unsubscribe send an email to mptcp-leave(a)lists.01.org

--
Mat Martineau
Intel

author
#9 lore raw

[MPTCP] Re: [MPTCP][RFC PATCH mptcp-next 4/6] mptcp: send out MP_PRIO before RM_ADDR

Hi Mat,

Thanks for your suggestions. It's very helpful.

Quoted 9 lines · Mat Martineau <mathew.j.martineau(a)linux.intel.com> 于2020年11月10日周二 上午10:07写道:
Quoted 5 lines · Geliang Tang

Before sending the RM_ADDR suboption, we also send the MP_PRIO suboption to change the related subflow's priority as backup. So here invoke mptcp_pm_mp_prio_send_ack from mptcp_pm_remove_anno_addr to send the MP_PRIO suboption and check whether the subflow's backup value is changed.

Quoted 7 lines

Geliang,

I also think this patch is not needed. The part of RFC 8684 that mentions using the backup flag before a close is assuming a much longer period of time between the ACK that changes priority and the REMOVE_ADDR. It will be up to the path manager to coordinate the timing on that.

If we drop this patch, when should we trigger the MP_PRIO sending? In which case does mptcp_pm_mp_prio_send_ack need to be called?

Should we use the PM netlink to trigger it? Use the MPTCP_PM_ADDR_FLAG_BACKUP flag or something?

-Geliang

Quoted 44 lines

Thanks,

Mat

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

---
net/mptcp/pm_netlink.c | 2 ++

1 file changed, 2 insertions(+)
net/mptcp/pm_netlink.c +2 -1
index a243017c4892..f80ebd4f6a29 100644
@@ -491,6 +491,7 @@ void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
              if (msk->pm.rm_id != subflow->remote_id)
                      continue;
 
+             WARN_ON_ONCE(!subflow->backup);
              spin_unlock_bh(&msk->pm.lock);
              mptcp_subflow_shutdown(sk, ssk, how);
              __mptcp_close_ssk(sk, ssk, subflow);
@@ -830,6 +831,7 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk,
      ret = remove_anno_list_by_saddr(msk, addr);
      if (ret || force) {
              spin_lock_bh(&msk->pm.lock);
+             mptcp_pm_mp_prio_send_ack(msk, addr, 1);
              mptcp_pm_remove_addr(msk, addr->id);
              spin_unlock_bh(&msk->pm.lock);
      }
--
Quoted 5 lines

2.26.2
_______________________________________________
mptcp mailing list -- mptcp(a)lists.01.org
To unsubscribe send an email to mptcp-leave(a)lists.01.org

--
Mat Martineau
Intel
_______________________________________________
mptcp mailing list -- mptcp(a)lists.01.org
To unsubscribe send an email to mptcp-leave(a)lists.01.org

#10 lore raw

[MPTCP] Re: [MPTCP][RFC PATCH mptcp-next 4/6] mptcp: send out MP_PRIO before RM_ADDR

Quoted 22 lines · Geliang Tang

Hi Mat,

Thanks for your suggestions. It's very helpful.

Quoted 9 lines · Mat Martineau <mathew.j.martineau(a)linux.intel.com> 于2020年11月10日周二 上午10:07写道:
Quoted 5 lines · Geliang Tang

Before sending the RM_ADDR suboption, we also send the MP_PRIO suboption to change the related subflow's priority as backup. So here invoke mptcp_pm_mp_prio_send_ack from mptcp_pm_remove_anno_addr to send the MP_PRIO suboption and check whether the subflow's backup value is changed.

Quoted 7 lines

Geliang,

I also think this patch is not needed. The part of RFC 8684 that mentions using the backup flag before a close is assuming a much longer period of time between the ACK that changes priority and the REMOVE_ADDR. It will be up to the path manager to coordinate the timing on that.

Quoted 5 lines

If we drop this patch, when should we trigger the MP_PRIO sending? In which case does mptcp_pm_mp_prio_send_ack need to be called?

Should we use the PM netlink to trigger it? Use the MPTCP_PM_ADDR_FLAG_BACKUP flag or something?

Yes, I think netlink is the way to trigger it. Maybe mptcp_nl_cmd_add_addr() could check for and modify an existing entry to change the 'backup' setting?

Mat

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

---
net/mptcp/pm_netlink.c | 2 ++

1 file changed, 2 insertions(+)
net/mptcp/pm_netlink.c +0 -0
index a243017c4892..f80ebd4f6a29 100644
@@ -491,6 +491,7 @@ void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
              if (msk->pm.rm_id != subflow->remote_id)
                      continue;
 
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
net/mptcp/pm_netlink.c +1 -0
+             WARN_ON_ONCE(!subflow->backup);
              spin_unlock_bh(&msk->pm.lock);
              mptcp_subflow_shutdown(sk, ssk, how);
              __mptcp_close_ssk(sk, ssk, subflow);
@@ -830,6 +831,7 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk,
      ret = remove_anno_list_by_saddr(msk, addr);
Quoted 8 lines
Quoted 8 lines
net/mptcp/pm_netlink.c +1 -1
      if (ret || force) {
              spin_lock_bh(&msk->pm.lock);
+             mptcp_pm_mp_prio_send_ack(msk, addr, 1);
              mptcp_pm_remove_addr(msk, addr->id);
              spin_unlock_bh(&msk->pm.lock);
      }
--

2.26.2

--
Mat Martineau
Intel

#11 lore raw

[MPTCP] Re: [MPTCP][RFC PATCH mptcp-next 3/6] mptcp: add prio_changed flag

In reply to Geliang Tang
Quoted 7 lines · Geliang Tang

This patch add a new flag named prio_changed in msk. When we received the MP_PRIO suboption, we set this flag to true.

In mptcp_subflow_get_send, we check whether prio_changed is set. If it is, we pick a new subflow to send data.

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

Hi Geliang -

This patch should be dropped. mptcp_subflow_get_send() already uses subflow->backup when choosing a subflow to transmit on.

Thanks,

Mat

Quoted 58 lines

---

net/mptcp/pm.c       | 1 +
net/mptcp/protocol.c | 4 +++-
net/mptcp/protocol.h | 1 +
3 files changed, 5 insertions(+), 1 deletion(-)
net/mptcp/pm.c +1 -0
index a4dc4aa39ad8..b6f4f54e6546 100644
@@ -195,6 +195,7 @@ void mptcp_pm_mp_prio_received(struct sock *sk, u8 prio_bkup)
 
 	spin_lock_bh(&msk->pm.lock);
 	subflow->backup = prio_bkup;
+	WRITE_ONCE(msk->prio_changed, true);
 	spin_unlock_bh(&msk->pm.lock);
 }
 
net/mptcp/protocol.c +3 -1
index a6bd06c724d5..7a7561ba9edf 100644
@@ -1133,7 +1133,8 @@ static struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk,
 	/* re-use last subflow, if the burst allow that */
 	if (msk->last_snd && msk->snd_burst > 0 &&
 	    sk_stream_memory_free(msk->last_snd) &&
-	    mptcp_subflow_active(mptcp_subflow_ctx(msk->last_snd))) {
+	    mptcp_subflow_active(mptcp_subflow_ctx(msk->last_snd)) &&
+	    !READ_ONCE(msk->prio_changed)) {
 		mptcp_for_each_subflow(msk, subflow) {
 			ssk =  mptcp_subflow_tcp_sock(subflow);
 			*sndbuf = max(tcp_sk(ssk)->snd_wnd, *sndbuf);
@@ -1180,6 +1181,7 @@ static struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk,
 		msk->last_snd = send_info[0].ssk;
 		msk->snd_burst = min_t(int, MPTCP_SEND_BURST_SIZE,
 				       sk_stream_wspace(msk->last_snd));
+		WRITE_ONCE(msk->prio_changed, false);
 		return msk->last_snd;
 	}
 	return NULL;
net/mptcp/protocol.h +1 -0
index 871b73046de0..c3386a6a7a16 100644
@@ -240,6 +240,7 @@ struct mptcp_sock {
 	bool		rcv_data_fin;
 	bool		snd_data_fin_enable;
 	bool		use_64bit_ack; /* Set when we received a 64-bit DSN */
+	bool		prio_changed;
 	spinlock_t	join_list_lock;
 	struct work_struct work;
 	struct sk_buff  *ooo_last_skb;
Signature · 4 lines
2.26.2
_______________________________________________
mptcp mailing list -- mptcp(a)lists.01.org
To unsubscribe send an email to mptcp-leave(a)lists.01.org

--
Mat Martineau
Intel

#12 lore raw

[MPTCP] Re: [MPTCP][RFC PATCH mptcp-next 2/6] mptcp: add the incoming MP_PRIO support

In reply to Geliang Tang
Quoted 9 lines · Geliang Tang

This patch added the incoming MP_PRIO logic:

Added a flag named mp_prio in mptcp_options_received, to mark the MP_PRIO is received, and save the priority value to the new prio_bkup field. Then invoke mptcp_pm_mp_prio_received with the receiving subsocket and the prio_bkup value.

In mptcp_pm_mp_prio_received, find the subflow according the subsocket, and change the subflow's backup as the incoming priority value.

The incoming option applies to the subflow it arrives on, so the receiver doesn't need to find the subflow because it is already known. This is what the code shows too, the commit message here just needs to match the code.

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

---

net/mptcp/options.c  | 16 ++++++++++++++++
net/mptcp/pm.c       | 10 ++++++++++
net/mptcp/protocol.h |  6 ++++++
3 files changed, 32 insertions(+)
net/mptcp/options.c +16 -0
index b74e6ab2d605..affbadb77faf 100644
@@ -282,6 +282,15 @@ static void mptcp_parse_option(const struct sk_buff *skb,
 		pr_debug("RM_ADDR: id=%d", mp_opt->rm_id);
 		break;
 
+	case MPTCPOPT_MP_PRIO:
+		if (opsize != TCPOLEN_MPTCP_PRIO)
+			break;
+
+		mp_opt->mp_prio = 1;
+		mp_opt->prio_bkup = *ptr++ & MPTCP_PRIO_BKUP;
+		pr_debug("MP_PRIO: prio=%d", mp_opt->prio_bkup);
+		break;
+
 	default:
 		break;
 	}
@@ -302,6 +311,8 @@ void mptcp_get_options(const struct sk_buff *skb,
 	mp_opt->port = 0;
 	mp_opt->rm_addr = 0;
 	mp_opt->dss = 0;
+	mp_opt->mp_prio = 0;
+	mp_opt->prio_bkup = 0;
 
 	length = (th->doff * 4) - sizeof(struct tcphdr);
 	ptr = (const unsigned char *)(th + 1);
@@ -997,6 +1008,11 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
 		mp_opt.rm_addr = 0;
 	}
 
+	if (mp_opt.mp_prio) {
+		mptcp_pm_mp_prio_received(sk, mp_opt.prio_bkup);
+		mp_opt.mp_prio = 0;
+	}
+
 	if (!mp_opt.dss)
 		return;
 
net/mptcp/pm.c +0 -0
index e63e14f4cf2a..a4dc4aa39ad8 100644
@@ -188,6 +188,16 @@ void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id)
 	spin_unlock_bh(&pm->lock);
 }

net/mptcp/pm.c void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id) · line 199

Quoted 10 lines
net/mptcp/pm.c +9 -0
 
+void mptcp_pm_mp_prio_received(struct sock *sk, u8 prio_bkup)
+{
+	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
+	struct mptcp_sock *msk = mptcp_sk(subflow->conn);
+
+	spin_lock_bh(&msk->pm.lock);
+	subflow->backup = prio_bkup;
+	spin_unlock_bh(&msk->pm.lock);
+}

I don't think the incoming MP_PRIO needs to go through the path manager or acquire the PM lock, if WRITE_ONCE is used to write subflow->backup here and existing access to subflow->backup is updated to use READ_ONCE/WRITE_ONCE.

Quoted 27 lines
net/mptcp/pm.c +1 -0
+
 /* path manager helpers */
 
 bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
net/mptcp/protocol.h +4 -0
index a8ed1de1cb05..871b73046de0 100644
@@ -87,6 +87,9 @@
 #define MPTCP_ADDR_IPVERSION_4	4
 #define MPTCP_ADDR_IPVERSION_6	6
 
+/* MPTCP MP_PRIO flags */
+#define MPTCP_PRIO_BKUP		BIT(0)
+
 /* MPTCP socket flags */
 #define MPTCP_DATA_READY	0
 #define MPTCP_NOSPACE		1
@@ -115,6 +118,7 @@ struct mptcp_options_received {
 		dss : 1,
 		add_addr : 1,
 		rm_addr : 1,
+		mp_prio : 1,
 		family : 4,
 		echo : 1,
 		backup : 1;

net/mptcp/protocol.h struct mptcp_options_received { · line 147

Quoted 4 lines
net/mptcp/protocol.h +1 -0
@@ -140,6 +144,7 @@ struct mptcp_options_received {
 	};
 	u64	ahmac;
 	u16	port;
+	u8	prio_bkup;

The existing 'backup' bit works for this.

Quoted 13 lines
net/mptcp/protocol.h +1 -0
 };
 
 static inline __be32 mptcp_option(u8 subopt, u8 len, u8 nib, u8 field)
@@ -519,6 +524,7 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk,
 				const struct mptcp_addr_info *addr);
 void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk);
 void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id);
+void mptcp_pm_mp_prio_received(struct sock *sk, u8 prio_bkup);
 void mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk,
 			       struct mptcp_addr_info *addr,
 			       u8 prio_bkup);
Signature · 1 line
2.26.2

--
Mat Martineau
Intel

#13 lore raw

[MPTCP] Re: [MPTCP][RFC PATCH mptcp-next 1/6] mptcp: add the outgoing MP_PRIO support

In reply to Geliang Tang
Quoted 7 lines · Geliang Tang

This patch added the outgoing MP_PRIO logic:

In mptcp_pm_mp_prio_send_ack, find the related subflow and subsocket according to the input parameter address, then set subflow's send_mp_prio flag to true, and save the input priority value to suflow's prio_bkup. Finally, send out a pure ACK on the related subsocket.

Quoted 8 lines

In mptcp_established_options_mp_prio, check whether the subflow's send_mp_prio is set. If it is, this is the packet for send MP_PRIO. So save subflow->prio_bkup value to mptcp_out_options's prio_bkup, and change the option type to OPTION_MPTCP_PRIO.

In mptcp_write_options, sent out the MP_PRIO suboption with mptcp_out_options's prio_bkup value.

Hi Geliang,

Thanks for working on this additional feature!

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

---

include/net/mptcp.h    |  1 +
net/mptcp/options.c    | 36 ++++++++++++++++++++++++++++++++++++
net/mptcp/pm_netlink.c | 30 ++++++++++++++++++++++++++++++
net/mptcp/protocol.h   |  7 +++++++
4 files changed, 74 insertions(+)
include/net/mptcp.h +0 -0
index 5694370be3d4..f71259fb04cd 100644

include/net/mptcp.h struct mptcp_out_options { · line 54

Quoted 4 lines
include/net/mptcp.h +1 -0
@@ -51,6 +51,7 @@ struct mptcp_out_options {
 	u8 rm_id;
 	u8 join_id;
 	u8 backup;
+	u8 prio_bkup;

The existing 'backup' struct member can be used for this.

Quoted 15 lines
include/net/mptcp.h +0 -0
 	u32 nonce;
 	u64 thmac;
 	u32 token;
net/mptcp/options.c +4 -0
index f611fbcbd6d0..b74e6ab2d605 100644
@@ -665,6 +665,30 @@ static bool mptcp_established_options_rm_addr(struct sock *sk,
 	return true;
 }
 
+static bool mptcp_established_options_mp_prio(struct sock *sk,
+					      unsigned int *size,
+					      unsigned int remaining,
+					      struct mptcp_out_options *opts)

net/mptcp/options.c static bool mptcp_established_options_rm_addr(struct sock *sk, · line 681

Quoted 10 lines
net/mptcp/options.c +10 -0
+{
+	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
+
+	if (!subflow->send_mp_prio)
+		return false;
+
+	if (remaining < TCPOLEN_MPTCP_PRIO)
+		return false;
+
+	subflow->send_mp_prio = 0;

tcp_established_options() is called by tcp_current_mss(), so clearing send_mp_prio here will stop MP_PRIO from being sent sometimes.

Quoted 109 lines
net/mptcp/options.c +22 -0
+
+	*size = TCPOLEN_MPTCP_PRIO;
+	opts->suboptions |= OPTION_MPTCP_PRIO;
+	opts->prio_bkup = subflow->prio_bkup;
+
+	pr_debug("prio=%d", opts->prio_bkup);
+
+	return true;
+}
+
 bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
 			       unsigned int *size, unsigned int remaining,
 			       struct mptcp_out_options *opts)
@@ -707,6 +731,12 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
 		ret = true;
 	}
 
+	if (mptcp_established_options_mp_prio(sk, &opt_size, remaining, opts)) {
+		*size += opt_size;
+		remaining -= opt_size;
+		ret = true;
+	}
+
 	return ret;
 }
 
@@ -1138,6 +1168,12 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
 				      0, opts->rm_id);
 	}
 
+	if (OPTION_MPTCP_PRIO & opts->suboptions) {
+		*ptr++ = mptcp_option(MPTCPOPT_MP_PRIO,
+				      TCPOLEN_MPTCP_PRIO,
+				      opts->prio_bkup, TCPOPT_NOP);
+	}
+
 	if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) {
 		*ptr++ = mptcp_option(MPTCPOPT_MP_JOIN,
 				      TCPOLEN_MPTCP_MPJ_SYN,
net/mptcp/pm_netlink.c +30 -0
index 069447424ddb..a243017c4892 100644
@@ -441,6 +441,36 @@ void mptcp_pm_nl_add_addr_send_ack(struct mptcp_sock *msk)
 	}
 }
 
+void mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk,
+			       struct mptcp_addr_info *addr,
+			       u8 prio_bkup)
+{
+	struct mptcp_subflow_context *subflow, *tmp;
+
+	if (list_empty(&msk->conn_list))
+		return;
+
+	list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
+		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
+		struct mptcp_addr_info local;
+
+		local_address((struct sock_common *)ssk, &local);
+		if (!addresses_equal(&local, addr, false))
+			continue;
+
+		subflow->send_mp_prio = 1;
+		subflow->prio_bkup = prio_bkup;
+		spin_unlock_bh(&msk->pm.lock);
+		pr_debug("send ack for mp_prio");
+		lock_sock(ssk);
+		tcp_send_ack(ssk);
+		release_sock(ssk);
+		spin_lock_bh(&msk->pm.lock);
+
+		break;
+	}
+}
+
 void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
 {
 	struct mptcp_subflow_context *subflow, *tmp;
net/mptcp/protocol.h +3 -0
index b01c1fae9d8f..a8ed1de1cb05 100644
@@ -23,6 +23,7 @@
 #define OPTION_MPTCP_ADD_ADDR	BIT(6)
 #define OPTION_MPTCP_ADD_ADDR6	BIT(7)
 #define OPTION_MPTCP_RM_ADDR	BIT(8)
+#define OPTION_MPTCP_PRIO	BIT(9)
 
 /* MPTCP option subtypes */
 #define MPTCPOPT_MP_CAPABLE	0
@@ -59,6 +60,7 @@
 #define TCPOLEN_MPTCP_PORT_LEN		4
 #define TCPOLEN_MPTCP_ADD_ADDR_HMAC	8
 #define TCPOLEN_MPTCP_RM_ADDR_BASE	4
+#define TCPOLEN_MPTCP_PRIO		4
 
 /* MPTCP MP_JOIN flags */
 #define MPTCPOPT_BACKUP		BIT(0)
@@ -362,6 +364,7 @@ struct mptcp_subflow_context {
 		map_valid : 1,
 		mpc_map : 1,
 		backup : 1,
+		send_mp_prio : 1,
 		rx_eof : 1,
 		can_ack : 1,        /* only after processing the remote a key */
 		disposable : 1;	    /* ctx can be free at ulp release time */

net/mptcp/protocol.h struct mptcp_subflow_context { · line 379

Quoted 4 lines
net/mptcp/protocol.h +1 -0
@@ -373,6 +376,7 @@ struct mptcp_subflow_context {
 	u8	hmac[MPTCPOPT_HMAC_LEN];
 	u8	local_id;
 	u8	remote_id;
+	u8	prio_bkup;

The existing 'backup' bit in this struct is keeping track of the peer's requested backup flag, which affects the choice for the local msk to send on that subflow.

The existing 'request_bkup' bit is tracking which priority (backup or normal) we have requested from the peer. I think prio_bkup duplicates this bit.

Quoted 11 lines
net/mptcp/protocol.h +3 -0
 	struct	sock *tcp_sock;	    /* tcp sk backpointer */
 	struct	sock *conn;	    /* parent mptcp_sock */
@@ -515,6 +519,9 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk,
 				const struct mptcp_addr_info *addr);
 void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk);
 void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id);
+void mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk,
+			       struct mptcp_addr_info *addr,
+			       u8 prio_bkup);
 void mptcp_pm_free_anno_list(struct mptcp_sock *msk);
Quoted 4 lines

struct mptcp_pm_add_entry *
mptcp_pm_del_add_timer(struct mptcp_sock *msk,

Signature · 1 line
2.26.2

--
Mat Martineau
Intel

author
#14 lore raw

[MPTCP] Re: [MPTCP][RFC PATCH mptcp-next 1/6] mptcp: add the outgoing MP_PRIO support

Hi Mat,

Quoted 64 lines · Mat Martineau <mathew.j.martineau(a)linux.intel.com> 于2020年11月10日周二 上午9:48写道:
Quoted 7 lines · Geliang Tang

This patch added the outgoing MP_PRIO logic:

In mptcp_pm_mp_prio_send_ack, find the related subflow and subsocket according to the input parameter address, then set subflow's send_mp_prio flag to true, and save the input priority value to suflow's prio_bkup. Finally, send out a pure ACK on the related subsocket.

Quoted 8 lines

In mptcp_established_options_mp_prio, check whether the subflow's send_mp_prio is set. If it is, this is the packet for send MP_PRIO. So save subflow->prio_bkup value to mptcp_out_options's prio_bkup, and change the option type to OPTION_MPTCP_PRIO.

In mptcp_write_options, sent out the MP_PRIO suboption with mptcp_out_options's prio_bkup value.

Hi Geliang,

Thanks for working on this additional feature!

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

---

include/net/mptcp.h    |  1 +
net/mptcp/options.c    | 36 ++++++++++++++++++++++++++++++++++++
net/mptcp/pm_netlink.c | 30 ++++++++++++++++++++++++++++++
net/mptcp/protocol.h   |  7 +++++++
4 files changed, 74 insertions(+)
include/net/mptcp.h +0 -0
index 5694370be3d4..f71259fb04cd 100644

include/net/mptcp.h struct mptcp_out_options { · line 54

Quoted 4 lines
include/net/mptcp.h +1 -0
@@ -51,6 +51,7 @@ struct mptcp_out_options {
      u8 rm_id;
      u8 join_id;
      u8 backup;
+     u8 prio_bkup;

The existing 'backup' struct member can be used for this.

Quoted 20 lines
include/net/mptcp.h +0 -0
      u32 nonce;
      u64 thmac;
      u32 token;
net/mptcp/options.c +9 -0
index f611fbcbd6d0..b74e6ab2d605 100644
@@ -665,6 +665,30 @@ static bool mptcp_established_options_rm_addr(struct sock *sk,
      return true;
 }
 
+static bool mptcp_established_options_mp_prio(struct sock *sk,
+                                           unsigned int *size,
+                                           unsigned int remaining,
+                                           struct mptcp_out_options *opts)
+{
+     struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
+
+     if (!subflow->send_mp_prio)
+             return false;
Quoted 9 lines

net/mptcp/options.c static bool mptcp_established_options_rm_addr(struct sock *sk, · line 681

Quoted 5 lines
net/mptcp/options.c +5 -0
+
+     if (remaining < TCPOLEN_MPTCP_PRIO)
+             return false;
+
+     subflow->send_mp_prio = 0;

tcp_established_options() is called by tcp_current_mss(), so clearing send_mp_prio here will stop MP_PRIO from being sent sometimes.

Should we move this clearing to the end of this function? Or move it into mptcp_write_options? Please give me some hint for this.

Thanks.

-Geliang

Quoted 141 lines
Quoted 109 lines
net/mptcp/options.c +22 -0
+
+     *size = TCPOLEN_MPTCP_PRIO;
+     opts->suboptions |= OPTION_MPTCP_PRIO;
+     opts->prio_bkup = subflow->prio_bkup;
+
+     pr_debug("prio=%d", opts->prio_bkup);
+
+     return true;
+}
+
 bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
                             unsigned int *size, unsigned int remaining,
                             struct mptcp_out_options *opts)
@@ -707,6 +731,12 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
              ret = true;
      }
 
+     if (mptcp_established_options_mp_prio(sk, &opt_size, remaining, opts)) {
+             *size += opt_size;
+             remaining -= opt_size;
+             ret = true;
+     }
+
      return ret;
 }
 
@@ -1138,6 +1168,12 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
                                    0, opts->rm_id);
      }
 
+     if (OPTION_MPTCP_PRIO & opts->suboptions) {
+             *ptr++ = mptcp_option(MPTCPOPT_MP_PRIO,
+                                   TCPOLEN_MPTCP_PRIO,
+                                   opts->prio_bkup, TCPOPT_NOP);
+     }
+
      if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) {
              *ptr++ = mptcp_option(MPTCPOPT_MP_JOIN,
                                    TCPOLEN_MPTCP_MPJ_SYN,
net/mptcp/pm_netlink.c +30 -0
index 069447424ddb..a243017c4892 100644
@@ -441,6 +441,36 @@ void mptcp_pm_nl_add_addr_send_ack(struct mptcp_sock *msk)
      }
 }
 
+void mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk,
+                            struct mptcp_addr_info *addr,
+                            u8 prio_bkup)
+{
+     struct mptcp_subflow_context *subflow, *tmp;
+
+     if (list_empty(&msk->conn_list))
+             return;
+
+     list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
+             struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
+             struct mptcp_addr_info local;
+
+             local_address((struct sock_common *)ssk, &local);
+             if (!addresses_equal(&local, addr, false))
+                     continue;
+
+             subflow->send_mp_prio = 1;
+             subflow->prio_bkup = prio_bkup;
+             spin_unlock_bh(&msk->pm.lock);
+             pr_debug("send ack for mp_prio");
+             lock_sock(ssk);
+             tcp_send_ack(ssk);
+             release_sock(ssk);
+             spin_lock_bh(&msk->pm.lock);
+
+             break;
+     }
+}
+
 void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
 {
      struct mptcp_subflow_context *subflow, *tmp;
net/mptcp/protocol.h +3 -0
index b01c1fae9d8f..a8ed1de1cb05 100644
@@ -23,6 +23,7 @@
 #define OPTION_MPTCP_ADD_ADDR BIT(6)
 #define OPTION_MPTCP_ADD_ADDR6        BIT(7)
 #define OPTION_MPTCP_RM_ADDR  BIT(8)
+#define OPTION_MPTCP_PRIO    BIT(9)
 
 /* MPTCP option subtypes */
 #define MPTCPOPT_MP_CAPABLE   0
@@ -59,6 +60,7 @@
 #define TCPOLEN_MPTCP_PORT_LEN                4
 #define TCPOLEN_MPTCP_ADD_ADDR_HMAC   8
 #define TCPOLEN_MPTCP_RM_ADDR_BASE    4
+#define TCPOLEN_MPTCP_PRIO           4
 
 /* MPTCP MP_JOIN flags */
 #define MPTCPOPT_BACKUP               BIT(0)
@@ -362,6 +364,7 @@ struct mptcp_subflow_context {
              map_valid : 1,
              mpc_map : 1,
              backup : 1,
+             send_mp_prio : 1,
              rx_eof : 1,
              can_ack : 1,        /* only after processing the remote a key */
              disposable : 1;     /* ctx can be free at ulp release time */

net/mptcp/protocol.h struct mptcp_subflow_context { · line 379

Quoted 4 lines
net/mptcp/protocol.h +1 -0
@@ -373,6 +376,7 @@ struct mptcp_subflow_context {
      u8      hmac[MPTCPOPT_HMAC_LEN];
      u8      local_id;
      u8      remote_id;
+     u8      prio_bkup;

The existing 'backup' bit in this struct is keeping track of the peer's requested backup flag, which affects the choice for the local msk to send on that subflow.

The existing 'request_bkup' bit is tracking which priority (backup or normal) we have requested from the peer. I think prio_bkup duplicates this bit.

Quoted 11 lines
net/mptcp/protocol.h +3 -0
      struct  sock *tcp_sock;     /* tcp sk backpointer */
      struct  sock *conn;         /* parent mptcp_sock */
@@ -515,6 +519,9 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk,
                              const struct mptcp_addr_info *addr);
 void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk);
 void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id);
+void mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk,
+                            struct mptcp_addr_info *addr,
+                            u8 prio_bkup);
 void mptcp_pm_free_anno_list(struct mptcp_sock *msk);
Quoted 4 lines

struct mptcp_pm_add_entry *
mptcp_pm_del_add_timer(struct mptcp_sock *msk,
--
2.26.2

--
Mat Martineau
Intel

#15 lore raw

[MPTCP] Re: [MPTCP][RFC PATCH mptcp-next 1/6] mptcp: add the outgoing MP_PRIO support

Quoted 77 lines · Geliang Tang

Hi Mat,

Quoted 64 lines · Mat Martineau <mathew.j.martineau(a)linux.intel.com> 于2020年11月10日周二 上午9:48写道:
Quoted 7 lines · Geliang Tang

This patch added the outgoing MP_PRIO logic:

In mptcp_pm_mp_prio_send_ack, find the related subflow and subsocket according to the input parameter address, then set subflow's send_mp_prio flag to true, and save the input priority value to suflow's prio_bkup. Finally, send out a pure ACK on the related subsocket.

Quoted 8 lines

In mptcp_established_options_mp_prio, check whether the subflow's send_mp_prio is set. If it is, this is the packet for send MP_PRIO. So save subflow->prio_bkup value to mptcp_out_options's prio_bkup, and change the option type to OPTION_MPTCP_PRIO.

In mptcp_write_options, sent out the MP_PRIO suboption with mptcp_out_options's prio_bkup value.

Hi Geliang,

Thanks for working on this additional feature!

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

---

include/net/mptcp.h    |  1 +
net/mptcp/options.c    | 36 ++++++++++++++++++++++++++++++++++++
net/mptcp/pm_netlink.c | 30 ++++++++++++++++++++++++++++++
net/mptcp/protocol.h   |  7 +++++++
4 files changed, 74 insertions(+)
include/net/mptcp.h +0 -0
index 5694370be3d4..f71259fb04cd 100644

include/net/mptcp.h struct mptcp_out_options { · line 54

Quoted 4 lines
include/net/mptcp.h +1 -0
@@ -51,6 +51,7 @@ struct mptcp_out_options {
      u8 rm_id;
      u8 join_id;
      u8 backup;
+     u8 prio_bkup;

The existing 'backup' struct member can be used for this.

Quoted 20 lines
include/net/mptcp.h +0 -0
      u32 nonce;
      u64 thmac;
      u32 token;
net/mptcp/options.c +9 -0
index f611fbcbd6d0..b74e6ab2d605 100644
@@ -665,6 +665,30 @@ static bool mptcp_established_options_rm_addr(struct sock *sk,
      return true;
 }
 
+static bool mptcp_established_options_mp_prio(struct sock *sk,
+                                           unsigned int *size,
+                                           unsigned int remaining,
+                                           struct mptcp_out_options *opts)
+{
+     struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
+
+     if (!subflow->send_mp_prio)
+             return false;
Quoted 9 lines

net/mptcp/options.c static bool mptcp_established_options_rm_addr(struct sock *sk, · line 681

Quoted 5 lines
net/mptcp/options.c +5 -0
+
+     if (remaining < TCPOLEN_MPTCP_PRIO)
+             return false;
+
+     subflow->send_mp_prio = 0;

tcp_established_options() is called by tcp_current_mss(), so clearing send_mp_prio here will stop MP_PRIO from being sent sometimes.

Quoted 3 lines

Should we move this clearing to the end of this function? Or move it into mptcp_write_options? Please give me some hint for this.

Moving to mptcp_write_options() would be good.

Mat

Quoted 123 lines
Quoted 123 lines
Quoted 109 lines
net/mptcp/options.c +22 -0
+
+     *size = TCPOLEN_MPTCP_PRIO;
+     opts->suboptions |= OPTION_MPTCP_PRIO;
+     opts->prio_bkup = subflow->prio_bkup;
+
+     pr_debug("prio=%d", opts->prio_bkup);
+
+     return true;
+}
+
 bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
                             unsigned int *size, unsigned int remaining,
                             struct mptcp_out_options *opts)
@@ -707,6 +731,12 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
              ret = true;
      }
 
+     if (mptcp_established_options_mp_prio(sk, &opt_size, remaining, opts)) {
+             *size += opt_size;
+             remaining -= opt_size;
+             ret = true;
+     }
+
      return ret;
 }
 
@@ -1138,6 +1168,12 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
                                    0, opts->rm_id);
      }
 
+     if (OPTION_MPTCP_PRIO & opts->suboptions) {
+             *ptr++ = mptcp_option(MPTCPOPT_MP_PRIO,
+                                   TCPOLEN_MPTCP_PRIO,
+                                   opts->prio_bkup, TCPOPT_NOP);
+     }
+
      if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) {
              *ptr++ = mptcp_option(MPTCPOPT_MP_JOIN,
                                    TCPOLEN_MPTCP_MPJ_SYN,
net/mptcp/pm_netlink.c +30 -0
index 069447424ddb..a243017c4892 100644
@@ -441,6 +441,36 @@ void mptcp_pm_nl_add_addr_send_ack(struct mptcp_sock *msk)
      }
 }
 
+void mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk,
+                            struct mptcp_addr_info *addr,
+                            u8 prio_bkup)
+{
+     struct mptcp_subflow_context *subflow, *tmp;
+
+     if (list_empty(&msk->conn_list))
+             return;
+
+     list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
+             struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
+             struct mptcp_addr_info local;
+
+             local_address((struct sock_common *)ssk, &local);
+             if (!addresses_equal(&local, addr, false))
+                     continue;
+
+             subflow->send_mp_prio = 1;
+             subflow->prio_bkup = prio_bkup;
+             spin_unlock_bh(&msk->pm.lock);
+             pr_debug("send ack for mp_prio");
+             lock_sock(ssk);
+             tcp_send_ack(ssk);
+             release_sock(ssk);
+             spin_lock_bh(&msk->pm.lock);
+
+             break;
+     }
+}
+
 void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
 {
      struct mptcp_subflow_context *subflow, *tmp;
net/mptcp/protocol.h +3 -0
index b01c1fae9d8f..a8ed1de1cb05 100644
@@ -23,6 +23,7 @@
 #define OPTION_MPTCP_ADD_ADDR BIT(6)
 #define OPTION_MPTCP_ADD_ADDR6        BIT(7)
 #define OPTION_MPTCP_RM_ADDR  BIT(8)
+#define OPTION_MPTCP_PRIO    BIT(9)
 
 /* MPTCP option subtypes */
 #define MPTCPOPT_MP_CAPABLE   0
@@ -59,6 +60,7 @@
 #define TCPOLEN_MPTCP_PORT_LEN                4
 #define TCPOLEN_MPTCP_ADD_ADDR_HMAC   8
 #define TCPOLEN_MPTCP_RM_ADDR_BASE    4
+#define TCPOLEN_MPTCP_PRIO           4
 
 /* MPTCP MP_JOIN flags */
 #define MPTCPOPT_BACKUP               BIT(0)
@@ -362,6 +364,7 @@ struct mptcp_subflow_context {
              map_valid : 1,
              mpc_map : 1,
              backup : 1,
+             send_mp_prio : 1,
              rx_eof : 1,
              can_ack : 1,        /* only after processing the remote a key */
              disposable : 1;     /* ctx can be free at ulp release time */

net/mptcp/protocol.h struct mptcp_subflow_context { · line 379

Quoted 4 lines
net/mptcp/protocol.h +1 -0
@@ -373,6 +376,7 @@ struct mptcp_subflow_context {
      u8      hmac[MPTCPOPT_HMAC_LEN];
      u8      local_id;
      u8      remote_id;
+     u8      prio_bkup;

The existing 'backup' bit in this struct is keeping track of the peer's requested backup flag, which affects the choice for the local msk to send on that subflow.

The existing 'request_bkup' bit is tracking which priority (backup or normal) we have requested from the peer. I think prio_bkup duplicates this bit.

Quoted 1 line
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
      struct  sock *tcp_sock;     /* tcp sk backpointer */
      struct  sock *conn;         /* parent mptcp_sock */
net/mptcp/protocol.h +0 -0
@@ -515,6 +519,9 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk,
                              const struct mptcp_addr_info *addr);
 void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk);
 void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id);
Quoted 8 lines
Quoted 8 lines
net/mptcp/protocol.h +3 -0
+void mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk,
+                            struct mptcp_addr_info *addr,
+                            u8 prio_bkup);
 void mptcp_pm_free_anno_list(struct mptcp_sock *msk);

struct mptcp_pm_add_entry *
mptcp_pm_del_add_timer(struct mptcp_sock *msk,
--
2.26.2

--
Mat Martineau
Intel