From: Mat Martineau <hidden> Date: 2021-03-31 00:10:07
An MPTCP connection is aggregated from multiple TCP subflows, and can
involve multiple IP addresses on either peer. The addresses used in the
initial subflow connection are assigned address id 0 on each side of the
link. More addresses can be added and shared with the peer using address
IDs of 1 or larger. MPTCP in Linux shares non-zero address IDs across
all MPTCP connections in a net namespace, which allows userspace to
manage subflow connections across a number of sockets. However, this
makes the address with id 0 a special case, since the IP address
associated with id 0 is potentially different for each socket.
This patch set allows the initial subflow to be disconnected when
userspace specifies an address to remove using both id 0 and an IP
address, or when the peer sends an RM_ADDR for id 0.
Patches 1 and 3 implement the change for requests from the peer and
userspace, respectively.
Patch 2 consolidates some code for disconnecting subflows.
Patches 4-6 update the self tests to cover removal of subflows using
address id 0.
Geliang Tang (5):
mptcp: remove all subflows involving id 0 address
mptcp: unify RM_ADDR and RM_SUBFLOW receiving
mptcp: remove id 0 address
selftests: mptcp: add addr argument for del_addr
selftests: mptcp: remove id 0 address testcases
Matthieu Baerts (1):
selftests: mptcp: avoid calling pm_nl_ctl with bad IDs
net/mptcp/pm_netlink.c | 129 +++++++++++-------
.../testing/selftests/net/mptcp/mptcp_join.sh | 35 ++++-
.../testing/selftests/net/mptcp/pm_netlink.sh | 6 +-
tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 34 ++++-
4 files changed, 143 insertions(+), 61 deletions(-)
base-commit: cda1893e9f7c1d78e391dbb6ef1798cd32354113
--
2.31.1
From: Mat Martineau <hidden> Date: 2021-03-31 00:10:07
From: Geliang Tang <redacted>
There are some duplicate code in mptcp_pm_nl_rm_addr_received and
mptcp_pm_nl_rm_subflow_received. This patch unifies them into a new
function named mptcp_pm_nl_rm_addr_or_subflow. In it, use the input
parameter rm_type to identify it's now removing an address or a subflow.
Suggested-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Mat Martineau <redacted>
Signed-off-by: Geliang Tang <redacted>
---
net/mptcp/pm_netlink.c | 82 +++++++++++++++++-------------------------
1 file changed, 33 insertions(+), 49 deletions(-)
From: Mat Martineau <hidden> Date: 2021-03-31 00:10:07
From: Geliang Tang <redacted>
There's only one subflow involving the non-zero id address, but there
may be multi subflows involving the id 0 address.
Here's an example:
local_id=0, remote_id=0
local_id=1, remote_id=0
local_id=0, remote_id=1
If the removing address id is 0, all the subflows involving the id 0
address need to be removed.
In mptcp_pm_nl_rm_addr_received/mptcp_pm_nl_rm_subflow_received, the
"break" prevents the iteration to the next subflow, so this patch
dropped them.
Reviewed-by: Mat Martineau <redacted>
Signed-off-by: Geliang Tang <redacted>
---
net/mptcp/pm_netlink.c | 4 ----
1 file changed, 4 deletions(-)
From: Mat Martineau <hidden> Date: 2021-03-31 00:10:07
From: Geliang Tang <redacted>
For the id 0 address, different MPTCP connections could be using
different IP addresses for id 0.
This patch added an extra argument IP address for del_addr when
using id 0.
Reviewed-by: Mat Martineau <redacted>
Signed-off-by: Geliang Tang <redacted>
---
tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 34 +++++++++++++++++--
1 file changed, 31 insertions(+), 3 deletions(-)
@@ -301,6 +301,7 @@ int del_addr(int fd, int pm_family, int argc, char *argv[])1024];structrtattr*rta,*nest;structnlmsghdr*nh;+u_int16_tfamily;intnest_start;u_int8_tid;intoff=0;
@@ -310,11 +311,14 @@ int del_addr(int fd, int pm_family, int argc, char *argv[])off=init_genl_req(data,pm_family,MPTCP_PM_CMD_DEL_ADDR,MPTCP_PM_VER);-/* the only argument is the address id */-if(argc!=3)+/* the only argument is the address id (nonzero) */+if(argc!=3&&argc!=4)syntax(argv);id=atoi(argv[2]);+/* zero id with the IP address */+if(!id&&argc!=4)+syntax(argv);nest_start=off;nest=(void*)(data+off);
@@ -328,6 +332,30 @@ int del_addr(int fd, int pm_family, int argc, char *argv[])rta->rta_len=RTA_LENGTH(1);memcpy(RTA_DATA(rta),&id,1);off+=NLMSG_ALIGN(rta->rta_len);++if(!id){+/* addr data */+rta=(void*)(data+off);+if(inet_pton(AF_INET,argv[3],RTA_DATA(rta))){+family=AF_INET;+rta->rta_type=MPTCP_PM_ADDR_ATTR_ADDR4;+rta->rta_len=RTA_LENGTH(4);+}elseif(inet_pton(AF_INET6,argv[3],RTA_DATA(rta))){+family=AF_INET6;+rta->rta_type=MPTCP_PM_ADDR_ATTR_ADDR6;+rta->rta_len=RTA_LENGTH(16);+}else{+error(1,errno,"can't parse ip %s",argv[3]);+}+off+=NLMSG_ALIGN(rta->rta_len);++/* family */+rta=(void*)(data+off);+rta->rta_type=MPTCP_PM_ADDR_ATTR_FAMILY;+rta->rta_len=RTA_LENGTH(2);+memcpy(RTA_DATA(rta),&family,2);+off+=NLMSG_ALIGN(rta->rta_len);+}nest->rta_len=off-nest_start;do_nl_req(fd,nh,off,0);
From: Mat Martineau <hidden> Date: 2021-03-31 00:10:07
From: Geliang Tang <redacted>
This patch added the testcases for removing the id 0 subflow and the id 0
address.
In do_transfer, use the removing addresses number '9' for deleting the id
0 address.
Reviewed-by: Mat Martineau <redacted>
Signed-off-by: Geliang Tang <redacted>
---
.../testing/selftests/net/mptcp/mptcp_join.sh | 35 +++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
From: Mat Martineau <hidden> Date: 2021-03-31 00:10:07
From: Matthieu Baerts <redacted>
IDs are supposed to be between 0 and 255.
In pm_nl_ctl, for both the 'add' and 'get' instruction, the ID is casted
in a u_int8_t. So if we give 256, we will delete ID 0. Obviously, the
goal is not to delete this ID by giving 256.
We could modify pm_nl_ctl and stop if the ID is negative or higher than
255 but probably better not to increase the number of lines for such
things in this tool which is only used in selftests. Instead, we use it
within the limits.
This modification also means that we will no longer add a new ID for the
2nd entry. That's why we removed an expected entry from the dump and
introduced with
commit dc8eb10e95a8 ("selftests: mptcp: add testcases for setting the address ID").
So now we delete ID 9 like before and we add entries for IDs 10 to 255
that are deleted just after.
Note that this could be seen as a fix but it was not really an issue so
far: we were simply playing with ID 0/1 once again. With the following
commit ("selftests: mptcp: add addr argument for del_addr"), it will be
different because ID 0 is going to required an address. We don't want
errors when trying to delete ID 0 without the address argument.
Acked-and-tested-by: Geliang Tang [off-list ref]
Signed-off-by: Matthieu Baerts <redacted>
---
tools/testing/selftests/net/mptcp/pm_netlink.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
From: Mat Martineau <hidden> Date: 2021-03-31 00:10:07
From: Geliang Tang <redacted>
This patch added a new function mptcp_nl_remove_id_zero_address to
remove the id 0 address.
In this function, traverse all the existing msk sockets to find the
msk matched the input IP address. Then fill the removing list with
id 0, and pass it to mptcp_pm_remove_addr and mptcp_pm_remove_subflow.
Suggested-by: Paolo Abeni <pabeni@redhat.com>
Suggested-by: Matthieu Baerts <redacted>
Reviewed-by: Mat Martineau <redacted>
Signed-off-by: Geliang Tang <redacted>
---
net/mptcp/pm_netlink.c | 43 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
@@ -1168,6 +1203,14 @@ static int mptcp_nl_cmd_del_addr(struct sk_buff *skb, struct genl_info *info)if(ret<0)returnret;+/* the zero id address is special: the first address used by the msk+*alwaysgetssuchanid,sodifferentsubflowscanhavedifferentzero+*idaddresses.Additionallyzeroidisnotaccountedforinid_bitmap.+*Let'susean'mptcp_rm_list'insteadofthecommonremovecode.+*/+if(addr.addr.id==0)+returnmptcp_nl_remove_id_zero_address(sock_net(skb->sk),&addr.addr);+spin_lock_bh(&pernet->lock);entry=__lookup_addr_by_id(pernet,addr.addr.id);if(!entry){
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
On Tue, 30 Mar 2021 17:08:50 -0700 you wrote:
An MPTCP connection is aggregated from multiple TCP subflows, and can
involve multiple IP addresses on either peer. The addresses used in the
initial subflow connection are assigned address id 0 on each side of the
link. More addresses can be added and shared with the peer using address
IDs of 1 or larger. MPTCP in Linux shares non-zero address IDs across
all MPTCP connections in a net namespace, which allows userspace to
manage subflow connections across a number of sockets. However, this
makes the address with id 0 a special case, since the IP address
associated with id 0 is potentially different for each socket.
[...]