aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2009-11-08 05:17:05 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-08 23:53:04 -0500
commitfdcc8aa953a1123a289791dd192090651036d593 (patch)
treeb30e27d1ba4d3330e5eb9b7da43d4dfb3a4e42f8 /net/ipv4
parent415ce61aef5e9b2ed2516a13888c733bea15aedf (diff)
udp: add a counter into udp_hslot
Adds a counter in udp_hslot to keep an accurate count of sockets present in chain. This will permit to upcoming UDP lookup algo to chose the shortest chain when secondary hash is added. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/udp.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index d5e75e976513..ffc837643a04 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -218,6 +218,7 @@ found:
218 sk->sk_hash = snum; 218 sk->sk_hash = snum;
219 if (sk_unhashed(sk)) { 219 if (sk_unhashed(sk)) {
220 sk_nulls_add_node_rcu(sk, &hslot->head); 220 sk_nulls_add_node_rcu(sk, &hslot->head);
221 hslot->count++;
221 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 222 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
222 } 223 }
223 error = 0; 224 error = 0;
@@ -1053,6 +1054,7 @@ void udp_lib_unhash(struct sock *sk)
1053 1054
1054 spin_lock_bh(&hslot->lock); 1055 spin_lock_bh(&hslot->lock);
1055 if (sk_nulls_del_node_init_rcu(sk)) { 1056 if (sk_nulls_del_node_init_rcu(sk)) {
1057 hslot->count--;
1056 inet_sk(sk)->inet_num = 0; 1058 inet_sk(sk)->inet_num = 0;
1057 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); 1059 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
1058 } 1060 }
@@ -1862,6 +1864,7 @@ void __init udp_table_init(struct udp_table *table, const char *name)
1862 } 1864 }
1863 for (i = 0; i <= table->mask; i++) { 1865 for (i = 0; i <= table->mask; i++) {
1864 INIT_HLIST_NULLS_HEAD(&table->hash[i].head, i); 1866 INIT_HLIST_NULLS_HEAD(&table->hash[i].head, i);
1867 table->hash[i].count = 0;
1865 spin_lock_init(&table->hash[i].lock); 1868 spin_lock_init(&table->hash[i].lock);
1866 } 1869 }
1867} 1870}