]> git.ipfire.org Git - thirdparty/kernel/linux.git/blobdiff - net/ipv4/inet_timewait_sock.c
Merge tag 'net-next-6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev...
[thirdparty/kernel/linux.git] / net / ipv4 / inet_timewait_sock.c
index e8de45d34d56a507a4bdcceaccbd5707692b6c0a..e28075f0006e333897ad379ebc8c87fc3f9643bd 100644 (file)
@@ -264,14 +264,18 @@ void __inet_twsk_schedule(struct inet_timewait_sock *tw, int timeo, bool rearm)
 EXPORT_SYMBOL_GPL(__inet_twsk_schedule);
 
 /* Remove all non full sockets (TIME_WAIT and NEW_SYN_RECV) for dead netns */
-void inet_twsk_purge(struct inet_hashinfo *hashinfo, int family)
+void inet_twsk_purge(struct inet_hashinfo *hashinfo)
 {
+       struct inet_ehash_bucket *head = &hashinfo->ehash[0];
+       unsigned int ehash_mask = hashinfo->ehash_mask;
        struct hlist_nulls_node *node;
        unsigned int slot;
        struct sock *sk;
 
-       for (slot = 0; slot <= hashinfo->ehash_mask; slot++) {
-               struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
+       for (slot = 0; slot <= ehash_mask; slot++, head++) {
+               if (hlist_nulls_empty(&head->chain))
+                       continue;
+
 restart_rcu:
                cond_resched();
                rcu_read_lock();
@@ -283,15 +287,13 @@ restart:
                                             TCPF_NEW_SYN_RECV))
                                continue;
 
-                       if (sk->sk_family != family ||
-                           refcount_read(&sock_net(sk)->ns.count))
+                       if (refcount_read(&sock_net(sk)->ns.count))
                                continue;
 
                        if (unlikely(!refcount_inc_not_zero(&sk->sk_refcnt)))
                                continue;
 
-                       if (unlikely(sk->sk_family != family ||
-                                    refcount_read(&sock_net(sk)->ns.count))) {
+                       if (refcount_read(&sock_net(sk)->ns.count)) {
                                sock_gen_put(sk);
                                goto restart;
                        }