Skip to contentSkip to conversation

RM_ADDR: remove a list of addrs

PATCH Superseded Geliang Tang 2 participants 12 messages Jan 29, 2021 – Jan 30, 2021

Subsystems (3)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Geliang Tang

author
#0 lore raw

cover RM_ADDR: remove a list of addrs

This patchset added the removing a list of addresses support for RM_ADDR. It addressed issue #140.

tag: export/20210129T064739

Geliang Tang (8):
mptcp: remove multi addrs on outgoing path
mptcp: remove multi addrs on incoming path
mptcp: add removing multi addrs support in PM
mptcp: add removing multi addrs support in netlink
mptcp: implement mptcp_nl_remove_addrs_and_subflows
mptcp: remove a list of addrs when flushing
mptcp: update the netlink event for rm_addr
selftests: mptcp: add testcases for removing addrs

 include/net/mptcp.h                           |   2 +-
 include/uapi/linux/mptcp.h                    |   1 +
 net/mptcp/options.c                           |  53 +++--
 net/mptcp/pm.c                                |  26 +--
 net/mptcp/pm_netlink.c                        | 182 ++++++++++++++----
 net/mptcp/protocol.h                          |  23 ++-
 .../testing/selftests/net/mptcp/mptcp_join.sh |  23 +++
 7 files changed, 235 insertions(+), 75 deletions(-)
Signature · 1 line
2.29.2
author
#1 lore raw

PATCH 1/8 mptcp: remove multi addrs on outgoing path

This patch changed the type of rm_id in struct mptcp_out_options from u8 to u64, and renamed it to rm_ids. It was used as a map of address ids that need to be removed. Up to 8 address ids could be encoded in it.

Added a new macro named mptcp_for_each_id to iterate out each address id form the ids map.

In mptcp_established_options_rm_addr, invoked mptcp_pm_rm_addr_signal to get the ids map. According the number of addresses in the ids map, calculated the padded RM_ADDR suboption length. And saved the ids map in struct mptcp_out_options's rm_ids member.

In mptcp_write_options, used mptcp_for_each_id to iterate out each address id, then filled them into the RM_ADDR suboption.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 include/net/mptcp.h  |  2 +-
 net/mptcp/options.c  | 40 ++++++++++++++++++++++++++++++++--------
 net/mptcp/pm.c       |  4 ++--
 net/mptcp/protocol.h |  9 +++++++--
 4 files changed, 42 insertions(+), 13 deletions(-)
include/net/mptcp.h +1 -1
index 5694370be3d4..21232c4e15fe 100644
@@ -48,7 +48,7 @@ struct mptcp_out_options {
 	u8 addr_id;
 	u16 port;
 	u64 ahmac;
-	u8 rm_id;
+	u64 rm_ids;
 	u8 join_id;
 	u8 backup;
 	u32 nonce;
net/mptcp/options.c +32 -8
index 775f0576592e..11f6182b8319 100644
@@ -671,20 +671,29 @@ static bool mptcp_established_options_rm_addr(struct sock *sk,
 {
 	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
 	struct mptcp_sock *msk = mptcp_sk(subflow->conn);
-	u8 rm_id;
+	u8 *ptr, id, nr;
+	u64 rm_ids;
 
 	if (!mptcp_pm_should_rm_signal(msk) ||
-	    !(mptcp_pm_rm_addr_signal(msk, remaining, &rm_id)))
+	    !(mptcp_pm_rm_addr_signal(msk, remaining, &rm_ids)))
 		return false;
 
-	if (remaining < TCPOLEN_MPTCP_RM_ADDR_BASE)
+	mptcp_for_each_id(rm_ids, nr, ptr, id)
+		;
+
+	if (nr > 1)
+		nr = 5;
+	if (nr > 5)
+		nr = 9;
+
+	if (remaining < TCPOLEN_MPTCP_RM_ADDR_BASE + nr)
 		return false;
 
-	*size = TCPOLEN_MPTCP_RM_ADDR_BASE;
+	*size = TCPOLEN_MPTCP_RM_ADDR_BASE + nr;
 	opts->suboptions |= OPTION_MPTCP_RM_ADDR;
-	opts->rm_id = rm_id;
+	opts->rm_ids = rm_ids;
 
-	pr_debug("rm_id=%d", opts->rm_id);
+	pr_debug("rm_ids=%llu", opts->rm_ids);
 
 	return true;
 }
@@ -1211,9 +1220,24 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
 	}
 
 	if (OPTION_MPTCP_RM_ADDR & opts->suboptions) {
+		u8 rm_ids[8] = { 0 };
+		u8 *tmp, id, nr;
+
+		mptcp_for_each_id(opts->rm_ids, nr, tmp, id)
+			rm_ids[nr] = id;
 		*ptr++ = mptcp_option(MPTCPOPT_RM_ADDR,
-				      TCPOLEN_MPTCP_RM_ADDR_BASE,
-				      0, opts->rm_id);
+				      TCPOLEN_MPTCP_RM_ADDR_BASE + nr,
+				      0, rm_ids[0]);
+		if (nr > 1) {
+			put_unaligned_be32(rm_ids[1] << 24 | rm_ids[2] << 16 |
+					   rm_ids[3] << 8 | rm_ids[4], ptr);
+			ptr += 1;
+		}
+		if (nr > 5) {
+			put_unaligned_be32(rm_ids[5] << 24 | rm_ids[6] << 16 |
+					   rm_ids[7] << 8 | TCPOPT_NOP, ptr);
+			ptr += 1;
+		}
 	}
 
 	if (OPTION_MPTCP_PRIO & opts->suboptions) {
net/mptcp/pm.c +2 -2
index 6fd4b2c1b076..7ec1d2a1582b 100644
@@ -258,7 +258,7 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
 }
 
 bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
-			     u8 *rm_id)
+			     u64 *rm_ids)
 {
 	int ret = false;
 
@@ -271,7 +271,7 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
 	if (remaining < TCPOLEN_MPTCP_RM_ADDR_BASE)
 		goto out_unlock;
 
-	*rm_id = msk->pm.rm_id;
+	*rm_ids = msk->pm.rm_id;
 	WRITE_ONCE(msk->pm.addr_signal, 0);
 	ret = true;
 
net/mptcp/protocol.h +7 -2
index 447ce4631b43..962cc1b4dd48 100644
@@ -60,7 +60,7 @@
 #define TCPOLEN_MPTCP_ADD_ADDR6_BASE	20
 #define TCPOLEN_MPTCP_ADD_ADDR6_BASE_PORT	24
 #define TCPOLEN_MPTCP_PORT_LEN		4
-#define TCPOLEN_MPTCP_RM_ADDR_BASE	4
+#define TCPOLEN_MPTCP_RM_ADDR_BASE	3
 #define TCPOLEN_MPTCP_PRIO		4
 #define TCPOLEN_MPTCP_FASTCLOSE		12
 
@@ -288,6 +288,11 @@ struct mptcp_sock {
 #define mptcp_for_each_subflow(__msk, __subflow)			\
 	list_for_each_entry(__subflow, &((__msk)->conn_list), node)
 
+#define mptcp_for_each_id(ids, nr, ptr, id)				\
+	for ((nr) = 0, (ptr) = (u8 *)&(ids);				\
+	     (nr) < 8 && (id = *(ptr));					\
+	     (nr)++, (ptr)++)
+
 static inline void msk_owned_by_me(const struct mptcp_sock *msk)
 {
 	sock_owned_by_me((const struct sock *)msk);
@@ -713,7 +718,7 @@ static inline unsigned int mptcp_add_addr_len(int family, bool echo, bool port)
 bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
 			      struct mptcp_addr_info *saddr, bool *echo, bool *port);
 bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
-			     u8 *rm_id);
+			     u64 *rm_ids);
 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.29.2
author
#2 lore raw

PATCH 2/8 mptcp: remove multi addrs on incoming path

This patch changed the type of rm_id in struct mptcp_options_received from u8 to u64, and renamed it to rm_ids.

In mptcp_parse_option, parsed the RM_ADDR suboption and filled them into the ids map in struct mptcp_options_received.

In mptcp_incoming_options, passed this ids map to the function mptcp_pm_rm_addr_received.

It alse changed the parameter type of mptcp_pm_rm_addr_received.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/options.c  | 13 +++++++++----
 net/mptcp/pm.c       |  8 ++++----
 net/mptcp/protocol.h |  4 ++--
 3 files changed, 15 insertions(+), 10 deletions(-)
net/mptcp/options.c +9 -4
index 11f6182b8319..53035c2ec40f 100644
@@ -25,6 +25,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
 	u8 subtype = *ptr >> 4;
 	int expected_opsize;
 	u8 version;
+	u8 *p, i;
 	u8 flags;
 
 	switch (subtype) {
@@ -272,14 +273,18 @@ static void mptcp_parse_option(const struct sk_buff *skb,
 		break;
 
 	case MPTCPOPT_RM_ADDR:
-		if (opsize != TCPOLEN_MPTCP_RM_ADDR_BASE)
+		if (opsize < TCPOLEN_MPTCP_RM_ADDR_BASE + 1 ||
+		    opsize > TCPOLEN_MPTCP_RM_ADDR_BASE + 8)
 			break;
 
 		ptr++;
 
 		mp_opt->rm_addr = 1;
-		mp_opt->rm_id = *ptr++;
-		pr_debug("RM_ADDR: id=%d", mp_opt->rm_id);
+		mp_opt->rm_ids = 0;
+		p = (u8 *)&mp_opt->rm_ids;
+		for (i = 0; i < opsize - TCPOLEN_MPTCP_RM_ADDR_BASE; i++)
+			*p++ = *ptr++;
+		pr_debug("RM_ADDR: ids=%llu", mp_opt->rm_ids);
 		break;
 
 	case MPTCPOPT_MP_PRIO:
@@ -1041,7 +1046,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
 	}
 
 	if (mp_opt.rm_addr) {
-		mptcp_pm_rm_addr_received(msk, mp_opt.rm_id);
+		mptcp_pm_rm_addr_received(msk, mp_opt.rm_ids);
 		mp_opt.rm_addr = 0;
 	}
 
net/mptcp/pm.c +4 -4
index 7ec1d2a1582b..1c10011e5abf 100644
@@ -205,17 +205,17 @@ void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk)
 	mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_SEND_ACK);
 }
 
-void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id)
+void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u64 rm_ids)
 {
 	struct mptcp_pm_data *pm = &msk->pm;
 
-	pr_debug("msk=%p remote_id=%d", msk, rm_id);
+	pr_debug("msk=%p remote_ids=%llu", msk, rm_ids);
 
-	mptcp_event_addr_removed(msk, rm_id);
+	mptcp_event_addr_removed(msk, rm_ids);
 
 	spin_lock_bh(&pm->lock);
 	mptcp_pm_schedule_work(msk, MPTCP_PM_RM_ADDR_RECEIVED);
-	pm->rm_id = rm_id;
+	pm->rm_id = rm_ids;
 	spin_unlock_bh(&pm->lock);
 }
 
net/mptcp/protocol.h +2 -2
index 962cc1b4dd48..dd6899ab1f19 100644
@@ -139,7 +139,7 @@ struct mptcp_options_received {
 		mpc_map:1,
 		__unused:2;
 	u8	addr_id;
-	u8	rm_id;
+	u64	rm_ids;
 	union {
 		struct in_addr	addr;
 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
@@ -654,7 +654,7 @@ 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_add_addr_send_ack(struct mptcp_sock *msk);
-void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id);
+void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u64 rm_ids);
 void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup);
 int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,
 				 struct mptcp_addr_info *addr,
Signature · 1 line
2.29.2
author
#3 lore raw

PATCH 3/8 mptcp: add removing multi addrs support in PM

This patch changed the type of rm_id in struct mptcp_pm_data from u8 to u64, and renamed it to rm_ids. Every place where pm.rm_id was used had been modified too.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/pm.c         | 12 ++++++------
 net/mptcp/pm_netlink.c |  6 +++---
 net/mptcp/protocol.h   |  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)
net/mptcp/pm.c +6 -6
index 1c10011e5abf..117ba05f60c0 100644
@@ -39,18 +39,18 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk,
 	return 0;
 }
 
-int mptcp_pm_remove_addr(struct mptcp_sock *msk, u8 local_id)
+int mptcp_pm_remove_addr(struct mptcp_sock *msk, u64 local_ids)
 {
 	u8 rm_addr = READ_ONCE(msk->pm.addr_signal);
 
-	pr_debug("msk=%p, local_id=%d", msk, local_id);
+	pr_debug("msk=%p, local_ids=%llu", msk, local_ids);
 
 	if (rm_addr) {
 		pr_warn("addr_signal error, rm_addr=%d", rm_addr);
 		return -EINVAL;
 	}
 
-	msk->pm.rm_id = local_id;
+	msk->pm.rm_ids = local_ids;
 	rm_addr |= BIT(MPTCP_RM_ADDR_SIGNAL);
 	WRITE_ONCE(msk->pm.addr_signal, rm_addr);
 	return 0;
@@ -215,7 +215,7 @@ void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u64 rm_ids)
 
 	spin_lock_bh(&pm->lock);
 	mptcp_pm_schedule_work(msk, MPTCP_PM_RM_ADDR_RECEIVED);
-	pm->rm_id = rm_ids;
+	pm->rm_ids = rm_ids;
 	spin_unlock_bh(&pm->lock);
 }
 
@@ -271,7 +271,7 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
 	if (remaining < TCPOLEN_MPTCP_RM_ADDR_BASE)
 		goto out_unlock;
 
-	*rm_ids = msk->pm.rm_id;
+	*rm_ids = msk->pm.rm_ids;
 	WRITE_ONCE(msk->pm.addr_signal, 0);
 	ret = true;
 
@@ -291,7 +291,7 @@ void mptcp_pm_data_init(struct mptcp_sock *msk)
 	msk->pm.add_addr_accepted = 0;
 	msk->pm.local_addr_used = 0;
 	msk->pm.subflows = 0;
-	msk->pm.rm_id = 0;
+	msk->pm.rm_ids = 0;
 	WRITE_ONCE(msk->pm.work_pending, false);
 	WRITE_ONCE(msk->pm.addr_signal, 0);
 	WRITE_ONCE(msk->pm.accept_addr, false);
net/mptcp/pm_netlink.c +3 -3
index f2a6e77c1dec..aa0c471b82c4 100644
@@ -575,11 +575,11 @@ static void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
 	struct mptcp_subflow_context *subflow, *tmp;
 	struct sock *sk = (struct sock *)msk;
 
-	pr_debug("address rm_id %d", msk->pm.rm_id);
+	pr_debug("address rm_ids %llu", msk->pm.rm_ids);
 
 	msk_owned_by_me(msk);
 
-	if (!msk->pm.rm_id)
+	if (!msk->pm.rm_ids)
 		return;
 
 	if (list_empty(&msk->conn_list))
@@ -589,7 +589,7 @@ static void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
 		int how = RCV_SHUTDOWN | SEND_SHUTDOWN;
 
-		if (msk->pm.rm_id != subflow->remote_id)
+		if (msk->pm.rm_ids != subflow->remote_id)
 			continue;
 
 		spin_unlock_bh(&msk->pm.lock);
net/mptcp/protocol.h +2 -2
index dd6899ab1f19..c5a3950a25e3 100644
@@ -204,7 +204,7 @@ struct mptcp_pm_data {
 	u8		local_addr_used;
 	u8		subflows;
 	u8		status;
-	u8		rm_id;
+	u64		rm_ids;
 };
 
 struct mptcp_data_frag {
@@ -668,7 +668,7 @@ mptcp_pm_del_add_timer(struct mptcp_sock *msk,
 int mptcp_pm_announce_addr(struct mptcp_sock *msk,
 			   const struct mptcp_addr_info *addr,
 			   bool echo, bool port);
-int mptcp_pm_remove_addr(struct mptcp_sock *msk, u8 local_id);
+int mptcp_pm_remove_addr(struct mptcp_sock *msk, u64 local_ids);
 int mptcp_pm_remove_subflow(struct mptcp_sock *msk, u8 local_id);
 
 void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk,
Signature · 1 line
2.29.2
author
#4 lore raw

PATCH 4/8 mptcp: add removing multi addrs support in netlink

In mptcp_pm_nl_rm_addr_received and mptcp_pm_nl_rm_subflow_received, used mptcp_for_each_id to iterate out each addree id from the received ids map. Then shut down and closed each addree id's subsocket.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/pm_netlink.c | 68 +++++++++++++++++++++++-------------------
 net/mptcp/protocol.h   |  2 +-
 2 files changed, 39 insertions(+), 31 deletions(-)
net/mptcp/pm_netlink.c +38 -30
index aa0c471b82c4..d6da874e6179 100644
@@ -574,6 +574,7 @@ static void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
 {
 	struct mptcp_subflow_context *subflow, *tmp;
 	struct sock *sk = (struct sock *)msk;
+	u8 *ptr, id, nr;
 
 	pr_debug("address rm_ids %llu", msk->pm.rm_ids);
 
@@ -585,25 +586,28 @@ static void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
 	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);
-		int how = RCV_SHUTDOWN | SEND_SHUTDOWN;
+	mptcp_for_each_id(msk->pm.rm_ids, nr, ptr, id) {
+		list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
+			struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
+			int how = RCV_SHUTDOWN | SEND_SHUTDOWN;
 
-		if (msk->pm.rm_ids != subflow->remote_id)
-			continue;
+			if (id != subflow->remote_id)
+				continue;
 
-		spin_unlock_bh(&msk->pm.lock);
-		mptcp_subflow_shutdown(sk, ssk, how);
-		mptcp_close_ssk(sk, ssk, subflow);
-		spin_lock_bh(&msk->pm.lock);
+			pr_debug("address rm_id=%u", id);
+			spin_unlock_bh(&msk->pm.lock);
+			mptcp_subflow_shutdown(sk, ssk, how);
+			mptcp_close_ssk(sk, ssk, subflow);
+			spin_lock_bh(&msk->pm.lock);
 
-		msk->pm.add_addr_accepted--;
-		msk->pm.subflows--;
-		WRITE_ONCE(msk->pm.accept_addr, true);
+			msk->pm.add_addr_accepted--;
+			msk->pm.subflows--;
+			WRITE_ONCE(msk->pm.accept_addr, true);
 
-		__MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RMADDR);
+			__MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RMADDR);
 
-		break;
+			break;
+		}
 	}
 }
 
@@ -640,39 +644,43 @@ void mptcp_pm_nl_work(struct mptcp_sock *msk)
 	spin_unlock_bh(&msk->pm.lock);
 }
 
-void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, u8 rm_id)
+void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, u64 rm_ids)
 {
 	struct mptcp_subflow_context *subflow, *tmp;
 	struct sock *sk = (struct sock *)msk;
+	u8 *ptr, id, nr;
 
-	pr_debug("subflow rm_id %d", rm_id);
+	pr_debug("subflow rm_ids %llu", rm_ids);
 
 	msk_owned_by_me(msk);
 
-	if (!rm_id)
+	if (!rm_ids)
 		return;
 
 	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);
-		int how = RCV_SHUTDOWN | SEND_SHUTDOWN;
+	mptcp_for_each_id(rm_ids, nr, ptr, id) {
+		list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
+			struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
+			int how = RCV_SHUTDOWN | SEND_SHUTDOWN;
 
-		if (rm_id != subflow->local_id)
-			continue;
+			if (id != subflow->local_id)
+				continue;
 
-		spin_unlock_bh(&msk->pm.lock);
-		mptcp_subflow_shutdown(sk, ssk, how);
-		mptcp_close_ssk(sk, ssk, subflow);
-		spin_lock_bh(&msk->pm.lock);
+			pr_debug("subflow rm_id=%u", id);
+			spin_unlock_bh(&msk->pm.lock);
+			mptcp_subflow_shutdown(sk, ssk, how);
+			mptcp_close_ssk(sk, ssk, subflow);
+			spin_lock_bh(&msk->pm.lock);
 
-		msk->pm.local_addr_used--;
-		msk->pm.subflows--;
+			msk->pm.local_addr_used--;
+			msk->pm.subflows--;
 
-		__MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RMSUBFLOW);
+			__MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RMSUBFLOW);
 
-		break;
+			break;
+		}
 	}
 }
 
net/mptcp/protocol.h +1 -1
index c5a3950a25e3..02bb9c882041 100644
@@ -724,7 +724,7 @@ int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);
 void __init mptcp_pm_nl_init(void);
 void mptcp_pm_nl_data_init(struct mptcp_sock *msk);
 void mptcp_pm_nl_work(struct mptcp_sock *msk);
-void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, u8 rm_id);
+void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, u64 rm_ids);
 int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);
 unsigned int mptcp_pm_get_add_addr_signal_max(struct mptcp_sock *msk);
 unsigned int mptcp_pm_get_add_addr_accept_max(struct mptcp_sock *msk);
Signature · 1 line
2.29.2
author
#5 lore raw

PATCH 5/8 mptcp: implement mptcp_nl_remove_addrs_and_subflows

This patch implemented a new function named mptcp_nl_remove_addrs_and_subflows, which had a input parameter rm_ids as a ids map.

If the msk->conn_list is empty, only invoke mptcp_pm_remove_anno_addrs to remove the announced addresses. If it's not empty, invoke mptcp_pm_remove_anno_addrs_and_subflows to remove the announced addresses and the subflows.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/pm.c         |  6 +--
 net/mptcp/pm_netlink.c | 85 ++++++++++++++++++++++++++++++++++++++++++
 net/mptcp/protocol.h   |  2 +-
 3 files changed, 89 insertions(+), 4 deletions(-)
net/mptcp/pm.c +3 -3
index 117ba05f60c0..63be14625457 100644
@@ -56,12 +56,12 @@ int mptcp_pm_remove_addr(struct mptcp_sock *msk, u64 local_ids)
 	return 0;
 }
 
-int mptcp_pm_remove_subflow(struct mptcp_sock *msk, u8 local_id)
+int mptcp_pm_remove_subflow(struct mptcp_sock *msk, u64 local_ids)
 {
-	pr_debug("msk=%p, local_id=%d", msk, local_id);
+	pr_debug("msk=%p, local_ids=%llu", msk, local_ids);
 
 	spin_lock_bh(&msk->pm.lock);
-	mptcp_pm_nl_rm_subflow_received(msk, local_id);
+	mptcp_pm_nl_rm_subflow_received(msk, local_ids);
 	spin_unlock_bh(&msk->pm.lock);
 	return 0;
 }
net/mptcp/pm_netlink.c +85 -0

91 lines not on this page · raw message

net/mptcp/protocol.h +1 -1
index 02bb9c882041..9dd276cb1f71 100644
@@ -669,7 +669,7 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk,
 			   const struct mptcp_addr_info *addr,
 			   bool echo, bool port);
 int mptcp_pm_remove_addr(struct mptcp_sock *msk, u64 local_ids);
-int mptcp_pm_remove_subflow(struct mptcp_sock *msk, u8 local_id);
+int mptcp_pm_remove_subflow(struct mptcp_sock *msk, u64 local_ids);
 
 void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk,
 		 const struct sock *ssk, gfp_t gfp);
Signature · 1 line
2.29.2
author
#6 lore raw

PATCH 6/8 mptcp: remove a list of addrs when flushing

This patch invoked mptcp_nl_remove_addrs_and_subflows to remove a list of addresses when the netlink flushes addresses, instead of using mptcp_nl_remove_subflow_and_signal_addr to remove them one by one.

Since mptcp_nl_remove_subflow_and_signal_addr was dropped from __flush_addrs, __flush_addrs could be invoked under the locks. So dropped the useless free_list in mptcp_nl_cmd_flush_addrs and the unused parameter net in __flush_addrs.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/pm_netlink.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
net/mptcp/pm_netlink.c +15 -6
index e5d36814909c..3801931ab9ea 100644
@@ -1277,14 +1277,13 @@ static void mptcp_nl_remove_addrs_and_subflows(struct net *net, u64 rm_ids)
 	}
 }
 
-static void __flush_addrs(struct net *net, struct list_head *list)
+static void __flush_addrs(struct list_head *list)
 {
 	while (!list_empty(list)) {
 		struct mptcp_pm_addr_entry *cur;
 
 		cur = list_entry(list->next,
 				 struct mptcp_pm_addr_entry, list);
-		mptcp_nl_remove_subflow_and_signal_addr(net, &cur->addr);
 		list_del_rcu(&cur->list);
 		mptcp_pm_free_addr_entry(cur);
 	}
@@ -1301,15 +1300,25 @@ static void __reset_counters(struct pm_nl_pernet *pernet)
 static int mptcp_nl_cmd_flush_addrs(struct sk_buff *skb, struct genl_info *info)
 {
 	struct pm_nl_pernet *pernet = genl_info_pm_nl(info);
-	LIST_HEAD(free_list);
+	struct mptcp_pm_addr_entry *entry;
+	u64 rm_ids = 0;
+	u8 *id;
+
+	id = (u8 *)&rm_ids;
+	spin_lock_bh(&pernet->lock);
+	list_for_each_entry(entry, &pernet->local_addr_list, list) {
+		if (entry->addr.id)
+			*id++ = entry->addr.id;
+	}
+	spin_unlock_bh(&pernet->lock);
+	mptcp_nl_remove_addrs_and_subflows(sock_net(skb->sk), rm_ids);
 
 	spin_lock_bh(&pernet->lock);
-	list_splice_init(&pernet->local_addr_list, &free_list);
+	__flush_addrs(&pernet->local_addr_list);
 	__reset_counters(pernet);
 	pernet->next_id = 1;
 	bitmap_zero(pernet->id_bitmap, MAX_ADDR_ID + 1);
 	spin_unlock_bh(&pernet->lock);
-	__flush_addrs(sock_net(skb->sk), &free_list);
 	return 0;
 }
 
@@ -1906,7 +1915,7 @@ static void __net_exit pm_nl_exit_net(struct list_head *net_list)
 		/* net is removed from namespace list, can't race with
 		 * other modifiers
 		 */
-		__flush_addrs(net, &pernet->local_addr_list);
+		__flush_addrs(&pernet->local_addr_list);
 	}
 }
 
Signature · 1 line
2.29.2
author
#7 lore raw

PATCH 7/8 mptcp: update the netlink event for rm_addr

Since the parameter id passed to mptcp_event_addr_removed was changed as a u64 number, the netlink event for removing addresses needed to be updated.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 include/uapi/linux/mptcp.h | 1 +
 net/mptcp/pm_netlink.c     | 4 ++--
 net/mptcp/protocol.h       | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)
include/uapi/linux/mptcp.h +1 -0
index c91578aaab32..227e8edb4a28 100644
@@ -172,6 +172,7 @@ enum mptcp_event_attr {
 	MPTCP_ATTR_FLAGS,	/* u16 */
 	MPTCP_ATTR_TIMEOUT,	/* u32 */
 	MPTCP_ATTR_IF_IDX,	/* s32 */
+	MPTCP_ATTR_PAD,
 
 	__MPTCP_ATTR_AFTER_LAST
 };
net/mptcp/pm_netlink.c +2 -2
index 3801931ab9ea..bc473ea4fcc2 100644
@@ -1705,7 +1705,7 @@ static int mptcp_event_created(struct sk_buff *skb,
 	return mptcp_event_add_subflow(skb, ssk);
 }
 
-void mptcp_event_addr_removed(const struct mptcp_sock *msk, uint8_t id)
+void mptcp_event_addr_removed(const struct mptcp_sock *msk, uint64_t ids)
 {
 	struct net *net = sock_net((const struct sock *)msk);
 	struct nlmsghdr *nlh;
@@ -1725,7 +1725,7 @@ void mptcp_event_addr_removed(const struct mptcp_sock *msk, uint8_t id)
 	if (nla_put_u32(skb, MPTCP_ATTR_TOKEN, msk->token))
 		goto nla_put_failure;
 
-	if (nla_put_u8(skb, MPTCP_ATTR_REM_ID, id))
+	if (nla_put_u64_64bit(skb, MPTCP_ATTR_REM_ID, ids, MPTCP_ATTR_PAD))
 		goto nla_put_failure;
 
 	genlmsg_end(skb, nlh);
net/mptcp/protocol.h +1 -1
index 9dd276cb1f71..af1d70843791 100644
@@ -674,7 +674,7 @@ int mptcp_pm_remove_subflow(struct mptcp_sock *msk, u64 local_ids);
 void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk,
 		 const struct sock *ssk, gfp_t gfp);
 void mptcp_event_addr_announced(const struct mptcp_sock *msk, const struct mptcp_addr_info *info);
-void mptcp_event_addr_removed(const struct mptcp_sock *msk, u8 id);
+void mptcp_event_addr_removed(const struct mptcp_sock *msk, u64 ids);
 
 static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk)
 {
Signature · 1 line
2.29.2
author
#8 lore raw

PATCH 8/8 selftests: mptcp: add testcases for removing addrs

This patch added the testcases for removing a list of addresses. Used the netlink to flush the addresses in the testcases.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_join.sh +23 -0
index 964db9ed544f..45e1aff7a31c 100755
@@ -869,6 +869,29 @@ remove_tests()
 	chk_join_nr "flush subflows and signal" 3 3 3
 	chk_add_nr 1 1
 	chk_rm_nr 2 2
+
+	# subflows flush
+	reset
+	ip netns exec $ns1 ./pm_nl_ctl limits 3 3
+	ip netns exec $ns2 ./pm_nl_ctl limits 3 3
+	ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow id 150
+	ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
+	ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow
+	run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow
+	chk_join_nr "flush subflows" 3 3 3
+	chk_rm_nr 3 3
+
+	# addresses flush
+	reset
+	ip netns exec $ns1 ./pm_nl_ctl limits 3 3
+	ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal id 250
+	ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal
+	ip netns exec $ns1 ./pm_nl_ctl add 10.0.4.1 flags signal
+	ip netns exec $ns2 ./pm_nl_ctl limits 3 3
+	run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow
+	chk_join_nr "flush addresses" 3 3 3
+	chk_add_nr 3 3
+	chk_rm_nr 0 0
 }
 
 add_tests()
Signature · 1 line
2.29.2
#11 lore raw

[MPTCP] Re: [MPTCP][PATCH mptcp-next 1/8] mptcp: remove multi addrs on outgoing path

In reply to Geliang Tang
Quoted 28 lines · Geliang Tang

This patch changed the type of rm_id in struct mptcp_out_options from u8 to u64, and renamed it to rm_ids. It was used as a map of address ids that need to be removed. Up to 8 address ids could be encoded in it.

Added a new macro named mptcp_for_each_id to iterate out each address id form the ids map.

In mptcp_established_options_rm_addr, invoked mptcp_pm_rm_addr_signal to get the ids map. According the number of addresses in the ids map, calculated the padded RM_ADDR suboption length. And saved the ids map in struct mptcp_out_options's rm_ids member.

In mptcp_write_options, used mptcp_for_each_id to iterate out each address id, then filled them into the RM_ADDR suboption.

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

---

include/net/mptcp.h  |  2 +-
net/mptcp/options.c  | 40 ++++++++++++++++++++++++++++++++--------
net/mptcp/pm.c       |  4 ++--
net/mptcp/protocol.h |  9 +++++++--
4 files changed, 42 insertions(+), 13 deletions(-)
include/net/mptcp.h +0 -0
index 5694370be3d4..21232c4e15fe 100644

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

Quoted 5 lines
include/net/mptcp.h +1 -1
@@ -48,7 +48,7 @@ struct mptcp_out_options {
 	u8 addr_id;
 	u16 port;
 	u64 ahmac;
-	u8 rm_id;
+	u64 rm_ids;

It looks like this u64 is used as an array of u8's, so it would be better to use an array instead of manually doing all the pointer manipulation.

Looking at the RFC, there doesn't seem to be a limit on the number of address ids other than the maximum TCP option size. Did you choose 8 address ids to mach MPTCP_PM_ADDR_MAX?

Quoted 51 lines
include/net/mptcp.h +0 -0
 	u8 join_id;
 	u8 backup;
 	u32 nonce;
net/mptcp/options.c +19 -6
index 775f0576592e..11f6182b8319 100644
@@ -671,20 +671,29 @@ static bool mptcp_established_options_rm_addr(struct sock *sk,
 {
 	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
 	struct mptcp_sock *msk = mptcp_sk(subflow->conn);
-	u8 rm_id;
+	u8 *ptr, id, nr;
+	u64 rm_ids;
 
 	if (!mptcp_pm_should_rm_signal(msk) ||
-	    !(mptcp_pm_rm_addr_signal(msk, remaining, &rm_id)))
+	    !(mptcp_pm_rm_addr_signal(msk, remaining, &rm_ids)))
 		return false;
 
-	if (remaining < TCPOLEN_MPTCP_RM_ADDR_BASE)
+	mptcp_for_each_id(rm_ids, nr, ptr, id)
+		;
+
+	if (nr > 1)
+		nr = 5;
+	if (nr > 5)
+		nr = 9;
+
+	if (remaining < TCPOLEN_MPTCP_RM_ADDR_BASE + nr)
 		return false;
 
-	*size = TCPOLEN_MPTCP_RM_ADDR_BASE;
+	*size = TCPOLEN_MPTCP_RM_ADDR_BASE + nr;
 	opts->suboptions |= OPTION_MPTCP_RM_ADDR;
-	opts->rm_id = rm_id;
+	opts->rm_ids = rm_ids;
 
-	pr_debug("rm_id=%d", opts->rm_id);
+	pr_debug("rm_ids=%llu", opts->rm_ids);
 
 	return true;
 }
@@ -1211,9 +1220,24 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
 	}
 
 	if (OPTION_MPTCP_RM_ADDR & opts->suboptions) {
+		u8 rm_ids[8] = { 0 };
+		u8 *tmp, id, nr;
+
+		mptcp_for_each_id(opts->rm_ids, nr, tmp, id)

net/mptcp/options.c void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, · line 1234

Quoted 10 lines
net/mptcp/options.c +7 -2
+			rm_ids[nr] = id;
 		*ptr++ = mptcp_option(MPTCPOPT_RM_ADDR,
-				      TCPOLEN_MPTCP_RM_ADDR_BASE,
-				      0, opts->rm_id);
+				      TCPOLEN_MPTCP_RM_ADDR_BASE + nr,
+				      0, rm_ids[0]);
+		if (nr > 1) {
+			put_unaligned_be32(rm_ids[1] << 24 | rm_ids[2] << 16 |
+					   rm_ids[3] << 8 | rm_ids[4], ptr);
+			ptr += 1;

All of the unused bytes would have to be set to TCPOPT_NOP here...

net/mptcp/options.c void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, · line 1239

Quoted 5 lines
net/mptcp/options.c +5 -0
+		}
+		if (nr > 5) {
+			put_unaligned_be32(rm_ids[5] << 24 | rm_ids[6] << 16 |
+					   rm_ids[7] << 8 | TCPOPT_NOP, ptr);
+			ptr += 1;

...and here.

Quoted 40 lines
net/mptcp/options.c +1 -0
+		}
 	}
 
 	if (OPTION_MPTCP_PRIO & opts->suboptions) {
net/mptcp/pm.c +2 -2
index 6fd4b2c1b076..7ec1d2a1582b 100644
@@ -258,7 +258,7 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
 }
 
 bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
-			     u8 *rm_id)
+			     u64 *rm_ids)
 {
 	int ret = false;
 
@@ -271,7 +271,7 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
 	if (remaining < TCPOLEN_MPTCP_RM_ADDR_BASE)
 		goto out_unlock;
 
-	*rm_id = msk->pm.rm_id;
+	*rm_ids = msk->pm.rm_id;
 	WRITE_ONCE(msk->pm.addr_signal, 0);
 	ret = true;
 
net/mptcp/protocol.h +1 -1
index 447ce4631b43..962cc1b4dd48 100644
@@ -60,7 +60,7 @@
 #define TCPOLEN_MPTCP_ADD_ADDR6_BASE	20
 #define TCPOLEN_MPTCP_ADD_ADDR6_BASE_PORT	24
 #define TCPOLEN_MPTCP_PORT_LEN		4
-#define TCPOLEN_MPTCP_RM_ADDR_BASE	4
+#define TCPOLEN_MPTCP_RM_ADDR_BASE	3
 #define TCPOLEN_MPTCP_PRIO		4
 #define TCPOLEN_MPTCP_FASTCLOSE		12
 

net/mptcp/protocol.h struct mptcp_sock { · line 295

Quoted 8 lines
net/mptcp/protocol.h +5 -0
@@ -288,6 +288,11 @@ struct mptcp_sock {
 #define mptcp_for_each_subflow(__msk, __subflow)			\
 	list_for_each_entry(__subflow, &((__msk)->conn_list), node)
 
+#define mptcp_for_each_id(ids, nr, ptr, id)				\
+	for ((nr) = 0, (ptr) = (u8 *)&(ids);				\
+	     (nr) < 8 && (id = *(ptr));					\
+	     (nr)++, (ptr)++)
+

If rm_ids is an array instead, it would be simpler to just memcpy the array as needed and count the non-zero entries in the array.

Quoted 18 lines
net/mptcp/protocol.h +1 -1
 static inline void msk_owned_by_me(const struct mptcp_sock *msk)
 {
 	sock_owned_by_me((const struct sock *)msk);
@@ -713,7 +718,7 @@ static inline unsigned int mptcp_add_addr_len(int family, bool echo, bool port)
 bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
 			      struct mptcp_addr_info *saddr, bool *echo, bool *port);
 bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
-			     u8 *rm_id);
+			     u64 *rm_ids);
 int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);
 
 void __init mptcp_pm_nl_init(void);
Signature · 4 lines
2.29.2
_______________________________________________
mptcp mailing list -- mptcp(a)lists.01.org
To unsubscribe send an email to mptcp-leave(a)lists.01.org

--
Mat Martineau
Intel

#10 lore raw

[MPTCP] Re: [MPTCP][PATCH mptcp-next 2/8] mptcp: remove multi addrs on incoming path

In reply to Geliang Tang
Quoted 92 lines · Geliang Tang

This patch changed the type of rm_id in struct mptcp_options_received from u8 to u64, and renamed it to rm_ids.

In mptcp_parse_option, parsed the RM_ADDR suboption and filled them into the ids map in struct mptcp_options_received.

In mptcp_incoming_options, passed this ids map to the function mptcp_pm_rm_addr_received.

It alse changed the parameter type of mptcp_pm_rm_addr_received.

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

---

net/mptcp/options.c  | 13 +++++++++----
net/mptcp/pm.c       |  8 ++++----
net/mptcp/protocol.h |  4 ++--
3 files changed, 15 insertions(+), 10 deletions(-)
net/mptcp/options.c +9 -4
index 11f6182b8319..53035c2ec40f 100644
@@ -25,6 +25,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
 	u8 subtype = *ptr >> 4;
 	int expected_opsize;
 	u8 version;
+	u8 *p, i;
 	u8 flags;
 
 	switch (subtype) {
@@ -272,14 +273,18 @@ static void mptcp_parse_option(const struct sk_buff *skb,
 		break;
 
 	case MPTCPOPT_RM_ADDR:
-		if (opsize != TCPOLEN_MPTCP_RM_ADDR_BASE)
+		if (opsize < TCPOLEN_MPTCP_RM_ADDR_BASE + 1 ||
+		    opsize > TCPOLEN_MPTCP_RM_ADDR_BASE + 8)
 			break;
 
 		ptr++;
 
 		mp_opt->rm_addr = 1;
-		mp_opt->rm_id = *ptr++;
-		pr_debug("RM_ADDR: id=%d", mp_opt->rm_id);
+		mp_opt->rm_ids = 0;
+		p = (u8 *)&mp_opt->rm_ids;
+		for (i = 0; i < opsize - TCPOLEN_MPTCP_RM_ADDR_BASE; i++)
+			*p++ = *ptr++;
+		pr_debug("RM_ADDR: ids=%llu", mp_opt->rm_ids);
 		break;
 
 	case MPTCPOPT_MP_PRIO:
@@ -1041,7 +1046,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
 	}
 
 	if (mp_opt.rm_addr) {
-		mptcp_pm_rm_addr_received(msk, mp_opt.rm_id);
+		mptcp_pm_rm_addr_received(msk, mp_opt.rm_ids);
 		mp_opt.rm_addr = 0;
 	}
 
net/mptcp/pm.c +4 -4
index 7ec1d2a1582b..1c10011e5abf 100644
@@ -205,17 +205,17 @@ void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk)
 	mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_SEND_ACK);
 }
 
-void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id)
+void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u64 rm_ids)
 {
 	struct mptcp_pm_data *pm = &msk->pm;
 
-	pr_debug("msk=%p remote_id=%d", msk, rm_id);
+	pr_debug("msk=%p remote_ids=%llu", msk, rm_ids);
 
-	mptcp_event_addr_removed(msk, rm_id);
+	mptcp_event_addr_removed(msk, rm_ids);
 
 	spin_lock_bh(&pm->lock);
 	mptcp_pm_schedule_work(msk, MPTCP_PM_RM_ADDR_RECEIVED);
-	pm->rm_id = rm_id;
+	pm->rm_id = rm_ids;
 	spin_unlock_bh(&pm->lock);
 }
 
net/mptcp/protocol.h +0 -0
index 962cc1b4dd48..dd6899ab1f19 100644

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

Quoted 5 lines
net/mptcp/protocol.h +1 -1
@@ -139,7 +139,7 @@ struct mptcp_options_received {
 		mpc_map:1,
 		__unused:2;
 	u8	addr_id;
-	u8	rm_id;
+	u64	rm_ids;

Like patch 1, an array of u8s would be better.

Quoted 14 lines
net/mptcp/protocol.h +1 -1
 	union {
 		struct in_addr	addr;
 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
@@ -654,7 +654,7 @@ 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_add_addr_send_ack(struct mptcp_sock *msk);
-void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id);
+void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u64 rm_ids);
 void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup);
 int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,
 				 struct mptcp_addr_info *addr,
Signature · 1 line
2.29.2

--
Mat Martineau
Intel

#9 lore raw

[MPTCP] Re: [MPTCP][PATCH mptcp-next 7/8] mptcp: update the netlink event for rm_addr

In reply to Geliang Tang
Quoted 37 lines · Geliang Tang

Since the parameter id passed to mptcp_event_addr_removed was changed as a u64 number, the netlink event for removing addresses needed to be updated.

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

---

include/uapi/linux/mptcp.h | 1 +
net/mptcp/pm_netlink.c     | 4 ++--
net/mptcp/protocol.h       | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
include/uapi/linux/mptcp.h +1 -0
index c91578aaab32..227e8edb4a28 100644
@@ -172,6 +172,7 @@ enum mptcp_event_attr {
 	MPTCP_ATTR_FLAGS,	/* u16 */
 	MPTCP_ATTR_TIMEOUT,	/* u32 */
 	MPTCP_ATTR_IF_IDX,	/* s32 */
+	MPTCP_ATTR_PAD,
 
 	__MPTCP_ATTR_AFTER_LAST
 };
net/mptcp/pm_netlink.c +1 -1
index 3801931ab9ea..bc473ea4fcc2 100644
@@ -1705,7 +1705,7 @@ static int mptcp_event_created(struct sk_buff *skb,
 	return mptcp_event_add_subflow(skb, ssk);
 }
 
-void mptcp_event_addr_removed(const struct mptcp_sock *msk, uint8_t id)
+void mptcp_event_addr_removed(const struct mptcp_sock *msk, uint64_t ids)
 {
 	struct net *net = sock_net((const struct sock *)msk);
 	struct nlmsghdr *nlh;

net/mptcp/pm_netlink.c void mptcp_event_addr_removed(const struct mptcp_sock *msk, uint8_t id) · line 1728

Quoted 5 lines
net/mptcp/pm_netlink.c +1 -1
@@ -1725,7 +1725,7 @@ void mptcp_event_addr_removed(const struct mptcp_sock *msk, uint8_t id)
 	if (nla_put_u32(skb, MPTCP_ATTR_TOKEN, msk->token))
 		goto nla_put_failure;
 
-	if (nla_put_u8(skb, MPTCP_ATTR_REM_ID, id))
+	if (nla_put_u64_64bit(skb, MPTCP_ATTR_REM_ID, ids, MPTCP_ATTR_PAD))

This kind of change to an existing userspace API isn't allowed. To have an event with a list of remote IDs, you would have to add a new event. But I think instead mptcp_event_addr_removed() could send multiple REM_ID events, without any change to the userspace API.

Quoted 18 lines
net/mptcp/pm_netlink.c +0 -0
 		goto nla_put_failure;
 
 	genlmsg_end(skb, nlh);
net/mptcp/protocol.h +1 -1
index 9dd276cb1f71..af1d70843791 100644
@@ -674,7 +674,7 @@ int mptcp_pm_remove_subflow(struct mptcp_sock *msk, u64 local_ids);
 void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk,
 		 const struct sock *ssk, gfp_t gfp);
 void mptcp_event_addr_announced(const struct mptcp_sock *msk, const struct mptcp_addr_info *info);
-void mptcp_event_addr_removed(const struct mptcp_sock *msk, u8 id);
+void mptcp_event_addr_removed(const struct mptcp_sock *msk, u64 ids);
 
 static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk)
 {
Signature · 1 line
2.29.2

--
Mat Martineau
Intel