inetpeer.h (ecd740c6f2f092b90b95fa35f757973589eaaca2) | inetpeer.h (73f156a6e8c1074ac6327e0abd1169e95eb66463) |
---|---|
1/* 2 * INETPEER - A storage for permanent information about peers 3 * 4 * Authors: Andrey V. Savochkin <saw@msu.ru> 5 */ 6 7#ifndef _NET_INETPEER_H 8#define _NET_INETPEER_H --- 27 unchanged lines hidden (view full) --- 36 u32 metrics[RTAX_MAX]; 37 u32 rate_tokens; /* rate limiting for ICMP */ 38 unsigned long rate_last; 39 union { 40 struct list_head gc_list; 41 struct rcu_head gc_rcu; 42 }; 43 /* | 1/* 2 * INETPEER - A storage for permanent information about peers 3 * 4 * Authors: Andrey V. Savochkin <saw@msu.ru> 5 */ 6 7#ifndef _NET_INETPEER_H 8#define _NET_INETPEER_H --- 27 unchanged lines hidden (view full) --- 36 u32 metrics[RTAX_MAX]; 37 u32 rate_tokens; /* rate limiting for ICMP */ 38 unsigned long rate_last; 39 union { 40 struct list_head gc_list; 41 struct rcu_head gc_rcu; 42 }; 43 /* |
44 * Once inet_peer is queued for deletion (refcnt == -1), following fields 45 * are not available: rid, ip_id_count | 44 * Once inet_peer is queued for deletion (refcnt == -1), following field 45 * is not available: rid |
46 * We can share memory with rcu_head to help keep inet_peer small. 47 */ 48 union { 49 struct { 50 atomic_t rid; /* Frag reception counter */ | 46 * We can share memory with rcu_head to help keep inet_peer small. 47 */ 48 union { 49 struct { 50 atomic_t rid; /* Frag reception counter */ |
51 atomic_t ip_id_count; /* IP ID for the next packet */ | |
52 }; 53 struct rcu_head rcu; 54 struct inet_peer *gc_next; 55 }; 56 57 /* following fields might be frequently dirtied */ 58 __u32 dtime; /* the time of last use of not referenced entries */ 59 atomic_t refcnt; --- 100 unchanged lines hidden (view full) --- 160 161/* can be called from BH context or outside */ 162void inet_putpeer(struct inet_peer *p); 163bool inet_peer_xrlim_allow(struct inet_peer *peer, int timeout); 164 165void inetpeer_invalidate_tree(struct inet_peer_base *); 166 167/* | 51 }; 52 struct rcu_head rcu; 53 struct inet_peer *gc_next; 54 }; 55 56 /* following fields might be frequently dirtied */ 57 __u32 dtime; /* the time of last use of not referenced entries */ 58 atomic_t refcnt; --- 100 unchanged lines hidden (view full) --- 159 160/* can be called from BH context or outside */ 161void inet_putpeer(struct inet_peer *p); 162bool inet_peer_xrlim_allow(struct inet_peer *peer, int timeout); 163 164void inetpeer_invalidate_tree(struct inet_peer_base *); 165 166/* |
168 * temporary check to make sure we dont access rid, ip_id_count, tcp_ts, | 167 * temporary check to make sure we dont access rid, tcp_ts, |
169 * tcp_ts_stamp if no refcount is taken on inet_peer 170 */ 171static inline void inet_peer_refcheck(const struct inet_peer *p) 172{ 173 WARN_ON_ONCE(atomic_read(&p->refcnt) <= 0); 174} 175 | 168 * tcp_ts_stamp if no refcount is taken on inet_peer 169 */ 170static inline void inet_peer_refcheck(const struct inet_peer *p) 171{ 172 WARN_ON_ONCE(atomic_read(&p->refcnt) <= 0); 173} 174 |
176 177/* can be called with or without local BH being disabled */ 178static inline int inet_getid(struct inet_peer *p, int more) 179{ 180 int old, new; 181 more++; 182 inet_peer_refcheck(p); 183 do { 184 old = atomic_read(&p->ip_id_count); 185 new = old + more; 186 if (!new) 187 new = 1; 188 } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old); 189 return new; 190} 191 | |
192#endif /* _NET_INETPEER_H */ | 175#endif /* _NET_INETPEER_H */ |