diff options
author | Eric Dumazet <edumazet@google.com> | 2015-03-18 17:05:36 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-18 22:00:35 -0400 |
commit | 77a6a471bc18763cb2e80a8cc92f4c04eae37d32 (patch) | |
tree | 47b4a53ce453ec42d096467ad1a3c2130f7cf362 | |
parent | d1e559d0b1b0d02f76a6bd5b768a99dc834ae926 (diff) |
ipv6: get rid of __inet6_hash()
We can now use inet_hash() and __inet_hash() instead of private
functions.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/inet6_hashtables.h | 2 | ||||
-rw-r--r-- | include/net/inet_hashtables.h | 1 | ||||
-rw-r--r-- | net/dccp/ipv6.c | 17 | ||||
-rw-r--r-- | net/ipv4/inet_hashtables.c | 12 | ||||
-rw-r--r-- | net/ipv6/inet6_hashtables.c | 38 | ||||
-rw-r--r-- | net/ipv6/tcp_ipv6.c | 17 |
6 files changed, 12 insertions, 75 deletions
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h index 9201afe083fa..7ff588ca6817 100644 --- a/include/net/inet6_hashtables.h +++ b/include/net/inet6_hashtables.h | |||
@@ -38,8 +38,6 @@ static inline unsigned int __inet6_ehashfn(const u32 lhash, | |||
38 | return jhash_3words(lhash, fhash, ports, initval); | 38 | return jhash_3words(lhash, fhash, ports, initval); |
39 | } | 39 | } |
40 | 40 | ||
41 | int __inet6_hash(struct sock *sk, struct inet_timewait_sock *twp); | ||
42 | |||
43 | /* | 41 | /* |
44 | * Sockets in TCP_CLOSE state are _always_ taken out of the hash, so | 42 | * Sockets in TCP_CLOSE state are _always_ taken out of the hash, so |
45 | * we need not check it for TCP lookups anymore, thanks Alexey. -DaveM | 43 | * we need not check it for TCP lookups anymore, thanks Alexey. -DaveM |
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index 06ad42182ec2..eee6c3399990 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h | |||
@@ -249,6 +249,7 @@ void inet_put_port(struct sock *sk); | |||
249 | void inet_hashinfo_init(struct inet_hashinfo *h); | 249 | void inet_hashinfo_init(struct inet_hashinfo *h); |
250 | 250 | ||
251 | int __inet_hash_nolisten(struct sock *sk, struct inet_timewait_sock *tw); | 251 | int __inet_hash_nolisten(struct sock *sk, struct inet_timewait_sock *tw); |
252 | int __inet_hash(struct sock *sk, struct inet_timewait_sock *tw); | ||
252 | void inet_hash(struct sock *sk); | 253 | void inet_hash(struct sock *sk); |
253 | void inet_unhash(struct sock *sk); | 254 | void inet_unhash(struct sock *sk); |
254 | 255 | ||
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index 9216d173dd5f..c655de5f67c9 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c | |||
@@ -40,19 +40,6 @@ | |||
40 | static const struct inet_connection_sock_af_ops dccp_ipv6_mapped; | 40 | static const struct inet_connection_sock_af_ops dccp_ipv6_mapped; |
41 | static const struct inet_connection_sock_af_ops dccp_ipv6_af_ops; | 41 | static const struct inet_connection_sock_af_ops dccp_ipv6_af_ops; |
42 | 42 | ||
43 | static void dccp_v6_hash(struct sock *sk) | ||
44 | { | ||
45 | if (sk->sk_state != DCCP_CLOSED) { | ||
46 | if (inet_csk(sk)->icsk_af_ops == &dccp_ipv6_mapped) { | ||
47 | inet_hash(sk); | ||
48 | return; | ||
49 | } | ||
50 | local_bh_disable(); | ||
51 | __inet6_hash(sk, NULL); | ||
52 | local_bh_enable(); | ||
53 | } | ||
54 | } | ||
55 | |||
56 | /* add pseudo-header to DCCP checksum stored in skb->csum */ | 43 | /* add pseudo-header to DCCP checksum stored in skb->csum */ |
57 | static inline __sum16 dccp_v6_csum_finish(struct sk_buff *skb, | 44 | static inline __sum16 dccp_v6_csum_finish(struct sk_buff *skb, |
58 | const struct in6_addr *saddr, | 45 | const struct in6_addr *saddr, |
@@ -588,7 +575,7 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, | |||
588 | dccp_done(newsk); | 575 | dccp_done(newsk); |
589 | goto out; | 576 | goto out; |
590 | } | 577 | } |
591 | __inet6_hash(newsk, NULL); | 578 | __inet_hash(newsk, NULL); |
592 | 579 | ||
593 | return newsk; | 580 | return newsk; |
594 | 581 | ||
@@ -1056,7 +1043,7 @@ static struct proto dccp_v6_prot = { | |||
1056 | .sendmsg = dccp_sendmsg, | 1043 | .sendmsg = dccp_sendmsg, |
1057 | .recvmsg = dccp_recvmsg, | 1044 | .recvmsg = dccp_recvmsg, |
1058 | .backlog_rcv = dccp_v6_do_rcv, | 1045 | .backlog_rcv = dccp_v6_do_rcv, |
1059 | .hash = dccp_v6_hash, | 1046 | .hash = inet_hash, |
1060 | .unhash = inet_unhash, | 1047 | .unhash = inet_unhash, |
1061 | .accept = inet_csk_accept, | 1048 | .accept = inet_csk_accept, |
1062 | .get_port = inet_csk_get_port, | 1049 | .get_port = inet_csk_get_port, |
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index ab7f677a97db..82753bd57e79 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c | |||
@@ -434,15 +434,13 @@ int __inet_hash_nolisten(struct sock *sk, struct inet_timewait_sock *tw) | |||
434 | } | 434 | } |
435 | EXPORT_SYMBOL_GPL(__inet_hash_nolisten); | 435 | EXPORT_SYMBOL_GPL(__inet_hash_nolisten); |
436 | 436 | ||
437 | static void __inet_hash(struct sock *sk) | 437 | int __inet_hash(struct sock *sk, struct inet_timewait_sock *tw) |
438 | { | 438 | { |
439 | struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; | 439 | struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; |
440 | struct inet_listen_hashbucket *ilb; | 440 | struct inet_listen_hashbucket *ilb; |
441 | 441 | ||
442 | if (sk->sk_state != TCP_LISTEN) { | 442 | if (sk->sk_state != TCP_LISTEN) |
443 | __inet_hash_nolisten(sk, NULL); | 443 | return __inet_hash_nolisten(sk, tw); |
444 | return; | ||
445 | } | ||
446 | 444 | ||
447 | WARN_ON(!sk_unhashed(sk)); | 445 | WARN_ON(!sk_unhashed(sk)); |
448 | ilb = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)]; | 446 | ilb = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)]; |
@@ -451,13 +449,15 @@ static void __inet_hash(struct sock *sk) | |||
451 | __sk_nulls_add_node_rcu(sk, &ilb->head); | 449 | __sk_nulls_add_node_rcu(sk, &ilb->head); |
452 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); | 450 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); |
453 | spin_unlock(&ilb->lock); | 451 | spin_unlock(&ilb->lock); |
452 | return 0; | ||
454 | } | 453 | } |
454 | EXPORT_SYMBOL(__inet_hash); | ||
455 | 455 | ||
456 | void inet_hash(struct sock *sk) | 456 | void inet_hash(struct sock *sk) |
457 | { | 457 | { |
458 | if (sk->sk_state != TCP_CLOSE) { | 458 | if (sk->sk_state != TCP_CLOSE) { |
459 | local_bh_disable(); | 459 | local_bh_disable(); |
460 | __inet_hash(sk); | 460 | __inet_hash(sk, NULL); |
461 | local_bh_enable(); | 461 | local_bh_enable(); |
462 | } | 462 | } |
463 | } | 463 | } |
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c index ed5787b20192..b86b429f5f81 100644 --- a/net/ipv6/inet6_hashtables.c +++ b/net/ipv6/inet6_hashtables.c | |||
@@ -42,42 +42,6 @@ u32 inet6_ehashfn(const struct net *net, | |||
42 | inet6_ehash_secret + net_hash_mix(net)); | 42 | inet6_ehash_secret + net_hash_mix(net)); |
43 | } | 43 | } |
44 | 44 | ||
45 | int __inet6_hash(struct sock *sk, struct inet_timewait_sock *tw) | ||
46 | { | ||
47 | struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; | ||
48 | int twrefcnt = 0; | ||
49 | |||
50 | WARN_ON(!sk_unhashed(sk)); | ||
51 | |||
52 | if (sk->sk_state == TCP_LISTEN) { | ||
53 | struct inet_listen_hashbucket *ilb; | ||
54 | |||
55 | ilb = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)]; | ||
56 | spin_lock(&ilb->lock); | ||
57 | __sk_nulls_add_node_rcu(sk, &ilb->head); | ||
58 | spin_unlock(&ilb->lock); | ||
59 | } else { | ||
60 | unsigned int hash; | ||
61 | struct hlist_nulls_head *list; | ||
62 | spinlock_t *lock; | ||
63 | |||
64 | sk->sk_hash = hash = sk_ehashfn(sk); | ||
65 | list = &inet_ehash_bucket(hashinfo, hash)->chain; | ||
66 | lock = inet_ehash_lockp(hashinfo, hash); | ||
67 | spin_lock(lock); | ||
68 | __sk_nulls_add_node_rcu(sk, list); | ||
69 | if (tw) { | ||
70 | WARN_ON(sk->sk_hash != tw->tw_hash); | ||
71 | twrefcnt = inet_twsk_unhash(tw); | ||
72 | } | ||
73 | spin_unlock(lock); | ||
74 | } | ||
75 | |||
76 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); | ||
77 | return twrefcnt; | ||
78 | } | ||
79 | EXPORT_SYMBOL(__inet6_hash); | ||
80 | |||
81 | /* | 45 | /* |
82 | * Sockets in TCP_CLOSE state are _always_ taken out of the hash, so | 46 | * Sockets in TCP_CLOSE state are _always_ taken out of the hash, so |
83 | * we need not check it for TCP lookups anymore, thanks Alexey. -DaveM | 47 | * we need not check it for TCP lookups anymore, thanks Alexey. -DaveM |
@@ -306,6 +270,6 @@ int inet6_hash_connect(struct inet_timewait_death_row *death_row, | |||
306 | struct sock *sk) | 270 | struct sock *sk) |
307 | { | 271 | { |
308 | return __inet_hash_connect(death_row, sk, inet6_sk_port_offset(sk), | 272 | return __inet_hash_connect(death_row, sk, inet6_sk_port_offset(sk), |
309 | __inet6_check_established, __inet6_hash); | 273 | __inet6_check_established, __inet_hash_nolisten); |
310 | } | 274 | } |
311 | EXPORT_SYMBOL_GPL(inet6_hash_connect); | 275 | EXPORT_SYMBOL_GPL(inet6_hash_connect); |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 5546df074583..720676d073d9 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -104,19 +104,6 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb) | |||
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | static void tcp_v6_hash(struct sock *sk) | ||
108 | { | ||
109 | if (sk->sk_state != TCP_CLOSE) { | ||
110 | if (inet_csk(sk)->icsk_af_ops == &ipv6_mapped) { | ||
111 | tcp_prot.hash(sk); | ||
112 | return; | ||
113 | } | ||
114 | local_bh_disable(); | ||
115 | __inet6_hash(sk, NULL); | ||
116 | local_bh_enable(); | ||
117 | } | ||
118 | } | ||
119 | |||
120 | static __u32 tcp_v6_init_sequence(const struct sk_buff *skb) | 107 | static __u32 tcp_v6_init_sequence(const struct sk_buff *skb) |
121 | { | 108 | { |
122 | return secure_tcpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32, | 109 | return secure_tcpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32, |
@@ -1224,7 +1211,7 @@ static struct sock *tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
1224 | tcp_done(newsk); | 1211 | tcp_done(newsk); |
1225 | goto out; | 1212 | goto out; |
1226 | } | 1213 | } |
1227 | __inet6_hash(newsk, NULL); | 1214 | __inet_hash(newsk, NULL); |
1228 | 1215 | ||
1229 | return newsk; | 1216 | return newsk; |
1230 | 1217 | ||
@@ -1883,7 +1870,7 @@ struct proto tcpv6_prot = { | |||
1883 | .sendpage = tcp_sendpage, | 1870 | .sendpage = tcp_sendpage, |
1884 | .backlog_rcv = tcp_v6_do_rcv, | 1871 | .backlog_rcv = tcp_v6_do_rcv, |
1885 | .release_cb = tcp_release_cb, | 1872 | .release_cb = tcp_release_cb, |
1886 | .hash = tcp_v6_hash, | 1873 | .hash = inet_hash, |
1887 | .unhash = inet_unhash, | 1874 | .unhash = inet_unhash, |
1888 | .get_port = inet_csk_get_port, | 1875 | .get_port = inet_csk_get_port, |
1889 | .enter_memory_pressure = tcp_enter_memory_pressure, | 1876 | .enter_memory_pressure = tcp_enter_memory_pressure, |