Skip to contentSkip to conversation

Add REMOVE_ADDR support

PATCH Superseded Geliang Tang 3 participants 11 messages Jul 22, 2020 – Jul 29, 2020

Subsystems (2)

v2 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Geliang Tang

author
#0 lore raw

v2 cover Add REMOVE_ADDR support

Add REMOVE_ADDR support.

Geliang Tang (4):
mptcp: rename the existing ADD_ADDR related functions
mptcp: add the RM_ADDR option writing
mptcp: add the RM_ADDR option parsing
mptcp: trigger the RM_ADDR signal

 net/mptcp/options.c    | 49 ++++++++++++++++++++++++++++++++------
 net/mptcp/pm.c         | 54 ++++++++++++++++++++++++++++++++++++------
 net/mptcp/pm_netlink.c | 52 +++++++++++++++++++++++++++++++++++++++-
 net/mptcp/protocol.c   |  9 +++++--
 net/mptcp/protocol.h   | 25 +++++++++++++++----
 net/mptcp/subflow.c    |  1 +
 6 files changed, 168 insertions(+), 22 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 1/4 mptcp: rename the existing ADD_ADDR related functions

This patch renamed the existing ADD_ADDR related functions with the explicit word "add".

Suggested-by Matthieu Baerts <matthieu.baerts(a)tessares.net>
Suggested-by Paolo Abeni <pabeni(a)redhat.com>
Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/options.c  | 14 +++++++-------
 net/mptcp/pm.c       | 12 ++++++------
 net/mptcp/protocol.h | 10 +++++-----
 3 files changed, 18 insertions(+), 18 deletions(-)
net/mptcp/options.c +7 -7
index 19707c07efc1..a3ab4669289b 100644
@@ -572,18 +572,18 @@ static u64 add_addr6_generate_hmac(u64 key1, u64 key2, u8 addr_id,
 }
 #endif
 
-static bool mptcp_established_options_addr(struct sock *sk,
-					   unsigned int *size,
-					   unsigned int remaining,
-					   struct mptcp_out_options *opts)
+static bool mptcp_established_options_add_addr(struct sock *sk,
+					       unsigned int *size,
+					       unsigned int remaining,
+					       struct mptcp_out_options *opts)
 {
 	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
 	struct mptcp_sock *msk = mptcp_sk(subflow->conn);
 	struct mptcp_addr_info saddr;
 	int len;
 
-	if (!mptcp_pm_should_signal(msk) ||
-	    !(mptcp_pm_addr_signal(msk, remaining, &saddr)))
+	if (!mptcp_pm_should_add_signal(msk) ||
+	    !(mptcp_pm_add_addr_signal(msk, remaining, &saddr)))
 		return false;
 
 	len = mptcp_add_addr_len(saddr.family);
@@ -641,7 +641,7 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
 
 	*size += opt_size;
 	remaining -= opt_size;
-	if (mptcp_established_options_addr(sk, &opt_size, remaining, opts)) {
+	if (mptcp_established_options_add_addr(sk, &opt_size, remaining, opts)) {
 		*size += opt_size;
 		remaining -= opt_size;
 		ret = true;
net/mptcp/pm.c +6 -6
index a8ad20559aaa..ce12b8b26ad2 100644
@@ -18,7 +18,7 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk,
 	pr_debug("msk=%p, local_id=%d", msk, addr->id);
 
 	msk->pm.local = *addr;
-	WRITE_ONCE(msk->pm.addr_signal, true);
+	WRITE_ONCE(msk->pm.add_addr_signal, true);
 	return 0;
 }
 
@@ -151,22 +151,22 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk,
 
 /* path manager helpers */
 
-bool mptcp_pm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
-			  struct mptcp_addr_info *saddr)
+bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
+			      struct mptcp_addr_info *saddr)
 {
 	int ret = false;
 
 	spin_lock_bh(&msk->pm.lock);
 
 	/* double check after the lock is acquired */
-	if (!mptcp_pm_should_signal(msk))
+	if (!mptcp_pm_should_add_signal(msk))
 		goto out_unlock;
 
 	if (remaining < mptcp_add_addr_len(msk->pm.local.family))
 		goto out_unlock;
 
 	*saddr = msk->pm.local;
-	WRITE_ONCE(msk->pm.addr_signal, false);
+	WRITE_ONCE(msk->pm.add_addr_signal, false);
 	ret = true;
 
 out_unlock:
@@ -186,7 +186,7 @@ void mptcp_pm_data_init(struct mptcp_sock *msk)
 	msk->pm.local_addr_used = 0;
 	msk->pm.subflows = 0;
 	WRITE_ONCE(msk->pm.work_pending, false);
-	WRITE_ONCE(msk->pm.addr_signal, false);
+	WRITE_ONCE(msk->pm.add_addr_signal, false);
 	WRITE_ONCE(msk->pm.accept_addr, false);
 	WRITE_ONCE(msk->pm.accept_subflow, false);
 	msk->pm.status = 0;
net/mptcp/protocol.h +5 -5
index e5baaef5ec89..adb63ad49a04 100644
@@ -160,7 +160,7 @@ struct mptcp_pm_data {
 
 	spinlock_t	lock;		/*protects the whole PM data */
 
-	bool		addr_signal;
+	bool		add_addr_signal;
 	bool		server_side;
 	bool		work_pending;
 	bool		accept_addr;
@@ -427,9 +427,9 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk,
 int mptcp_pm_remove_addr(struct mptcp_sock *msk, u8 local_id);
 int mptcp_pm_remove_subflow(struct mptcp_sock *msk, u8 remote_id);
 
-static inline bool mptcp_pm_should_signal(struct mptcp_sock *msk)
+static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk)
 {
-	return READ_ONCE(msk->pm.addr_signal);
+	return READ_ONCE(msk->pm.add_addr_signal);
 }
 
 static inline unsigned int mptcp_add_addr_len(int family)
@@ -439,8 +439,8 @@ static inline unsigned int mptcp_add_addr_len(int family)
 	return TCPOLEN_MPTCP_ADD_ADDR6;
 }
 
-bool mptcp_pm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
-			  struct mptcp_addr_info *saddr);
+bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
+			      struct mptcp_addr_info *saddr);
 int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);
 
 void __init mptcp_pm_nl_init(void);
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH v2 2/4 mptcp: add the RM_ADDR option writing

In reply to Geliang Tang

This patch added the RM_ADDR option writing using
mptcp_established_options_rm_addr.

Suggested-by Matthieu Baerts <matthieu.baerts(a)tessares.net>
Suggested-by Paolo Abeni <pabeni(a)redhat.com>
Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/options.c  | 30 ++++++++++++++++++++++++++++++
 net/mptcp/pm.c       | 24 ++++++++++++++++++++++++
 net/mptcp/protocol.h |  9 +++++++++
 3 files changed, 63 insertions(+)
net/mptcp/options.c +30 -0
index a3ab4669289b..38685e0e06db 100644
@@ -615,6 +615,31 @@ static bool mptcp_established_options_add_addr(struct sock *sk,
 	return true;
 }
 
+static bool mptcp_established_options_rm_addr(struct sock *sk,
+					      unsigned int *size,
+					      unsigned int remaining,
+					      struct mptcp_out_options *opts)
+{
+	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
+	struct mptcp_sock *msk = mptcp_sk(subflow->conn);
+	u8 rm_id;
+
+	if (!mptcp_pm_should_rm_signal(msk) ||
+	    !(mptcp_pm_rm_addr_signal(msk, remaining, &rm_id)))
+		return false;
+
+	if (remaining < TCPOLEN_MPTCP_RM_ADDR_BASE)
+		return false;
+
+	*size = TCPOLEN_MPTCP_RM_ADDR_BASE;
+	opts->suboptions |= OPTION_MPTCP_RM_ADDR;
+	opts->rm_id = rm_id;
+
+	pr_debug("rm_id=%d", opts->rm_id);
+
+	return true;
+}
+
 bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
 			       unsigned int *size, unsigned int remaining,
 			       struct mptcp_out_options *opts)
@@ -646,6 +671,11 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
 		remaining -= opt_size;
 		ret = true;
 	}
+	if (mptcp_established_options_rm_addr(sk, &opt_size, remaining, opts)) {
+		*size += opt_size;
+		remaining -= opt_size;
+		ret = true;
+	}
 
 	return ret;
 }
net/mptcp/pm.c +24 -0
index ce12b8b26ad2..91b74ca47fa1 100644
@@ -174,6 +174,29 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
 	return ret;
 }
 
+bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
+			     u8 *rm_id)
+{
+	int ret = false;
+
+	spin_lock_bh(&msk->pm.lock);
+
+	/* double check after the lock is acquired */
+	if (!mptcp_pm_should_rm_signal(msk))
+		goto out_unlock;
+
+	if (remaining < TCPOLEN_MPTCP_RM_ADDR_BASE)
+		goto out_unlock;
+
+	*rm_id = msk->pm.rm_id;
+	WRITE_ONCE(msk->pm.rm_addr_signal, false);
+	ret = true;
+
+out_unlock:
+	spin_unlock_bh(&msk->pm.lock);
+	return ret;
+}
+
 int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc)
 {
 	return mptcp_pm_nl_get_local_id(msk, skc);
@@ -187,6 +210,7 @@ void mptcp_pm_data_init(struct mptcp_sock *msk)
 	msk->pm.subflows = 0;
 	WRITE_ONCE(msk->pm.work_pending, false);
 	WRITE_ONCE(msk->pm.add_addr_signal, false);
+	WRITE_ONCE(msk->pm.rm_addr_signal, false);
 	WRITE_ONCE(msk->pm.accept_addr, false);
 	WRITE_ONCE(msk->pm.accept_subflow, false);
 	msk->pm.status = 0;
net/mptcp/protocol.h +9 -0
index adb63ad49a04..7bd8d08c8fc0 100644
@@ -161,6 +161,7 @@ struct mptcp_pm_data {
 	spinlock_t	lock;		/*protects the whole PM data */
 
 	bool		add_addr_signal;
+	bool		rm_addr_signal;
 	bool		server_side;
 	bool		work_pending;
 	bool		accept_addr;
@@ -174,6 +175,7 @@ struct mptcp_pm_data {
 	u8		local_addr_max;
 	u8		subflows_max;
 	u8		status;
+	u8		rm_id;
 };
 
 struct mptcp_data_frag {
@@ -432,6 +434,11 @@ static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk)
 	return READ_ONCE(msk->pm.add_addr_signal);
 }
 
+static inline bool mptcp_pm_should_rm_signal(struct mptcp_sock *msk)
+{
+	return READ_ONCE(msk->pm.rm_addr_signal);
+}
+
 static inline unsigned int mptcp_add_addr_len(int family)
 {
 	if (family == AF_INET)
@@ -441,6 +448,8 @@ static inline unsigned int mptcp_add_addr_len(int family)
 
 bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
 			      struct mptcp_addr_info *saddr);
+bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
+			     u8 *rm_id);
 int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);
 
 void __init mptcp_pm_nl_init(void);
Signature · 1 line
2.17.1
author
#3 lore raw

PATCH v2 3/4 mptcp: add the RM_ADDR option parsing

In reply to Geliang Tang

This patch added the RM_ADDR option parsing logic.

Suggested-by Matthieu Baerts <matthieu.baerts(a)tessares.net>
Suggested-by Paolo Abeni <pabeni(a)redhat.com>
Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/options.c    |  5 +++++
 net/mptcp/pm.c         | 12 ++++++++++++
 net/mptcp/pm_netlink.c | 20 ++++++++++++++++++++
 net/mptcp/protocol.c   |  8 ++++++--
 net/mptcp/protocol.h   |  5 +++++
 net/mptcp/subflow.c    |  1 +
 6 files changed, 49 insertions(+), 2 deletions(-)
net/mptcp/options.c +5 -0
index 38685e0e06db..b9e6e67ed195 100644
@@ -875,6 +875,11 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb,
 		mp_opt.add_addr = 0;
 	}
 
+	if (mp_opt.rm_addr) {
+		mptcp_pm_rm_addr_received(msk, mp_opt.rm_id);
+		mp_opt.rm_addr = 0;
+	}
+
 	if (!mp_opt.dss)
 		return;
 
net/mptcp/pm.c +12 -0
index 91b74ca47fa1..84fad1fec28b 100644
@@ -149,6 +149,18 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk,
 	spin_unlock_bh(&pm->lock);
 }
 
+void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id)
+{
+	struct mptcp_pm_data *pm = &msk->pm;
+
+	pr_debug("msk=%p remote_id=%d", msk, rm_id);
+
+	spin_lock_bh(&pm->lock);
+	mptcp_pm_schedule_work(msk, MPTCP_PM_RM_ADDR_RECEIVED);
+	pm->rm_id = rm_id;
+	spin_unlock_bh(&pm->lock);
+}
+
 /* path manager helpers */
 
 bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
net/mptcp/pm_netlink.c +20 -0
index c8820c4156e6..2ee7227f5f2b 100644
@@ -261,6 +261,26 @@ void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk)
 	spin_lock_bh(&msk->pm.lock);
 }
 
+void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
+{
+	struct mptcp_subflow_context *subflow, *tmp;
+
+	pr_debug("remote_id %d", msk->pm.rm_id);
+
+	msk->pm.add_addr_accepted--;
+	msk->pm.subflows--;
+	WRITE_ONCE(msk->pm.accept_addr, true);
+
+	list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
+		struct sock *tcp_sk = mptcp_subflow_tcp_sock(subflow);
+
+		if (msk->pm.rm_id == subflow->remote_id) {
+			mptcp_subflow_shutdown(tcp_sk, 1, 1, msk->write_seq);
+			list_del(&subflow->node);
+		}
+	}
+}
+
 static bool address_use_port(struct mptcp_pm_addr_entry *entry)
 {
 	return (entry->flags &
net/mptcp/protocol.c +6 -2
index f0b0b503c262..fcd16e815aa5 100644
@@ -1225,6 +1225,10 @@ static void pm_work(struct mptcp_sock *msk)
 		pm->status &= ~BIT(MPTCP_PM_ADD_ADDR_RECEIVED);
 		mptcp_pm_nl_add_addr_received(msk);
 	}
+	if (pm->status & BIT(MPTCP_PM_RM_ADDR_RECEIVED)) {
+		pm->status &= ~BIT(MPTCP_PM_RM_ADDR_RECEIVED);
+		mptcp_pm_nl_rm_addr_received(msk);
+	}
 	if (pm->status & BIT(MPTCP_PM_ESTABLISHED)) {
 		pm->status &= ~BIT(MPTCP_PM_ESTABLISHED);
 		mptcp_pm_nl_fully_established(msk);
@@ -1381,8 +1385,8 @@ static void mptcp_cancel_work(struct sock *sk)
 		sock_put(sk);
 }
 
-static void mptcp_subflow_shutdown(struct sock *ssk, int how,
-				   bool data_fin_tx_enable, u64 data_fin_tx_seq)
+void mptcp_subflow_shutdown(struct sock *ssk, int how,
+			    bool data_fin_tx_enable, u64 data_fin_tx_seq)
 {
 	lock_sock(ssk);
 
net/mptcp/protocol.h +5 -0
index 7bd8d08c8fc0..fb09b6fb854e 100644
@@ -150,6 +150,7 @@ struct mptcp_addr_info {
 
 enum mptcp_pm_status {
 	MPTCP_PM_ADD_ADDR_RECEIVED,
+	MPTCP_PM_RM_ADDR_RECEIVED,
 	MPTCP_PM_ESTABLISHED,
 	MPTCP_PM_SUBFLOW_ESTABLISHED,
 };
@@ -346,6 +347,8 @@ mptcp_subflow_get_mapped_dsn(const struct mptcp_subflow_context *subflow)
 int mptcp_is_enabled(struct net *net);
 bool mptcp_subflow_data_available(struct sock *sk);
 void __init mptcp_subflow_init(void);
+void mptcp_subflow_shutdown(struct sock *ssk, int how,
+			    bool data_fin_tx_enable, u64 data_fin_tx_seq);
 
 /* called with sk socket lock held */
 int __mptcp_subflow_connect(struct sock *sk, int ifindex,
@@ -423,6 +426,7 @@ void mptcp_pm_subflow_established(struct mptcp_sock *msk,
 void mptcp_pm_subflow_closed(struct mptcp_sock *msk, u8 id);
 void mptcp_pm_add_addr_received(struct mptcp_sock *msk,
 				const struct mptcp_addr_info *addr);
+void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id);
 
 int mptcp_pm_announce_addr(struct mptcp_sock *msk,
 			   const struct mptcp_addr_info *addr);
@@ -457,6 +461,7 @@ void mptcp_pm_nl_data_init(struct mptcp_sock *msk);
 void mptcp_pm_nl_fully_established(struct mptcp_sock *msk);
 void mptcp_pm_nl_subflow_established(struct mptcp_sock *msk);
 void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk);
+void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk);
 int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);
 
 static inline struct mptcp_ext *mptcp_get_ext(struct sk_buff *skb)
net/mptcp/subflow.c +1 -0
index 519122e66f17..2864b8d20dbd 100644
@@ -990,6 +990,7 @@ int __mptcp_subflow_connect(struct sock *sk, int ifindex,
 	subflow->remote_key = msk->remote_key;
 	subflow->local_key = msk->local_key;
 	subflow->token = msk->token;
+	subflow->remote_id = remote->id;
 	mptcp_info2sockaddr(loc, &addr);
 
 	addrlen = sizeof(struct sockaddr_in);
Signature · 1 line
2.17.1
#4 lore raw

[MPTCP] Re: [MPTCP][PATCH v2 mptcp-next 3/4] mptcp: add the RM_ADDR option parsing

Quoted 1 line · Geliang Tang

This patch added the RM_ADDR option parsing logic.

It would be nice if you could elaborate a bit the commit message, briefly describing how the RM_ADDR options are now handled (e.g. subflows matching the addr id are closed, and pm counter updated).

Quoted 64 lines
Suggested-by Matthieu Baerts <matthieu.baerts(a)tessares.net>
Suggested-by Paolo Abeni <pabeni(a)redhat.com>
Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/options.c    |  5 +++++
 net/mptcp/pm.c         | 12 ++++++++++++
 net/mptcp/pm_netlink.c | 20 ++++++++++++++++++++
 net/mptcp/protocol.c   |  8 ++++++--
 net/mptcp/protocol.h   |  5 +++++
 net/mptcp/subflow.c    |  1 +
 6 files changed, 49 insertions(+), 2 deletions(-)
net/mptcp/options.c +5 -0
index 38685e0e06db..b9e6e67ed195 100644
@@ -875,6 +875,11 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb,
 		mp_opt.add_addr = 0;
 	}
 
+	if (mp_opt.rm_addr) {
+		mptcp_pm_rm_addr_received(msk, mp_opt.rm_id);
+		mp_opt.rm_addr = 0;
+	}
+
 	if (!mp_opt.dss)
 		return;
 
net/mptcp/pm.c +12 -0
index 91b74ca47fa1..84fad1fec28b 100644
@@ -149,6 +149,18 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk,
 	spin_unlock_bh(&pm->lock);
 }
 
+void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id)
+{
+	struct mptcp_pm_data *pm = &msk->pm;
+
+	pr_debug("msk=%p remote_id=%d", msk, rm_id);
+
+	spin_lock_bh(&pm->lock);
+	mptcp_pm_schedule_work(msk, MPTCP_PM_RM_ADDR_RECEIVED);
+	pm->rm_id = rm_id;
+	spin_unlock_bh(&pm->lock);
+}
+
 /* path manager helpers */
 
 bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
net/mptcp/pm_netlink.c +5 -0
index c8820c4156e6..2ee7227f5f2b 100644
@@ -261,6 +261,26 @@ void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk)
 	spin_lock_bh(&msk->pm.lock);
 }
 
+void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
+{
+	struct mptcp_subflow_context *subflow, *tmp;
+
+	pr_debug("remote_id %d", msk->pm.rm_id);

net/mptcp/pm_netlink.c void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk) · line 278

Quoted 10 lines
net/mptcp/pm_netlink.c +10 -0
+
+	msk->pm.add_addr_accepted--;
+	msk->pm.subflows--;
+	WRITE_ONCE(msk->pm.accept_addr, true);
+
+	list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
+		struct sock *tcp_sk = mptcp_subflow_tcp_sock(subflow);
+
+		if (msk->pm.rm_id == subflow->remote_id) {
+			mptcp_subflow_shutdown(tcp_sk, 1, 1, msk->write_seq);

the 2nd argument for mptcp_subflow_shutdown() should be something alike 'RCV_SHUTDOWN|SEND_SHUTDOWN' - we are closing the subflow in both direction - and the third argument '0' - the msk will remain open/established.

I think here the subflow socket will be leaked. Can you please double check that with a CONFIG_DEBUG_KMEMLEAK enabled build?

Likely something alike what __mptcp_close_ssk() is currently doing should be added here, but that will not fit nicely with a proper shutdown, so I'm unsure how to address this correctly.

Quoted 4 lines
net/mptcp/pm_netlink.c +4 -0
+			list_del(&subflow->node);
+		}
+	}
+}

[...]

net/mptcp/subflow.c int __mptcp_subflow_connect(struct sock *sk, int ifindex, · line 994

Quoted 10 lines
net/mptcp/subflow.c +1 -0
index 519122e66f17..2864b8d20dbd 100644
@@ -990,6 +990,7 @@ int __mptcp_subflow_connect(struct sock *sk, int ifindex,
 	subflow->remote_key = msk->remote_key;
 	subflow->local_key = msk->local_key;
 	subflow->token = msk->token;
+	subflow->remote_id = remote->id;
 	mptcp_info2sockaddr(loc, &addr);

Whoops... this chunk looks like fixing a long standing bug, thanks!

net/mptcp/subflow.c int __mptcp_subflow_connect(struct sock *sk, int ifindex, · line 996

Quoted 1 line
net/mptcp/subflow.c +0 -0
 	addrlen = sizeof(struct sockaddr_in);

/P

#5 lore raw

[MPTCP] Re: [MPTCP][PATCH v2 mptcp-next 3/4] mptcp: add the RM_ADDR option parsing

Quoted 21 lines · Paolo Abeni
Quoted 5 lines
net/mptcp/pm_netlink.c +5 -0
+void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
+{
+	struct mptcp_subflow_context *subflow, *tmp;
+
+	pr_debug("remote_id %d", msk->pm.rm_id);

net/mptcp/pm_netlink.c void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk) · line 278

Quoted 10 lines
net/mptcp/pm_netlink.c +10 -0
+
+	msk->pm.add_addr_accepted--;
+	msk->pm.subflows--;
+	WRITE_ONCE(msk->pm.accept_addr, true);
+
+	list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
+		struct sock *tcp_sk = mptcp_subflow_tcp_sock(subflow);
+
+		if (msk->pm.rm_id == subflow->remote_id) {
+			mptcp_subflow_shutdown(tcp_sk, 1, 1, msk->write_seq);

the 2nd argument for mptcp_subflow_shutdown() should be something alike 'RCV_SHUTDOWN|SEND_SHUTDOWN' - we are closing the subflow in both direction - and the third argument '0' - the msk will remain open/established.

Quoted 6 lines

I think here the subflow socket will be leaked. Can you please double check that with a CONFIG_DEBUG_KMEMLEAK enabled build?

Likely something alike what __mptcp_close_ssk() is currently doing should be added here, but that will not fit nicely with a proper shutdown, so I'm unsure how to address this correctly.

Whoops... some additional things I missed before:

You must release the msk.pm lock before
invoking mptcp_subflow_shutdown() and re-acquiring it after the function call completes (some CONFIG_DEBUG_ know should warn you at run time).

And the RFC states:

"""
if a host receives a REMOVE_ADDR option, it
must ensure that the affected path or paths are no longer in use before it instigates closure. The receipt of REMOVE_ADDR SHOULD first trigger the sending of a TCP keepalive [RFC1122] on the path, and if a response is received, the path SHOULD NOT be removed. If the path is found to still be alive, the receiving host SHOULD no longer use the specified address for future connections, but it is the responsibility of the host that sent the REMOVE_ADDR to shut down the subflow.
"""

I'm unsure what "the affected path or paths are no longer in use" means here. @Christoph: how is mptcp.org handling this? With a quick glance it looks like it unconditionally remove the subflow[s] ???

Thanks!

Paolo

#6 lore raw

[MPTCP] Re: [MPTCP][PATCH v2 mptcp-next 3/4] mptcp: add the RM_ADDR option parsing

Quoted 50 lines · Paolo Abeni
Quoted 21 lines · Paolo Abeni
Quoted 5 lines
net/mptcp/pm_netlink.c +5 -0
+void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
+{
+	struct mptcp_subflow_context *subflow, *tmp;
+
+	pr_debug("remote_id %d", msk->pm.rm_id);

net/mptcp/pm_netlink.c void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk) · line 278

Quoted 10 lines
net/mptcp/pm_netlink.c +10 -0
+
+	msk->pm.add_addr_accepted--;
+	msk->pm.subflows--;
+	WRITE_ONCE(msk->pm.accept_addr, true);
+
+	list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
+		struct sock *tcp_sk = mptcp_subflow_tcp_sock(subflow);
+
+		if (msk->pm.rm_id == subflow->remote_id) {
+			mptcp_subflow_shutdown(tcp_sk, 1, 1, msk->write_seq);

the 2nd argument for mptcp_subflow_shutdown() should be something alike 'RCV_SHUTDOWN|SEND_SHUTDOWN' - we are closing the subflow in both direction - and the third argument '0' - the msk will remain open/established.

Quoted 6 lines

I think here the subflow socket will be leaked. Can you please double check that with a CONFIG_DEBUG_KMEMLEAK enabled build?

Likely something alike what __mptcp_close_ssk() is currently doing should be added here, but that will not fit nicely with a proper shutdown, so I'm unsure how to address this correctly.

Whoops... some additional things I missed before:

You must release the msk.pm lock before
invoking mptcp_subflow_shutdown() and re-acquiring it after the function call completes (some CONFIG_DEBUG_ know should warn you at run time).

And the RFC states:

"""
if a host receives a REMOVE_ADDR option, it
must ensure that the affected path or paths are no longer in use before it instigates closure. The receipt of REMOVE_ADDR SHOULD first trigger the sending of a TCP keepalive [RFC1122] on the path, and if a response is received, the path SHOULD NOT be removed. If the path is found to still be alive, the receiving host SHOULD no longer use the specified address for future connections, but it is the responsibility of the host that sent the REMOVE_ADDR to shut down the subflow.
"""

Quoted 3 lines

I'm unsure what "the affected path or paths are no longer in use" means here. @Christoph: how is mptcp.org handling this? With a quick glance it looks like it unconditionally remove the subflow[s] ???

Yes, we do unconditionally remove the subflows. The reason was for simplicity, as otherwise we would need to send probes or TCP Keep-alives to check the path.

The risk is that an on-path attacker could inject remove_addr to steer traffic to the path that the attacker has "access" to so that he can monitor the entire connection.

I think that it is OK for now in net-next to unconditionally remove the subflows.

Christoph

author
#7 lore raw

PATCH v2 4/4 mptcp: trigger the RM_ADDR signal

In reply to Geliang Tang

Trigger the RM_ADDR signal when the PM netlink removes an address.

Suggested-by Matthieu Baerts <matthieu.baerts(a)tessares.net>
Suggested-by Paolo Abeni <pabeni(a)redhat.com>
Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/pm.c         |  6 +++++-
 net/mptcp/pm_netlink.c | 32 +++++++++++++++++++++++++++++++-
 net/mptcp/protocol.c   |  1 +
 net/mptcp/protocol.h   |  1 +
 4 files changed, 38 insertions(+), 2 deletions(-)
net/mptcp/pm.c +5 -1
index 84fad1fec28b..4194fd2591c5 100644
@@ -24,7 +24,11 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk,
 
 int mptcp_pm_remove_addr(struct mptcp_sock *msk, u8 local_id)
 {
-	return -ENOTSUPP;
+	pr_debug("msk=%p, local_id=%d", msk, local_id);
+
+	msk->pm.rm_id = local_id;
+	WRITE_ONCE(msk->pm.rm_addr_signal, true);
+	return 0;
 }
 
 int mptcp_pm_remove_subflow(struct mptcp_sock *msk, u8 remote_id)
net/mptcp/pm_netlink.c +31 -1
index 2ee7227f5f2b..646398f16ce8 100644
@@ -23,6 +23,7 @@ static int pm_nl_pernet_id;
 
 struct mptcp_pm_addr_entry {
 	struct list_head	list;
+	struct list_head	alist;
 	unsigned int		flags;
 	int			ifindex;
 	struct mptcp_addr_info	addr;
@@ -169,6 +170,13 @@ static void check_work_pending(struct mptcp_sock *msk)
 		WRITE_ONCE(msk->pm.work_pending, false);
 }
 
+static int mptcp_pm_add_announce_list(struct mptcp_sock *msk,
+				      struct mptcp_pm_addr_entry *entry)
+{
+	list_add(&entry->alist, &msk->anno_list);
+	return 0;
+}
+
 static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
 {
 	struct sock *sk = (struct sock *)msk;
@@ -191,6 +199,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
 		if (local) {
 			msk->pm.add_addr_signaled++;
 			mptcp_pm_announce_addr(msk, &local->addr);
+			mptcp_pm_add_announce_list(msk, local);
 		} else {
 			/* pick failed, avoid fourther attempts later */
 			msk->pm.local_addr_used = msk->pm.add_addr_signal_max;
@@ -537,6 +546,25 @@ __lookup_addr_by_id(struct pm_nl_pernet *pernet, unsigned int id)
 	return NULL;
 }
 
+static void mptcp_nl_remove_addr(struct sk_buff *skb, struct mptcp_addr_info *addr)
+{
+	struct mptcp_sock *msk;
+	long s_slot = 0, s_num = 0;
+	struct net *net = sock_net(skb->sk);
+
+	while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) {
+		struct mptcp_pm_addr_entry *entry, *tmp;
+
+		pr_debug("msk=%p\n", msk);
+		list_for_each_entry_safe(entry, tmp, &msk->anno_list, alist) {
+			if (addresses_equal(&entry->addr, addr, false)) {
+				mptcp_pm_remove_addr(msk, addr->id);
+				list_del(&entry->alist);
+			}
+		}
+	}
+}
+
 static int mptcp_nl_cmd_del_addr(struct sk_buff *skb, struct genl_info *info)
 {
 	struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR];
@@ -555,8 +583,10 @@ static int mptcp_nl_cmd_del_addr(struct sk_buff *skb, struct genl_info *info)
 		ret = -EINVAL;
 		goto out;
 	}
-	if (entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL)
+	if (entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL) {
 		pernet->add_addr_signal_max--;
+		mptcp_nl_remove_addr(skb, &entry->addr);
+	}
 	if (entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW)
 		pernet->local_addr_max--;
 
net/mptcp/protocol.c +1 -0
index fcd16e815aa5..277c5893b4aa 100644
@@ -1325,6 +1325,7 @@ static int __mptcp_init_sock(struct sock *sk)
 
 	INIT_LIST_HEAD(&msk->conn_list);
 	INIT_LIST_HEAD(&msk->join_list);
+	INIT_LIST_HEAD(&msk->anno_list);
 	INIT_LIST_HEAD(&msk->rtx_queue);
 	__set_bit(MPTCP_SEND_SPACE, &msk->flags);
 	INIT_WORK(&msk->work, mptcp_worker);
net/mptcp/protocol.h +1 -0
index fb09b6fb854e..821ac3de0779 100644
@@ -206,6 +206,7 @@ struct mptcp_sock {
 	struct list_head conn_list;
 	struct list_head rtx_queue;
 	struct list_head join_list;
+	struct list_head anno_list;
 	struct skb_ext	*cached_ext;	/* for the next sendmsg */
 	struct socket	*subflow; /* outgoing connect/listener/!mp_capable */
 	struct sock	*first;
Signature · 1 line
2.17.1
#8 lore raw

[MPTCP] Re: [MPTCP][PATCH v2 mptcp-next 4/4] mptcp: trigger the RM_ADDR signal

Quoted 34 lines · Geliang Tang

Trigger the RM_ADDR signal when the PM netlink removes an address.

Suggested-by Matthieu Baerts <matthieu.baerts(a)tessares.net>
Suggested-by Paolo Abeni <pabeni(a)redhat.com>
Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/pm.c         |  6 +++++-
 net/mptcp/pm_netlink.c | 32 +++++++++++++++++++++++++++++++-
 net/mptcp/protocol.c   |  1 +
 net/mptcp/protocol.h   |  1 +
 4 files changed, 38 insertions(+), 2 deletions(-)
net/mptcp/pm.c +5 -1
index 84fad1fec28b..4194fd2591c5 100644
@@ -24,7 +24,11 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk,
 
 int mptcp_pm_remove_addr(struct mptcp_sock *msk, u8 local_id)
 {
-	return -ENOTSUPP;
+	pr_debug("msk=%p, local_id=%d", msk, local_id);
+
+	msk->pm.rm_id = local_id;
+	WRITE_ONCE(msk->pm.rm_addr_signal, true);
+	return 0;
 }
 
 int mptcp_pm_remove_subflow(struct mptcp_sock *msk, u8 remote_id)
net/mptcp/pm_netlink.c +0 -0
index 2ee7227f5f2b..646398f16ce8 100644

net/mptcp/pm_netlink.c static int pm_nl_pernet_id; · line 26

Quoted 4 lines
net/mptcp/pm_netlink.c +1 -0
@@ -23,6 +23,7 @@ static int pm_nl_pernet_id;
 
 struct mptcp_pm_addr_entry {
 	struct list_head	list;
+	struct list_head	alist;

I think this new field is not needed, see below...

Quoted 18 lines
net/mptcp/pm_netlink.c +7 -0
 	unsigned int		flags;
 	int			ifindex;
 	struct mptcp_addr_info	addr;
@@ -169,6 +170,13 @@ static void check_work_pending(struct mptcp_sock *msk)
 		WRITE_ONCE(msk->pm.work_pending, false);
 }
 
+static int mptcp_pm_add_announce_list(struct mptcp_sock *msk,
+				      struct mptcp_pm_addr_entry *entry)
+{
+	list_add(&entry->alist, &msk->anno_list);
+	return 0;
+}
+
 static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
 {
 	struct sock *sk = (struct sock *)msk;

net/mptcp/pm_netlink.c static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) · line 202

Quoted 4 lines
net/mptcp/pm_netlink.c +1 -0
@@ -191,6 +199,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
 		if (local) {
 			msk->pm.add_addr_signaled++;
 			mptcp_pm_announce_addr(msk, &local->addr);
+			mptcp_pm_add_announce_list(msk, local);

Here we need to allocate a new mptcp_pm_addr_entry struct, copy the data from local, and finally add the new entry to anno_list. I guess all the logic could be encapsulated
into mptcp_pm_create_subflow_or_signal_addr(), which could return a bool indicating if the allocation was successful.

In cause of memory allocation failure the announce addr should not be performed.

The same address can be signaled from multiple msks. If we always use the same struct we will see data corruption.

I *think* dynamically allocation of announced address could be ok, I'd like to ear opinions from others.

Quoted 15 lines
net/mptcp/pm_netlink.c +8 -0
 		} else {
 			/* pick failed, avoid fourther attempts later */
 			msk->pm.local_addr_used = msk->pm.add_addr_signal_max;
@@ -537,6 +546,25 @@ __lookup_addr_by_id(struct pm_nl_pernet *pernet, unsigned int id)
 	return NULL;
 }
 
+static void mptcp_nl_remove_addr(struct sk_buff *skb, struct mptcp_addr_info *addr)
+{
+	struct mptcp_sock *msk;
+	long s_slot = 0, s_num = 0;
+	struct net *net = sock_net(skb->sk);
+
+	while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) {
+		struct mptcp_pm_addr_entry *entry, *tmp;

net/mptcp/pm_netlink.c __lookup_addr_by_id(struct pm_nl_pernet *pernet, unsigned int id) · line 566

Quoted 10 lines
net/mptcp/pm_netlink.c +10 -0
+
+		pr_debug("msk=%p\n", msk);
+		list_for_each_entry_safe(entry, tmp, &msk->anno_list, alist) {
+			if (addresses_equal(&entry->addr, addr, false)) {
+				mptcp_pm_remove_addr(msk, addr->id);
+				list_del(&entry->alist);
+			}
+		}
+	}
+}

Here you need to acquire the msk pm lock before traversing the anno_list and eventually removing the entry.

Additionally, we should also shutdown the subflows with the local address matching the removed one. Note that the 'id' could not be used for the first subflow, being always 0, and we should to this for any removed address, regardless of the 'MPTCP_PM_ADDR_FLAG_SIGNAL' flag.

Cheers,

Paolo

author
#9 lore raw

[MPTCP] Re: [MPTCP][PATCH v2 mptcp-next 4/4] mptcp: trigger the RM_ADDR signal

Hi Paolo,

I have sent out REMOVE_ADDR patchset v3 to you.

Quoted 14 lines · Paolo Abeni
Quoted 13 lines · Paolo Abeni
Quoted 13 lines
(quoted diff) +13 -0
+void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
+{
+ struct mptcp_subflow_context *subflow, *tmp;
+
+ pr_debug("remote_id %d", msk->pm.rm_id);
+
+ msk->pm.add_addr_accepted--;
+ msk->pm.subflows--;
+ WRITE_ONCE(msk->pm.accept_addr, true);
+
+ list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
+         struct sock *tcp_sk = mptcp_subflow_tcp_sock(subflow);
+
Quoted 8 lines
Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+         if (msk->pm.rm_id == subflow->remote_id) {
+                 mptcp_subflow_shutdown(tcp_sk, 1, 1, msk->write_seq);

the 2nd argument for mptcp_subflow_shutdown() should be something alike 'RCV_SHUTDOWN|SEND_SHUTDOWN' - we are closing the subflow in both direction - and the third argument '0' - the msk will remain open/established.

I have updated these arguments in patchset v3.

Quoted 6 lines
Quoted 6 lines

I think here the subflow socket will be leaked. Can you please double check that with a CONFIG_DEBUG_KMEMLEAK enabled build?

Likely something alike what __mptcp_close_ssk() is currently doing should be added here, but that will not fit nicely with a proper shutdown, so I'm unsure how to address this correctly.

Yes, there is a memory leak here. I have fixed it in patchset v3 by calling __mptcp_close_ssk.

And there is another memory leak in mptcp_nl_remove_addr, and I fixed it by calling sock_put in patchset v3.

Quoted 7 lines

Whoops... some additional things I missed before:

You must release the msk.pm lock before
invoking mptcp_subflow_shutdown() and re-acquiring it after the function call completes (some CONFIG_DEBUG_ know should warn you at run time).

Fixed in patchset v3.

Quoted 18 lines

And the RFC states:

"""
if a host receives a REMOVE_ADDR option, it
must ensure that the affected path or paths are no longer in use before it instigates closure. The receipt of REMOVE_ADDR SHOULD first trigger the sending of a TCP keepalive [RFC1122] on the path, and if a response is received, the path SHOULD NOT be removed. If the path is found to still be alive, the receiving host SHOULD no longer use the specified address for future connections, but it is the responsibility of the host that sent the REMOVE_ADDR to shut down the subflow.
"""

I'm unsure what "the affected path or paths are no longer in use" means here. @Christoph: how is mptcp.org handling this? With a quick glance it looks like it unconditionally remove the subflow[s] ???

Quoted 71 lines · Paolo Abeni
Quoted 34 lines · Geliang Tang

Trigger the RM_ADDR signal when the PM netlink removes an address.

Suggested-by Matthieu Baerts <matthieu.baerts(a)tessares.net>
Suggested-by Paolo Abeni <pabeni(a)redhat.com>
Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/pm.c         |  6 +++++-
 net/mptcp/pm_netlink.c | 32 +++++++++++++++++++++++++++++++-
 net/mptcp/protocol.c   |  1 +
 net/mptcp/protocol.h   |  1 +
 4 files changed, 38 insertions(+), 2 deletions(-)
net/mptcp/pm.c +5 -1
index 84fad1fec28b..4194fd2591c5 100644
@@ -24,7 +24,11 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk,
 
 int mptcp_pm_remove_addr(struct mptcp_sock *msk, u8 local_id)
 {
-	return -ENOTSUPP;
+	pr_debug("msk=%p, local_id=%d", msk, local_id);
+
+	msk->pm.rm_id = local_id;
+	WRITE_ONCE(msk->pm.rm_addr_signal, true);
+	return 0;
 }
 
 int mptcp_pm_remove_subflow(struct mptcp_sock *msk, u8 remote_id)
net/mptcp/pm_netlink.c +0 -0
index 2ee7227f5f2b..646398f16ce8 100644

net/mptcp/pm_netlink.c static int pm_nl_pernet_id; · line 26

Quoted 4 lines
net/mptcp/pm_netlink.c +1 -0
@@ -23,6 +23,7 @@ static int pm_nl_pernet_id;
 
 struct mptcp_pm_addr_entry {
 	struct list_head	list;
+	struct list_head	alist;

I think this new field is not needed, see below...

Quoted 18 lines
net/mptcp/pm_netlink.c +7 -0
 	unsigned int		flags;
 	int			ifindex;
 	struct mptcp_addr_info	addr;
@@ -169,6 +170,13 @@ static void check_work_pending(struct mptcp_sock *msk)
 		WRITE_ONCE(msk->pm.work_pending, false);
 }
 
+static int mptcp_pm_add_announce_list(struct mptcp_sock *msk,
+				      struct mptcp_pm_addr_entry *entry)
+{
+	list_add(&entry->alist, &msk->anno_list);
+	return 0;
+}
+
 static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
 {
 	struct sock *sk = (struct sock *)msk;

net/mptcp/pm_netlink.c static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) · line 202

Quoted 4 lines
net/mptcp/pm_netlink.c +1 -0
@@ -191,6 +199,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
 		if (local) {
 			msk->pm.add_addr_signaled++;
 			mptcp_pm_announce_addr(msk, &local->addr);
+			mptcp_pm_add_announce_list(msk, local);

Here we need to allocate a new mptcp_pm_addr_entry struct, copy the data from local, and finally add the new entry to anno_list. I guess all the logic could be encapsulated
into mptcp_pm_create_subflow_or_signal_addr(), which could return a bool indicating if the allocation was successful.

Quoted 9 lines

In cause of memory allocation failure the announce addr should not be performed.

The same address can be signaled from multiple msks. If we always use the same struct we will see data corruption.

I *think* dynamically allocation of announced address could be ok, I'd like to ear opinions from others.

Fixed in patchset v3.

Quoted 20 lines
Quoted 20 lines
net/mptcp/pm_netlink.c +13 -0
 		} else {
 			/* pick failed, avoid fourther attempts later */
 			msk->pm.local_addr_used = msk->pm.add_addr_signal_max;
@@ -537,6 +546,25 @@ __lookup_addr_by_id(struct pm_nl_pernet *pernet, unsigned int id)
 	return NULL;
 }
 
+static void mptcp_nl_remove_addr(struct sk_buff *skb, struct mptcp_addr_info *addr)
+{
+	struct mptcp_sock *msk;
+	long s_slot = 0, s_num = 0;
+	struct net *net = sock_net(skb->sk);
+
+	while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) {
+		struct mptcp_pm_addr_entry *entry, *tmp;
+
+		pr_debug("msk=%p\n", msk);
+		list_for_each_entry_safe(entry, tmp, &msk->anno_list, alist) {
+			if (addresses_equal(&entry->addr, addr, false)) {
+				mptcp_pm_remove_addr(msk, addr->id);
Quoted 9 lines

net/mptcp/pm_netlink.c __lookup_addr_by_id(struct pm_nl_pernet *pernet, unsigned int id) · line 566

Quoted 5 lines
net/mptcp/pm_netlink.c +5 -0
+				list_del(&entry->alist);
+			}
+		}
+	}
+}

Here you need to acquire the msk pm lock before traversing the anno_list and eventually removing the entry.

Fixed in patchset v3.

Quoted 4 lines

Additionally, we should also shutdown the subflows with the local address matching the removed one. Note that the 'id' could not be used for the first subflow, being always 0, and we should to this for any removed address, regardless of the 'MPTCP_PM_ADDR_FLAG_SIGNAL' flag.

I'll add a new function mptcp_nl_remove_subflow to handle the 'MPTCP_PM_ADDR_FLAG_SUBFLOW' flag case. Do the local subflow removing in this function. I'll send out this patch later.

Thanks.

-Geliang

Quoted 4 lines

Cheers,

Paolo

#10 lore raw

[MPTCP] Re: [MPTCP][PATCH v2 mptcp-next 4/4] mptcp: trigger the RM_ADDR signal

Quoted 26 lines · Geliang Tang

I have sent out REMOVE_ADDR patchset v3 to you.

Quoted 14 lines · Paolo Abeni
Quoted 13 lines · Paolo Abeni
Quoted 13 lines
(quoted diff) +13 -0
+void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
+{
+ struct mptcp_subflow_context *subflow, *tmp;
+
+ pr_debug("remote_id %d", msk->pm.rm_id);
+
+ msk->pm.add_addr_accepted--;
+ msk->pm.subflows--;
+ WRITE_ONCE(msk->pm.accept_addr, true);
+
+ list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
+         struct sock *tcp_sk = mptcp_subflow_tcp_sock(subflow);
+
Quoted 8 lines
Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+         if (msk->pm.rm_id == subflow->remote_id) {
+                 mptcp_subflow_shutdown(tcp_sk, 1, 1, msk->write_seq);

the 2nd argument for mptcp_subflow_shutdown() should be something alike 'RCV_SHUTDOWN|SEND_SHUTDOWN' - we are closing the subflow in both direction - and the third argument '0' - the msk will remain open/established.

Quoted 1 line

I have updated these arguments in patchset v3.

Thanks! I'll try to review before tomorrow's mtg - sorry for the latency, I'm lagging behind other tasks.

/P