2 * net/dst.h Protocol independent destination cache definitions.
4 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
11 #include <linux/config.h>
12 #include <net/neighbour.h>
15 * 0 - no debugging messages
16 * 1 - rare events and bugs (default)
19 #define RT_CACHE_DEBUG 0
21 #define DST_GC_MIN (1*HZ)
22 #define DST_GC_INC (5*HZ)
23 #define DST_GC_MAX (120*HZ)
29 struct dst_entry
*next
;
30 atomic_t __refcnt
; /* client references */
32 struct net_device
*dev
;
34 unsigned long lastuse
;
35 unsigned long expires
;
44 unsigned long rate_last
; /* rate limiting for ICMP */
45 unsigned long rate_tokens
;
49 struct neighbour
*neighbour
;
52 int (*input
)(struct sk_buff
*);
53 int (*output
)(struct sk_buff
*);
55 #ifdef CONFIG_NET_CLS_ROUTE
67 unsigned short family
;
68 unsigned short protocol
;
72 struct dst_entry
* (*check
)(struct dst_entry
*, __u32 cookie
);
73 struct dst_entry
* (*reroute
)(struct dst_entry
*,
75 void (*destroy
)(struct dst_entry
*);
76 struct dst_entry
* (*negative_advice
)(struct dst_entry
*);
77 void (*link_failure
)(struct sk_buff
*);
81 kmem_cache_t
*kmem_cachep
;
86 extern __inline__
void dst_hold(struct dst_entry
* dst
)
88 atomic_inc(&dst
->__refcnt
);
92 struct dst_entry
* dst_clone(struct dst_entry
* dst
)
95 atomic_inc(&dst
->__refcnt
);
100 void dst_release(struct dst_entry
* dst
)
103 atomic_dec(&dst
->__refcnt
);
106 extern void * dst_alloc(struct dst_ops
* ops
);
107 extern void __dst_free(struct dst_entry
* dst
);
108 extern void dst_destroy(struct dst_entry
* dst
);
111 void dst_free(struct dst_entry
* dst
)
113 if (dst
->obsolete
> 1)
115 if (!atomic_read(&dst
->__refcnt
)) {
122 extern __inline__
void dst_confirm(struct dst_entry
*dst
)
125 neigh_confirm(dst
->neighbour
);
128 extern __inline__
void dst_negative_advice(struct dst_entry
**dst_p
)
130 struct dst_entry
* dst
= *dst_p
;
131 if (dst
&& dst
->ops
->negative_advice
)
132 *dst_p
= dst
->ops
->negative_advice(dst
);
135 extern __inline__
void dst_link_failure(struct sk_buff
*skb
)
137 struct dst_entry
* dst
= skb
->dst
;
138 if (dst
&& dst
->ops
&& dst
->ops
->link_failure
)
139 dst
->ops
->link_failure(skb
);
142 extern __inline__
void dst_set_expires(struct dst_entry
*dst
, int timeout
)
144 unsigned long expires
= jiffies
+ timeout
;
149 if (dst
->expires
== 0 || (long)(dst
->expires
- expires
) > 0)
150 dst
->expires
= expires
;
153 extern void dst_init(void);
157 #endif /* _NET_DST_H */