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 (HZ/10)
22 #define DST_GC_INC (HZ/2)
23 #define DST_GC_MAX (120*HZ)
29 struct dst_entry *next;
30 atomic_t __refcnt; /* client references */
32 struct net_device *dev;
36 unsigned long lastuse;
37 unsigned long expires;
49 unsigned long rate_last; /* rate limiting for ICMP */
50 unsigned long rate_tokens;
54 struct neighbour *neighbour;
57 int (*input)(struct sk_buff*);
58 int (*output)(struct sk_buff*);
60 #ifdef CONFIG_NET_CLS_ROUTE
72 unsigned short family;
73 unsigned short protocol;
77 struct dst_entry * (*check)(struct dst_entry *, __u32 cookie);
78 struct dst_entry * (*reroute)(struct dst_entry *,
80 void (*destroy)(struct dst_entry *);
81 struct dst_entry * (*negative_advice)(struct dst_entry *);
82 void (*link_failure)(struct sk_buff *);
86 kmem_cache_t *kmem_cachep;
91 static inline void dst_hold(struct dst_entry * dst)
93 atomic_inc(&dst->__refcnt);
97 struct dst_entry * dst_clone(struct dst_entry * dst)
100 atomic_inc(&dst->__refcnt);
105 void dst_release(struct dst_entry * dst)
108 smp_mb__before_atomic_dec();
109 atomic_dec(&dst->__refcnt);
113 extern void * dst_alloc(struct dst_ops * ops);
114 extern void __dst_free(struct dst_entry * dst);
115 extern void dst_destroy(struct dst_entry * dst);
118 void dst_free(struct dst_entry * dst)
120 if (dst->obsolete > 1)
122 if (!atomic_read(&dst->__refcnt)) {
129 static inline void dst_confirm(struct dst_entry *dst)
132 neigh_confirm(dst->neighbour);
135 static inline void dst_negative_advice(struct dst_entry **dst_p)
137 struct dst_entry * dst = *dst_p;
138 if (dst && dst->ops->negative_advice)
139 *dst_p = dst->ops->negative_advice(dst);
142 static inline void dst_link_failure(struct sk_buff *skb)
144 struct dst_entry * dst = skb->dst;
145 if (dst && dst->ops && dst->ops->link_failure)
146 dst->ops->link_failure(skb);
149 static inline void dst_set_expires(struct dst_entry *dst, int timeout)
151 unsigned long expires = jiffies + timeout;
156 if (dst->expires == 0 || (long)(dst->expires - expires) > 0)
157 dst->expires = expires;
160 extern void dst_init(void);
164 #endif /* _NET_DST_H */