Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 224719
b: refs/heads/master
c: 582a72d
h: refs/heads/master
i:
  224717: 623a1b0
  224715: 795130e
  224711: cbc7cd9
  224703: 5746395
v: v3
  • Loading branch information
David S. Miller committed Nov 30, 2010
1 parent 617ff65 commit 601042e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 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: 98158f5a853cafd33b254ae0eacc0dd69f90b93b
refs/heads/master: 582a72da9a41be9227dc931d728ae2906880a589
10 changes: 9 additions & 1 deletion trunk/include/net/inetpeer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@
#include <linux/spinlock.h>
#include <asm/atomic.h>

typedef struct {
union {
__be32 a4;
__be32 a6[4];
};
__u16 family;
} inet_peer_address_t;

struct inet_peer {
/* group together avl_left,avl_right,v4daddr to speedup lookups */
struct inet_peer __rcu *avl_left, *avl_right;
__be32 v4daddr; /* peer's address */
inet_peer_address_t daddr;
__u32 avl_height;
struct list_head unused;
__u32 dtime; /* the time of last use of not
Expand Down
16 changes: 8 additions & 8 deletions trunk/net/ipv4/inetpeer.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
* refcnt: atomically against modifications on other CPU;
* usually under some other lock to prevent node disappearing
* dtime: unused node list lock
* v4daddr: unchangeable
* daddr: unchangeable
* ip_id_count: atomic value (no lock needed)
*/

Expand Down Expand Up @@ -165,9 +165,9 @@ static void unlink_from_unused(struct inet_peer *p)
for (u = rcu_dereference_protected(_base->root, \
lockdep_is_held(&_base->lock)); \
u != peer_avl_empty; ) { \
if (_daddr == u->v4daddr) \
if (_daddr == u->daddr.a4) \
break; \
if ((__force __u32)_daddr < (__force __u32)u->v4daddr) \
if ((__force __u32)_daddr < (__force __u32)u->daddr.a4) \
v = &u->avl_left; \
else \
v = &u->avl_right; \
Expand All @@ -191,7 +191,7 @@ static struct inet_peer *lookup_rcu_bh(__be32 daddr, struct inet_peer_base *base
int count = 0;

while (u != peer_avl_empty) {
if (daddr == u->v4daddr) {
if (daddr == u->daddr.a4) {
/* Before taking a reference, check if this entry was
* deleted, unlink_from_pool() sets refcnt=-1 to make
* distinction between an unused entry (refcnt=0) and
Expand All @@ -201,7 +201,7 @@ static struct inet_peer *lookup_rcu_bh(__be32 daddr, struct inet_peer_base *base
u = NULL;
return u;
}
if ((__force __u32)daddr < (__force __u32)u->v4daddr)
if ((__force __u32)daddr < (__force __u32)u->daddr.a4)
u = rcu_dereference_bh(u->avl_left);
else
u = rcu_dereference_bh(u->avl_right);
Expand Down Expand Up @@ -354,7 +354,7 @@ static void unlink_from_pool(struct inet_peer *p, struct inet_peer_base *base)
if (atomic_cmpxchg(&p->refcnt, 1, -1) == 1) {
struct inet_peer __rcu **stack[PEER_MAXDEPTH];
struct inet_peer __rcu ***stackptr, ***delp;
if (lookup(p->v4daddr, stack, base) != p)
if (lookup(p->daddr.a4, stack, base) != p)
BUG();
delp = stackptr - 1; /* *delp[0] == p */
if (p->avl_left == peer_avl_empty_rcu) {
Expand All @@ -367,7 +367,7 @@ static void unlink_from_pool(struct inet_peer *p, struct inet_peer_base *base)
BUG_ON(rcu_dereference_protected(*stackptr[-1],
lockdep_is_held(&base->lock)) != t);
**--stackptr = t->avl_left;
/* t is removed, t->v4daddr > x->v4daddr for any
/* t is removed, t->daddr > x->daddr for any
* x in p->avl_left subtree.
* Put t in the old place of p. */
RCU_INIT_POINTER(*delp[0], t);
Expand Down Expand Up @@ -479,7 +479,7 @@ struct inet_peer *inet_getpeer(__be32 daddr, int create)
}
p = create ? kmem_cache_alloc(peer_cachep, GFP_ATOMIC) : NULL;
if (p) {
p->v4daddr = daddr;
p->daddr.a4 = daddr;
atomic_set(&p->refcnt, 1);
atomic_set(&p->rid, 0);
atomic_set(&p->ip_id_count, secure_ip_id(daddr));
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 @@ -1347,7 +1347,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
tcp_death_row.sysctl_tw_recycle &&
(dst = inet_csk_route_req(sk, req)) != NULL &&
(peer = rt_get_peer((struct rtable *)dst)) != NULL &&
peer->v4daddr == saddr) {
peer->daddr.a4 == saddr) {
inet_peer_refcheck(peer);
if ((u32)get_seconds() - peer->tcp_ts_stamp < TCP_PAWS_MSL &&
(s32)(peer->tcp_ts - req->ts_recent) >
Expand Down

0 comments on commit 601042e

Please sign in to comment.