Add REMOVE_ADDR support
Subsystems (3)
Geliang Tang
v7 cover Add REMOVE_ADDR support
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 (5):
mptcp: remove addr and subflow in PM netlink
mptcp: add RM_ADDR mib
selftests: mptcp: drop first flag in do_rnd_write
selftests: mptcp: add remove addr and subflow test case
selftests: mptcp: add RM_ADDR mib check function
net/mptcp/mib.c | 1 + net/mptcp/mib.h | 1 + net/mptcp/options.c | 2 + net/mptcp/pm.c | 7 +- net/mptcp/pm_netlink.c | 87 ++++++++++++++++++- net/mptcp/protocol.c | 2 + net/mptcp/protocol.h | 2 + .../selftests/net/mptcp/mptcp_connect.c | 7 +- .../testing/selftests/net/mptcp/mptcp_join.sh | 67 ++++++++++++++ 9 files changed, 166 insertions(+), 10 deletions(-)
Signature · 1 line
2.17.1
Geliang Tang
PATCH v7 1/5 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.
We add a new list named anno_list in mptcp_pm_data, to record all the announced addrs. In the traversing, we check if it has been recorded. If it has been, we trigger the RM_ADDR signal.
We also check if this address is in conn_list. If it is, we remove the subflow which using this local address.
--- net/mptcp/pm.c | 7 +++- net/mptcp/pm_netlink.c | 87 ++++++++++++++++++++++++++++++++++++++++-- net/mptcp/protocol.c | 2 + net/mptcp/protocol.h | 2 + 4 files changed, 93 insertions(+), 5 deletions(-)
net/mptcp/pm.c +6 -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)
@@ -229,6 +233,7 @@ void mptcp_pm_data_init(struct mptcp_sock *msk) msk->pm.status =0 ;spin_lock_init (&msk->pm.lock); +INIT_LIST_HEAD (&msk->pm.anno_list);mptcp_pm_nl_data_init (msk); }
net/mptcp/pm_netlink.c +83 -4
120 lines not on this page · raw message
net/mptcp/protocol.c +2 -0
@@ -1961,6 +1961,8 @@ static void mptcp_close(struct sock *sk, long timeout)__mptcp_close_ssk (sk, ssk, subflow, timeout); } +mptcp_pm_free_anno_list (msk); +mptcp_cancel_work (sk);__skb_queue_purge (&sk->sk_receive_queue);
net/mptcp/protocol.h +2 -0
@@ -179,6 +179,7 @@ struct mptcp_pm_data {u8 subflows_max;u8 status;u8 rm_id; +struct list_head anno_list; };struct mptcp_data_frag {
@@ -446,6 +447,7 @@ 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); +void mptcp_pm_free_anno_list (struct mptcp_sock *msk);static inline bool mptcp_pm_should_add_signal (struct mptcp_sock *msk) {
Signature · 1 line
2.17.1
Mat Martineau
[MPTCP] Re: [MPTCP][PATCH v7 mptcp-next 1/5] mptcp: remove addr and subflow in PM netlink
Quoted 74 lines · Geliang Tang
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.
We add a new list named
anno_listinmptcp_pm_data, to record all the announced addrs. In the traversing, we check if it has been recorded. If it has been, we trigger theRM_ADDRsignal.We also check if this address is in
conn_list. If it is, we remove the subflow which using this local address.Suggested-by Matthieu Baerts <matthieu.baerts(a)tessares.net>Suggested-by Paolo Abeni <pabeni(a)redhat.com>Suggested-by Mat Martineau <mathew.j.martineau(a)linux.intel.com>Signed-off-by Geliang Tang <geliangtang(a)gmail.com>---
net/mptcp/pm.c | 7 +++- net/mptcp/pm_netlink.c | 87 ++++++++++++++++++++++++++++++++++++++++-- net/mptcp/protocol.c | 2 + net/mptcp/protocol.h | 2 + 4 files changed, 93 insertions(+), 5 deletions(-)net/mptcp/pm.c +6
-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)@@ -229,6 +233,7 @@ void mptcp_pm_data_init(struct mptcp_sock *msk) msk->pm.status =0 ;spin_lock_init (&msk->pm.lock); +INIT_LIST_HEAD (&msk->pm.anno_list);mptcp_pm_nl_data_init (msk); }net/mptcp/pm_netlink.c +13
-0@@ -167,6 +167,19 @@ static void check_work_pending(struct mptcp_sock *msk)WRITE_ONCE (msk->pm.work_pending, false); } +void mptcp_pm_free_anno_list (struct mptcp_sock *msk) +{ +struct mptcp_pm_addr_entry *entry, *tmp; + +pr_debug ("msk=%p\n" , msk); +spin_lock_bh (&msk->pm.lock); +list_for_each_entry_safe (entry, tmp, &msk->pm.anno_list, list) { +list_del (&entry->list); +kfree (entry); + } +spin_unlock_bh (&msk->pm.lock); +} +static void mptcp_pm_create_subflow_or_signal_addr (struct mptcp_sock *msk) {struct sock *sk = (struct sock *)msk;
net/mptcp/pm_netlink.c static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) · line 204
Quoted 5 lines
net/mptcp/pm_netlink.c +2
-0@@ -187,8 +200,16 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) msk->pm.add_addr_signaled);if (local) { +struct mptcp_pm_addr_entry *clone =NULL ; +
I suggest doing the kmemdup() here and handling the failure before triggering the add_addr signal, so no signal is sent without being added to anno_list.
Should this function check to see if an address is already announced so it is not added to anno_list twice?
Quoted 117 lines
net/mptcp/pm_netlink.c +68
-4msk->pm.add_addr_signaled++;mptcp_pm_announce_addr (msk, &local->addr); + + clone =kmemdup (local,sizeof (*local),GFP_ATOMIC ); +if (!clone) +return ; + +list_add (&clone->list, &msk->pm.anno_list); }else {/* pick failed, avoid fourther attempts later */ msk->pm.local_addr_used = msk->pm.add_addr_signal_max;@@ -552,6 +573,62 @@ __lookup_addr_by_id(struct pm_nl_pernet *pernet, unsigned int id)return NULL ; } +static bool remove_anno_list_by_saddr (struct mptcp_sock *msk, +struct mptcp_addr_info *addr) +{ +struct mptcp_pm_addr_entry *entry, *tmp; + +list_for_each_entry_safe (entry, tmp, &msk->pm.anno_list, list) { +if (addresses_equal (&entry->addr, addr, false)) { +list_del (&entry->list); +kfree (entry); +return true; + } + } + +return false; +} + +static int mptcp_nl_remove_subflow_or_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; +bool ret = false; + +/* check first for announced addr */ +if (list_empty (&msk->pm.anno_list)) + goto remove_subflow; + +spin_lock_bh (&msk->pm.lock); + ret =remove_anno_list_by_saddr (msk, addr); +spin_unlock_bh (&msk->pm.lock); +if (ret) +mptcp_pm_remove_addr (msk, addr->id); + +/* check if should remove a subflow */ +remove_subflow: +if (list_empty (&msk->conn_list)) + goto next; + +lock_sock (sk); +if (lookup_subflow_by_saddr (&msk->conn_list, addr)) +mptcp_pm_rm_addr_received (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 +644,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 +654,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_or_signal_addr (sock_net (skb->sk), &entry->addr); +kfree_rcu (entry, rcu); +return ret; }net/mptcp/protocol.c +2
-0@@ -1961,6 +1961,8 @@ static void mptcp_close(struct sock *sk, long timeout)__mptcp_close_ssk (sk, ssk, subflow, timeout); } +mptcp_pm_free_anno_list (msk); +mptcp_cancel_work (sk);__skb_queue_purge (&sk->sk_receive_queue);net/mptcp/protocol.h +0
-0
net/mptcp/protocol.h struct mptcp_pm_data { · line 182
Quoted 4 lines
net/mptcp/protocol.h +1
-0@@ -179,6 +179,7 @@ struct mptcp_pm_data {u8 subflows_max;u8 status;u8 rm_id; +struct list_head anno_list;
Minor: I'd move this new struct member just after the local & remote members at the beginning of this struct.
Quoted 13 lines
net/mptcp/protocol.h +1
-0};struct mptcp_data_frag {@@ -446,6 +447,7 @@ 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); +void mptcp_pm_free_anno_list (struct mptcp_sock *msk);static inline bool mptcp_pm_should_add_signal (struct mptcp_sock *msk) {Signature · 1 line
2.17.1
Thanks!
--
Mat Martineau
Intel
Geliang Tang
[MPTCP] Re: [MPTCP][PATCH v7 mptcp-next 1/5] mptcp: remove addr and subflow in PM netlink
Hi Mat,
Thanks for your review.
Quoted 87 lines · Mat Martineau <mathew.j.martineau(a)linux.intel.com> 于2020年8月21日周五 上午11:48写道:
Quoted 74 lines · Geliang Tang
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.
We add a new list named
anno_listinmptcp_pm_data, to record all the announced addrs. In the traversing, we check if it has been recorded. If it has been, we trigger theRM_ADDRsignal.We also check if this address is in
conn_list. If it is, we remove the subflow which using this local address.Suggested-by Matthieu Baerts <matthieu.baerts(a)tessares.net>Suggested-by Paolo Abeni <pabeni(a)redhat.com>Suggested-by Mat Martineau <mathew.j.martineau(a)linux.intel.com>Signed-off-by Geliang Tang <geliangtang(a)gmail.com>---
net/mptcp/pm.c | 7 +++- net/mptcp/pm_netlink.c | 87 ++++++++++++++++++++++++++++++++++++++++-- net/mptcp/protocol.c | 2 + net/mptcp/protocol.h | 2 + 4 files changed, 93 insertions(+), 5 deletions(-)net/mptcp/pm.c +6
-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)@@ -229,6 +233,7 @@ void mptcp_pm_data_init(struct mptcp_sock *msk) msk->pm.status =0 ;spin_lock_init (&msk->pm.lock); +INIT_LIST_HEAD (&msk->pm.anno_list);mptcp_pm_nl_data_init (msk); }net/mptcp/pm_netlink.c +13
-0@@ -167,6 +167,19 @@ static void check_work_pending(struct mptcp_sock *msk)WRITE_ONCE (msk->pm.work_pending, false); } +void mptcp_pm_free_anno_list (struct mptcp_sock *msk) +{ +struct mptcp_pm_addr_entry *entry, *tmp; + +pr_debug ("msk=%p\n" , msk); +spin_lock_bh (&msk->pm.lock); +list_for_each_entry_safe (entry, tmp, &msk->pm.anno_list, list) { +list_del (&entry->list); +kfree (entry); + } +spin_unlock_bh (&msk->pm.lock); +} +static void mptcp_pm_create_subflow_or_signal_addr (struct mptcp_sock *msk) {struct sock *sk = (struct sock *)msk;net/mptcp/pm_netlink.c static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) · line 204
Quoted 5 lines
net/mptcp/pm_netlink.c +2
-0@@ -187,8 +200,16 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) msk->pm.add_addr_signaled);if (local) { +struct mptcp_pm_addr_entry *clone =NULL ; +I suggest doing the
kmemdup()here and handling the failure before triggering theadd_addrsignal, so no signal is sent without being added toanno_list.
Quoted 3 lines
Should this function check to see if an address is already announced so it is not added to
anno_listtwice?
Fixed in 'Squash-to: "mptcp: remove addr and subflow in PM netlink v9"'.
Quoted 111 lines
Quoted 111 lines
net/mptcp/pm_netlink.c +68
-4msk->pm.add_addr_signaled++;mptcp_pm_announce_addr (msk, &local->addr); + + clone =kmemdup (local,sizeof (*local),GFP_ATOMIC ); +if (!clone) +return ; + +list_add (&clone->list, &msk->pm.anno_list); }else {/* pick failed, avoid fourther attempts later */ msk->pm.local_addr_used = msk->pm.add_addr_signal_max;@@ -552,6 +573,62 @@ __lookup_addr_by_id(struct pm_nl_pernet *pernet, unsigned int id)return NULL ; } +static bool remove_anno_list_by_saddr (struct mptcp_sock *msk, +struct mptcp_addr_info *addr) +{ +struct mptcp_pm_addr_entry *entry, *tmp; + +list_for_each_entry_safe (entry, tmp, &msk->pm.anno_list, list) { +if (addresses_equal (&entry->addr, addr, false)) { +list_del (&entry->list); +kfree (entry); +return true; + } + } + +return false; +} + +static int mptcp_nl_remove_subflow_or_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; +bool ret = false; + +/* check first for announced addr */ +if (list_empty (&msk->pm.anno_list)) + goto remove_subflow; + +spin_lock_bh (&msk->pm.lock); + ret =remove_anno_list_by_saddr (msk, addr); +spin_unlock_bh (&msk->pm.lock); +if (ret) +mptcp_pm_remove_addr (msk, addr->id); + +/* check if should remove a subflow */ +remove_subflow: +if (list_empty (&msk->conn_list)) + goto next; + +lock_sock (sk); +if (lookup_subflow_by_saddr (&msk->conn_list, addr)) +mptcp_pm_rm_addr_received (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 +644,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 +654,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_or_signal_addr (sock_net (skb->sk), &entry->addr); +kfree_rcu (entry, rcu); +return ret; }net/mptcp/protocol.c +2
-0@@ -1961,6 +1961,8 @@ static void mptcp_close(struct sock *sk, long timeout)__mptcp_close_ssk (sk, ssk, subflow, timeout); } +mptcp_pm_free_anno_list (msk); +mptcp_cancel_work (sk);
Quoted 14 lines
net/mptcp/protocol.h struct mptcp_pm_data { · line 182
Quoted 10 lines
net/mptcp/protocol.c +0
-0__skb_queue_purge (&sk->sk_receive_queue);net/mptcp/protocol.h +1
-0@@ -179,6 +179,7 @@ struct mptcp_pm_data {u8 subflows_max;u8 status;u8 rm_id; +struct list_head anno_list;Minor: I'd move this new struct member just after the local & remote members at the beginning of this struct.
Fixed in 'Squash-to: "mptcp: remove addr and subflow in PM netlink v9"'.
-Geliang
Quoted 19 lines
Quoted 12 lines
net/mptcp/protocol.h +1
-1};struct mptcp_data_frag {@@ -446,6 +447,7 @@ 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); +void mptcp_pm_free_anno_list (struct mptcp_sock *msk);static inline bool mptcp_pm_should_add_signal (struct mptcp_sock *msk) { --Quoted 1 line
2.17.1
Thanks!
--
Mat Martineau
Intel
Geliang Tang
PATCH v7 2/5 mptcp: add RM_ADDR mib
In reply to Geliang TangThis patch added a new mib for RM_ADDR, named MPTCP_MIB_RMADDR, when the RM_ADDR suboption is received, increase this mib counter.
--- net/mptcp/mib.c | 1 + net/mptcp/mib.h | 1 + net/mptcp/options.c | 2 ++ 3 files changed, 4 insertions(+)
net/mptcp/mib.c +1 -0
@@ -27,6 +27,7 @@ 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_SENTINEL };
net/mptcp/mib.h +1 -0
@@ -20,6 +20,7 @@ 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_MAX };
net/mptcp/options.c +2 -0
@@ -11,6 +11,7 @@#include <net/tcp.h> #include <net/mptcp.h> #include "protocol.h" +#include "mib.h" static bool mptcp_cap_flag_sha256 (u8 flags) {
@@ -890,6 +891,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb,if (mp_opt.rm_addr) {mptcp_pm_rm_addr_received (msk, mp_opt.rm_id); +__MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_RMADDR ); mp_opt.rm_addr =0 ; }
Signature · 1 line
2.17.1
Geliang Tang
PATCH v7 3/5 selftests: mptcp: drop first flag in do_rnd_write
In reply to Geliang TangThis patch dropped the flag "first" in do_rnd_write to make RM_ADDR test case work. Since we need to slow down not only the transfer process of the first 100 bytes, but also all the transfer process of all data to let the RM_ADDR suboption can be sent and received completely.
--- tools/testing/selftests/net/mptcp/mptcp_connect.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.c +2 -5
@@ -260,7 +260,6 @@ static int sock_connect_mptcp(const char * const remoteaddr,static size_t do_rnd_write (const int fd,char *buf,const size_t len) { -static bool first = true;unsigned int do_w;ssize_t bw;
@@ -268,7 +267,7 @@ static size_t do_rnd_write(const int fd, char *buf, const size_t len)if (do_w ==0 || do_w > len) do_w = len; -if (cfg_join && first && do_w >100 ) +if (cfg_join && do_w >100 ) do_w =100 ; bw =write (fd, buf, do_w);
@@ -276,10 +275,8 @@ static size_t do_rnd_write(const int fd, char *buf, const size_t len)perror ("write" );/* let the join handshake complete, before going on */ -if (cfg_join && first) { +if (cfg_join)usleep (200000 ); - first = false; - }return bw; }
Signature · 1 line
2.17.1
Mat Martineau
[MPTCP] Re: [MPTCP][PATCH v7 mptcp-next 3/5] selftests: mptcp: drop first flag in do_rnd_write
Quoted 4 lines · Geliang Tang
This patch dropped the flag "first" in
do_rnd_writeto makeRM_ADDRtest case work. Since we need to slow down not only the transfer process of the first 100 bytes, but also all the transfer process of all data to let theRM_ADDRsuboption can be sent and received completely.
It would be better to only slow down the RM_ADDR test. Maybe add a command line parameter that sets a global cfg_join_slow or something?
Mat
Quoted 41 lines
Signed-off-by Geliang Tang <geliangtang(a)gmail.com>---
tools/testing/selftests/net/mptcp/mptcp_connect.c| 7 ++-----1 file changed, 2 insertions(+), 5 deletions(-)tools/testing/selftests/net/mptcp/mptcp_connect.c +2
-5@@ -260,7 +260,6 @@ static int sock_connect_mptcp(const char * const remoteaddr,static size_t do_rnd_write (const int fd,char *buf,const size_t len) { -static bool first = true;unsigned int do_w;ssize_t bw;@@ -268,7 +267,7 @@ static size_t do_rnd_write(const int fd, char *buf, const size_t len)if (do_w ==0 || do_w > len) do_w = len; -if (cfg_join && first && do_w >100 ) +if (cfg_join && do_w >100 ) do_w =100 ; bw =write (fd, buf, do_w);@@ -276,10 +275,8 @@ static size_t do_rnd_write(const int fd, char *buf, const size_t len)perror ("write" );/* let the join handshake complete, before going on */ -if (cfg_join && first) { +if (cfg_join)usleep (200000 ); - first = false; - }return bw; }Signature · 1 line
2.17.1
--
Mat Martineau
Intel
Geliang Tang
PATCH v7 4/5 selftests: mptcp: add remove addr and subflow test case
In reply to Geliang TangThis patch added a new argument in do_transfer, a callback function. We passed do_remove_addr to do_transfer to remove the addr and subflow in the transfer process.
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_join.sh +29 -0
@@ -164,6 +164,11 @@ do_transfer() ip netns exec ${connector_ns} ./mptcp_connect -j -t $timeout -p $port -s ${cl_proto} $connect_addr < "$cin" > "$cout" & cpid=$! + # call a function if it has been passed as a parameter + if [ $# -eq 6 ]; then + ($6) + fi + wait $cpid retc=$? wait $spid
@@ -363,6 +368,30 @@ 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 +# remove subflow and signal +reset +ip netns exec $ns1 ./pm_nl_ctl limits 2 2 +ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal +ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags subflow +ip netns exec $ns2 ./pm_nl_ctl limits 2 2 +ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags signal +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow + +do_remove_addr() +{ + sleep 1 + ip netns exec $ns1 ./pm_nl_ctl del 1 + ip netns exec $ns2 ./pm_nl_ctl del 1 + + sleep 1 + ip netns exec $ns1 ./pm_nl_ctl del 2 + ip netns exec $ns2 ./pm_nl_ctl del 2 + + sleep 2 +} +do_transfer $ns1 $ns2 MPTCP MPTCP 10.0.1.1 do_remove_addr +chk_join_nr "remove subflow and signal" 2 2 1 + # single subflow, syncookies reset_with_cookies ip netns exec $ns1 ./pm_nl_ctl limits 0 1
Signature · 1 line
2.17.1
Geliang Tang
PATCH v7 5/5 selftests: mptcp: add RM_ADDR mib check function
In reply to Geliang TangThis patch added the RM_ADDR mib counter check function chk_rm_nr(). This function check this mib both on server side and client side.
The output looks like this:
11 remove subflow and signal syn[ ok ] - synack[ ok ] - ack[ ok ]
rm [ ok ] - rm [ ok ]
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_join.sh +38 -0
@@ -281,6 +281,43 @@ chk_join_nr() fi } +chk_rm_nr() +{ + local rm_nr_server=$1 + local rm_nr_client=$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_nr_server" ]; then + echo "[fail] got $count JOIN[s] ack expected $add_nr" + ret=1 + dump_stats=1 + else + echo -n "[ ok ]" + fi + + echo -n " - rm " + count=`ip netns exec $ns2 nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$rm_nr_client" ]; then + echo "[fail] got $count JOIN[s] ack expected $echo_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)
@@ -391,6 +428,7 @@ do_remove_addr() } do_transfer $ns1 $ns2 MPTCP MPTCP 10.0.1.1 do_remove_addr chk_join_nr "remove subflow and signal" 2 2 1 +chk_rm_nr 1 1 # single subflow, syncookies reset_with_cookies
Signature · 1 line
2.17.1