diff options
author | David S. Miller <davem@davemloft.net> | 2010-11-30 15:12:23 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-11-30 15:12:23 -0500 |
commit | 021e9299113363cc1b713f86b2cba30b8e6cb5dd (patch) | |
tree | 2e6f5bb98960ba927280beb987168f6bd5a4ba6d | |
parent | 026630450244b8f8d1baf54548be0800aa1823ed (diff) |
inetpeer: Add v6 peers tree, abstract root properly.
Add the ipv6 peer tree instance, and adapt remaining
direct references to 'v4_peers' as needed.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/inetpeer.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c index c96dc51c2e49..1c1335b0d401 100644 --- a/net/ipv4/inetpeer.c +++ b/net/ipv4/inetpeer.c | |||
@@ -79,15 +79,24 @@ static const struct inet_peer peer_fake_node = { | |||
79 | .avl_height = 0 | 79 | .avl_height = 0 |
80 | }; | 80 | }; |
81 | 81 | ||
82 | static struct inet_peer_base { | 82 | struct inet_peer_base { |
83 | struct inet_peer __rcu *root; | 83 | struct inet_peer __rcu *root; |
84 | spinlock_t lock; | 84 | spinlock_t lock; |
85 | int total; | 85 | int total; |
86 | } v4_peers = { | 86 | }; |
87 | |||
88 | static struct inet_peer_base v4_peers = { | ||
87 | .root = peer_avl_empty_rcu, | 89 | .root = peer_avl_empty_rcu, |
88 | .lock = __SPIN_LOCK_UNLOCKED(v4_peers.lock), | 90 | .lock = __SPIN_LOCK_UNLOCKED(v4_peers.lock), |
89 | .total = 0, | 91 | .total = 0, |
90 | }; | 92 | }; |
93 | |||
94 | static struct inet_peer_base v6_peers = { | ||
95 | .root = peer_avl_empty_rcu, | ||
96 | .lock = __SPIN_LOCK_UNLOCKED(v6_peers.lock), | ||
97 | .total = 0, | ||
98 | }; | ||
99 | |||
91 | #define PEER_MAXDEPTH 40 /* sufficient for about 2^27 nodes */ | 100 | #define PEER_MAXDEPTH 40 /* sufficient for about 2^27 nodes */ |
92 | 101 | ||
93 | /* Exported for sysctl_net_ipv4. */ | 102 | /* Exported for sysctl_net_ipv4. */ |
@@ -415,9 +424,14 @@ static void unlink_from_pool(struct inet_peer *p, struct inet_peer_base *base) | |||
415 | inet_putpeer(p); | 424 | inet_putpeer(p); |
416 | } | 425 | } |
417 | 426 | ||
427 | static struct inet_peer_base *family_to_base(int family) | ||
428 | { | ||
429 | return (family == AF_INET ? &v4_peers : &v6_peers); | ||
430 | } | ||
431 | |||
418 | static struct inet_peer_base *peer_to_base(struct inet_peer *p) | 432 | static struct inet_peer_base *peer_to_base(struct inet_peer *p) |
419 | { | 433 | { |
420 | return &v4_peers; | 434 | return family_to_base(p->daddr.family); |
421 | } | 435 | } |
422 | 436 | ||
423 | /* May be called with local BH enabled. */ | 437 | /* May be called with local BH enabled. */ |
@@ -457,11 +471,6 @@ static int cleanup_once(unsigned long ttl) | |||
457 | return 0; | 471 | return 0; |
458 | } | 472 | } |
459 | 473 | ||
460 | static struct inet_peer_base *family_to_base(int family) | ||
461 | { | ||
462 | return &v4_peers; | ||
463 | } | ||
464 | |||
465 | /* Called with or without local BH being disabled. */ | 474 | /* Called with or without local BH being disabled. */ |
466 | struct inet_peer *inet_getpeer(inet_peer_address_t *daddr, int create) | 475 | struct inet_peer *inet_getpeer(inet_peer_address_t *daddr, int create) |
467 | { | 476 | { |
@@ -521,7 +530,7 @@ struct inet_peer *inet_getpeer(inet_peer_address_t *daddr, int create) | |||
521 | 530 | ||
522 | static int compute_total(void) | 531 | static int compute_total(void) |
523 | { | 532 | { |
524 | return v4_peers.total; | 533 | return v4_peers.total + v6_peers.total; |
525 | } | 534 | } |
526 | 535 | ||
527 | /* Called with local BH disabled. */ | 536 | /* Called with local BH disabled. */ |