mptcp: retransmit ADD_ADDR when timeout and others
Subsystems (3)
Geliang Tang
v5 cover mptcp: retransmit ADD_ADDR when timeout and others
v5:
- add mptcp_pm_should_add_signal check
- use list_splice_init instead of list_move
- reuse lookup_anno_list_by_saddr
- reuse mptcp_pm_del_add_timer
- add new helper sk_stop_timer_sync
- this patchset deponds on my two little squash-to patches:
Squash-to: "mptcp: remove addr and subflow in PM netlink" Part 3
Squash-to: "mptcp: implement mptcp_pm_remove_subflow" Part 2
v4:
- split in two patches
- fix racy issues
v3:
- use timer.
- drop bh_lock_sock.
- move __sock_put at the end of mptcp_pm_add_timer.
v2:
- Use delayed_work instead of timer.
- This patch depends on my another patch named 'Squash-to: "mptcp: remove addr and subflow in PM netlink"'.
Geliang Tang (3):
mptcp: add struct mptcp_pm_add_entry
mptcp: add sk_stop_timer_sync helper
mptcp: retransmit ADD_ADDR when timeout
include/net/sock.h | 2 + net/core/sock.c | 7 +++ net/mptcp/options.c | 1 + net/mptcp/pm_netlink.c | 128 +++++++++++++++++++++++++++++++++-------- net/mptcp/protocol.h | 3 + 5 files changed, 117 insertions(+), 24 deletions(-)
Signature · 1 line
2.17.1
Geliang Tang
PATCH v5 1/3 mptcp: add struct mptcp_pm_add_entry
Add a new struct mptcp_pm_add_entry to describe add_addr's entry.
--- net/mptcp/pm_netlink.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
net/mptcp/pm_netlink.c +12 -7
@@ -28,6 +28,11 @@ struct mptcp_pm_addr_entry {struct rcu_head rcu; }; +struct mptcp_pm_add_entry { +struct list_head list; +struct mptcp_addr_info addr; +}; +struct pm_nl_pernet {/* protects pernet updates */ spinlock_t lock;
@@ -181,7 +186,7 @@ static void check_work_pending(struct mptcp_sock *msk)static bool lookup_anno_list_by_saddr (struct mptcp_sock *msk,struct mptcp_addr_info *addr) { -struct mptcp_pm_addr_entry *entry; +struct mptcp_pm_add_entry *entry;list_for_each_entry (entry, &msk->pm.anno_list, list) {if (addresses_equal (&entry->addr, addr, false))
@@ -194,23 +199,23 @@ static bool lookup_anno_list_by_saddr(struct mptcp_sock *msk,static bool mptcp_pm_alloc_anno_list (struct mptcp_sock *msk,struct mptcp_pm_addr_entry *entry) { -struct mptcp_pm_addr_entry *clone =NULL ; +struct mptcp_pm_add_entry *add_entry =NULL ;if (lookup_anno_list_by_saddr (msk, &entry->addr))return false; - clone =kmemdup (entry,sizeof (*entry),GFP_ATOMIC ); -if (!clone) + add_entry =kmalloc (sizeof (*add_entry),GFP_ATOMIC ); +if (!add_entry)return false; -list_add (&clone->list, &msk->pm.anno_list); +list_add (&add_entry->list, &msk->pm.anno_list);return true; }void mptcp_pm_free_anno_list (struct mptcp_sock *msk) { -struct mptcp_pm_addr_entry *entry, *tmp; +struct mptcp_pm_add_entry *entry, *tmp;pr_debug ("msk=%p" , msk);
@@ -654,7 +659,7 @@ __lookup_addr_by_id(struct pm_nl_pernet *pernet, unsigned int id)static bool remove_anno_list_by_saddr (struct mptcp_sock *msk,struct mptcp_addr_info *addr) { -struct mptcp_pm_addr_entry *entry, *tmp; +struct mptcp_pm_add_entry *entry, *tmp;list_for_each_entry_safe (entry, tmp, &msk->pm.anno_list, list) {if (addresses_equal (&entry->addr, addr, false)) {
Signature · 1 line
2.17.1
Geliang Tang
PATCH v5 2/3 mptcp: add sk_stop_timer_sync helper
In reply to Geliang TangThis patch added a new helper sk_stop_timer_sync, it deactivates a timer like sk_stop_timer, but waits for the handler to finish.
--- include/net/sock.h | 2 ++ net/core/sock.c | 7 +++++++ 2 files changed, 9 insertions(+)
include/net/sock.h +2 -0
@@ -2195,6 +2195,8 @@ void sk_reset_timer(struct sock *sk, struct timer_list *timer,void sk_stop_timer (struct sock *sk,struct timer_list *timer); +void sk_stop_timer_sync (struct sock *sk,struct timer_list *timer); + int __sk_queue_drop_skb(struct sock *sk, struct sk_buff_head *sk_queue, struct sk_buff *skb, unsigned int flags, void (*destructor)(struct sock *sk,
net/core/sock.c +7 -0
@@ -2947,6 +2947,13 @@ void sk_stop_timer(struct sock *sk, struct timer_list* timer) }EXPORT_SYMBOL (sk_stop_timer); +void sk_stop_timer_sync (struct sock *sk,struct timer_list *timer) +{ +if (del_timer_sync (timer)) +__sock_put (sk); +} +EXPORT_SYMBOL (sk_stop_timer_sync); +void sock_init_data (struct socket *sock,struct sock *sk) {sk_init_common (sk);
Signature · 1 line
2.17.1
Geliang Tang
PATCH v5 3/3 mptcp: retransmit ADD_ADDR when timeout
In reply to Geliang TangThis patch implemented the retransmition of ADD_ADDR when no ADD_ADDR echo is received. It added a timer with the announced address. When timeout occurs, ADD_ADDR will be retransmitted.
--- net/mptcp/options.c | 1 + net/mptcp/pm_netlink.c | 113 ++++++++++++++++++++++++++++++++++------- net/mptcp/protocol.h | 3 ++ 3 files changed, 98 insertions(+), 19 deletions(-)
net/mptcp/options.c +1 -0
@@ -893,6 +893,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb,mptcp_pm_add_addr_received (msk, &addr);MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_ADDADDR ); }else { +mptcp_pm_del_add_timer (msk, &addr);MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_ECHOADD ); } mp_opt.add_addr =0 ;
net/mptcp/pm_netlink.c +94 -19
175 lines not on this page · raw message
net/mptcp/protocol.h +3 -0
@@ -444,6 +444,9 @@ 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_free_anno_list (struct mptcp_sock *msk); +struct mptcp_pm_add_entry * +mptcp_pm_del_add_timer (struct mptcp_sock *msk, +struct mptcp_addr_info *addr); int mptcp_pm_announce_addr(struct mptcp_sock *msk, const struct mptcp_addr_info *addr,
Signature · 1 line
2.17.1
Paolo Abeni
[MPTCP] Re: [MPTCP][PATCH v5 mptcp-next 3/3] mptcp: retransmit ADD_ADDR when timeout
Hi,
Thank you for the prompt turn-over. There is still a somewhat relevant item - the last comment in this patch. The others comments are mostly nit picking, but nice to have.
Quoted 63 lines · Geliang Tang
This patch implemented the retransmition of
ADD_ADDRwhen noADD_ADDRecho
is received. It added a timer with the announced address. When timeout
occurs,ADD_ADDRwill be retransmitted.Suggested-by Mat Martineau <mathew.j.martineau(a)linux.intel.com>Suggested-by Paolo Abeni <pabeni(a)redhat.com>Signed-off-by Geliang Tang <geliangtang(a)gmail.com>--- net/mptcp/options.c | 1 + net/mptcp/pm_netlink.c | 113 ++++++++++++++++++++++++++++++++++----- -- net/mptcp/protocol.h | 3 ++ 3 files changed, 98 insertions(+), 19 deletions(-)net/mptcp/options.c +1
-0@@ -893,6 +893,7 @@ void mptcp_incoming_options(struct sock *sk,struct sk_buff *skb, mptcp_pm_add_addr_received(msk, &addr);MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_ADDADDR ); }else { +mptcp_pm_del_add_timer (msk, &addr); MPTCP_INC_STATS(sock_net(sk),
MPTCP_MIB_ECHOADD);net/mptcp/options.c +0
-0} mp_opt.add_addr =0 ;net/mptcp/pm_netlink.c +7
-2@@ -31,6 +31,9 @@ struct mptcp_pm_addr_entry {struct mptcp_pm_add_entry {struct list_head list;struct mptcp_addr_info addr; +struct timer_list add_timer; +struct mptcp_sock *sock; +u8 retrans_times; };struct pm_nl_pernet {@@ -46,6 +49,7 @@ struct pm_nl_pernet { };#define MPTCP_PM_ADDR_MAX 8 +#define ADD_ADDR_RETRANS_MAX 3static bool addresses_equal (const struct mptcp_addr_info *a,struct mptcp_addr_info *b,bool use_port)@@ -183,23 +187,83 @@ static void check_work_pending(struct mptcp_sock *msk) WRITE_ONCE(msk->pm.work_pending, false); } -static bool lookup_anno_list_by_saddr (struct mptcp_sock *msk, -struct mptcp_addr_info *addr) +static struct mptcp_pm_add_entry * +lookup_anno_list_by_saddr (struct mptcp_sock *msk, +struct mptcp_addr_info *addr)
net/mptcp/pm_netlink.c static void check_work_pending(struct · line 200
Quoted 10 lines
net/mptcp/pm_netlink.c +4
-3{ -struct mptcp_pm_add_entry *entry; +struct mptcp_pm_add_entry *entry, *ret =NULL ;list_for_each_entry (entry, &msk->pm.anno_list, list) { -if (addresses_equal (&entry->addr, addr, false)) -return true; +if (addresses_equal (&entry->addr, addr, false)) { + ret = entry; +break ;
Or simply:
return entry;
No braches, no break, no local variable.
net/mptcp/pm_netlink.c static void check_work_pending(struct mptcp_sock *msk) · line 203
Quoted 5 lines
net/mptcp/pm_netlink.c +2
-1+ } } -return false; +return ret;
[with the above change]
return NULL;
Quoted 5 lines
net/mptcp/pm_netlink.c +5
-0+} + +static void mptcp_pm_add_timer (struct timer_list *timer) +{ + struct mptcp_pm_add_entry *entry = from_timer(entry, timer,
net/mptcp/pm_netlink.c static void check_work_pending(struct mptcp_sock *msk) · line 217
Quoted 10 lines
net/mptcp/pm_netlink.c +9
-0add_timer); +struct mptcp_sock *msk = entry->sock; +struct sock *sk = (struct sock *)msk; + +pr_debug ("msk=%p" , msk); + +if (!msk) +return ; + +if (sk->sk_state ==TCP_CLOSE )
Since this is a lockless context (sorry for not noticing it before):
if (inet_sk_state_load(sk))
Quoted 26 lines
net/mptcp/pm_netlink.c +26
-0+return ; + +if (!entry->addr.id) +return ; + +if (mptcp_pm_should_add_signal (msk)) { +sk_reset_timer (sk, timer, jiffies +TCP_RTO_MAX /8 ); + goto out; + } + +spin_lock_bh (&msk->pm.lock); + +if (!mptcp_pm_should_add_signal (msk)) { +pr_debug ("retransmit ADD_ADDR id=%d" , entry->addr.id); +mptcp_pm_announce_addr (msk, &entry->addr, false); + entry->retrans_times++; + } + +if (entry->retrans_times <ADD_ADDR_RETRANS_MAX ) +sk_reset_timer (sk, timer, jiffies +TCP_RTO_MAX ); + +spin_unlock_bh (&msk->pm.lock); + +out: +__sock_put (sk); +}
net/mptcp/pm_netlink.c static void check_work_pending(struct mptcp_sock *msk) · line 253
Quoted 10 lines
net/mptcp/pm_netlink.c +10
-0+ +struct mptcp_pm_add_entry * +mptcp_pm_del_add_timer (struct mptcp_sock *msk, +struct mptcp_addr_info *addr) +{ +struct mptcp_pm_add_entry *entry; +struct sock *sk = (struct sock *)msk; + +spin_lock_bh (&msk->pm.lock); + entry =lookup_anno_list_by_saddr (msk, addr);
here it's additionally needed:
entry->retrans_times = ADD_ADDR_RETRANS_MAX;
to prevent the timer re-scheduling, or bad things could happen!
Cheers,
Paolo
Matthieu Baerts
[MPTCP] Re: [MPTCP][PATCH v5 mptcp-next 3/3] mptcp: retransmit ADD_ADDR when timeout
Hi Geliang, Paolo
Quoted 16 lines · Paolo Abeni
Hi,
Thank you for the prompt turn-over. There is still a somewhat relevant item - the last comment in this patch. The others comments are mostly nit picking, but nice to have.
Quoted 9 lines · Geliang Tang
This patch implemented the retransmition of
ADD_ADDRwhen noADD_ADDRecho
is received. It added a timer with the announced address. When timeout
occurs,ADD_ADDRwill be retransmitted.Suggested-by Mat Martineau <mathew.j.martineau(a)linux.intel.com>Suggested-by Paolo Abeni <pabeni(a)redhat.com>Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
As discussed on IRC, I just applied this patch + the "squash to" one:
- a972ed5d1ec5: mptcp: add struct mptcp_pm_add_entry
- 39a25e21cbca: mptcp: add sk_stop_timer_sync helper
- e83b080276ea: mptcp: retransmit ADD_ADDR when timeout
Paolo's ACK has been added to these three patches. I applied these patches after Geliang' selftests patches because the timeout feature is not validated by any kselftests.
- fe8df13fc5d3..8c5acf4c1ab3: result
Note that it would maybe be more interesting to add packetdrill test to validate this feature.
Tests + export are going to be started soon.
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net
Geliang Tang
[MPTCP] Re: [MPTCP][PATCH v5 mptcp-next 3/3] mptcp: retransmit ADD_ADDR when timeout
Hi Matt,
Quoted 23 lines · Matthieu Baerts <matthieu.baerts(a)tessares.net> 于2020年9月22日周二 上午1:53写道:
Hi Geliang, Paolo
Quoted 16 lines · Paolo Abeni
Hi,
Thank you for the prompt turn-over. There is still a somewhat relevant item - the last comment in this patch. The others comments are mostly nit picking, but nice to have.
Quoted 9 lines · Geliang Tang
This patch implemented the retransmition of
ADD_ADDRwhen noADD_ADDRecho
is received. It added a timer with the announced address. When timeout
occurs,ADD_ADDRwill be retransmitted.Suggested-by Mat Martineau <mathew.j.martineau(a)linux.intel.com>Suggested-by Paolo Abeni <pabeni(a)redhat.com>Signed-off-by Geliang Tang <geliangtang(a)gmail.com>As discussed on IRC, I just applied this patch + the "squash to" one:
Quoted 7 lines
-
a972ed5d1ec5: mptcp: add structmptcp_pm_add_entry
-39a25e21cbca: mptcp: addsk_stop_timer_synchelper
-e83b080276ea: mptcp: retransmitADD_ADDRwhen timeoutPaolo's ACK has been added to these three patches. I applied these patches after Geliang' selftests patches because the timeout feature is not validated by any kselftests.
Thanks, as these patches have been applied, I think both issue #49 (ADD_ADDR:
echo bit support) and issue #50 (REMOVE_ADDR support) could be closed.
And I'll write the selftest case of these patches later.
-Geliang
Quoted 13 lines
-
fe8df13fc5d3..8c5acf4c1ab3: resultNote that it would maybe be more interesting to add packetdrill test to validate this feature.
Tests + export are going to be started soon.
Cheers,
Matt
--
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net