[PATCH mptcp-net] mptcp: allow changing the 'backup' bit when no sockets are open

Davide Caratti posted 1 patch 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/dcaratti/mptcp_net-next tags/patchew/db472a753375c011d3dc7b810262935473e481aa.1631821658.git.dcaratti@redhat.com
Maintainers: Mat Martineau <mathew.j.martineau@linux.intel.com>, "David S. Miller" <davem@davemloft.net>, Matthieu Baerts <matthieu.baerts@tessares.net>, Jakub Kicinski <kuba@kernel.org>, Geliang Tang <geliangtang@gmail.com>
net/mptcp/pm_netlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

[PATCH mptcp-net] mptcp: allow changing the 'backup' bit when no sockets are open

Posted by Davide Caratti 1 month ago
current Linux refuses to change the 'backup' bit of MPTCP endpoints, i.e.
using MPTCP_PM_CMD_SET_FLAGS, unless it finds (at least) one subflow that
matches the endpoint address. There is no reason for that, so we can make
mptcp_nl_addr_backup() return without error even when 0 MPTCP sockets are
open and no MP_PRIO message is sent out.

Fixes: 0f9f696a502e ("mptcp: add set_flags command in PM netlink")
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
 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 c4f9a5ce3815..8a7048c5b9b4 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -1678,7 +1678,7 @@ static int mptcp_nl_addr_backup(struct net *net,
 {
 	long s_slot = 0, s_num = 0;
 	struct mptcp_sock *msk;
-	int ret = -EINVAL;
+	int ret = 0;
 
 	while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) {
 		struct sock *sk = (struct sock *)msk;
-- 
2.31.1


Re: [PATCH mptcp-net] mptcp: allow changing the 'backup' bit when no sockets are open

Posted by Mat Martineau 1 month ago
On Thu, 16 Sep 2021, Davide Caratti wrote:

> current Linux refuses to change the 'backup' bit of MPTCP endpoints, i.e.
> using MPTCP_PM_CMD_SET_FLAGS, unless it finds (at least) one subflow that
> matches the endpoint address. There is no reason for that, so we can make
> mptcp_nl_addr_backup() return without error even when 0 MPTCP sockets are
> open and no MP_PRIO message is sent out.
>
> Fixes: 0f9f696a502e ("mptcp: add set_flags command in PM netlink")
> Signed-off-by: Davide Caratti <dcaratti@redhat.com>
> ---
> 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 c4f9a5ce3815..8a7048c5b9b4 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
> @@ -1678,7 +1678,7 @@ static int mptcp_nl_addr_backup(struct net *net,
> {
> 	long s_slot = 0, s_num = 0;
> 	struct mptcp_sock *msk;
> -	int ret = -EINVAL;
> +	int ret = 0;

Hi Davide & Geliang -

The ret value in mptcp_nl_addr_backup() can still get set to -EINVAL if 
mptcp_pm_nl_mp_prio_send_ack() returns that error and it happens to be the 
last token. So the error is not consistently propagated, and it doesn't 
seem like it's useful to propagate the -EINVAL to mptcp_nl_cmd_set_flags() 
anyway.

How about making mptcp_nl_cmd_set_flags() ignore the value returned by 
mptcp_nl_addr_backup()?

--
Mat Martineau
Intel