Add REMOVE_ADDR support
Subsystems (3)
Geliang Tang
v6 cover Add REMOVE_ADDR support
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 (2):
mptcp: remove addr and subflow in PM netlink
selftests: mptcp: add remove addr and subflow test case
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 | 62 +++++++++---- 6 files changed, 140 insertions(+), 27 deletions(-)
Signature · 1 line
2.17.1
Geliang Tang
PATCH v6 1/2 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
Geliang Tang
PATCH v6 2/2 selftests: mptcp: add remove addr and subflow test case
In reply to Geliang TangThis patch added remove addr and subflow test case.
1 We droped the flag "first" in do_rnd_write, since we need to slow down all the transfer process to let the sending and receiving of the RM_ADDR suboption complete.
2 We added a new argument "remove_addr" in run_tests and do_transfer, if this flag is true, we called do_remove_addr to remove the addr and subflow.
--- .../selftests/net/mptcp/mptcp_connect.c | 7 +-- .../testing/selftests/net/mptcp/mptcp_join.sh | 62 ++++++++++++++----- 2 files changed, 47 insertions(+), 22 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; }
tools/testing/selftests/net/mptcp/mptcp_join.sh +45 -17
183 lines not on this page · raw message
Signature · 1 line
2.17.1
Paolo Abeni
Quoted 8 lines · Geliang Tang
v6:
- renamelookup_anno_list_by_saddrtoremove_anno_list_by_saddras Paolo suggested.
- add msk socket lock when traversemsk->conn_listas 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.
Thank you for the great work.
I'm currently on PTO, and likely will not able to review it till aug
24. Hopefully someone else will step-in before :)
Cheers,
Paolo