Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 78577
b: refs/heads/master
c: 152da81
h: refs/heads/master
i:
  78575: b3d4844
v: v3
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Jan 28, 2008
1 parent 1dbaa4b commit cb8c7f1
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 31 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d6701191329b51793bc56724548f0863d2149c29
refs/heads/master: 152da81deb9a4870aeac352336184b2b14d4b2ba
29 changes: 3 additions & 26 deletions trunk/include/net/inet_hashtables.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,37 +264,14 @@ static inline void inet_listen_unlock(struct inet_hashinfo *hashinfo)
wake_up(&hashinfo->lhash_wait);
}

static inline void __inet_hash(struct inet_hashinfo *hashinfo,
struct sock *sk, const int listen_possible)
{
struct hlist_head *list;
rwlock_t *lock;

BUG_TRAP(sk_unhashed(sk));
if (listen_possible && sk->sk_state == TCP_LISTEN) {
list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)];
lock = &hashinfo->lhash_lock;
inet_listen_wlock(hashinfo);
} else {
struct inet_ehash_bucket *head;
sk->sk_hash = inet_sk_ehashfn(sk);
head = inet_ehash_bucket(hashinfo, sk->sk_hash);
list = &head->chain;
lock = inet_ehash_lockp(hashinfo, sk->sk_hash);
write_lock(lock);
}
__sk_add_node(sk, list);
sock_prot_inc_use(sk->sk_prot);
write_unlock(lock);
if (listen_possible && sk->sk_state == TCP_LISTEN)
wake_up(&hashinfo->lhash_wait);
}
extern void __inet_hash(struct inet_hashinfo *hashinfo, struct sock *sk);
extern void __inet_hash_nolisten(struct inet_hashinfo *hinfo, struct sock *sk);

static inline void inet_hash(struct inet_hashinfo *hashinfo, struct sock *sk)
{
if (sk->sk_state != TCP_CLOSE) {
local_bh_disable();
__inet_hash(hashinfo, sk, 1);
__inet_hash(hashinfo, sk);
local_bh_enable();
}
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/net/dccp/ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ struct sock *dccp_v4_request_recv_sock(struct sock *sk, struct sk_buff *skb,

dccp_sync_mss(newsk, dst_mtu(dst));

__inet_hash(&dccp_hashinfo, newsk, 0);
__inet_hash_nolisten(&dccp_hashinfo, newsk);
__inet_inherit_port(&dccp_hashinfo, sk, newsk);

return newsk;
Expand Down
46 changes: 44 additions & 2 deletions trunk/net/ipv4/inet_hashtables.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,48 @@ static inline u32 inet_sk_port_offset(const struct sock *sk)
inet->dport);
}

void __inet_hash_nolisten(struct inet_hashinfo *hashinfo, struct sock *sk)
{
struct hlist_head *list;
rwlock_t *lock;
struct inet_ehash_bucket *head;

BUG_TRAP(sk_unhashed(sk));

sk->sk_hash = inet_sk_ehashfn(sk);
head = inet_ehash_bucket(hashinfo, sk->sk_hash);
list = &head->chain;
lock = inet_ehash_lockp(hashinfo, sk->sk_hash);

write_lock(lock);
__sk_add_node(sk, list);
sock_prot_inc_use(sk->sk_prot);
write_unlock(lock);
}
EXPORT_SYMBOL_GPL(__inet_hash_nolisten);

void __inet_hash(struct inet_hashinfo *hashinfo, struct sock *sk)
{
struct hlist_head *list;
rwlock_t *lock;

if (sk->sk_state != TCP_LISTEN) {
__inet_hash_nolisten(hashinfo, sk);
return;
}

BUG_TRAP(sk_unhashed(sk));
list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)];
lock = &hashinfo->lhash_lock;

inet_listen_wlock(hashinfo);
__sk_add_node(sk, list);
sock_prot_inc_use(sk->sk_prot);
write_unlock(lock);
wake_up(&hashinfo->lhash_wait);
}
EXPORT_SYMBOL_GPL(__inet_hash);

/*
* Bind a port for a connect operation and hash it.
*/
Expand Down Expand Up @@ -334,7 +376,7 @@ int inet_hash_connect(struct inet_timewait_death_row *death_row,
inet_bind_hash(sk, tb, port);
if (sk_unhashed(sk)) {
inet_sk(sk)->sport = htons(port);
__inet_hash(hinfo, sk, 0);
__inet_hash_nolisten(hinfo, sk);
}
spin_unlock(&head->lock);

Expand All @@ -351,7 +393,7 @@ int inet_hash_connect(struct inet_timewait_death_row *death_row,
tb = inet_csk(sk)->icsk_bind_hash;
spin_lock_bh(&head->lock);
if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) {
__inet_hash(hinfo, sk, 0);
__inet_hash_nolisten(hinfo, sk);
spin_unlock_bh(&head->lock);
return 0;
} else {
Expand Down
2 changes: 1 addition & 1 deletion trunk/net/ipv4/tcp_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,7 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
}
#endif

__inet_hash(&tcp_hashinfo, newsk, 0);
__inet_hash_nolisten(&tcp_hashinfo, newsk);
__inet_inherit_port(&tcp_hashinfo, sk, newsk);

return newsk;
Expand Down

0 comments on commit cb8c7f1

Please sign in to comment.