Add REMOVE_ADDR support
Subsystems (3)
Geliang Tang
v8 cover Add REMOVE_ADDR support
v8:
- drop anno_list in v7.
We don't need to add a new list, conn_list is enough for the signal
address and local subflow.
- fix local_id and remote_id issues.
The RM_ADDR logic uses an address id to identify the removing
address, so we must make sure the subflow's local_id and remote_id be set properly.
- fix mptcp_pm_nl_rm_addr_received logic issue
- update selftests
v7:
- add RM_ADDR mib
- update RM_ADDR selftests test case
v6:
- rename lookup_anno_list_by_saddr to remove_anno_list_by_saddr as Paolo suggested.
- add msk socket lock when traverse msk->conn_list as Paolo suggested.
- Since the first three patches in v5 have been merged to export branch, drop them from this patchset.
- add remove addr and subflow selftest test case.
- this patchset is against mptcp_net-next's export branch.
v5:
- merge mptcp_nl_remove_subflow() and mptcp_nl_remove_addr()
- add cond_resched
- reduce the indentation level in mptcp_pm_nl_rm_addr_received
v4:
- update mptcp_subflow_shutdown()'s args.
- add rm_id check to make sure we don't shutdown the first subflow.
- add conn_list empty check.
- move anno_list to mptcp_pm_data.
- add a new patch 'mptcp: add remove subflow support'.
v3:
- fix memory leak and lock issue in v2.
- drop alist in v2.
- fix mptcp_subflow_shutdown's arguments.
- bzero remote in mptcp_pm_create_subflow_or_signal_addr.
- add more commit message.
Geliang Tang (8):
mptcp: remove addr and subflow in PM netlink
mptcp: fix mptcp_pm_nl_rm_addr_received logic issue
mptcp: implementing mptcp_pm_remove_subflow
mptcp: fix every subflow's local_id is zero
mptcp: fix subflow's remote_id is zero issue
mptcp: add RM_ADDR related mibs
selftests: mptcp: add remove cfg in mptcp_connect
selftests: mptcp: add remove addr and subflow test cases
net/mptcp/mib.c | 2 + net/mptcp/mib.h | 2 + net/mptcp/pm.c | 25 ++- net/mptcp/pm_netlink.c | 105 +++++++++++-- net/mptcp/protocol.c | 4 + net/mptcp/protocol.h | 5 +- net/mptcp/subflow.c | 8 +- .../selftests/net/mptcp/mptcp_connect.c | 18 ++- .../testing/selftests/net/mptcp/mptcp_join.sh | 142 +++++++++++++++++- 9 files changed, 288 insertions(+), 23 deletions(-)
Signature · 1 line
2.17.1
Geliang Tang
PATCH v8 1/8 mptcp: remove addr and subflow in PM netlink
This patch implements the remove announced addr and subflow logic in PM netlink.
When the PM netlink removes an address, we traverse all the existing msk sockets to find the relevant sockets.
In the traversing, we check if this address is in conn_list. If it is, we trigger the RM_ADDR signal to remove the remote subflow and remove the local subflow which using this local address.
--- net/mptcp/pm.c | 6 +++++- net/mptcp/pm_netlink.c | 39 +++++++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 5 deletions(-)
net/mptcp/pm.c +5 -1
@@ -24,7 +24,11 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk,int mptcp_pm_remove_addr (struct mptcp_sock *msk,u8 local_id) { -return -ENOTSUPP ; +pr_debug ("msk=%p, local_id=%d" , msk, local_id); + + msk->pm.rm_id = local_id; +WRITE_ONCE (msk->pm.rm_addr_signal, true); +return 0 ; }int mptcp_pm_remove_subflow (struct mptcp_sock *msk,u8 remote_id)
net/mptcp/pm_netlink.c +35 -4
@@ -552,6 +552,35 @@ __lookup_addr_by_id(struct pm_nl_pernet *pernet, unsigned int id)return NULL ; } +static int mptcp_nl_remove_subflow_and_signal_addr (struct net *net, +struct mptcp_addr_info *addr) +{ +struct mptcp_sock *msk; +long s_slot =0 , s_num =0 ; + +pr_debug ("remove_id=%d\n" , addr->id); + +while ((msk =mptcp_token_iter_next (net, &s_slot, &s_num)) !=NULL ) { +struct sock *sk = (struct sock *)msk; + +if (list_empty (&msk->conn_list)) + goto next; + +lock_sock (sk); +if (lookup_subflow_by_saddr (&msk->conn_list, addr)) { +mptcp_pm_remove_addr (msk, addr->id); +mptcp_pm_remove_subflow (msk, addr->id); + } +release_sock (sk); + +next: +sock_put (sk); +cond_resched (); + } + +return 0 ; +} +static int mptcp_nl_cmd_del_addr (struct sk_buff *skb,struct genl_info *info) {struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR ];
@@ -567,8 +596,8 @@ static int mptcp_nl_cmd_del_addr(struct sk_buff *skb, struct genl_info *info) entry =__lookup_addr_by_id (pernet, addr.addr.id);if (!entry) {GENL_SET_ERR_MSG (info,"address not found" ); - ret = -EINVAL ; - goto out; +spin_unlock_bh (&pernet->lock); +return -EINVAL ; }if (entry->addr.flags &MPTCP_PM_ADDR_FLAG_SIGNAL ) pernet->add_addr_signal_max--;
@@ -577,9 +606,11 @@ static int mptcp_nl_cmd_del_addr(struct sk_buff *skb, struct genl_info *info) pernet->addrs--;list_del_rcu (&entry->list); -kfree_rcu (entry, rcu); -out:spin_unlock_bh (&pernet->lock); + +mptcp_nl_remove_subflow_and_signal_addr (sock_net (skb->sk), &entry->addr); +kfree_rcu (entry, rcu); +return ret; }
Signature · 1 line
2.17.1
Geliang Tang
PATCH v8 2/8 mptcp: fix mptcp_pm_nl_rm_addr_received logic issue
In reply to Geliang TangWe want to use mptcp_pm_nl_rm_addr_received to deal with both removing an address and removing a subflow. But it not work. Here is the problem:
Suppose there are three subflows,
1 local_id=0 remote_id=0
2 local_id=0 remote_id=1
3 local_id=1 remote_id=0.Here we want to remove the local subflow, the No.3 subflow, so we passed msk->pm.rm_id=1 to mptcp_pm_nl_rm_addr_received.
According to this logic,
if (msk->pm.rm_id != subflow->remote_id &&
msk->pm.rm_id != subflow->local_id)We removed the wrong subflow, the No.2 subflow.
So we need to deal with removing an address and removing a subflow separately. We check subflow->remote_id in mptcp_pm_nl_rm_addr_received to remove an address and check subflow->local_id in mptcp_pm_nl_rm_subflow_received to remove a subflow.
--- net/mptcp/pm_netlink.c | 43 +++++++++++++++++++++++++++++++++++++----- net/mptcp/protocol.h | 1 + 2 files changed, 39 insertions(+), 5 deletions(-)
net/mptcp/pm_netlink.c +38 -5
@@ -271,23 +271,56 @@ void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)if (list_empty (&msk->conn_list))return ; - msk->pm.add_addr_accepted--; - msk->pm.subflows--; -WRITE_ONCE (msk->pm.accept_addr, true); +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 ; +long timeout =0 ; + +if (msk->pm.rm_id != subflow->remote_id) +continue ; + +spin_unlock_bh (&msk->pm.lock); +mptcp_subflow_shutdown (sk, ssk, how); +__mptcp_close_ssk (sk, ssk, subflow, timeout); +spin_lock_bh (&msk->pm.lock); + + msk->pm.add_addr_accepted--; + msk->pm.subflows--; +WRITE_ONCE (msk->pm.accept_addr, true); + +break ; + } +} + +void mptcp_pm_nl_rm_subflow_received (struct mptcp_sock *msk) +{ +struct mptcp_subflow_context *subflow, *tmp; +struct sock *sk = (struct sock *)msk; + +pr_debug ("rm_id %d" , msk->pm.rm_id); + +if (!msk->pm.rm_id) +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 ;long timeout =0 ; -if (msk->pm.rm_id != subflow->remote_id && - msk->pm.rm_id != subflow->local_id) +if (msk->pm.rm_id != subflow->local_id)continue ;spin_unlock_bh (&msk->pm.lock);mptcp_subflow_shutdown (sk, ssk, how);__mptcp_close_ssk (sk, ssk, subflow, timeout);spin_lock_bh (&msk->pm.lock); + + msk->pm.local_addr_used--; + msk->pm.subflows--; +break ; } }
net/mptcp/protocol.h +1 -0
@@ -476,6 +476,7 @@ void mptcp_pm_nl_fully_established(struct mptcp_sock *msk);void mptcp_pm_nl_subflow_established (struct mptcp_sock *msk);void mptcp_pm_nl_add_addr_received (struct mptcp_sock *msk);void mptcp_pm_nl_rm_addr_received (struct mptcp_sock *msk); +void mptcp_pm_nl_rm_subflow_received (struct mptcp_sock *msk);int mptcp_pm_nl_get_local_id (struct mptcp_sock *msk,struct sock_common *skc);static inline struct mptcp_ext *mptcp_get_ext (struct sk_buff *skb)
Signature · 1 line
2.17.1
Geliang Tang
PATCH v8 3/8 mptcp: implementing mptcp_pm_remove_subflow
In reply to Geliang TangLike mptcp_pm_rm_addr_received and the related functions, we implemented the remove subflow logic.
We use mptcp_pm_remove_subflow to remove a local subflow, so change it's argument from remote_id to local_id.
--- net/mptcp/pm.c | 19 +++++++++++++++++-- net/mptcp/protocol.c | 4 ++++ net/mptcp/protocol.h | 4 +++- 3 files changed, 24 insertions(+), 3 deletions(-)
net/mptcp/pm.c +17 -2
@@ -31,9 +31,12 @@ int mptcp_pm_remove_addr(struct mptcp_sock *msk, u8 local_id)return 0 ; } -int mptcp_pm_remove_subflow (struct mptcp_sock *msk,u8 remote_id) +int mptcp_pm_remove_subflow (struct mptcp_sock *msk,u8 local_id) { -return -ENOTSUPP ; +pr_debug ("%s msk=%p, local_id=%d" , __func__, msk, local_id); + +mptcp_pm_rm_subflow_received (msk, local_id); +return 0 ; }/* path manager event handlers */
@@ -165,6 +168,18 @@ void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id)spin_unlock_bh (&pm->lock); } +void mptcp_pm_rm_subflow_received (struct mptcp_sock *msk,u8 rm_id) +{ +struct mptcp_pm_data *pm = &msk->pm; + +pr_debug ("msk=%p local_id=%d" , msk, rm_id); + +spin_lock_bh (&pm->lock); +mptcp_pm_schedule_work (msk,MPTCP_PM_RM_SUBFLOW_RECEIVED ); + pm->rm_id = rm_id; +spin_unlock_bh (&pm->lock); +} +/* path manager helpers */ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
net/mptcp/protocol.c +4 -0
@@ -1695,6 +1695,10 @@ static void pm_work(struct mptcp_sock *msk) pm->status &= ~BIT (MPTCP_PM_RM_ADDR_RECEIVED );mptcp_pm_nl_rm_addr_received (msk); } +if (pm->status &BIT (MPTCP_PM_RM_SUBFLOW_RECEIVED )) { + pm->status &= ~BIT (MPTCP_PM_RM_SUBFLOW_RECEIVED ); +mptcp_pm_nl_rm_subflow_received (msk); + }if (pm->status &BIT (MPTCP_PM_ESTABLISHED )) { pm->status &= ~BIT (MPTCP_PM_ESTABLISHED );mptcp_pm_nl_fully_established (msk);
net/mptcp/protocol.h +3 -1
@@ -153,6 +153,7 @@ struct mptcp_addr_info {enum mptcp_pm_status {MPTCP_PM_ADD_ADDR_RECEIVED ,MPTCP_PM_RM_ADDR_RECEIVED , +MPTCP_PM_RM_SUBFLOW_RECEIVED ,MPTCP_PM_ESTABLISHED ,MPTCP_PM_SUBFLOW_ESTABLISHED , };
@@ -441,11 +442,12 @@ 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_rm_addr_received (struct mptcp_sock *msk,u8 rm_id); +void mptcp_pm_rm_subflow_received (struct mptcp_sock *msk,u8 rm_id);int mptcp_pm_announce_addr (struct mptcp_sock *msk,const struct mptcp_addr_info *addr);int mptcp_pm_remove_addr (struct mptcp_sock *msk,u8 local_id); -int mptcp_pm_remove_subflow (struct mptcp_sock *msk,u8 remote_id); +int mptcp_pm_remove_subflow (struct mptcp_sock *msk,u8 local_id);static inline bool mptcp_pm_should_add_signal (struct mptcp_sock *msk) {
Signature · 1 line
2.17.1
Geliang Tang
PATCH v8 4/8 mptcp: fix every subflow's local_id is zero
In reply to Geliang Tangskc_local is the same as msk_local, so mptcp_pm_nl_get_local_id always return 0. Thus every subflow's local_id is 0.
This patch fixed this issue.
Also, we need to ignore the zero address here, like 0.0.0.0 in IPv4, when we use the zero address as a local address, we means that we can use any one of the local addresses. The zero address is not a new address, we don't need to add it to PM, so this patch added a new function address_zero to check whether an address is the zero address, if it is, we ignore this address.
--- net/mptcp/pm_netlink.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
net/mptcp/pm_netlink.c +17 -1
@@ -64,6 +64,19 @@ static bool addresses_equal(const struct mptcp_addr_info *a,return a->port == b->port; } +static bool address_zero (const struct mptcp_addr_info *addr) +{ +struct mptcp_addr_info zero; + +memset (&zero,0 ,sizeof (zero)); + zero.family = addr->family; + +if (addresses_equal (addr, &zero, false)) +return true; + +return false; +} +static void local_address (const struct sock_common *skc,struct mptcp_addr_info *addr) {
@@ -387,10 +400,13 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc)* addr */ local_address ((struct sock_common *)msk, &msk_local); -local_address ((struct sock_common *)msk, &skc_local); +local_address ((struct sock_common *)skc, &skc_local);if (addresses_equal (&msk_local, &skc_local, false))return 0 ; +if (address_zero (&skc_local)) +return 0 ; + pernet =net_generic (sock_net ((struct sock *)msk), pm_nl_pernet_id);rcu_read_lock ();
Signature · 1 line
2.17.1
Geliang Tang
PATCH v8 5/8 mptcp: fix subflow's remote_id is zero issue
In reply to Geliang TangThis patch added the missing remote_id set in subflow_ulp_clone. And also updated the remote_id set in __mptcp_subflow_connect, to make the code more like local_id set.
--- net/mptcp/subflow.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/mptcp/subflow.c +5 -3
@@ -1042,6 +1042,7 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc,struct mptcp_subflow_context *subflow;struct sockaddr_storage addr;int local_id = loc->id; +int remote_id = remote->id;struct socket *sf;struct sock *ssk;u32 remote_token;
@@ -1072,7 +1073,6 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc, subflow->remote_key = msk->remote_key; subflow->local_key = msk->local_key; subflow->token = msk->token; - subflow->remote_id = remote->id;mptcp_info2sockaddr (loc, &addr); addrlen =sizeof (struct sockaddr_in );
@@ -1086,10 +1086,11 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc, goto failed;mptcp_crypto_key_sha (subflow->remote_key, &remote_token,NULL ); -pr_debug ("msk=%p remote_token=%u local_id=%d" , msk, remote_token, - local_id); +pr_debug ("msk=%p remote_token=%u local_id=%d remote_id=%d" , msk, remote_token, + local_id, remote_id); subflow->remote_token = remote_token; subflow->local_id = local_id; + subflow->remote_id = remote_id; subflow->request_join =1 ; subflow->request_bkup = !!(loc->flags &MPTCP_PM_ADDR_FLAG_BACKUP );mptcp_info2sockaddr (remote, &addr);
@@ -1354,6 +1355,7 @@ static void subflow_ulp_clone(const struct request_sock *req, new_ctx->fully_established =1 ; new_ctx->backup = subflow_req->backup; new_ctx->local_id = subflow_req->local_id; + new_ctx->remote_id = subflow_req->remote_id; new_ctx->token = subflow_req->token; new_ctx->thmac = subflow_req->thmac; }
Signature · 1 line
2.17.1
Geliang Tang
PATCH v8 6/8 mptcp: add RM_ADDR related mibs
In reply to Geliang TangThis patch added two new mibs for RM_ADDR, named MPTCP_MIB_RMADDR and MPTCP_MIB_RMSUBFLOW, when the RM_ADDR suboption is received, increase the first mib counter, when the local subflow is removed, increase the second mib counter.
--- net/mptcp/mib.c | 2 ++ net/mptcp/mib.h | 2 ++ net/mptcp/pm_netlink.c | 5 +++++ 3 files changed, 9 insertions(+)
net/mptcp/mib.c +2 -0
@@ -27,6 +27,8 @@ static const struct snmp_mib mptcp_snmp_list[] = {SNMP_MIB_ITEM ("OFOMerge" ,MPTCP_MIB_OFOMERGE ),SNMP_MIB_ITEM ("NoDSSInWindow" ,MPTCP_MIB_NODSSWINDOW ),SNMP_MIB_ITEM ("DuplicateData" ,MPTCP_MIB_DUPDATA ), +SNMP_MIB_ITEM ("RmAddr" ,MPTCP_MIB_RMADDR ), +SNMP_MIB_ITEM ("RmSubflow" ,MPTCP_MIB_RMSUBFLOW ), SNMP_MIB_SENTINEL };
net/mptcp/mib.h +2 -0
@@ -20,6 +20,8 @@ enum linux_mptcp_mib_field {MPTCP_MIB_OFOMERGE ,/* Segments merged in OoO queue */ MPTCP_MIB_NODSSWINDOW ,/* Segments not in MPTCP windows */ MPTCP_MIB_DUPDATA ,/* Segments discarded due to duplicate DSS */ +MPTCP_MIB_RMADDR ,/* Received RM_ADDR */ +MPTCP_MIB_RMSUBFLOW ,/* Remove a subflow */ __MPTCP_MIB_MAX };
net/mptcp/pm_netlink.c +5 -0
@@ -15,6 +15,7 @@#include <uapi/linux/mptcp.h> #include "protocol.h" +#include "mib.h" /* forward declaration */ static struct genl_family mptcp_genl_family;
@@ -301,6 +302,8 @@ void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk) msk->pm.subflows--;WRITE_ONCE (msk->pm.accept_addr, true); +__MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_RMADDR ); +break ; } }
@@ -334,6 +337,8 @@ void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk) msk->pm.local_addr_used--; msk->pm.subflows--; +__MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_RMSUBFLOW ); +break ; } }
Signature · 1 line
2.17.1
Geliang Tang
PATCH v8 7/8 selftests: mptcp: add remove cfg in mptcp_connect
In reply to Geliang TangThis patch added a new cfg, named cfg_remove in mptcp_connect. This new cfg_remove is copied from cfg_join. The only difference between them is in the do_rnd_write function. Here we slow down the transfer process of all data to let the RM_ADDR suboption can be sent and received completely. Otherwise the remove address and subflow test cases don't work.
--- .../selftests/net/mptcp/mptcp_connect.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.c +15 -3
@@ -54,6 +54,7 @@ static int pf = AF_INET;static int cfg_sndbuf;static int cfg_rcvbuf;static bool cfg_join; +static bool cfg_remove;static int cfg_wait;static void die_usage (void )
@@ -271,6 +272,9 @@ static size_t do_rnd_write(const int fd, char *buf, const size_t len)if (cfg_join && first && do_w >100 ) do_w =100 ; +if (cfg_remove && do_w >50 ) + do_w =50 ; + bw =write (fd, buf, do_w);if (bw <0 )perror ("write" );
@@ -281,6 +285,9 @@ static size_t do_rnd_write(const int fd, char *buf, const size_t len) first = false; } +if (cfg_remove) +usleep (200000 ); +return bw; }
@@ -428,7 +435,7 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd) }/* leave some time for late join/announce */ -if (cfg_join) +if (cfg_join || cfg_remove)usleep (cfg_wait);close (peerfd);
@@ -686,7 +693,7 @@ static void maybe_close(int fd) {unsigned int r =rand (); -if (!cfg_join && (r &1 )) +if (!(cfg_join || cfg_remove) && (r &1 ))close (fd); }
@@ -822,13 +829,18 @@ static void parse_opts(int argc, char **argv) {int c; -while ((c =getopt (argc, argv,"6jlp:s:hut:m:S:R:w:" )) !=-1 ) { +while ((c =getopt (argc, argv,"6jrlp:s:hut:m:S:R:w:" )) !=-1 ) {switch (c) {case 'j' : cfg_join = true; cfg_mode =CFG_MODE_POLL ; cfg_wait =400000 ;break ; +case 'r' : + cfg_remove = true; + cfg_mode =CFG_MODE_POLL ; + cfg_wait =400000 ; +break ;case 'l' : listen_mode = true;break ;
Signature · 1 line
2.17.1
Geliang Tang
PATCH v8 8/8 selftests: mptcp: add remove addr and subflow test cases
In reply to Geliang TangThis patch added the remove addr and subflow test cases and two new functions.
The first function run_remove_tests calls do_transfer with two new arguments, rm_nr_ns1 and rm_nr_ns2, for the numbers of addresses should be removed during the transfer process in namespace 1 and namespace 2.
If both these two arguments are 0, we do the join test cases with "mptcp_connect -j" command. Otherwise, do the remove test cases with "mptcp_connect -r" command.
The second function chk_rm_nr checks the RM_ADDR related mibs's counters.
The output of the test cases looks like this:
11 remove single subflow syn[ ok ] - synack[ ok ] - ack[ ok ]
rm [ ok ] - sf [ ok ]
12 remove multiple subflows syn[ ok ] - synack[ ok ] - ack[ ok ]
rm [ ok ] - sf [ ok ]
13 remove single address syn[ ok ] - synack[ ok ] - ack[ ok ]
rm [ ok ] - sf [ ok ]
14 remove subflow and signal syn[ ok ] - synack[ ok ] - ack[ ok ]
rm [ ok ] - sf [ ok ]
15 remove subflows and signal syn[ ok ] - synack[ ok ] - ack[ ok ]
rm [ ok ] - sf [ ok ]
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 142 +++++++++++++++++- 1 file changed, 139 insertions(+), 3 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +139 -3
@@ -8,6 +8,7 @@ cin="" cout="" ksft_skip=4 timeout=30 +mptcp_connect="" capture=0 TEST_COUNT=0
@@ -132,6 +133,8 @@ do_transfer() cl_proto="$3" srv_proto="$4" connect_addr="$5" + rm_nr_ns1="$6" + rm_nr_ns2="$7" port=$((10000+$TEST_COUNT)) TEST_COUNT=$((TEST_COUNT+1))
@@ -156,14 +159,44 @@ do_transfer() sleep 1 fi - ip netns exec ${listener_ns} ./mptcp_connect -j -t $timeout -l -p $port -s ${srv_proto} 0.0.0.0 < "$sin" > "$sout" & + if [[ $rm_nr_ns1 -eq 0 && $rm_nr_ns2 -eq 0 ]]; then + mptcp_connect="./mptcp_connect -j" + else + mptcp_connect="./mptcp_connect -r" + fi + + ip netns exec ${listener_ns} $mptcp_connect -t $timeout -l -p $port -s ${srv_proto} 0.0.0.0 < "$sin" > "$sout" & spid=$! sleep 1 - ip netns exec ${connector_ns} ./mptcp_connect -j -t $timeout -p $port -s ${cl_proto} $connect_addr < "$cin" > "$cout" & + ip netns exec ${connector_ns} $mptcp_connect -t $timeout -p $port -s ${cl_proto} $connect_addr < "$cin" > "$cout" & cpid=$! + if [ $rm_nr_ns1 -gt 0 ]; then + counter=1 + sleep 1 + + while [ $counter -le $rm_nr_ns1 ] + do + ip netns exec ${listener_ns} ./pm_nl_ctl del $counter + sleep 1 + let counter+=1 + done + fi + + if [ $rm_nr_ns2 -gt 0 ]; then + counter=1 + sleep 1 + + while [ $counter -le $rm_nr_ns2 ] + do + ip netns exec ${connector_ns} ./pm_nl_ctl del $counter + sleep 1 + let counter+=1 + done + fi + wait $cpid retc=$? wait $spid
@@ -219,7 +252,24 @@ run_tests() connect_addr="$3" lret=0 - do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} + do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} 0 0 + lret=$? + if [ $lret -ne 0 ]; then + ret=$lret + return + fi +} + +run_remove_tests() +{ + listener_ns="$1" + connector_ns="$2" + connect_addr="$3" + rm_nr_ns1="$4" + rm_nr_ns2="$5" + lret=0 + + do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} ${rm_nr_ns1} ${rm_nr_ns2} lret=$? if [ $lret -ne 0 ]; then ret=$lret
@@ -276,6 +326,43 @@ chk_join_nr() fi } +chk_rm_nr() +{ + local rm_addr_nr=$1 + local rm_subflow_nr=$2 + local count + local dump_stats + + printf "%-39s %s" " " "rm " + count=`ip netns exec $ns1 nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$rm_addr_nr" ]; then + echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr" + ret=1 + dump_stats=1 + else + echo -n "[ ok ]" + fi + + echo -n " - sf " + count=`ip netns exec $ns2 nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$rm_subflow_nr" ]; then + echo "[fail] got $count RM_SUBFLOW[s] expected $rm_subflow_nr" + ret=1 + dump_stats=1 + else + echo "[ ok ]" + fi + + if [ "${dump_stats}" = 1 ]; then + echo Server ns stats + ip netns exec $ns1 nstat -as | grep MPTcp + echo Client ns stats + ip netns exec $ns2 nstat -as | grep MPTcp + fi +} + sin=$(mktemp) sout=$(mktemp) cin=$(mktemp)
@@ -363,6 +450,55 @@ ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow run_tests $ns1 $ns2 10.0.1.1 chk_join_nr "multiple subflows and signal" 3 3 3 +# single subflow, remove +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 1 +ip netns exec $ns2 ./pm_nl_ctl limits 0 1 +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow +run_remove_tests $ns1 $ns2 10.0.1.1 0 1 +chk_join_nr "remove single subflow" 1 1 1 +chk_rm_nr 1 1 + +# multiple subflows, remove +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 2 +ip netns exec $ns2 ./pm_nl_ctl limits 0 2 +ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow +run_remove_tests $ns1 $ns2 10.0.1.1 0 2 +chk_join_nr "remove multiple subflows" 2 2 2 +chk_rm_nr 2 2 + +# single address, remove +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 1 +ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal +ip netns exec $ns2 ./pm_nl_ctl limits 1 1 +run_remove_tests $ns1 $ns2 10.0.1.1 1 0 +chk_join_nr "remove single address" 1 1 1 +chk_rm_nr 0 0 + +# subflow and signal, remove +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 2 +ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal +ip netns exec $ns2 ./pm_nl_ctl limits 1 2 +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow +run_remove_tests $ns1 $ns2 10.0.1.1 1 1 +chk_join_nr "remove subflow and signal" 2 2 2 +chk_rm_nr 1 1 + +# subflows and signal, remove +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 3 +ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal +ip netns exec $ns2 ./pm_nl_ctl limits 1 3 +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_remove_tests $ns1 $ns2 10.0.1.1 1 2 +chk_join_nr "remove subflows and signal" 3 3 3 +chk_rm_nr 2 2 + # single subflow, syncookies reset_with_cookies ip netns exec $ns1 ./pm_nl_ctl limits 0 1
Signature · 1 line
2.17.1
Paolo Abeni
[MPTCP] Re: [MPTCP][PATCH v8 mptcp-next 5/8] mptcp: fix subflow's remote_id is zero issue
In reply to Geliang TangQuoted 14 lines · Geliang Tang
This patch added the missing
remote_idset insubflow_ulp_clone. And also updated theremote_idset in__mptcp_subflow_connect, to make the code more likelocal_idset.Signed-off-by Geliang Tang <geliangtang(a)gmail.com>--- net/mptcp/subflow.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)net/mptcp/subflow.c +0
-0
net/mptcp/subflow.c int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc, · line 1048
Quoted 7 lines
net/mptcp/subflow.c +1
-0@@ -1042,6 +1042,7 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc,struct mptcp_subflow_context *subflow;struct sockaddr_storage addr;int local_id = loc->id; +int remote_id = remote->id;struct socket *sf;struct sock *ssk;u32 remote_token;
very minor note: this does not respect the reverse x-mas tree order.
Otherwise looks good.
Note: I think you can submit this patch and the previous one (4/8) directly to -net (with an appropriate Fixes tag).
Cheers,
Paolo
Paolo Abeni
Quoted 4 lines · Geliang Tang
v8:
- dropanno_listin v7.
We don't need to add a new list,conn_listis enough for the signal
address and local subflow.
I think this could be problematic.
An MPTCP socket could refuse or delay the creation of new subflows for addresses received via ADD_ADDR.
But an MPTCP should send REMOVE_ADDR for accounced addresses, even if no subflows exists on top of them.
Removing the anno_list we lose this ability.
I'd like to avoid additional interations, if possible, and eventually add squash-to fixes if/where needed. Other options more than welcome.
Cheers,
Paolo
Paolo Abeni
[MPTCP] Re: [MPTCP][PATCH v8 mptcp-next 3/8] mptcp: implementing mptcp_pm_remove_subflow
In reply to Geliang TangQuoted 18 lines · Geliang Tang
Like
mptcp_pm_rm_addr_receivedand the related functions, we implemented the remove subflow logic.We use
mptcp_pm_remove_subflowto remove a local subflow, so change it's argument fromremote_idtolocal_id.Signed-off-by Geliang Tang <geliangtang(a)gmail.com>--- net/mptcp/pm.c | 19 +++++++++++++++++-- net/mptcp/protocol.c | 4 ++++ net/mptcp/protocol.h | 4 +++- 3 files changed, 24 insertions(+), 3 deletions(-)net/mptcp/pm.c +0
-0
net/mptcp/pm.c int mptcp_pm_remove_addr(struct mptcp_sock *msk, u8 local_id) · line 38
Quoted 10 lines
net/mptcp/pm.c +4
-2@@ -31,9 +31,12 @@ int mptcp_pm_remove_addr(struct mptcp_sock *msk, u8 local_id)return 0 ; } -int mptcp_pm_remove_subflow (struct mptcp_sock *msk,u8 remote_id) +int mptcp_pm_remove_subflow (struct mptcp_sock *msk,u8 local_id) { -return -ENOTSUPP ; +pr_debug ("%s msk=%p, local_id=%d" , __func__, msk, local_id); + +mptcp_pm_rm_subflow_received (msk, local_id);
Since here the caller can block and have already acquired the msk socket lock, you could simply acquire the pm spin lock and call:
mptcp_pm_nl_rm_subflow_received();
No need for an additional work queue scheduling, I think.
Cheers,
Paolo
Geliang Tang
Hi Paolo,
Thanks for your review.
Quoted 9 lines · Paolo Abeni <pabeni(a)redhat.com> 于2020年9月2日周三 上午12:02写道:
Quoted 4 lines · Geliang Tang
v8:
- dropanno_listin v7.
We don't need to add a new list,conn_listis enough for the signal
address and local subflow.I think this could be problematic.
Quoted 7 lines
An MPTCP socket could refuse or delay the creation of new subflows for addresses received via
ADD_ADDR.But an MPTCP should send
REMOVE_ADDRfor accounced addresses, even if no subflows exists on top of them.Removing the
anno_listwe lose this ability.
Yes, we can't cover this case, but the v7 code with anno_list can't cover it either. Since anno_list only recorded the local announced addresses, we need also record the received addresses on the remote side.
I'll write a patch to fix this problem later.
Quoted 3 lines
I'd like to avoid additional interations, if possible, and eventually add squash-to fixes if/where needed. Other options more than welcome.
Since my another patchset 'add ADD_ADDR echo flag support' is accepted, v8 will conflict with it. So here I simply updated the v8 patchset as you suggested and sent out the v9 version.
Quoted 6 lines
Cheers,
Paolo
Quoted 7 lines
very minor note: this does not respect the reverse x-mas tree order.
Otherwise looks good.
Note: I think you can submit this patch and the previous one (4/8) directly to -net (with an appropriate Fixes tag).
Since patch 5/8 is depended on the patch 'mptcp: add the incoming RM_ADDR support', which is only on net-next's export branch, we can't directly submit 4/8 and 5/8 to -net. So here I still keeped them in the v9 patchset.
Thanks.
-Geliang
Paolo Abeni
Quoted 16 lines · Geliang Tang
Hi Paolo,
Thanks for your review.
Quoted 11 lines · Paolo Abeni <pabeni(a)redhat.com> 于2020年9月2日周三 上午12:02写道:
Quoted 4 lines · Geliang Tang
v8:
- dropanno_listin v7.
We don't need to add a new list,conn_listis enough for the signal
address and local subflow.I think this could be problematic.
An MPTCP socket could refuse or delay the creation of new subflows for addresses received via
ADD_ADDR.
Quoted 8 lines
Quoted 4 lines
But an MPTCP should send
REMOVE_ADDRfor accounced addresses, even if no subflows exists on top of them.Removing the
anno_listwe lose this ability.Yes, we can't cover this case, but the v7 code with
anno_listcan't cover it either. Sinceanno_listonly recorded the local announced addresses, we need also record the received addresses on the remote side.
I think we don't need this latter list ?!? when the mptcp receives an ADD_ADDR option it will either create a new subflow with such address or will never use such address later.
When the mptcp stack receives a REMOVE_ADDR option, it just need to check vs the existing subflows. If the relevant address has been ignored, no additional action is needed.
Do I miss something?
Thanks!
Paolo
Geliang Tang
Hi Paolo,
Quoted 47 lines · Geliang Tang <geliangtang(a)gmail.com> 于2020年9月2日周三 下午7:30写道:
Hi Paolo,
Thanks for your review.
Quoted 9 lines · Paolo Abeni <pabeni(a)redhat.com> 于2020年9月2日周三 上午12:02写道:
Quoted 4 lines · Geliang Tang
v8:
- dropanno_listin v7.
We don't need to add a new list,conn_listis enough for the signal
address and local subflow.I think this could be problematic.
Quoted 7 lines
An MPTCP socket could refuse or delay the creation of new subflows for addresses received via
ADD_ADDR.But an MPTCP should send
REMOVE_ADDRfor accounced addresses, even if no subflows exists on top of them.Removing the
anno_listwe lose this ability.Yes, we can't cover this case, but the v7 code with
anno_listcan't cover it either. Sinceanno_listonly recorded the local announced addresses, we need also record the received addresses on the remote side.I'll write a patch to fix this problem later.
Quoted 3 lines
I'd like to avoid additional interations, if possible, and eventually add squash-to fixes if/where needed. Other options more than welcome.
Since my another patchset 'add
ADD_ADDRecho flag support' is accepted, v8 will conflict with it. So here I simply updated the v8 patchset as you suggested and sent out the v9 version.Quoted 10 lines
Cheers,
Paolo
very minor note: this does not respect the reverse x-mas tree order.
Otherwise looks good.
Quoted 8 lines
Quoted 3 lines
Note: I think you can submit this patch and the previous one (4/8) directly to -net (with an appropriate Fixes tag).
Since patch 5/8 is depended on the patch 'mptcp: add the incoming
RM_ADDRsupport', which is only on net-next's export branch, we can't directly submit 4/8 and 5/8 to -net. So here I still keeped them in the v9 patchset.
I have just sent out a Squash-to patch for "mptcp: add the incoming RM_ADDR support", to drop the remote_id fixing code in it. Then we can submit 4/8 and 5/8
directly to -net.
-Geliang
Quoted 3 lines
Thanks.
-Geliang
Geliang Tang
Hi Paolo,
Quoted 27 lines · Paolo Abeni <pabeni(a)redhat.com> 于2020年9月2日周三 下午11:20写道:
Quoted 16 lines · Geliang Tang
Hi Paolo,
Thanks for your review.
Quoted 11 lines · Paolo Abeni <pabeni(a)redhat.com> 于2020年9月2日周三 上午12:02写道:
Quoted 4 lines · Geliang Tang
v8:
- dropanno_listin v7.
We don't need to add a new list,conn_listis enough for the signal
address and local subflow.I think this could be problematic.
An MPTCP socket could refuse or delay the creation of new subflows for addresses received via
ADD_ADDR.Quoted 8 lines
Quoted 4 lines
But an MPTCP should send
REMOVE_ADDRfor accounced addresses, even if no subflows exists on top of them.Removing the
anno_listwe lose this ability.Yes, we can't cover this case, but the v7 code with
anno_listcan't cover it either. Sinceanno_listonly recorded the local announced addresses, we need also record the received addresses on the remote side.
Quoted 8 lines
I think we don't need this latter list ?!? when the mptcp receives an
ADD_ADDRoption it will either create a new subflow with such address or will never use such address later.When the mptcp stack receives a
REMOVE_ADDRoption, it just need to check vs the existing subflows. If the relevant address has been ignored, no additional action is needed.
I have just sent out a squash-to patch named 'Squash-to: "mptcp: remove addr and subflow in PM netlink v9"' to fix this. Please give me some suggestions about it.
Thanks.
-Geliang
Quoted 6 lines
Do I miss something?
Thanks!
Paolo