Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tcp: Remove inet6_hash().

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>

authored by

Kuniyuki Iwashima and committed by
Jakub Kicinski
0ac44301 6445bb83

+6 -27
-2
include/net/inet6_hashtables.h
··· 167 167 const struct in6_addr *daddr, const __be16 dport, 168 168 const int dif); 169 169 170 - int inet6_hash(struct sock *sk); 171 - 172 170 static inline bool inet6_match(const struct net *net, const struct sock *sk, 173 171 const struct in6_addr *saddr, 174 172 const struct in6_addr *daddr,
-1
include/net/inet_hashtables.h
··· 289 289 bool inet_ehash_insert(struct sock *sk, struct sock *osk, bool *found_dup_sk); 290 290 bool inet_ehash_nolisten(struct sock *sk, struct sock *osk, 291 291 bool *found_dup_sk); 292 - int __inet_hash(struct sock *sk); 293 292 int inet_hash(struct sock *sk); 294 293 void inet_unhash(struct sock *sk); 295 294
+5 -12
net/ipv4/inet_hashtables.c
··· 739 739 return reuseport_alloc(sk, inet_rcv_saddr_any(sk)); 740 740 } 741 741 742 - int __inet_hash(struct sock *sk) 742 + int inet_hash(struct sock *sk) 743 743 { 744 744 struct inet_hashinfo *hashinfo = tcp_get_hashinfo(sk); 745 745 struct inet_listen_hashbucket *ilb2; 746 746 int err = 0; 747 + 748 + if (sk->sk_state == TCP_CLOSE) 749 + return 0; 747 750 748 751 if (sk->sk_state != TCP_LISTEN) { 749 752 local_bh_disable(); ··· 775 772 776 773 return err; 777 774 } 778 - EXPORT_IPV6_MOD(__inet_hash); 779 - 780 - int inet_hash(struct sock *sk) 781 - { 782 - int err = 0; 783 - 784 - if (sk->sk_state != TCP_CLOSE) 785 - err = __inet_hash(sk); 786 - 787 - return err; 788 - } 775 + EXPORT_IPV6_MOD(inet_hash); 789 776 790 777 void inet_unhash(struct sock *sk) 791 778 {
-11
net/ipv6/inet6_hashtables.c
··· 368 368 __inet6_check_established); 369 369 } 370 370 EXPORT_SYMBOL_GPL(inet6_hash_connect); 371 - 372 - int inet6_hash(struct sock *sk) 373 - { 374 - int err = 0; 375 - 376 - if (sk->sk_state != TCP_CLOSE) 377 - err = __inet_hash(sk); 378 - 379 - return err; 380 - } 381 - EXPORT_SYMBOL_GPL(inet6_hash);
+1 -1
net/ipv6/tcp_ipv6.c
··· 2355 2355 .splice_eof = tcp_splice_eof, 2356 2356 .backlog_rcv = tcp_v6_do_rcv, 2357 2357 .release_cb = tcp_release_cb, 2358 - .hash = inet6_hash, 2358 + .hash = inet_hash, 2359 2359 .unhash = inet_unhash, 2360 2360 .get_port = inet_csk_get_port, 2361 2361 .put_port = inet_put_port,