Skip to contentSkip to conversation

unify in-kernel and user PM interfaces

PATCH Superseded Geliang Tang 3 participants 10 messages May 25, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover unify in-kernel and user PM interfaces

Unify the three PM interfaces: get_local_id(),
get_flags_and_ifindex_by_id() and set_flags().

Geliang Tang (4):
mptcp: export local_address
mptcp: unify pm get_local_id interfaces
mptcp: unify pm get_flags_and_ifindex_by_id
mptcp: unify pm set_flags interfaces

 net/mptcp/pm.c         |  30 ++++++++++++
 net/mptcp/pm_netlink.c | 105 ++++++++++++++++++-----------------------
 net/mptcp/protocol.h   |   9 +++-
 3 files changed, 85 insertions(+), 59 deletions(-)
Signature · 1 line
2.35.3
#1 lore raw

PATCH 1/4 mptcp: export local_address

Rename local_address() with "mptcp_" prefix and export it in protocol.h.

This function will be re-used in the common PM code (pm.c) in the following commit.

---
 net/mptcp/pm_netlink.c | 17 ++++++++---------
 net/mptcp/protocol.h   |  1 +
 2 files changed, 9 insertions(+), 9 deletions(-)
net/mptcp/pm_netlink.c +8 -9
index ec892fb8d85f..2f58ab49512a 100644
@@ -86,8 +86,7 @@ bool mptcp_addresses_equal(const struct mptcp_addr_info *a,
 	return a->port == b->port;
 }
 
-static void local_address(const struct sock_common *skc,
-			  struct mptcp_addr_info *addr)
+void mptcp_local_address(const struct sock_common *skc, struct mptcp_addr_info *addr)
 {
 	addr->family = skc->skc_family;
 	addr->port = htons(skc->skc_num);
@@ -122,7 +121,7 @@ static bool lookup_subflow_by_saddr(const struct list_head *list,
 	list_for_each_entry(subflow, list, node) {
 		skc = (struct sock_common *)mptcp_subflow_tcp_sock(subflow);
 
-		local_address(skc, &cur);
+		mptcp_local_address(skc, &cur);
 		if (mptcp_addresses_equal(&cur, saddr, saddr->port))
 			return true;
 	}
@@ -263,7 +262,7 @@ bool mptcp_pm_sport_in_anno_list(struct mptcp_sock *msk, const struct sock *sk)
 	struct mptcp_addr_info saddr;
 	bool ret = false;
 
-	local_address((struct sock_common *)sk, &saddr);
+	mptcp_local_address((struct sock_common *)sk, &saddr);
 
 	spin_lock_bh(&msk->pm.lock);
 	list_for_each_entry(entry, &msk->pm.anno_list, list) {
@@ -538,7 +537,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
 		struct mptcp_addr_info mpc_addr;
 		bool backup = false;
 
-		local_address((struct sock_common *)msk->first, &mpc_addr);
+		mptcp_local_address((struct sock_common *)msk->first, &mpc_addr);
 		rcu_read_lock();
 		entry = __lookup_addr(pernet, &mpc_addr, false);
 		if (entry) {
@@ -749,7 +748,7 @@ int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,
 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
 		struct mptcp_addr_info local, remote;
 
-		local_address((struct sock_common *)ssk, &local);
+		mptcp_local_address((struct sock_common *)ssk, &local);
 		if (!mptcp_addresses_equal(&local, addr, addr->port))
 			continue;
 
@@ -1067,8 +1066,8 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc)
 	/* The 0 ID mapping is defined by the first subflow, copied into the msk
 	 * addr
 	 */
-	local_address((struct sock_common *)msk, &msk_local);
-	local_address((struct sock_common *)skc, &skc_local);
+	mptcp_local_address((struct sock_common *)msk, &msk_local);
+	mptcp_local_address((struct sock_common *)skc, &skc_local);
 	if (mptcp_addresses_equal(&msk_local, &skc_local, false))
 		return 0;
 
@@ -1488,7 +1487,7 @@ static int mptcp_nl_remove_id_zero_address(struct net *net,
 		if (list_empty(&msk->conn_list) || mptcp_pm_is_userspace(msk))
 			goto next;
 
-		local_address((struct sock_common *)msk, &msk_local);
+		mptcp_local_address((struct sock_common *)msk, &msk_local);
 		if (!mptcp_addresses_equal(&msk_local, addr, addr->port))
 			goto next;
 
net/mptcp/protocol.h +1 -0
index bd3771c7d79d..d8c9035c44fb 100644
@@ -640,6 +640,7 @@ void mptcp_set_owner_r(struct sk_buff *skb, struct sock *sk);
 
 bool mptcp_addresses_equal(const struct mptcp_addr_info *a,
 			   const struct mptcp_addr_info *b, bool use_port);
+void mptcp_local_address(const struct sock_common *skc, struct mptcp_addr_info *addr);
 
 /* called with sk socket lock held */
 int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc,
Signature · 1 line
2.35.3
#2 lore raw

PATCH 2/4 mptcp: unify pm get_local_id interfaces

In reply to Geliang Tang

This patch unifies the three PM get_local_id() interfaces:

mptcp_pm_nl_get_local_id() in mptcp/pm_netlink.c for the in-kernel PM and mptcp_userspace_pm_get_local_id() in mptcp/pm_userspace.c for the userspace PM.

They'll be switched in the common PM infterface mptcp_pm_get_local_id() in mptcp/pm.c.

---
 net/mptcp/pm.c         | 13 +++++++++++++
 net/mptcp/pm_netlink.c | 10 ----------
 net/mptcp/protocol.h   |  2 +-
 3 files changed, 14 insertions(+), 11 deletions(-)
net/mptcp/pm.c +13 -0
index e7f944d09fcd..e37df2f45c70 100644
@@ -408,6 +408,19 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
 
 int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc)
 {
+	struct mptcp_addr_info skc_local;
+	struct mptcp_addr_info msk_local;
+
+	/* The 0 ID mapping is defined by the first subflow, copied into the msk
+	 * addr
+	 */
+	mptcp_local_address((struct sock_common *)msk, &msk_local);
+	mptcp_local_address((struct sock_common *)skc, &skc_local);
+	if (mptcp_addresses_equal(&msk_local, &skc_local, false))
+		return 0;
+
+	if (mptcp_pm_is_userspace(msk))
+		return mptcp_userspace_pm_get_local_id(msk, &skc_local);
 	return mptcp_pm_nl_get_local_id(msk, skc);
 }
 
net/mptcp/pm_netlink.c +0 -10
index 2f58ab49512a..deb097f16abc 100644
@@ -1056,23 +1056,13 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc)
 {
 	struct mptcp_pm_addr_entry *entry;
 	struct mptcp_addr_info skc_local;
-	struct mptcp_addr_info msk_local;
 	struct pm_nl_pernet *pernet;
 	int ret = -1;
 
 	if (WARN_ON_ONCE(!msk))
 		return -1;
 
-	/* The 0 ID mapping is defined by the first subflow, copied into the msk
-	 * addr
-	 */
-	mptcp_local_address((struct sock_common *)msk, &msk_local);
 	mptcp_local_address((struct sock_common *)skc, &skc_local);
-	if (mptcp_addresses_equal(&msk_local, &skc_local, false))
-		return 0;
-
-	if (mptcp_pm_is_userspace(msk))
-		return mptcp_userspace_pm_get_local_id(msk, &skc_local);
 
 	pernet = pm_nl_get_pernet_from_msk(msk);
 
net/mptcp/protocol.h +1 -1
index d8c9035c44fb..58989303470f 100644
@@ -933,13 +933,13 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, const struct sk_buff *skb,
 bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
 			     struct mptcp_rm_list *rm_list);
 int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);
+int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);
 int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc);
 
 void __init mptcp_pm_nl_init(void);
 void mptcp_pm_nl_work(struct mptcp_sock *msk);
 void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk,
 				     const struct mptcp_rm_list *rm_list);
-int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);
 unsigned int mptcp_pm_get_add_addr_signal_max(const struct mptcp_sock *msk);
 unsigned int mptcp_pm_get_add_addr_accept_max(const struct mptcp_sock *msk);
 unsigned int mptcp_pm_get_subflows_max(const struct mptcp_sock *msk);
Signature · 1 line
2.35.3
#4 lore raw

PATCH 3/4 mptcp: unify pm get_flags_and_ifindex_by_id

In reply to Geliang Tang

This patch unifies the three PM get_flags_and_ifindex_by_id() interfaces:

mptcp_pm_nl_get_flags_and_ifindex_by_id() in mptcp/pm_netlink.c for the in-kernel PM and mptcp_userspace_pm_get_flags_and_ifindex_by_id() in mptcp/pm_userspace.c for the userspace PM.

They'll be switched in the common PM infterface mptcp_pm_get_flags_and_ifindex_by_id() in mptcp/pm.c.

---
 net/mptcp/pm.c         |  8 ++++++++
 net/mptcp/pm_netlink.c | 10 ++--------
 net/mptcp/protocol.h   |  2 ++
 3 files changed, 12 insertions(+), 8 deletions(-)
net/mptcp/pm.c +8 -0
index e37df2f45c70..8499196b8789 100644
@@ -424,6 +424,14 @@ int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc)
 	return mptcp_pm_nl_get_local_id(msk, skc);
 }
 
+int mptcp_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id,
+					 u8 *flags, int *ifindex)
+{
+	if (id && mptcp_pm_is_userspace(msk))
+		return mptcp_userspace_pm_get_flags_and_ifindex_by_id(msk, id, flags, ifindex);
+	return mptcp_pm_nl_get_flags_and_ifindex_by_id(msk, id, flags, ifindex);
+}
+
 void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk)
 {
 	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
net/mptcp/pm_netlink.c +2 -8
index deb097f16abc..ab4f0483d9d8 100644
@@ -1359,8 +1359,8 @@ static int mptcp_nl_cmd_add_addr(struct sk_buff *skb, struct genl_info *info)
 	return ret;
 }
 
-int mptcp_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id,
-					 u8 *flags, int *ifindex)
+int mptcp_pm_nl_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id,
+					    u8 *flags, int *ifindex)
 {
 	struct mptcp_pm_addr_entry *entry;
 	struct sock *sk = (struct sock *)msk;
@@ -1370,12 +1370,6 @@ int mptcp_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id
 	*ifindex = 0;
 
 	if (id) {
-		if (mptcp_pm_is_userspace(msk))
-			return mptcp_userspace_pm_get_flags_and_ifindex_by_id(msk,
-									      id,
-									      flags,
-									      ifindex);
-
 		rcu_read_lock();
 		entry = __lookup_addr_by_id(pm_nl_get_pernet(net), id);
 		if (entry) {
net/mptcp/protocol.h +2 -0
index 58989303470f..c91c9387f42d 100644
@@ -838,6 +838,8 @@ mptcp_lookup_anno_list_by_saddr(const struct mptcp_sock *msk,
 int mptcp_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk,
 					 unsigned int id,
 					 u8 *flags, int *ifindex);
+int mptcp_pm_nl_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id,
+					    u8 *flags, int *ifindex);
 int mptcp_userspace_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk,
 						   unsigned int id,
 						   u8 *flags, int *ifindex);
Signature · 1 line
2.35.3
#6 lore raw

PATCH 4/4 mptcp: unify pm set_flags interfaces

In reply to Geliang Tang

This patch unifies the three PM set_flags() interfaces:

mptcp_pm_nl_set_flags() in mptcp/pm_netlink.c for the in-kernel PM and mptcp_userspace_pm_set_flags() in mptcp/pm_userspace.c for the userspace PM.

They'll be switched in the common PM infterface mptcp_pm_set_flags() in mptcp/pm.c.

---
 net/mptcp/pm.c         |  9 ++++++
 net/mptcp/pm_netlink.c | 70 +++++++++++++++++++++++-------------------
 net/mptcp/protocol.h   |  4 +++
 3 files changed, 51 insertions(+), 32 deletions(-)
net/mptcp/pm.c +9 -0
index 8499196b8789..3d5f8afb7602 100644
@@ -432,6 +432,15 @@ int mptcp_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id
 	return mptcp_pm_nl_get_flags_and_ifindex_by_id(msk, id, flags, ifindex);
 }
 
+int mptcp_pm_set_flags(struct net *net, struct nlattr *token,
+		       struct mptcp_pm_addr_entry *loc,
+		       struct mptcp_pm_addr_entry *rem, u8 bkup)
+{
+	if (token)
+		return mptcp_userspace_pm_set_flags(net, token, loc, rem, bkup);
+	return mptcp_pm_nl_set_flags(net, loc, bkup);
+}
+
 void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk)
 {
 	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
net/mptcp/pm_netlink.c +38 -32

90 lines not on this page · raw message

net/mptcp/protocol.h +4 -0
index c91c9387f42d..5bea299a8499 100644
@@ -843,6 +843,10 @@ int mptcp_pm_nl_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int
 int mptcp_userspace_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk,
 						   unsigned int id,
 						   u8 *flags, int *ifindex);
+int mptcp_pm_set_flags(struct net *net, struct nlattr *token,
+		       struct mptcp_pm_addr_entry *loc,
+		       struct mptcp_pm_addr_entry *rem, u8 bkup);
+int mptcp_pm_nl_set_flags(struct net *net, struct mptcp_pm_addr_entry *addr, u8 bkup);
 int mptcp_userspace_pm_set_flags(struct net *net, struct nlattr *token,
 				 struct mptcp_pm_addr_entry *loc,
 				 struct mptcp_pm_addr_entry *rem, u8 bkup);
Signature · 1 line
2.35.3
#7 lore raw

Re: mptcp: unify pm set_flags interfaces: Tests Results

Hi Geliang,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join):
- Unstable: 1 failed test(s): packetdrill_sockopts 🔴:
- Task: https://cirrus-ci.com/task/6347681895809024
- Summary: https://api.cirrus-ci.com/v1/artifact/task/6347681895809024/summary/summary.txt

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

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

- KVM Validation: debug (except selftest_mptcp_join):
- Unstable: 2 failed test(s): packetdrill_fastopen selftest_diag 🔴:
- Task: https://cirrus-ci.com/task/6066206919098368
- Summary: https://api.cirrus-ci.com/v1/artifact/task/6066206919098368/summary/summary.txt

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

If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-debug

For more details:

https://github.com/multipath-tcp/mptcp-upstream-virtme-docker

Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (Tessares)

#9 lore raw
In reply to Geliang Tang

Hi Geliang,

Quoted 2 lines · Geliang Tang

Unify the three PM interfaces: get_local_id(),
get_flags_and_ifindex_by_id() and set_flags().

Good idea! Thank you for the patches and for the explanations in the commit messages!

This series looks good to me, just a few comments/ideas, please see my individual replies.

Cheers,
Matt

Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
#3 lore raw

Re: [PATCH mptcp-next 2/4] mptcp: unify pm get_local_id interfaces

In reply to Geliang Tang

Hi Geliang,

Quoted 50 lines · Geliang Tang

This patch unifies the three PM get_local_id() interfaces:

mptcp_pm_nl_get_local_id() in mptcp/pm_netlink.c for the in-kernel PM and mptcp_userspace_pm_get_local_id() in mptcp/pm_userspace.c for the userspace PM.

They'll be switched in the common PM infterface mptcp_pm_get_local_id() in mptcp/pm.c.

---
 net/mptcp/pm.c         | 13 +++++++++++++
 net/mptcp/pm_netlink.c | 10 ----------
 net/mptcp/protocol.h   |  2 +-
 3 files changed, 14 insertions(+), 11 deletions(-)
net/mptcp/pm.c +13 -0
index e7f944d09fcd..e37df2f45c70 100644
@@ -408,6 +408,19 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
 
 int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc)
 {
+	struct mptcp_addr_info skc_local;
+	struct mptcp_addr_info msk_local;
+
+	/* The 0 ID mapping is defined by the first subflow, copied into the msk
+	 * addr
+	 */
+	mptcp_local_address((struct sock_common *)msk, &msk_local);
+	mptcp_local_address((struct sock_common *)skc, &skc_local);
+	if (mptcp_addresses_equal(&msk_local, &skc_local, false))
+		return 0;
+
+	if (mptcp_pm_is_userspace(msk))
+		return mptcp_userspace_pm_get_local_id(msk, &skc_local);
 	return mptcp_pm_nl_get_local_id(msk, skc);
 }
 
net/mptcp/pm_netlink.c +0 -1
index 2f58ab49512a..deb097f16abc 100644
@@ -1056,23 +1056,13 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc)
 {
 	struct mptcp_pm_addr_entry *entry;
 	struct mptcp_addr_info skc_local;
-	struct mptcp_addr_info msk_local;
 	struct pm_nl_pernet *pernet;

net/mptcp/pm_netlink.c int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc) · line 1065

Quoted 10 lines
net/mptcp/pm_netlink.c +0 -4
 	int ret = -1;
 
 	if (WARN_ON_ONCE(!msk))
 		return -1;
 
-	/* The 0 ID mapping is defined by the first subflow, copied into the msk
-	 * addr
-	 */
-	mptcp_local_address((struct sock_common *)msk, &msk_local);
 	mptcp_local_address((struct sock_common *)skc, &skc_local);

If you still need skc_local for the in-kernel PM, why not passing it as a new argument to this function like what we do for the userspace PM?

Then we would have:

int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk,
struct sock_common *skc struct mptcp_addr_info *skc_local)

An no need to init it twice.

Quoted 13 lines
net/mptcp/pm_netlink.c +0 -5
-	if (mptcp_addresses_equal(&msk_local, &skc_local, false))
-		return 0;
-
-	if (mptcp_pm_is_userspace(msk))
-		return mptcp_userspace_pm_get_local_id(msk, &skc_local);
 
 	pernet = pm_nl_get_pernet_from_msk(msk);
 
net/mptcp/protocol.h +0 -0
index d8c9035c44fb..58989303470f 100644

net/mptcp/protocol.h bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, const struct sk_buff *skb, · line 936

Quoted 4 lines
net/mptcp/protocol.h +1 -0
@@ -933,13 +933,13 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, const struct sk_buff *skb,
 bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
 			     struct mptcp_rm_list *rm_list);
 int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);
+int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);

Mmm, usually, I think it is better to keep functions from the same .c file together but I see the one for the userspace is here below. I guess that's why you moved the pm_nl one here, right? If yes, I'm OK with your modification.

(I think we should not have mixed everything in protocol.h but create a pm_netlink.h, etc. anyway, not related to your modification :) )

net/mptcp/protocol.h bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, const struct sk_buff *skb, · line 937

Quoted 1 line
net/mptcp/protocol.h +0 -0
 int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc);

Cheers,
Matt

Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
#5 lore raw

Re: [PATCH mptcp-next 3/4] mptcp: unify pm get_flags_and_ifindex_by_id

In reply to Geliang Tang

Hi Geliang,

Quoted 21 lines · Geliang Tang

This patch unifies the three PM get_flags_and_ifindex_by_id() interfaces:

mptcp_pm_nl_get_flags_and_ifindex_by_id() in mptcp/pm_netlink.c for the in-kernel PM and mptcp_userspace_pm_get_flags_and_ifindex_by_id() in mptcp/pm_userspace.c for the userspace PM.

They'll be switched in the common PM infterface mptcp_pm_get_flags_and_ifindex_by_id() in mptcp/pm.c.

---
 net/mptcp/pm.c         |  8 ++++++++
 net/mptcp/pm_netlink.c | 10 ++--------
 net/mptcp/protocol.h   |  2 ++
 3 files changed, 12 insertions(+), 8 deletions(-)
net/mptcp/pm.c +0 -0
index e37df2f45c70..8499196b8789 100644

net/mptcp/pm.c int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc) · line 430

Quoted 7 lines
net/mptcp/pm.c +4 -0
@@ -424,6 +424,14 @@ int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc)
 	return mptcp_pm_nl_get_local_id(msk, skc);
 }
 
+int mptcp_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id,
+					 u8 *flags, int *ifindex)
+{
+	if (id && mptcp_pm_is_userspace(msk))

It looks strange to call mptcp_pm_nl_() if the userspace PM is used but id == 0. Maybe add this check in the userspace function?

Or maybe better to do:

  int mptcp_pm_get_flags_and_ifindex_by_id(...)
  {
      *flags = 0;
      *ifindex = 0;
      if (id == 0)
          return 0;

      if (mptcp_pm_is_userspace(msk))
          return mptcp_userspace_pm_(...);
      return return mptcp_pm_nl_(...);

}

By doing that, you can remove the init of flags and ifindex frmo the two PMs + the check of 'id' from the Netlink PM. WDYT?

Cheers,
Matt

Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
#8 lore raw

Re: [PATCH mptcp-next 4/4] mptcp: unify pm set_flags interfaces

In reply to Geliang Tang

Hi Geliang,

Quoted 8 lines · Geliang Tang

This patch unifies the three PM set_flags() interfaces:

mptcp_pm_nl_set_flags() in mptcp/pm_netlink.c for the in-kernel PM and mptcp_userspace_pm_set_flags() in mptcp/pm_userspace.c for the userspace PM.

They'll be switched in the common PM infterface mptcp_pm_set_flags() in mptcp/pm.c.

(...)

net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1922

Quoted 8 lines
net/mptcp/pm_netlink.c +0 -4
@@ -1916,34 +1948,8 @@ static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info)
 
 	if (addr.flags & MPTCP_PM_ADDR_FLAG_BACKUP)
 		bkup = 1;
-	if (addr.addr.family == AF_UNSPEC) {
-		lookup_by_id = 1;
-		if (!addr.addr.id)
-			return -EOPNOTSUPP;

If we move this, it means we could get a different error when the userspace PM is used. But because AF_UNSPEC should not be used anyway with the userspace PM, I guess that's fine. So all good, no need to change.

net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1926

Quoted 4 lines
net/mptcp/pm_netlink.c +0 -4
-	}
-
-	if (token)
-		return mptcp_userspace_pm_set_flags(net, token, &addr, &remote, bkup);

(...)

Cheers,
Matt

Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net