mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-25 08:02:56 +00:00
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>
This commit is contained in:
parent
d1e559d0b1
commit
77a6a471bc
6 changed files with 12 additions and 75 deletions
|
@ -38,8 +38,6 @@ static inline unsigned int __inet6_ehashfn(const u32 lhash,
|
||||||
return jhash_3words(lhash, fhash, ports, initval);
|
return jhash_3words(lhash, fhash, ports, initval);
|
||||||
}
|
}
|
||||||
|
|
||||||
int __inet6_hash(struct sock *sk, struct inet_timewait_sock *twp);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sockets in TCP_CLOSE state are _always_ taken out of the hash, so
|
* Sockets in TCP_CLOSE state are _always_ taken out of the hash, so
|
||||||
* we need not check it for TCP lookups anymore, thanks Alexey. -DaveM
|
* we need not check it for TCP lookups anymore, thanks Alexey. -DaveM
|
||||||
|
|
|
@ -249,6 +249,7 @@ void inet_put_port(struct sock *sk);
|
||||||
void inet_hashinfo_init(struct inet_hashinfo *h);
|
void inet_hashinfo_init(struct inet_hashinfo *h);
|
||||||
|
|
||||||
int __inet_hash_nolisten(struct sock *sk, struct inet_timewait_sock *tw);
|
int __inet_hash_nolisten(struct sock *sk, struct inet_timewait_sock *tw);
|
||||||
|
int __inet_hash(struct sock *sk, struct inet_timewait_sock *tw);
|
||||||
void inet_hash(struct sock *sk);
|
void inet_hash(struct sock *sk);
|
||||||
void inet_unhash(struct sock *sk);
|
void inet_unhash(struct sock *sk);
|
||||||
|
|
||||||
|
|
|
@ -40,19 +40,6 @@
|
||||||
static const struct inet_connection_sock_af_ops dccp_ipv6_mapped;
|
static const struct inet_connection_sock_af_ops dccp_ipv6_mapped;
|
||||||
static const struct inet_connection_sock_af_ops dccp_ipv6_af_ops;
|
static const struct inet_connection_sock_af_ops dccp_ipv6_af_ops;
|
||||||
|
|
||||||
static void dccp_v6_hash(struct sock *sk)
|
|
||||||
{
|
|
||||||
if (sk->sk_state != DCCP_CLOSED) {
|
|
||||||
if (inet_csk(sk)->icsk_af_ops == &dccp_ipv6_mapped) {
|
|
||||||
inet_hash(sk);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
local_bh_disable();
|
|
||||||
__inet6_hash(sk, NULL);
|
|
||||||
local_bh_enable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* add pseudo-header to DCCP checksum stored in skb->csum */
|
/* add pseudo-header to DCCP checksum stored in skb->csum */
|
||||||
static inline __sum16 dccp_v6_csum_finish(struct sk_buff *skb,
|
static inline __sum16 dccp_v6_csum_finish(struct sk_buff *skb,
|
||||||
const struct in6_addr *saddr,
|
const struct in6_addr *saddr,
|
||||||
|
@ -588,7 +575,7 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
|
||||||
dccp_done(newsk);
|
dccp_done(newsk);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
__inet6_hash(newsk, NULL);
|
__inet_hash(newsk, NULL);
|
||||||
|
|
||||||
return newsk;
|
return newsk;
|
||||||
|
|
||||||
|
@ -1056,7 +1043,7 @@ static struct proto dccp_v6_prot = {
|
||||||
.sendmsg = dccp_sendmsg,
|
.sendmsg = dccp_sendmsg,
|
||||||
.recvmsg = dccp_recvmsg,
|
.recvmsg = dccp_recvmsg,
|
||||||
.backlog_rcv = dccp_v6_do_rcv,
|
.backlog_rcv = dccp_v6_do_rcv,
|
||||||
.hash = dccp_v6_hash,
|
.hash = inet_hash,
|
||||||
.unhash = inet_unhash,
|
.unhash = inet_unhash,
|
||||||
.accept = inet_csk_accept,
|
.accept = inet_csk_accept,
|
||||||
.get_port = inet_csk_get_port,
|
.get_port = inet_csk_get_port,
|
||||||
|
|
|
@ -434,15 +434,13 @@ int __inet_hash_nolisten(struct sock *sk, struct inet_timewait_sock *tw)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(__inet_hash_nolisten);
|
EXPORT_SYMBOL_GPL(__inet_hash_nolisten);
|
||||||
|
|
||||||
static void __inet_hash(struct sock *sk)
|
int __inet_hash(struct sock *sk, struct inet_timewait_sock *tw)
|
||||||
{
|
{
|
||||||
struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo;
|
struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo;
|
||||||
struct inet_listen_hashbucket *ilb;
|
struct inet_listen_hashbucket *ilb;
|
||||||
|
|
||||||
if (sk->sk_state != TCP_LISTEN) {
|
if (sk->sk_state != TCP_LISTEN)
|
||||||
__inet_hash_nolisten(sk, NULL);
|
return __inet_hash_nolisten(sk, tw);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
WARN_ON(!sk_unhashed(sk));
|
WARN_ON(!sk_unhashed(sk));
|
||||||
ilb = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)];
|
ilb = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)];
|
||||||
|
@ -451,13 +449,15 @@ static void __inet_hash(struct sock *sk)
|
||||||
__sk_nulls_add_node_rcu(sk, &ilb->head);
|
__sk_nulls_add_node_rcu(sk, &ilb->head);
|
||||||
sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
|
sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
|
||||||
spin_unlock(&ilb->lock);
|
spin_unlock(&ilb->lock);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL(__inet_hash);
|
||||||
|
|
||||||
void inet_hash(struct sock *sk)
|
void inet_hash(struct sock *sk)
|
||||||
{
|
{
|
||||||
if (sk->sk_state != TCP_CLOSE) {
|
if (sk->sk_state != TCP_CLOSE) {
|
||||||
local_bh_disable();
|
local_bh_disable();
|
||||||
__inet_hash(sk);
|
__inet_hash(sk, NULL);
|
||||||
local_bh_enable();
|
local_bh_enable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,42 +42,6 @@ u32 inet6_ehashfn(const struct net *net,
|
||||||
inet6_ehash_secret + net_hash_mix(net));
|
inet6_ehash_secret + net_hash_mix(net));
|
||||||
}
|
}
|
||||||
|
|
||||||
int __inet6_hash(struct sock *sk, struct inet_timewait_sock *tw)
|
|
||||||
{
|
|
||||||
struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo;
|
|
||||||
int twrefcnt = 0;
|
|
||||||
|
|
||||||
WARN_ON(!sk_unhashed(sk));
|
|
||||||
|
|
||||||
if (sk->sk_state == TCP_LISTEN) {
|
|
||||||
struct inet_listen_hashbucket *ilb;
|
|
||||||
|
|
||||||
ilb = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)];
|
|
||||||
spin_lock(&ilb->lock);
|
|
||||||
__sk_nulls_add_node_rcu(sk, &ilb->head);
|
|
||||||
spin_unlock(&ilb->lock);
|
|
||||||
} else {
|
|
||||||
unsigned int hash;
|
|
||||||
struct hlist_nulls_head *list;
|
|
||||||
spinlock_t *lock;
|
|
||||||
|
|
||||||
sk->sk_hash = hash = sk_ehashfn(sk);
|
|
||||||
list = &inet_ehash_bucket(hashinfo, hash)->chain;
|
|
||||||
lock = inet_ehash_lockp(hashinfo, hash);
|
|
||||||
spin_lock(lock);
|
|
||||||
__sk_nulls_add_node_rcu(sk, list);
|
|
||||||
if (tw) {
|
|
||||||
WARN_ON(sk->sk_hash != tw->tw_hash);
|
|
||||||
twrefcnt = inet_twsk_unhash(tw);
|
|
||||||
}
|
|
||||||
spin_unlock(lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
|
|
||||||
return twrefcnt;
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL(__inet6_hash);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sockets in TCP_CLOSE state are _always_ taken out of the hash, so
|
* Sockets in TCP_CLOSE state are _always_ taken out of the hash, so
|
||||||
* we need not check it for TCP lookups anymore, thanks Alexey. -DaveM
|
* 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,
|
||||||
struct sock *sk)
|
struct sock *sk)
|
||||||
{
|
{
|
||||||
return __inet_hash_connect(death_row, sk, inet6_sk_port_offset(sk),
|
return __inet_hash_connect(death_row, sk, inet6_sk_port_offset(sk),
|
||||||
__inet6_check_established, __inet6_hash);
|
__inet6_check_established, __inet_hash_nolisten);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(inet6_hash_connect);
|
EXPORT_SYMBOL_GPL(inet6_hash_connect);
|
||||||
|
|
|
@ -104,19 +104,6 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tcp_v6_hash(struct sock *sk)
|
|
||||||
{
|
|
||||||
if (sk->sk_state != TCP_CLOSE) {
|
|
||||||
if (inet_csk(sk)->icsk_af_ops == &ipv6_mapped) {
|
|
||||||
tcp_prot.hash(sk);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
local_bh_disable();
|
|
||||||
__inet6_hash(sk, NULL);
|
|
||||||
local_bh_enable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static __u32 tcp_v6_init_sequence(const struct sk_buff *skb)
|
static __u32 tcp_v6_init_sequence(const struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
return secure_tcpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32,
|
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,
|
||||||
tcp_done(newsk);
|
tcp_done(newsk);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
__inet6_hash(newsk, NULL);
|
__inet_hash(newsk, NULL);
|
||||||
|
|
||||||
return newsk;
|
return newsk;
|
||||||
|
|
||||||
|
@ -1883,7 +1870,7 @@ struct proto tcpv6_prot = {
|
||||||
.sendpage = tcp_sendpage,
|
.sendpage = tcp_sendpage,
|
||||||
.backlog_rcv = tcp_v6_do_rcv,
|
.backlog_rcv = tcp_v6_do_rcv,
|
||||||
.release_cb = tcp_release_cb,
|
.release_cb = tcp_release_cb,
|
||||||
.hash = tcp_v6_hash,
|
.hash = inet_hash,
|
||||||
.unhash = inet_unhash,
|
.unhash = inet_unhash,
|
||||||
.get_port = inet_csk_get_port,
|
.get_port = inet_csk_get_port,
|
||||||
.enter_memory_pressure = tcp_enter_memory_pressure,
|
.enter_memory_pressure = tcp_enter_memory_pressure,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue