Skip to content

Commit 215d402

Browse files
JasonXingPaolo Abeni
authored andcommitted
mptcp: introducing a helper into active reset logic
Since we have mapped every mptcp reset reason definition in enum sk_rst_reason, introducing a new helper can cover some missing places where we have already set the subflow->reset_reason. Note: using SK_RST_REASON_NOT_SPECIFIED is the same as SK_RST_REASON_MPTCP_RST_EUNSPEC. They are both unknown. So we can convert it directly. Suggested-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Jason Xing <kernelxing@tencent.com> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 3e14049 commit 215d402

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

net/mptcp/protocol.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#endif
2222
#include <net/mptcp.h>
2323
#include <net/xfrm.h>
24-
#include <net/rstreason.h>
2524
#include <asm/ioctls.h>
2625
#include "protocol.h"
2726
#include "mib.h"
@@ -2570,8 +2569,7 @@ static void mptcp_check_fastclose(struct mptcp_sock *msk)
25702569

25712570
slow = lock_sock_fast(tcp_sk);
25722571
if (tcp_sk->sk_state != TCP_CLOSE) {
2573-
tcp_send_active_reset(tcp_sk, GFP_ATOMIC,
2574-
SK_RST_REASON_NOT_SPECIFIED);
2572+
mptcp_send_active_reset_reason(tcp_sk);
25752573
tcp_set_state(tcp_sk, TCP_CLOSE);
25762574
}
25772575
unlock_sock_fast(tcp_sk, slow);

net/mptcp/protocol.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <net/inet_connection_sock.h>
1313
#include <uapi/linux/mptcp.h>
1414
#include <net/genetlink.h>
15+
#include <net/rstreason.h>
1516

1617
#include "mptcp_pm_gen.h"
1718

@@ -608,6 +609,16 @@ sk_rst_convert_mptcp_reason(u32 reason)
608609
}
609610
}
610611

612+
static inline void
613+
mptcp_send_active_reset_reason(struct sock *sk)
614+
{
615+
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
616+
enum sk_rst_reason reason;
617+
618+
reason = sk_rst_convert_mptcp_reason(subflow->reset_reason);
619+
tcp_send_active_reset(sk, GFP_ATOMIC, reason);
620+
}
621+
611622
static inline u64
612623
mptcp_subflow_get_map_offset(const struct mptcp_subflow_context *subflow)
613624
{

net/mptcp/subflow.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <net/transp_v6.h>
2121
#endif
2222
#include <net/mptcp.h>
23-
#include <net/rstreason.h>
2423

2524
#include "protocol.h"
2625
#include "mib.h"
@@ -424,7 +423,7 @@ void mptcp_subflow_reset(struct sock *ssk)
424423
/* must hold: tcp_done() could drop last reference on parent */
425424
sock_hold(sk);
426425

427-
tcp_send_active_reset(ssk, GFP_ATOMIC, SK_RST_REASON_NOT_SPECIFIED);
426+
mptcp_send_active_reset_reason(ssk);
428427
tcp_done(ssk);
429428
if (!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &mptcp_sk(sk)->flags))
430429
mptcp_schedule_work(sk);
@@ -1362,8 +1361,7 @@ static bool subflow_check_data_avail(struct sock *ssk)
13621361
tcp_set_state(ssk, TCP_CLOSE);
13631362
while ((skb = skb_peek(&ssk->sk_receive_queue)))
13641363
sk_eat_skb(ssk, skb);
1365-
tcp_send_active_reset(ssk, GFP_ATOMIC,
1366-
SK_RST_REASON_NOT_SPECIFIED);
1364+
mptcp_send_active_reset_reason(ssk);
13671365
WRITE_ONCE(subflow->data_avail, false);
13681366
return false;
13691367
}

0 commit comments

Comments
 (0)