Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 172129
b: refs/heads/master
c: 575f4cd
h: refs/heads/master
i:
  172127: 7735e48
v: v3
  • Loading branch information
Eric W. Biederman authored and David S. Miller committed Dec 3, 2009
1 parent 955a823 commit 0074e7b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 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: e9c5158ac26affd5d8ce006521bdfb7148090e18
refs/heads/master: 575f4cd5a5b639457747434dbe18d175fa767db4
39 changes: 24 additions & 15 deletions trunk/net/ipv4/inet_timewait_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,31 +427,40 @@ void inet_twsk_purge(struct net *net, struct inet_hashinfo *hashinfo,
struct inet_timewait_sock *tw;
struct sock *sk;
struct hlist_nulls_node *node;
int h;
unsigned int slot;

local_bh_disable();
for (h = 0; h <= hashinfo->ehash_mask; h++) {
struct inet_ehash_bucket *head =
inet_ehash_bucket(hashinfo, h);
spinlock_t *lock = inet_ehash_lockp(hashinfo, h);
for (slot = 0; slot <= hashinfo->ehash_mask; slot++) {
struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
restart_rcu:
rcu_read_lock();
restart:
spin_lock(lock);
sk_nulls_for_each(sk, node, &head->twchain) {

sk_nulls_for_each_rcu(sk, node, &head->twchain) {
tw = inet_twsk(sk);
if (!net_eq(twsk_net(tw), net) ||
tw->tw_family != family)
continue;

atomic_inc(&tw->tw_refcnt);
spin_unlock(lock);
if (unlikely(!atomic_inc_not_zero(&tw->tw_refcnt)))
continue;

if (unlikely(!net_eq(twsk_net(tw), net) ||
tw->tw_family != family)) {
inet_twsk_put(tw);
goto restart;
}

rcu_read_unlock();
inet_twsk_deschedule(tw, twdr);
inet_twsk_put(tw);

goto restart;
goto restart_rcu;
}
spin_unlock(lock);
/* If the nulls value we got at the end of this lookup is
* not the expected one, we must restart lookup.
* We probably met an item that was moved to another chain.
*/
if (get_nulls_value(node) != slot)
goto restart;
rcu_read_unlock();
}
local_bh_enable();
}
EXPORT_SYMBOL_GPL(inet_twsk_purge);

0 comments on commit 0074e7b

Please sign in to comment.