diff mbox series

[net-next] tcp: rename inet_csk_{delete|reset}_keepalive_timer()

Message ID 20250206094605.2694118-1-edumazet@google.com (mailing list archive)
State Accepted
Commit be258f654a6ef5ab0d777f40fd3bcee540934307
Delegated to: Netdev Maintainers
Headers show
Series [net-next] tcp: rename inet_csk_{delete|reset}_keepalive_timer() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 14 this patch: 14
netdev/build_tools success Errors and warnings before: 26 (+1) this patch: 26 (+1)
netdev/cc_maintainers warning 1 maintainers not CCed: dsahern@kernel.org
netdev/build_clang success Errors and warnings before: 2971 this patch: 2971
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 2071 this patch: 2071
netdev/checkpatch warning CHECK: Alignment should match open parenthesis CHECK: spaces preferred around that '/' (ctx:VxV)
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 8 this patch: 8
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2025-02-06--12-00 (tests: 891)

Commit Message

Eric Dumazet Feb. 6, 2025, 9:46 a.m. UTC
inet_csk_delete_keepalive_timer() and inet_csk_reset_keepalive_timer()
are only used from core TCP, there is no need to export them.

Replace their prefix by tcp.

Move them to net/ipv4/tcp_timer.c and make tcp_delete_keepalive_timer()
static.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/net/inet_connection_sock.h |  3 ---
 include/net/tcp.h                  |  1 +
 net/ipv4/inet_connection_sock.c    | 12 ------------
 net/ipv4/tcp.c                     |  4 ++--
 net/ipv4/tcp_input.c               |  6 +++---
 net/ipv4/tcp_minisocks.c           |  3 +--
 net/ipv4/tcp_timer.c               | 21 +++++++++++++++------
 7 files changed, 22 insertions(+), 28 deletions(-)

Comments

Jason Xing Feb. 6, 2025, 10:25 a.m. UTC | #1
On Thu, Feb 6, 2025 at 5:46 PM Eric Dumazet <edumazet@google.com> wrote:
>
> inet_csk_delete_keepalive_timer() and inet_csk_reset_keepalive_timer()
> are only used from core TCP, there is no need to export them.
>
> Replace their prefix by tcp.
>
> Move them to net/ipv4/tcp_timer.c and make tcp_delete_keepalive_timer()
> static.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Reviewed-by: Jason Xing <kerneljasonxing@gmail.com>
Joe Damato Feb. 7, 2025, 12:41 a.m. UTC | #2
On Thu, Feb 06, 2025 at 09:46:05AM +0000, Eric Dumazet wrote:
> inet_csk_delete_keepalive_timer() and inet_csk_reset_keepalive_timer()
> are only used from core TCP, there is no need to export them.
> 
> Replace their prefix by tcp.
> 
> Move them to net/ipv4/tcp_timer.c and make tcp_delete_keepalive_timer()
> static.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
>  include/net/inet_connection_sock.h |  3 ---
>  include/net/tcp.h                  |  1 +
>  net/ipv4/inet_connection_sock.c    | 12 ------------
>  net/ipv4/tcp.c                     |  4 ++--
>  net/ipv4/tcp_input.c               |  6 +++---
>  net/ipv4/tcp_minisocks.c           |  3 +--
>  net/ipv4/tcp_timer.c               | 21 +++++++++++++++------
>  7 files changed, 22 insertions(+), 28 deletions(-)

[...]

> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 0d704bda6c416bd722223eb19bec5667df4e7bb7..4136535cd984d85c615a615f8991ce55ad5af42d 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -3174,7 +3174,7 @@ void __tcp_close(struct sock *sk, long timeout)
>  			const int tmo = tcp_fin_time(sk);
>  
>  			if (tmo > TCP_TIMEWAIT_LEN) {
> -				inet_csk_reset_keepalive_timer(sk,
> +				tcp_reset_keepalive_timer(sk,
>  						tmo - TCP_TIMEWAIT_LEN);

Extremely minor nit that I hesitate to mention: alignment above seems
odd visually and checkpatch also doesn't like it. I don't think it's
worth resending just for that, though.

Reviewed-by: Joe Damato <jdamato@fastly.com>
Kuniyuki Iwashima Feb. 7, 2025, 3:29 a.m. UTC | #3
From: Eric Dumazet <edumazet@google.com>
Date: Thu,  6 Feb 2025 09:46:05 +0000
> inet_csk_delete_keepalive_timer() and inet_csk_reset_keepalive_timer()
> are only used from core TCP, there is no need to export them.
> 
> Replace their prefix by tcp.
> 
> Move them to net/ipv4/tcp_timer.c and make tcp_delete_keepalive_timer()
> static.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
patchwork-bot+netdevbpf@kernel.org Feb. 7, 2025, 8:10 p.m. UTC | #4
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu,  6 Feb 2025 09:46:05 +0000 you wrote:
> inet_csk_delete_keepalive_timer() and inet_csk_reset_keepalive_timer()
> are only used from core TCP, there is no need to export them.
> 
> Replace their prefix by tcp.
> 
> Move them to net/ipv4/tcp_timer.c and make tcp_delete_keepalive_timer()
> static.
> 
> [...]

Here is the summary with links:
  - [net-next] tcp: rename inet_csk_{delete|reset}_keepalive_timer()
    https://git.kernel.org/netdev/net-next/c/be258f654a6e

You are awesome, thank you!
diff mbox series

Patch

diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index c7f42844c79a9bde6d77c457f392229b1d3a9d5c..055aa80b05c6da8c36b6acf2709ee116136918e6 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -189,9 +189,6 @@  static inline void inet_csk_delack_init(struct sock *sk)
 	memset(&inet_csk(sk)->icsk_ack, 0, sizeof(inet_csk(sk)->icsk_ack));
 }
 
-void inet_csk_delete_keepalive_timer(struct sock *sk);
-void inet_csk_reset_keepalive_timer(struct sock *sk, unsigned long timeout);
-
 static inline void inet_csk_clear_xmit_timer(struct sock *sk, const int what)
 {
 	struct inet_connection_sock *icsk = inet_csk(sk);
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 5b2b04835688f65daa25ca208e29775326520e1e..bb7edf0e72aa077ed4de02c6e7cd7048976d8a1e 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -415,6 +415,7 @@  int do_tcp_setsockopt(struct sock *sk, int level, int optname,
 		      sockptr_t optval, unsigned int optlen);
 int tcp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval,
 		   unsigned int optlen);
+void tcp_reset_keepalive_timer(struct sock *sk, unsigned long timeout);
 void tcp_set_keepalive(struct sock *sk, int val);
 void tcp_syn_ack_timeout(const struct request_sock *req);
 int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index e4decfb270fa1f9c81da76566c056dd5ce5b0447..2b7775b90a0907727fa3e4d04cfa77f6e76e82b0 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -799,18 +799,6 @@  void inet_csk_clear_xmit_timers_sync(struct sock *sk)
 	sk_stop_timer_sync(sk, &sk->sk_timer);
 }
 
-void inet_csk_delete_keepalive_timer(struct sock *sk)
-{
-	sk_stop_timer(sk, &sk->sk_timer);
-}
-EXPORT_SYMBOL(inet_csk_delete_keepalive_timer);
-
-void inet_csk_reset_keepalive_timer(struct sock *sk, unsigned long len)
-{
-	sk_reset_timer(sk, &sk->sk_timer, jiffies + len);
-}
-EXPORT_SYMBOL(inet_csk_reset_keepalive_timer);
-
 struct dst_entry *inet_csk_route_req(const struct sock *sk,
 				     struct flowi4 *fl4,
 				     const struct request_sock *req)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 0d704bda6c416bd722223eb19bec5667df4e7bb7..4136535cd984d85c615a615f8991ce55ad5af42d 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3174,7 +3174,7 @@  void __tcp_close(struct sock *sk, long timeout)
 			const int tmo = tcp_fin_time(sk);
 
 			if (tmo > TCP_TIMEWAIT_LEN) {
-				inet_csk_reset_keepalive_timer(sk,
+				tcp_reset_keepalive_timer(sk,
 						tmo - TCP_TIMEWAIT_LEN);
 			} else {
 				tcp_time_wait(sk, TCP_FIN_WAIT2, tmo);
@@ -3627,7 +3627,7 @@  int tcp_sock_set_keepidle_locked(struct sock *sk, int val)
 			elapsed = tp->keepalive_time - elapsed;
 		else
 			elapsed = 0;
-		inet_csk_reset_keepalive_timer(sk, elapsed);
+		tcp_reset_keepalive_timer(sk, elapsed);
 	}
 
 	return 0;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index eb82e01da911048b41ca380f913ef55566be79a7..f6b925985b802e0ce6811bd77ff8497c6fc9b055 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -6347,7 +6347,7 @@  void tcp_finish_connect(struct sock *sk, struct sk_buff *skb)
 	tp->lsndtime = tcp_jiffies32;
 
 	if (sock_flag(sk, SOCK_KEEPOPEN))
-		inet_csk_reset_keepalive_timer(sk, keepalive_time_when(tp));
+		tcp_reset_keepalive_timer(sk, keepalive_time_when(tp));
 
 	if (!tp->rx_opt.snd_wscale)
 		__tcp_fast_path_on(tp, tp->snd_wnd);
@@ -6922,7 +6922,7 @@  tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
 
 		tmo = tcp_fin_time(sk);
 		if (tmo > TCP_TIMEWAIT_LEN) {
-			inet_csk_reset_keepalive_timer(sk, tmo - TCP_TIMEWAIT_LEN);
+			tcp_reset_keepalive_timer(sk, tmo - TCP_TIMEWAIT_LEN);
 		} else if (th->fin || sock_owned_by_user(sk)) {
 			/* Bad case. We could lose such FIN otherwise.
 			 * It is not a big problem, but it looks confusing
@@ -6930,7 +6930,7 @@  tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
 			 * if it spins in bh_lock_sock(), but it is really
 			 * marginal case.
 			 */
-			inet_csk_reset_keepalive_timer(sk, tmo);
+			tcp_reset_keepalive_timer(sk, tmo);
 		} else {
 			tcp_time_wait(sk, TCP_FIN_WAIT2, tmo);
 			goto consume;
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index b089b08e9617862cd73b47ac06b5ac6c1e843ec6..0deb2ac85acf7a9e8377e97915087afec6f8a835 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -566,8 +566,7 @@  struct sock *tcp_create_openreq_child(const struct sock *sk,
 	WRITE_ONCE(newtp->write_seq, newtp->pushed_seq = treq->snt_isn + 1);
 
 	if (sock_flag(newsk, SOCK_KEEPOPEN))
-		inet_csk_reset_keepalive_timer(newsk,
-					       keepalive_time_when(newtp));
+		tcp_reset_keepalive_timer(newsk, keepalive_time_when(newtp));
 
 	newtp->rx_opt.tstamp_ok = ireq->tstamp_ok;
 	newtp->rx_opt.sack_ok = ireq->sack_ok;
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index b412ed88ccd9a81a2689cf38f13899551b1078e3..cfb6f4c4e4c9fc3eb6963dcb659b2c6489193dd9 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -751,20 +751,29 @@  void tcp_syn_ack_timeout(const struct request_sock *req)
 }
 EXPORT_SYMBOL(tcp_syn_ack_timeout);
 
+void tcp_reset_keepalive_timer(struct sock *sk, unsigned long len)
+{
+	sk_reset_timer(sk, &sk->sk_timer, jiffies + len);
+}
+
+static void tcp_delete_keepalive_timer(struct sock *sk)
+{
+	sk_stop_timer(sk, &sk->sk_timer);
+}
+
 void tcp_set_keepalive(struct sock *sk, int val)
 {
 	if ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))
 		return;
 
 	if (val && !sock_flag(sk, SOCK_KEEPOPEN))
-		inet_csk_reset_keepalive_timer(sk, keepalive_time_when(tcp_sk(sk)));
+		tcp_reset_keepalive_timer(sk, keepalive_time_when(tcp_sk(sk)));
 	else if (!val)
-		inet_csk_delete_keepalive_timer(sk);
+		tcp_delete_keepalive_timer(sk);
 }
 EXPORT_SYMBOL_GPL(tcp_set_keepalive);
 
-
-static void tcp_keepalive_timer (struct timer_list *t)
+static void tcp_keepalive_timer(struct timer_list *t)
 {
 	struct sock *sk = from_timer(sk, t, sk_timer);
 	struct inet_connection_sock *icsk = inet_csk(sk);
@@ -775,7 +784,7 @@  static void tcp_keepalive_timer (struct timer_list *t)
 	bh_lock_sock(sk);
 	if (sock_owned_by_user(sk)) {
 		/* Try again later. */
-		inet_csk_reset_keepalive_timer (sk, HZ/20);
+		tcp_reset_keepalive_timer(sk, HZ/20);
 		goto out;
 	}
 
@@ -841,7 +850,7 @@  static void tcp_keepalive_timer (struct timer_list *t)
 	}
 
 resched:
-	inet_csk_reset_keepalive_timer (sk, elapsed);
+	tcp_reset_keepalive_timer(sk, elapsed);
 	goto out;
 
 death: