Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 224722
b: refs/heads/master
c: 021e929
h: refs/heads/master
v: v3
  • Loading branch information
David S. Miller committed Nov 30, 2010
1 parent a67170b commit 0f9a950
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 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: 026630450244b8f8d1baf54548be0800aa1823ed
refs/heads/master: 021e9299113363cc1b713f86b2cba30b8e6cb5dd
27 changes: 18 additions & 9 deletions trunk/net/ipv4/inetpeer.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,24 @@ static const struct inet_peer peer_fake_node = {
.avl_height = 0
};

static struct inet_peer_base {
struct inet_peer_base {
struct inet_peer __rcu *root;
spinlock_t lock;
int total;
} v4_peers = {
};

static struct inet_peer_base v4_peers = {
.root = peer_avl_empty_rcu,
.lock = __SPIN_LOCK_UNLOCKED(v4_peers.lock),
.total = 0,
};

static struct inet_peer_base v6_peers = {
.root = peer_avl_empty_rcu,
.lock = __SPIN_LOCK_UNLOCKED(v6_peers.lock),
.total = 0,
};

#define PEER_MAXDEPTH 40 /* sufficient for about 2^27 nodes */

/* Exported for sysctl_net_ipv4. */
Expand Down Expand Up @@ -415,9 +424,14 @@ static void unlink_from_pool(struct inet_peer *p, struct inet_peer_base *base)
inet_putpeer(p);
}

static struct inet_peer_base *family_to_base(int family)
{
return (family == AF_INET ? &v4_peers : &v6_peers);
}

static struct inet_peer_base *peer_to_base(struct inet_peer *p)
{
return &v4_peers;
return family_to_base(p->daddr.family);
}

/* May be called with local BH enabled. */
Expand Down Expand Up @@ -457,11 +471,6 @@ static int cleanup_once(unsigned long ttl)
return 0;
}

static struct inet_peer_base *family_to_base(int family)
{
return &v4_peers;
}

/* Called with or without local BH being disabled. */
struct inet_peer *inet_getpeer(inet_peer_address_t *daddr, int create)
{
Expand Down Expand Up @@ -521,7 +530,7 @@ struct inet_peer *inet_getpeer(inet_peer_address_t *daddr, int create)

static int compute_total(void)
{
return v4_peers.total;
return v4_peers.total + v6_peers.total;
}

/* Called with local BH disabled. */
Expand Down

0 comments on commit 0f9a950

Please sign in to comment.