]> www.infradead.org Git - users/hch/misc.git/commitdiff
tcp: Remove inet6_hash().
authorKuniyuki Iwashima <kuniyu@google.com>
Fri, 19 Sep 2025 08:35:29 +0000 (08:35 +0000)
committerJakub Kicinski <kuba@kernel.org>
Mon, 22 Sep 2025 18:38:43 +0000 (11:38 -0700)
inet_hash() and inet6_hash() are exactly the same.

Also, we do not need to export inet6_hash().

Let's consolidate the two into __inet_hash() and rename it to inet_hash().

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20250919083706.1863217-3-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/inet6_hashtables.h
include/net/inet_hashtables.h
net/ipv4/inet_hashtables.c
net/ipv6/inet6_hashtables.c
net/ipv6/tcp_ipv6.c

index 1f985d2012cedee5f91ebd91da30497444a3eef2..282e29237d9367f3e9a602a9e2964e291a3bf263 100644 (file)
@@ -167,8 +167,6 @@ struct sock *inet6_lookup(const struct net *net, struct sk_buff *skb, int doff,
                          const struct in6_addr *daddr, const __be16 dport,
                          const int dif);
 
-int inet6_hash(struct sock *sk);
-
 static inline bool inet6_match(const struct net *net, const struct sock *sk,
                               const struct in6_addr *saddr,
                               const struct in6_addr *daddr,
index 64bc8870db8851b51e41cf1a40cdef3d608fac90..b787be651ce7f572ff81a332fb817631e57216a4 100644 (file)
@@ -289,7 +289,6 @@ int inet_hashinfo2_init_mod(struct inet_hashinfo *h);
 bool inet_ehash_insert(struct sock *sk, struct sock *osk, bool *found_dup_sk);
 bool inet_ehash_nolisten(struct sock *sk, struct sock *osk,
                         bool *found_dup_sk);
-int __inet_hash(struct sock *sk);
 int inet_hash(struct sock *sk);
 void inet_unhash(struct sock *sk);
 
index baee5c075e6cec9afb5652602e4ffe72e257d93e..efa8a615b868bff9125eb9551533f89142d9b1ba 100644 (file)
@@ -739,12 +739,15 @@ static int inet_reuseport_add_sock(struct sock *sk,
        return reuseport_alloc(sk, inet_rcv_saddr_any(sk));
 }
 
-int __inet_hash(struct sock *sk)
+int inet_hash(struct sock *sk)
 {
        struct inet_hashinfo *hashinfo = tcp_get_hashinfo(sk);
        struct inet_listen_hashbucket *ilb2;
        int err = 0;
 
+       if (sk->sk_state == TCP_CLOSE)
+               return 0;
+
        if (sk->sk_state != TCP_LISTEN) {
                local_bh_disable();
                inet_ehash_nolisten(sk, NULL, NULL);
@@ -772,17 +775,7 @@ unlock:
 
        return err;
 }
-EXPORT_IPV6_MOD(__inet_hash);
-
-int inet_hash(struct sock *sk)
-{
-       int err = 0;
-
-       if (sk->sk_state != TCP_CLOSE)
-               err = __inet_hash(sk);
-
-       return err;
-}
+EXPORT_IPV6_MOD(inet_hash);
 
 void inet_unhash(struct sock *sk)
 {
index 64fcd7df0c9aa84ea0e1ae6a879b96a5535341e0..5e1da088d8e11977c2ae92401eb4124e4af3b734 100644 (file)
@@ -368,14 +368,3 @@ int inet6_hash_connect(struct inet_timewait_death_row *death_row,
                                   __inet6_check_established);
 }
 EXPORT_SYMBOL_GPL(inet6_hash_connect);
-
-int inet6_hash(struct sock *sk)
-{
-       int err = 0;
-
-       if (sk->sk_state != TCP_CLOSE)
-               err = __inet_hash(sk);
-
-       return err;
-}
-EXPORT_SYMBOL_GPL(inet6_hash);
index d1e5b2a186fb809974bbf21ba0c15b869b05c246..9622c2776ade70e665a5bf730d2c9f762a4857c1 100644 (file)
@@ -2355,7 +2355,7 @@ struct proto tcpv6_prot = {
        .splice_eof             = tcp_splice_eof,
        .backlog_rcv            = tcp_v6_do_rcv,
        .release_cb             = tcp_release_cb,
-       .hash                   = inet6_hash,
+       .hash                   = inet_hash,
        .unhash                 = inet_unhash,
        .get_port               = inet_csk_get_port,
        .put_port               = inet_put_port,