aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2010-11-30 14:54:19 -0500
committerDavid S. Miller <davem@davemloft.net>2010-11-30 14:54:19 -0500
commitb534ecf1cd26f094497da6ae28a6ab64cdbe1617 (patch)
treebdf8a55183a38926b8f34f709cb51a4db2f5f6b8
parent582a72da9a41be9227dc931d728ae2906880a589 (diff)
inetpeer: Make inet_getpeer() take an inet_peer_adress_t pointer.
And make an inet_getpeer_v4() helper, update callers. Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/inetpeer.h11
-rw-r--r--net/ipv4/inetpeer.c10
-rw-r--r--net/ipv4/ip_fragment.c2
-rw-r--r--net/ipv4/route.c2
-rw-r--r--net/ipv4/tcp_ipv4.c4
5 files changed, 19 insertions, 10 deletions
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
index d7e60792d76e..834f0456c87e 100644
--- a/include/net/inetpeer.h
+++ b/include/net/inetpeer.h
@@ -50,7 +50,16 @@ struct inet_peer {
50void inet_initpeers(void) __init; 50void inet_initpeers(void) __init;
51 51
52/* can be called with or without local BH being disabled */ 52/* can be called with or without local BH being disabled */
53struct inet_peer *inet_getpeer(__be32 daddr, int create); 53struct inet_peer *inet_getpeer(inet_peer_address_t *daddr, int create);
54
55static inline struct inet_peer *inet_getpeer_v4(__be32 v4daddr, int create)
56{
57 inet_peer_address_t daddr;
58
59 daddr.a4 = v4daddr;
60 daddr.family = AF_INET;
61 return inet_getpeer(&daddr, create);
62}
54 63
55/* can be called from BH context or outside */ 64/* can be called from BH context or outside */
56extern void inet_putpeer(struct inet_peer *p); 65extern void inet_putpeer(struct inet_peer *p);
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index 893f998efdbb..9aa76b8dd490 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -444,7 +444,7 @@ static struct inet_peer_base *family_to_base(int family)
444} 444}
445 445
446/* Called with or without local BH being disabled. */ 446/* Called with or without local BH being disabled. */
447struct inet_peer *inet_getpeer(__be32 daddr, int create) 447struct inet_peer *inet_getpeer(inet_peer_address_t *daddr, int create)
448{ 448{
449 struct inet_peer __rcu **stack[PEER_MAXDEPTH], ***stackptr; 449 struct inet_peer __rcu **stack[PEER_MAXDEPTH], ***stackptr;
450 struct inet_peer_base *base = family_to_base(AF_INET); 450 struct inet_peer_base *base = family_to_base(AF_INET);
@@ -454,7 +454,7 @@ struct inet_peer *inet_getpeer(__be32 daddr, int create)
454 * Because of a concurrent writer, we might not find an existing entry. 454 * Because of a concurrent writer, we might not find an existing entry.
455 */ 455 */
456 rcu_read_lock_bh(); 456 rcu_read_lock_bh();
457 p = lookup_rcu_bh(daddr, base); 457 p = lookup_rcu_bh(daddr->a4, base);
458 rcu_read_unlock_bh(); 458 rcu_read_unlock_bh();
459 459
460 if (p) { 460 if (p) {
@@ -469,7 +469,7 @@ struct inet_peer *inet_getpeer(__be32 daddr, int create)
469 * At least, nodes should be hot in our cache. 469 * At least, nodes should be hot in our cache.
470 */ 470 */
471 spin_lock_bh(&base->lock); 471 spin_lock_bh(&base->lock);
472 p = lookup(daddr, stack, base); 472 p = lookup(daddr->a4, stack, base);
473 if (p != peer_avl_empty) { 473 if (p != peer_avl_empty) {
474 atomic_inc(&p->refcnt); 474 atomic_inc(&p->refcnt);
475 spin_unlock_bh(&base->lock); 475 spin_unlock_bh(&base->lock);
@@ -479,10 +479,10 @@ struct inet_peer *inet_getpeer(__be32 daddr, int create)
479 } 479 }
480 p = create ? kmem_cache_alloc(peer_cachep, GFP_ATOMIC) : NULL; 480 p = create ? kmem_cache_alloc(peer_cachep, GFP_ATOMIC) : NULL;
481 if (p) { 481 if (p) {
482 p->daddr.a4 = daddr; 482 p->daddr = *daddr;
483 atomic_set(&p->refcnt, 1); 483 atomic_set(&p->refcnt, 1);
484 atomic_set(&p->rid, 0); 484 atomic_set(&p->rid, 0);
485 atomic_set(&p->ip_id_count, secure_ip_id(daddr)); 485 atomic_set(&p->ip_id_count, secure_ip_id(daddr->a4));
486 p->tcp_ts_stamp = 0; 486 p->tcp_ts_stamp = 0;
487 INIT_LIST_HEAD(&p->unused); 487 INIT_LIST_HEAD(&p->unused);
488 488
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 168440834ade..e6215bdd96c0 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -141,7 +141,7 @@ static void ip4_frag_init(struct inet_frag_queue *q, void *a)
141 qp->daddr = arg->iph->daddr; 141 qp->daddr = arg->iph->daddr;
142 qp->user = arg->user; 142 qp->user = arg->user;
143 qp->peer = sysctl_ipfrag_max_dist ? 143 qp->peer = sysctl_ipfrag_max_dist ?
144 inet_getpeer(arg->iph->saddr, 1) : NULL; 144 inet_getpeer_v4(arg->iph->saddr, 1) : NULL;
145} 145}
146 146
147static __inline__ void ip4_frag_free(struct inet_frag_queue *q) 147static __inline__ void ip4_frag_free(struct inet_frag_queue *q)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index ec2333fb637e..3843c2dfde82 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1289,7 +1289,7 @@ void rt_bind_peer(struct rtable *rt, int create)
1289{ 1289{
1290 struct inet_peer *peer; 1290 struct inet_peer *peer;
1291 1291
1292 peer = inet_getpeer(rt->rt_dst, create); 1292 peer = inet_getpeer_v4(rt->rt_dst, create);
1293 1293
1294 if (peer && cmpxchg(&rt->peer, NULL, peer) != NULL) 1294 if (peer && cmpxchg(&rt->peer, NULL, peer) != NULL)
1295 inet_putpeer(peer); 1295 inet_putpeer(peer);
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index b8bbf89409b0..00285fcf6788 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1778,7 +1778,7 @@ int tcp_v4_remember_stamp(struct sock *sk)
1778 int release_it = 0; 1778 int release_it = 0;
1779 1779
1780 if (!rt || rt->rt_dst != inet->inet_daddr) { 1780 if (!rt || rt->rt_dst != inet->inet_daddr) {
1781 peer = inet_getpeer(inet->inet_daddr, 1); 1781 peer = inet_getpeer_v4(inet->inet_daddr, 1);
1782 release_it = 1; 1782 release_it = 1;
1783 } else { 1783 } else {
1784 if (!rt->peer) 1784 if (!rt->peer)
@@ -1804,7 +1804,7 @@ EXPORT_SYMBOL(tcp_v4_remember_stamp);
1804 1804
1805int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw) 1805int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw)
1806{ 1806{
1807 struct inet_peer *peer = inet_getpeer(tw->tw_daddr, 1); 1807 struct inet_peer *peer = inet_getpeer_v4(tw->tw_daddr, 1);
1808 1808
1809 if (peer) { 1809 if (peer) {
1810 const struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw); 1810 const struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw);