aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/inetpeer.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/inetpeer.h')
-rw-r--r--include/net/inetpeer.h32
1 files changed, 29 insertions, 3 deletions
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
index fe239bfe5f7f..599d96e74114 100644
--- a/include/net/inetpeer.h
+++ b/include/net/inetpeer.h
@@ -11,12 +11,21 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/jiffies.h> 12#include <linux/jiffies.h>
13#include <linux/spinlock.h> 13#include <linux/spinlock.h>
14#include <net/ipv6.h>
14#include <asm/atomic.h> 15#include <asm/atomic.h>
15 16
17struct inetpeer_addr {
18 union {
19 __be32 a4;
20 __be32 a6[4];
21 };
22 __u16 family;
23};
24
16struct inet_peer { 25struct inet_peer {
17 /* group together avl_left,avl_right,v4daddr to speedup lookups */ 26 /* group together avl_left,avl_right,v4daddr to speedup lookups */
18 struct inet_peer __rcu *avl_left, *avl_right; 27 struct inet_peer __rcu *avl_left, *avl_right;
19 __be32 v4daddr; /* peer's address */ 28 struct inetpeer_addr daddr;
20 __u32 avl_height; 29 __u32 avl_height;
21 struct list_head unused; 30 struct list_head unused;
22 __u32 dtime; /* the time of last use of not 31 __u32 dtime; /* the time of last use of not
@@ -26,7 +35,6 @@ struct inet_peer {
26 * Once inet_peer is queued for deletion (refcnt == -1), following fields 35 * Once inet_peer is queued for deletion (refcnt == -1), following fields
27 * are not available: rid, ip_id_count, tcp_ts, tcp_ts_stamp 36 * are not available: rid, ip_id_count, tcp_ts, tcp_ts_stamp
28 * We can share memory with rcu_head to keep inet_peer small 37 * We can share memory with rcu_head to keep inet_peer small
29 * (less then 64 bytes)
30 */ 38 */
31 union { 39 union {
32 struct { 40 struct {
@@ -42,7 +50,25 @@ struct inet_peer {
42void inet_initpeers(void) __init; 50void inet_initpeers(void) __init;
43 51
44/* can be called with or without local BH being disabled */ 52/* can be called with or without local BH being disabled */
45struct inet_peer *inet_getpeer(__be32 daddr, int create); 53struct inet_peer *inet_getpeer(struct inetpeer_addr *daddr, int create);
54
55static inline struct inet_peer *inet_getpeer_v4(__be32 v4daddr, int create)
56{
57 struct inetpeer_addr daddr;
58
59 daddr.a4 = v4daddr;
60 daddr.family = AF_INET;
61 return inet_getpeer(&daddr, create);
62}
63
64static inline struct inet_peer *inet_getpeer_v6(struct in6_addr *v6daddr, int create)
65{
66 struct inetpeer_addr daddr;
67
68 ipv6_addr_copy((struct in6_addr *)daddr.a6, v6daddr);
69 daddr.family = AF_INET6;
70 return inet_getpeer(&daddr, create);
71}
46 72
47/* can be called from BH context or outside */ 73/* can be called from BH context or outside */
48extern void inet_putpeer(struct inet_peer *p); 74extern void inet_putpeer(struct inet_peer *p);