* [PATCH net-next 01/10] mptcp: pm: remove unused ret value to set flags
2025-02-21 15:43 [PATCH net-next 00/10] mptcp: pm: misc cleanups, part 3 Matthieu Baerts (NGI0)
@ 2025-02-21 15:43 ` Matthieu Baerts (NGI0)
2025-02-21 15:43 ` [PATCH net-next 02/10] mptcp: pm: change to fullmesh only for 'subflow' Matthieu Baerts (NGI0)
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Matthieu Baerts (NGI0) @ 2025-02-21 15:43 UTC (permalink / raw)
To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, linux-kernel, Matthieu Baerts (NGI0)
The returned value is not used, it can then be dropped.
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
net/mptcp/pm_netlink.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index 99705a9c2238c6be96e320e8cd1d12bfa0e0e7f0..ff1e5695dc1db5e32d5f45bef7cf22e43aea0ef1 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -1922,13 +1922,11 @@ static void mptcp_pm_nl_fullmesh(struct mptcp_sock *msk,
spin_unlock_bh(&msk->pm.lock);
}
-static int mptcp_nl_set_flags(struct net *net,
- struct mptcp_addr_info *addr,
- u8 bkup, u8 changed)
+static void mptcp_nl_set_flags(struct net *net, struct mptcp_addr_info *addr,
+ u8 bkup, u8 changed)
{
long s_slot = 0, s_num = 0;
struct mptcp_sock *msk;
- int ret = -EINVAL;
while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) {
struct sock *sk = (struct sock *)msk;
@@ -1938,7 +1936,7 @@ static int mptcp_nl_set_flags(struct net *net,
lock_sock(sk);
if (changed & MPTCP_PM_ADDR_FLAG_BACKUP)
- ret = mptcp_pm_nl_mp_prio_send_ack(msk, addr, NULL, bkup);
+ mptcp_pm_nl_mp_prio_send_ack(msk, addr, NULL, bkup);
if (changed & MPTCP_PM_ADDR_FLAG_FULLMESH)
mptcp_pm_nl_fullmesh(msk, addr);
release_sock(sk);
@@ -1948,7 +1946,7 @@ static int mptcp_nl_set_flags(struct net *net,
cond_resched();
}
- return ret;
+ return;
}
int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *local,
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH net-next 02/10] mptcp: pm: change to fullmesh only for 'subflow'
2025-02-21 15:43 [PATCH net-next 00/10] mptcp: pm: misc cleanups, part 3 Matthieu Baerts (NGI0)
2025-02-21 15:43 ` [PATCH net-next 01/10] mptcp: pm: remove unused ret value to set flags Matthieu Baerts (NGI0)
@ 2025-02-21 15:43 ` Matthieu Baerts (NGI0)
2025-02-21 15:43 ` [PATCH net-next 03/10] mptcp: pm: add a build check for userspace_pm_dump_addr Matthieu Baerts (NGI0)
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Matthieu Baerts (NGI0) @ 2025-02-21 15:43 UTC (permalink / raw)
To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, linux-kernel, Matthieu Baerts (NGI0)
If an endpoint doesn't have the 'subflow' flag -- in fact, has no type,
so not 'subflow', 'signal', nor 'implicit' -- there are then no subflows
created from this local endpoint to at least the initial destination
address. In this case, no need to call mptcp_pm_nl_fullmesh() which is
there to recreate the subflows to reflect the new value of the fullmesh
attribute.
Similarly, there is then no need to iterate over all connections to do
nothing, if only the 'fullmesh' flag has been changed, and the endpoint
doesn't have the 'subflow' one. So stop early when dealing with this
specific case.
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
net/mptcp/pm_netlink.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index ff1e5695dc1db5e32d5f45bef7cf22e43aea0ef1..1a0695e087af02347678b9b6914d303554bcf1f3 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -1923,11 +1923,16 @@ static void mptcp_pm_nl_fullmesh(struct mptcp_sock *msk,
}
static void mptcp_nl_set_flags(struct net *net, struct mptcp_addr_info *addr,
- u8 bkup, u8 changed)
+ u8 flags, u8 changed)
{
+ u8 is_subflow = !!(flags & MPTCP_PM_ADDR_FLAG_SUBFLOW);
+ u8 bkup = !!(flags & MPTCP_PM_ADDR_FLAG_BACKUP);
long s_slot = 0, s_num = 0;
struct mptcp_sock *msk;
+ if (changed == MPTCP_PM_ADDR_FLAG_FULLMESH && !is_subflow)
+ return;
+
while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) {
struct sock *sk = (struct sock *)msk;
@@ -1937,7 +1942,8 @@ static void mptcp_nl_set_flags(struct net *net, struct mptcp_addr_info *addr,
lock_sock(sk);
if (changed & MPTCP_PM_ADDR_FLAG_BACKUP)
mptcp_pm_nl_mp_prio_send_ack(msk, addr, NULL, bkup);
- if (changed & MPTCP_PM_ADDR_FLAG_FULLMESH)
+ /* Subflows will only be recreated if the SUBFLOW flag is set */
+ if (is_subflow && (changed & MPTCP_PM_ADDR_FLAG_FULLMESH))
mptcp_pm_nl_fullmesh(msk, addr);
release_sock(sk);
@@ -1959,7 +1965,6 @@ int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *local,
struct mptcp_pm_addr_entry *entry;
struct pm_nl_pernet *pernet;
u8 lookup_by_id = 0;
- u8 bkup = 0;
pernet = pm_nl_get_pernet(net);
@@ -1972,9 +1977,6 @@ int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *local,
}
}
- if (local->flags & MPTCP_PM_ADDR_FLAG_BACKUP)
- bkup = 1;
-
spin_lock_bh(&pernet->lock);
entry = lookup_by_id ? __lookup_addr_by_id(pernet, local->addr.id) :
__lookup_addr(pernet, &local->addr);
@@ -1996,7 +1998,7 @@ int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *local,
*local = *entry;
spin_unlock_bh(&pernet->lock);
- mptcp_nl_set_flags(net, &local->addr, bkup, changed);
+ mptcp_nl_set_flags(net, &local->addr, entry->flags, changed);
return 0;
}
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH net-next 03/10] mptcp: pm: add a build check for userspace_pm_dump_addr
2025-02-21 15:43 [PATCH net-next 00/10] mptcp: pm: misc cleanups, part 3 Matthieu Baerts (NGI0)
2025-02-21 15:43 ` [PATCH net-next 01/10] mptcp: pm: remove unused ret value to set flags Matthieu Baerts (NGI0)
2025-02-21 15:43 ` [PATCH net-next 02/10] mptcp: pm: change to fullmesh only for 'subflow' Matthieu Baerts (NGI0)
@ 2025-02-21 15:43 ` Matthieu Baerts (NGI0)
2025-02-21 15:43 ` [PATCH net-next 04/10] mptcp: pm: add mptcp_pm_genl_fill_addr helper Matthieu Baerts (NGI0)
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Matthieu Baerts (NGI0) @ 2025-02-21 15:43 UTC (permalink / raw)
To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, linux-kernel, Matthieu Baerts (NGI0), Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
This patch adds a build check for mptcp_userspace_pm_dump_addr() to make
sure there is enough space in 'cb->ctx' to store an address id bitmap.
Just in case info stored in 'cb->ctx' are increased later.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
net/mptcp/pm_userspace.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index 277cf092a87042a85623470237a8ef24d29e65e6..b69fb5b18130cb3abd08e3ef47004f599895486a 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -643,6 +643,8 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,
struct sock *sk;
void *hdr;
+ BUILD_BUG_ON(sizeof(struct id_bitmap) > sizeof(cb->ctx));
+
bitmap = (struct id_bitmap *)cb->ctx;
msk = mptcp_userspace_pm_get_sock(info);
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH net-next 04/10] mptcp: pm: add mptcp_pm_genl_fill_addr helper
2025-02-21 15:43 [PATCH net-next 00/10] mptcp: pm: misc cleanups, part 3 Matthieu Baerts (NGI0)
` (2 preceding siblings ...)
2025-02-21 15:43 ` [PATCH net-next 03/10] mptcp: pm: add a build check for userspace_pm_dump_addr Matthieu Baerts (NGI0)
@ 2025-02-21 15:43 ` Matthieu Baerts (NGI0)
2025-02-21 15:43 ` [PATCH net-next 05/10] mptcp: pm: drop match in userspace_pm_append_new_local_addr Matthieu Baerts (NGI0)
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Matthieu Baerts (NGI0) @ 2025-02-21 15:43 UTC (permalink / raw)
To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, linux-kernel, Matthieu Baerts (NGI0), Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
To save some redundant code in dump_addr() interfaces of both the
netlink PM and userspace PM, the code that calls netlink message
helpers (genlmsg_put/cancel/end) and mptcp_nl_fill_addr() is wrapped
into a new helper mptcp_pm_genl_fill_addr().
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
net/mptcp/pm.c | 21 +++++++++++++++++++++
net/mptcp/pm_netlink.c | 12 +-----------
net/mptcp/pm_userspace.c | 12 +-----------
net/mptcp/protocol.h | 3 +++
4 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index b1f36dc1a09113594324ef0547093a5447664181..16cacce6c10fe86467aa7ef8e588f9f535b586fb 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -489,6 +489,27 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info)
return ret;
}
+int mptcp_pm_genl_fill_addr(struct sk_buff *msg,
+ struct netlink_callback *cb,
+ struct mptcp_pm_addr_entry *entry)
+{
+ void *hdr;
+
+ hdr = genlmsg_put(msg, NETLINK_CB(cb->skb).portid,
+ cb->nlh->nlmsg_seq, &mptcp_genl_family,
+ NLM_F_MULTI, MPTCP_PM_CMD_GET_ADDR);
+ if (!hdr)
+ return -EINVAL;
+
+ if (mptcp_nl_fill_addr(msg, entry) < 0) {
+ genlmsg_cancel(msg, hdr);
+ return -EINVAL;
+ }
+
+ genlmsg_end(msg, hdr);
+ return 0;
+}
+
static int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb)
{
const struct genl_info *info = genl_info_dump(cb);
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index 1a0695e087af02347678b9b6914d303554bcf1f3..98fcbf8b1465649961c568c6f8978e91d0a53668 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -1798,7 +1798,6 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg,
struct mptcp_pm_addr_entry *entry;
struct pm_nl_pernet *pernet;
int id = cb->args[0];
- void *hdr;
int i;
pernet = pm_nl_get_pernet(net);
@@ -1813,19 +1812,10 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg,
if (entry->addr.id <= id)
continue;
- hdr = genlmsg_put(msg, NETLINK_CB(cb->skb).portid,
- cb->nlh->nlmsg_seq, &mptcp_genl_family,
- NLM_F_MULTI, MPTCP_PM_CMD_GET_ADDR);
- if (!hdr)
+ if (mptcp_pm_genl_fill_addr(msg, cb, entry) < 0)
break;
- if (mptcp_nl_fill_addr(msg, entry) < 0) {
- genlmsg_cancel(msg, hdr);
- break;
- }
-
id = entry->addr.id;
- genlmsg_end(msg, hdr);
}
}
rcu_read_unlock();
diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index b69fb5b18130cb3abd08e3ef47004f599895486a..bedd6f9ebc8b07871d317dfaf65135342cdeeeee 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -641,7 +641,6 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,
struct mptcp_sock *msk;
int ret = -EINVAL;
struct sock *sk;
- void *hdr;
BUILD_BUG_ON(sizeof(struct id_bitmap) > sizeof(cb->ctx));
@@ -659,19 +658,10 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,
if (test_bit(entry->addr.id, bitmap->map))
continue;
- hdr = genlmsg_put(msg, NETLINK_CB(cb->skb).portid,
- cb->nlh->nlmsg_seq, &mptcp_genl_family,
- NLM_F_MULTI, MPTCP_PM_CMD_GET_ADDR);
- if (!hdr)
+ if (mptcp_pm_genl_fill_addr(msg, cb, entry) < 0)
break;
- if (mptcp_nl_fill_addr(msg, entry) < 0) {
- genlmsg_cancel(msg, hdr);
- break;
- }
-
__set_bit(entry->addr.id, bitmap->map);
- genlmsg_end(msg, hdr);
}
spin_unlock_bh(&msk->pm.lock);
release_sock(sk);
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index ca65f8bff632ff806fe761f86e9aa065b0657d1e..256677c43ca6514bf487a6d897240ae012b6128e 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -1057,6 +1057,9 @@ void mptcp_fastopen_subflow_synack_set_params(struct mptcp_subflow_context *subf
struct request_sock *req);
int mptcp_nl_fill_addr(struct sk_buff *skb,
struct mptcp_pm_addr_entry *entry);
+int mptcp_pm_genl_fill_addr(struct sk_buff *msg,
+ struct netlink_callback *cb,
+ struct mptcp_pm_addr_entry *entry);
static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk)
{
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH net-next 05/10] mptcp: pm: drop match in userspace_pm_append_new_local_addr
2025-02-21 15:43 [PATCH net-next 00/10] mptcp: pm: misc cleanups, part 3 Matthieu Baerts (NGI0)
` (3 preceding siblings ...)
2025-02-21 15:43 ` [PATCH net-next 04/10] mptcp: pm: add mptcp_pm_genl_fill_addr helper Matthieu Baerts (NGI0)
@ 2025-02-21 15:43 ` Matthieu Baerts (NGI0)
2025-02-21 15:43 ` [PATCH net-next 06/10] mptcp: pm: drop inet6_sk after inet_sk Matthieu Baerts (NGI0)
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Matthieu Baerts (NGI0) @ 2025-02-21 15:43 UTC (permalink / raw)
To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, linux-kernel, Matthieu Baerts (NGI0), Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
The variable 'match' in mptcp_userspace_pm_append_new_local_addr() is a
redundant one, and this patch drops it.
No need to define 'match' as 'struct mptcp_pm_addr_entry *' type. In this
function, it's only used to check whether it's NULL. It can be defined as
a Boolean one.
Also other variables 'addr_match' and 'id_match' make 'match' a redundant
one, which can be replaced by directly checking 'addr_match && id_match'.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
net/mptcp/pm_userspace.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index bedd6f9ebc8b07871d317dfaf65135342cdeeeee..a16e2fb45a6c68bc0c3c187122a54765ef0fb259 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -48,7 +48,6 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
bool needs_id)
{
DECLARE_BITMAP(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1);
- struct mptcp_pm_addr_entry *match = NULL;
struct sock *sk = (struct sock *)msk;
struct mptcp_pm_addr_entry *e;
bool addr_match = false;
@@ -63,16 +62,12 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
if (addr_match && entry->addr.id == 0 && needs_id)
entry->addr.id = e->addr.id;
id_match = (e->addr.id == entry->addr.id);
- if (addr_match && id_match) {
- match = e;
+ if (addr_match || id_match)
break;
- } else if (addr_match || id_match) {
- break;
- }
__set_bit(e->addr.id, id_bitmap);
}
- if (!match && !addr_match && !id_match) {
+ if (!addr_match && !id_match) {
/* Memory for the entry is allocated from the
* sock option buffer.
*/
@@ -90,7 +85,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
list_add_tail_rcu(&e->list, &msk->pm.userspace_pm_local_addr_list);
msk->pm.local_addr_used++;
ret = e->addr.id;
- } else if (match) {
+ } else if (addr_match && id_match) {
ret = entry->addr.id;
}
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH net-next 06/10] mptcp: pm: drop inet6_sk after inet_sk
2025-02-21 15:43 [PATCH net-next 00/10] mptcp: pm: misc cleanups, part 3 Matthieu Baerts (NGI0)
` (4 preceding siblings ...)
2025-02-21 15:43 ` [PATCH net-next 05/10] mptcp: pm: drop match in userspace_pm_append_new_local_addr Matthieu Baerts (NGI0)
@ 2025-02-21 15:43 ` Matthieu Baerts (NGI0)
2025-02-21 15:44 ` [PATCH net-next 07/10] mptcp: pm: use ipv6_addr_equal in addresses_equal Matthieu Baerts (NGI0)
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Matthieu Baerts (NGI0) @ 2025-02-21 15:43 UTC (permalink / raw)
To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, linux-kernel, Matthieu Baerts (NGI0), Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
In mptcp_event_add_subflow(), mptcp_event_pm_listener() and
mptcp_nl_find_ssk(), 'issk' has already been got through inet_sk().
No need to use inet6_sk() to get 'ipv6_pinfo' again, just use
issk->pinet6 instead. This patch also drops these 'ipv6_pinfo'
variables.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
net/mptcp/pm_netlink.c | 8 ++------
net/mptcp/pm_userspace.c | 4 +---
2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index 98fcbf8b1465649961c568c6f8978e91d0a53668..f67b637c1fcf7c2930ced8b5c6b9df156118cbcd 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -2022,9 +2022,7 @@ static int mptcp_event_add_subflow(struct sk_buff *skb, const struct sock *ssk)
break;
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
case AF_INET6: {
- const struct ipv6_pinfo *np = inet6_sk(ssk);
-
- if (nla_put_in6_addr(skb, MPTCP_ATTR_SADDR6, &np->saddr))
+ if (nla_put_in6_addr(skb, MPTCP_ATTR_SADDR6, &issk->pinet6->saddr))
return -EMSGSIZE;
if (nla_put_in6_addr(skb, MPTCP_ATTR_DADDR6, &ssk->sk_v6_daddr))
return -EMSGSIZE;
@@ -2251,9 +2249,7 @@ void mptcp_event_pm_listener(const struct sock *ssk,
break;
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
case AF_INET6: {
- const struct ipv6_pinfo *np = inet6_sk(ssk);
-
- if (nla_put_in6_addr(skb, MPTCP_ATTR_SADDR6, &np->saddr))
+ if (nla_put_in6_addr(skb, MPTCP_ATTR_SADDR6, &issk->pinet6->saddr))
goto nla_put_failure;
break;
}
diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index a16e2fb45a6c68bc0c3c187122a54765ef0fb259..6bf6a20ef7f3e50750b648032c9e8961d3222890 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -460,9 +460,7 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk,
break;
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
case AF_INET6: {
- const struct ipv6_pinfo *pinfo = inet6_sk(ssk);
-
- if (!ipv6_addr_equal(&local->addr6, &pinfo->saddr) ||
+ if (!ipv6_addr_equal(&local->addr6, &issk->pinet6->saddr) ||
!ipv6_addr_equal(&remote->addr6, &ssk->sk_v6_daddr))
continue;
break;
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH net-next 07/10] mptcp: pm: use ipv6_addr_equal in addresses_equal
2025-02-21 15:43 [PATCH net-next 00/10] mptcp: pm: misc cleanups, part 3 Matthieu Baerts (NGI0)
` (5 preceding siblings ...)
2025-02-21 15:43 ` [PATCH net-next 06/10] mptcp: pm: drop inet6_sk after inet_sk Matthieu Baerts (NGI0)
@ 2025-02-21 15:44 ` Matthieu Baerts (NGI0)
2025-02-21 15:44 ` [PATCH net-next 08/10] mptcp: sched: split get_subflow interface into two Matthieu Baerts (NGI0)
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Matthieu Baerts (NGI0) @ 2025-02-21 15:44 UTC (permalink / raw)
To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, linux-kernel, Matthieu Baerts (NGI0), Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
Use ipv6_addr_equal() to check whether two IPv6 addresses are equal in
mptcp_addresses_equal().
This is more appropriate than using !ipv6_addr_cmp().
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
net/mptcp/pm_netlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index f67b637c1fcf7c2930ced8b5c6b9df156118cbcd..ef85a60151ad796b445afc21bcbcae1c52ef64b6 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -64,7 +64,7 @@ bool mptcp_addresses_equal(const struct mptcp_addr_info *a,
addr_equals = a->addr.s_addr == b->addr.s_addr;
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
else
- addr_equals = !ipv6_addr_cmp(&a->addr6, &b->addr6);
+ addr_equals = ipv6_addr_equal(&a->addr6, &b->addr6);
} else if (a->family == AF_INET) {
if (ipv6_addr_v4mapped(&b->addr6))
addr_equals = a->addr.s_addr == b->addr6.s6_addr32[3];
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH net-next 08/10] mptcp: sched: split get_subflow interface into two
2025-02-21 15:43 [PATCH net-next 00/10] mptcp: pm: misc cleanups, part 3 Matthieu Baerts (NGI0)
` (6 preceding siblings ...)
2025-02-21 15:44 ` [PATCH net-next 07/10] mptcp: pm: use ipv6_addr_equal in addresses_equal Matthieu Baerts (NGI0)
@ 2025-02-21 15:44 ` Matthieu Baerts (NGI0)
2025-02-21 15:44 ` [PATCH net-next 09/10] mptcp: sched: reduce size for unused data Matthieu Baerts (NGI0)
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Matthieu Baerts (NGI0) @ 2025-02-21 15:44 UTC (permalink / raw)
To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, linux-kernel, Matthieu Baerts (NGI0), Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
get_retrans() interface of the burst packet scheduler invokes a sleeping
function mptcp_pm_subflow_chk_stale(), which calls __lock_sock_fast().
So get_retrans() interface should be set with BPF_F_SLEEPABLE flag in
BPF. But get_send() interface of this scheduler can't be set with
BPF_F_SLEEPABLE flag since it's invoked in ack_update_msk() under mptcp
data lock.
So this patch has to split get_subflow() interface of packet scheduer into
two interfaces: get_send() and get_retrans(). Then we can set get_retrans()
interface alone with BPF_F_SLEEPABLE flag.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
include/net/mptcp.h | 5 +++--
net/mptcp/sched.c | 35 ++++++++++++++++++++++++-----------
2 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/include/net/mptcp.h b/include/net/mptcp.h
index 814b5f2e3ed5e3e474a2bac5e4cca5a89abcfe1c..2c85ca92bb1c39989ae08a74ff4ef9b42099e60d 100644
--- a/include/net/mptcp.h
+++ b/include/net/mptcp.h
@@ -103,13 +103,14 @@ struct mptcp_out_options {
#define MPTCP_SUBFLOWS_MAX 8
struct mptcp_sched_data {
- bool reinject;
u8 subflows;
struct mptcp_subflow_context *contexts[MPTCP_SUBFLOWS_MAX];
};
struct mptcp_sched_ops {
- int (*get_subflow)(struct mptcp_sock *msk,
+ int (*get_send)(struct mptcp_sock *msk,
+ struct mptcp_sched_data *data);
+ int (*get_retrans)(struct mptcp_sock *msk,
struct mptcp_sched_data *data);
char name[MPTCP_SCHED_NAME_MAX];
diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c
index df7dbcfa3b71370cc4d7e4e4f16cc1e41a50dddf..94dc4b3ad82f6a462961ae5195b7eba2271d8275 100644
--- a/net/mptcp/sched.c
+++ b/net/mptcp/sched.c
@@ -16,13 +16,25 @@
static DEFINE_SPINLOCK(mptcp_sched_list_lock);
static LIST_HEAD(mptcp_sched_list);
-static int mptcp_sched_default_get_subflow(struct mptcp_sock *msk,
+static int mptcp_sched_default_get_send(struct mptcp_sock *msk,
+ struct mptcp_sched_data *data)
+{
+ struct sock *ssk;
+
+ ssk = mptcp_subflow_get_send(msk);
+ if (!ssk)
+ return -EINVAL;
+
+ mptcp_subflow_set_scheduled(mptcp_subflow_ctx(ssk), true);
+ return 0;
+}
+
+static int mptcp_sched_default_get_retrans(struct mptcp_sock *msk,
struct mptcp_sched_data *data)
{
struct sock *ssk;
- ssk = data->reinject ? mptcp_subflow_get_retrans(msk) :
- mptcp_subflow_get_send(msk);
+ ssk = mptcp_subflow_get_retrans(msk);
if (!ssk)
return -EINVAL;
@@ -31,7 +43,8 @@ static int mptcp_sched_default_get_subflow(struct mptcp_sock *msk,
}
static struct mptcp_sched_ops mptcp_sched_default = {
- .get_subflow = mptcp_sched_default_get_subflow,
+ .get_send = mptcp_sched_default_get_send,
+ .get_retrans = mptcp_sched_default_get_retrans,
.name = "default",
.owner = THIS_MODULE,
};
@@ -73,7 +86,7 @@ void mptcp_get_available_schedulers(char *buf, size_t maxlen)
int mptcp_register_scheduler(struct mptcp_sched_ops *sched)
{
- if (!sched->get_subflow)
+ if (!sched->get_send)
return -EINVAL;
spin_lock(&mptcp_sched_list_lock);
@@ -164,10 +177,9 @@ int mptcp_sched_get_send(struct mptcp_sock *msk)
return 0;
}
- data.reinject = false;
if (msk->sched == &mptcp_sched_default || !msk->sched)
- return mptcp_sched_default_get_subflow(msk, &data);
- return msk->sched->get_subflow(msk, &data);
+ return mptcp_sched_default_get_send(msk, &data);
+ return msk->sched->get_send(msk, &data);
}
int mptcp_sched_get_retrans(struct mptcp_sock *msk)
@@ -186,8 +198,9 @@ int mptcp_sched_get_retrans(struct mptcp_sock *msk)
return 0;
}
- data.reinject = true;
if (msk->sched == &mptcp_sched_default || !msk->sched)
- return mptcp_sched_default_get_subflow(msk, &data);
- return msk->sched->get_subflow(msk, &data);
+ return mptcp_sched_default_get_retrans(msk, &data);
+ if (msk->sched->get_retrans)
+ return msk->sched->get_retrans(msk, &data);
+ return msk->sched->get_send(msk, &data);
}
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH net-next 09/10] mptcp: sched: reduce size for unused data
2025-02-21 15:43 [PATCH net-next 00/10] mptcp: pm: misc cleanups, part 3 Matthieu Baerts (NGI0)
` (7 preceding siblings ...)
2025-02-21 15:44 ` [PATCH net-next 08/10] mptcp: sched: split get_subflow interface into two Matthieu Baerts (NGI0)
@ 2025-02-21 15:44 ` Matthieu Baerts (NGI0)
2025-02-21 15:44 ` [PATCH net-next 10/10] mptcp: blackhole: avoid checking the state twice Matthieu Baerts (NGI0)
2025-02-25 2:30 ` [PATCH net-next 00/10] mptcp: pm: misc cleanups, part 3 patchwork-bot+netdevbpf
10 siblings, 0 replies; 12+ messages in thread
From: Matthieu Baerts (NGI0) @ 2025-02-21 15:44 UTC (permalink / raw)
To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, linux-kernel, Matthieu Baerts (NGI0)
Thanks for the previous commit ("mptcp: sched: split get_subflow
interface into two"), the mptcp_sched_data structure is now currently
unused.
This structure has been added to allow future extensions that are not
ready yet. At the end, this structure will not even be used at all when
mptcp_subflow bpf_iter will be supported [1].
Here is a first step to save 64 bytes on the stack for each scheduling
operation. The structure is not removed yet not to break the WIP work on
these extensions, but will be done when [1] will be ready and applied.
Link: https://lore.kernel.org/6645ad6e-8874-44c5-8730-854c30673218@linux.dev [1]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
net/mptcp/sched.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c
index 94dc4b3ad82f6a462961ae5195b7eba2271d8275..c16c6fbd4ba2f89a2fffcfd6b1916098d7a18cbe 100644
--- a/net/mptcp/sched.c
+++ b/net/mptcp/sched.c
@@ -157,7 +157,7 @@ void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
int mptcp_sched_get_send(struct mptcp_sock *msk)
{
struct mptcp_subflow_context *subflow;
- struct mptcp_sched_data data;
+ struct mptcp_sched_data *data = NULL;
msk_owned_by_me(msk);
@@ -178,14 +178,14 @@ int mptcp_sched_get_send(struct mptcp_sock *msk)
}
if (msk->sched == &mptcp_sched_default || !msk->sched)
- return mptcp_sched_default_get_send(msk, &data);
- return msk->sched->get_send(msk, &data);
+ return mptcp_sched_default_get_send(msk, data);
+ return msk->sched->get_send(msk, data);
}
int mptcp_sched_get_retrans(struct mptcp_sock *msk)
{
struct mptcp_subflow_context *subflow;
- struct mptcp_sched_data data;
+ struct mptcp_sched_data *data = NULL;
msk_owned_by_me(msk);
@@ -199,8 +199,8 @@ int mptcp_sched_get_retrans(struct mptcp_sock *msk)
}
if (msk->sched == &mptcp_sched_default || !msk->sched)
- return mptcp_sched_default_get_retrans(msk, &data);
+ return mptcp_sched_default_get_retrans(msk, data);
if (msk->sched->get_retrans)
- return msk->sched->get_retrans(msk, &data);
- return msk->sched->get_send(msk, &data);
+ return msk->sched->get_retrans(msk, data);
+ return msk->sched->get_send(msk, data);
}
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH net-next 10/10] mptcp: blackhole: avoid checking the state twice
2025-02-21 15:43 [PATCH net-next 00/10] mptcp: pm: misc cleanups, part 3 Matthieu Baerts (NGI0)
` (8 preceding siblings ...)
2025-02-21 15:44 ` [PATCH net-next 09/10] mptcp: sched: reduce size for unused data Matthieu Baerts (NGI0)
@ 2025-02-21 15:44 ` Matthieu Baerts (NGI0)
2025-02-25 2:30 ` [PATCH net-next 00/10] mptcp: pm: misc cleanups, part 3 patchwork-bot+netdevbpf
10 siblings, 0 replies; 12+ messages in thread
From: Matthieu Baerts (NGI0) @ 2025-02-21 15:44 UTC (permalink / raw)
To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, linux-kernel, Matthieu Baerts (NGI0)
A small cleanup, reordering the conditions to avoid checking things
twice.
The code here is called in case of timeout on a TCP connection, before
triggering a retransmission. But it only acts on SYN + MPC packets.
So the conditions can be re-order to exit early in case of non-MPTCP
SYN + MPC. This also reduce the indentation levels.
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
net/mptcp/ctrl.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c
index 2dd81e6c26bdb5220abed68e26d70d2dc3ab14fb..be6c0237e10bfd7520edd3c57ec43ce4377b97d5 100644
--- a/net/mptcp/ctrl.c
+++ b/net/mptcp/ctrl.c
@@ -401,26 +401,30 @@ void mptcp_active_enable(struct sock *sk)
void mptcp_active_detect_blackhole(struct sock *ssk, bool expired)
{
struct mptcp_subflow_context *subflow;
+ u8 timeouts, to_max;
+ struct net *net;
- if (!sk_is_mptcp(ssk))
+ /* Only check MPTCP SYN ... */
+ if (likely(!sk_is_mptcp(ssk) || ssk->sk_state != TCP_SYN_SENT))
return;
subflow = mptcp_subflow_ctx(ssk);
- if (subflow->request_mptcp && ssk->sk_state == TCP_SYN_SENT) {
- struct net *net = sock_net(ssk);
- u8 timeouts, to_max;
-
- timeouts = inet_csk(ssk)->icsk_retransmits;
- to_max = mptcp_get_pernet(net)->syn_retrans_before_tcp_fallback;
-
- if (timeouts == to_max || (timeouts < to_max && expired)) {
- MPTCP_INC_STATS(net, MPTCP_MIB_MPCAPABLEACTIVEDROP);
- subflow->mpc_drop = 1;
- mptcp_subflow_early_fallback(mptcp_sk(subflow->conn), subflow);
- }
- } else if (ssk->sk_state == TCP_SYN_SENT) {
+ /* ... + MP_CAPABLE */
+ if (!subflow->request_mptcp) {
+ /* Mark as blackhole iif the 1st non-MPTCP SYN is accepted */
subflow->mpc_drop = 0;
+ return;
+ }
+
+ net = sock_net(ssk);
+ timeouts = inet_csk(ssk)->icsk_retransmits;
+ to_max = mptcp_get_pernet(net)->syn_retrans_before_tcp_fallback;
+
+ if (timeouts == to_max || (timeouts < to_max && expired)) {
+ MPTCP_INC_STATS(net, MPTCP_MIB_MPCAPABLEACTIVEDROP);
+ subflow->mpc_drop = 1;
+ mptcp_subflow_early_fallback(mptcp_sk(subflow->conn), subflow);
}
}
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH net-next 00/10] mptcp: pm: misc cleanups, part 3
2025-02-21 15:43 [PATCH net-next 00/10] mptcp: pm: misc cleanups, part 3 Matthieu Baerts (NGI0)
` (9 preceding siblings ...)
2025-02-21 15:44 ` [PATCH net-next 10/10] mptcp: blackhole: avoid checking the state twice Matthieu Baerts (NGI0)
@ 2025-02-25 2:30 ` patchwork-bot+netdevbpf
10 siblings, 0 replies; 12+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-02-25 2:30 UTC (permalink / raw)
To: Matthieu Baerts
Cc: mptcp, martineau, geliang, davem, edumazet, kuba, pabeni, horms,
netdev, linux-kernel
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 21 Feb 2025 16:43:53 +0100 you wrote:
> These cleanups lead the way to the unification of the path-manager
> interfaces, and allow future extensions. The following patches are not
> all linked to each others, but are all related to the path-managers,
> except the last three.
>
> - Patch 1: remove unused returned value in mptcp_nl_set_flags().
>
> [...]
Here is the summary with links:
- [net-next,01/10] mptcp: pm: remove unused ret value to set flags
https://git.kernel.org/netdev/net-next/c/bc337e8c0e76
- [net-next,02/10] mptcp: pm: change to fullmesh only for 'subflow'
https://git.kernel.org/netdev/net-next/c/145dc6cc4abd
- [net-next,03/10] mptcp: pm: add a build check for userspace_pm_dump_addr
https://git.kernel.org/netdev/net-next/c/63132fb05474
- [net-next,04/10] mptcp: pm: add mptcp_pm_genl_fill_addr helper
https://git.kernel.org/netdev/net-next/c/f8fe81746573
- [net-next,05/10] mptcp: pm: drop match in userspace_pm_append_new_local_addr
https://git.kernel.org/netdev/net-next/c/640e3d69d0bc
- [net-next,06/10] mptcp: pm: drop inet6_sk after inet_sk
https://git.kernel.org/netdev/net-next/c/dc41695200a1
- [net-next,07/10] mptcp: pm: use ipv6_addr_equal in addresses_equal
https://git.kernel.org/netdev/net-next/c/7720790fd56b
- [net-next,08/10] mptcp: sched: split get_subflow interface into two
https://git.kernel.org/netdev/net-next/c/9771a96a7a35
- [net-next,09/10] mptcp: sched: reduce size for unused data
https://git.kernel.org/netdev/net-next/c/b68b106b0f15
- [net-next,10/10] mptcp: blackhole: avoid checking the state twice
https://git.kernel.org/netdev/net-next/c/8275ac799ee1
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 12+ messages in thread