Skip to content

Commit eaa2ffa

Browse files
Paolo Abenikuba-moo
Paolo Abeni
authored andcommitted
mptcp: introduce MPTCP snd_nxt
Track the next MPTCP sequence number used on xmit, currently always equal to write_next. Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent f0e6a4c commit eaa2ffa

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

net/mptcp/options.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ static void update_una(struct mptcp_sock *msk,
813813
struct mptcp_options_received *mp_opt)
814814
{
815815
u64 new_snd_una, snd_una, old_snd_una = atomic64_read(&msk->snd_una);
816-
u64 write_seq = READ_ONCE(msk->write_seq);
816+
u64 snd_nxt = READ_ONCE(msk->snd_nxt);
817817

818818
/* avoid ack expansion on update conflict, to reduce the risk of
819819
* wrongly expanding to a future ack sequence number, which is way
@@ -822,7 +822,7 @@ static void update_una(struct mptcp_sock *msk,
822822
new_snd_una = expand_ack(old_snd_una, mp_opt->data_ack, mp_opt->ack64);
823823

824824
/* ACK for data not even sent yet? Ignore. */
825-
if (after64(new_snd_una, write_seq))
825+
if (after64(new_snd_una, snd_nxt))
826826
new_snd_una = old_snd_una;
827827

828828
while (after64(new_snd_una, old_snd_una)) {

net/mptcp/protocol.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ static void mptcp_clean_una(struct sock *sk)
834834
* plain TCP
835835
*/
836836
if (__mptcp_check_fallback(msk))
837-
atomic64_set(&msk->snd_una, msk->write_seq);
837+
atomic64_set(&msk->snd_una, msk->snd_nxt);
838838
snd_una = atomic64_read(&msk->snd_una);
839839

840840
list_for_each_entry_safe(dfrag, dtmp, &msk->rtx_queue, list) {
@@ -1338,6 +1338,7 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
13381338

13391339
release_sock(ssk);
13401340
out:
1341+
msk->snd_nxt = msk->write_seq;
13411342
ssk_check_wmem(msk);
13421343
release_sock(sk);
13431344
return copied ? : ret;
@@ -1629,7 +1630,7 @@ static void mptcp_retransmit_handler(struct sock *sk)
16291630
{
16301631
struct mptcp_sock *msk = mptcp_sk(sk);
16311632

1632-
if (atomic64_read(&msk->snd_una) == READ_ONCE(msk->write_seq)) {
1633+
if (atomic64_read(&msk->snd_una) == READ_ONCE(msk->snd_nxt)) {
16331634
mptcp_stop_timer(sk);
16341635
} else {
16351636
set_bit(MPTCP_WORK_RTX, &msk->flags);
@@ -2100,6 +2101,7 @@ struct sock *mptcp_sk_clone(const struct sock *sk,
21002101
WRITE_ONCE(msk->fully_established, false);
21012102

21022103
msk->write_seq = subflow_req->idsn + 1;
2104+
msk->snd_nxt = msk->write_seq;
21032105
atomic64_set(&msk->snd_una, msk->write_seq);
21042106
if (mp_opt->mp_capable) {
21052107
msk->can_ack = true;
@@ -2409,6 +2411,7 @@ void mptcp_finish_connect(struct sock *ssk)
24092411
WRITE_ONCE(msk->remote_key, subflow->remote_key);
24102412
WRITE_ONCE(msk->local_key, subflow->local_key);
24112413
WRITE_ONCE(msk->write_seq, subflow->idsn + 1);
2414+
WRITE_ONCE(msk->snd_nxt, msk->write_seq);
24122415
WRITE_ONCE(msk->ack_seq, ack_seq);
24132416
WRITE_ONCE(msk->can_ack, 1);
24142417
atomic64_set(&msk->snd_una, msk->write_seq);

net/mptcp/protocol.h

+9-8
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@
9292
#define MPTCP_FALLBACK_DONE 4
9393
#define MPTCP_WORK_CLOSE_SUBFLOW 5
9494

95+
static inline bool before64(__u64 seq1, __u64 seq2)
96+
{
97+
return (__s64)(seq1 - seq2) < 0;
98+
}
99+
100+
#define after64(seq2, seq1) before64(seq1, seq2)
101+
95102
struct mptcp_options_received {
96103
u64 sndr_key;
97104
u64 rcvr_key;
@@ -201,6 +208,7 @@ struct mptcp_sock {
201208
u64 local_key;
202209
u64 remote_key;
203210
u64 write_seq;
211+
u64 snd_nxt;
204212
u64 ack_seq;
205213
u64 rcv_data_fin_seq;
206214
struct sock *last_snd;
@@ -276,7 +284,7 @@ static inline struct mptcp_data_frag *mptcp_rtx_tail(const struct sock *sk)
276284
{
277285
struct mptcp_sock *msk = mptcp_sk(sk);
278286

279-
if (list_empty(&msk->rtx_queue))
287+
if (!before64(msk->snd_nxt, atomic64_read(&msk->snd_una)))
280288
return NULL;
281289

282290
return list_last_entry(&msk->rtx_queue, struct mptcp_data_frag, list);
@@ -528,13 +536,6 @@ static inline struct mptcp_ext *mptcp_get_ext(struct sk_buff *skb)
528536
return (struct mptcp_ext *)skb_ext_find(skb, SKB_EXT_MPTCP);
529537
}
530538

531-
static inline bool before64(__u64 seq1, __u64 seq2)
532-
{
533-
return (__s64)(seq1 - seq2) < 0;
534-
}
535-
536-
#define after64(seq2, seq1) before64(seq1, seq2)
537-
538539
void mptcp_diag_subflow_init(struct tcp_ulp_ops *ops);
539540

540541
static inline bool __mptcp_check_fallback(const struct mptcp_sock *msk)

0 commit comments

Comments
 (0)