Skip to content

Commit 77c3c95

Browse files
Paolo Abenikuba-moo
authored andcommitted
tcp: factor out __tcp_close() helper
unlocked version of protocol level close, will be used by MPTCP to allow decouple orphaning and subflow level close. Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e222399 commit 77c3c95

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

include/net/tcp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ void tcp_update_metrics(struct sock *sk);
395395
void tcp_init_metrics(struct sock *sk);
396396
void tcp_metrics_init(void);
397397
bool tcp_peer_is_proven(struct request_sock *req, struct dst_entry *dst);
398+
void __tcp_close(struct sock *sk, long timeout);
398399
void tcp_close(struct sock *sk, long timeout);
399400
void tcp_init_sock(struct sock *sk);
400401
void tcp_init_transfer(struct sock *sk, int bpf_op, struct sk_buff *skb);

net/ipv4/tcp.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,13 +2420,12 @@ bool tcp_check_oom(struct sock *sk, int shift)
24202420
return too_many_orphans || out_of_socket_memory;
24212421
}
24222422

2423-
void tcp_close(struct sock *sk, long timeout)
2423+
void __tcp_close(struct sock *sk, long timeout)
24242424
{
24252425
struct sk_buff *skb;
24262426
int data_was_unread = 0;
24272427
int state;
24282428

2429-
lock_sock(sk);
24302429
sk->sk_shutdown = SHUTDOWN_MASK;
24312430

24322431
if (sk->sk_state == TCP_LISTEN) {
@@ -2590,6 +2589,12 @@ void tcp_close(struct sock *sk, long timeout)
25902589
out:
25912590
bh_unlock_sock(sk);
25922591
local_bh_enable();
2592+
}
2593+
2594+
void tcp_close(struct sock *sk, long timeout)
2595+
{
2596+
lock_sock(sk);
2597+
__tcp_close(sk, timeout);
25932598
release_sock(sk);
25942599
sock_put(sk);
25952600
}

0 commit comments

Comments
 (0)