00001 /* 00002 * net/dst.h Protocol independent destination cache definitions. 00003 * 00004 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> 00005 * 00006 */ 00007 00008 #ifndef _NET_DST_H 00009 #define _NET_DST_H 00010 00011 #include <linux/config.h> 00012 #include <net/neighbour.h> 00013 00014 /* 00015 * 0 - no debugging messages 00016 * 1 - rare events and bugs (default) 00017 * 2 - trace mode. 00018 */ 00019 #define RT_CACHE_DEBUG 0 00020 00021 #define DST_GC_MIN (HZ/10) 00022 #define DST_GC_INC (HZ/2) 00023 #define DST_GC_MAX (120*HZ) 00024 00025 struct sk_buff; 00026 00027 struct dst_entry 00028 { 00029 struct dst_entry *next; 00030 atomic_t __refcnt; /* client references */ 00031 int __use; 00032 struct net_device *dev; 00033 int obsolete; 00034 int flags; 00035 #define DST_HOST 1 00036 unsigned long lastuse; 00037 unsigned long expires; 00038 00039 unsigned mxlock; 00040 unsigned pmtu; 00041 unsigned window; 00042 unsigned rtt; 00043 unsigned rttvar; 00044 unsigned ssthresh; 00045 unsigned cwnd; 00046 unsigned advmss; 00047 unsigned reordering; 00048 00049 unsigned long rate_last; /* rate limiting for ICMP */ 00050 unsigned long rate_tokens; 00051 00052 int error; 00053 00054 struct neighbour *neighbour; 00055 struct hh_cache *hh; 00056 00057 int (*input)(struct sk_buff*); 00058 int (*output)(struct sk_buff*); 00059 00060 #ifdef CONFIG_NET_CLS_ROUTE 00061 __u32 tclassid; 00062 #endif 00063 00064 struct dst_ops *ops; 00065 00066 char info[0]; 00067 }; 00068 00069 00070 struct dst_ops 00071 { 00072 unsigned short family; 00073 unsigned short protocol; 00074 unsigned gc_thresh; 00075 00076 int (*gc)(void); 00077 struct dst_entry * (*check)(struct dst_entry *, __u32 cookie); 00078 struct dst_entry * (*reroute)(struct dst_entry *, 00079 struct sk_buff *); 00080 void (*destroy)(struct dst_entry *); 00081 struct dst_entry * (*negative_advice)(struct dst_entry *); 00082 void (*link_failure)(struct sk_buff *); 00083 int entry_size; 00084 00085 atomic_t entries; 00086 kmem_cache_t *kmem_cachep; 00087 }; 00088 00089 #ifdef __KERNEL__ 00090 00091 static inline void dst_hold(struct dst_entry * dst) 00092 { 00093 atomic_inc(&dst->__refcnt); 00094 } 00095 00096 static inline 00097 struct dst_entry * dst_clone(struct dst_entry * dst) 00098 { 00099 if (dst) 00100 atomic_inc(&dst->__refcnt); 00101 return dst; 00102 } 00103 00104 static inline 00105 void dst_release(struct dst_entry * dst) 00106 { 00107 if (dst) 00108 atomic_dec(&dst->__refcnt); 00109 } 00110 00111 extern void * dst_alloc(struct dst_ops * ops); 00112 extern void __dst_free(struct dst_entry * dst); 00113 extern void dst_destroy(struct dst_entry * dst); 00114 00115 static inline 00116 void dst_free(struct dst_entry * dst) 00117 { 00118 if (dst->obsolete > 1) 00119 return; 00120 if (!atomic_read(&dst->__refcnt)) { 00121 dst_destroy(dst); 00122 return; 00123 } 00124 __dst_free(dst); 00125 } 00126 00127 static inline void dst_confirm(struct dst_entry *dst) 00128 { 00129 if (dst) 00130 neigh_confirm(dst->neighbour); 00131 } 00132 00133 static inline void dst_negative_advice(struct dst_entry **dst_p) 00134 { 00135 struct dst_entry * dst = *dst_p; 00136 if (dst && dst->ops->negative_advice) 00137 *dst_p = dst->ops->negative_advice(dst); 00138 } 00139 00140 static inline void dst_link_failure(struct sk_buff *skb) 00141 { 00142 struct dst_entry * dst = skb->dst; 00143 if (dst && dst->ops && dst->ops->link_failure) 00144 dst->ops->link_failure(skb); 00145 } 00146 00147 static inline void dst_set_expires(struct dst_entry *dst, int timeout) 00148 { 00149 unsigned long expires = jiffies + timeout; 00150 00151 if (expires == 0) 00152 expires = 1; 00153 00154 if (dst->expires == 0 || (long)(dst->expires - expires) > 0) 00155 dst->expires = expires; 00156 } 00157 00158 extern void dst_init(void); 00159 00160 #endif 00161 00162 #endif /* _NET_DST_H */
1.3.8