Main Page | Class List | File List | Class Members | File Members

dst.h File Reference

#include <linux/config.h>
#include <net/neighbour.h>

Go to the source code of this file.

Classes

struct  dst_entry
struct  dst_ops

Defines

#define RT_CACHE_DEBUG   0
#define DST_GC_MIN   (HZ/10)
#define DST_GC_INC   (HZ/2)
#define DST_GC_MAX   (120*HZ)
#define DST_HOST   1

Functions

void dst_hold (struct dst_entry *dst)
dst_entrydst_clone (struct dst_entry *dst)
void dst_release (struct dst_entry *dst)
void * dst_alloc (struct dst_ops *ops)
void __dst_free (struct dst_entry *dst)
void dst_destroy (struct dst_entry *dst)
void dst_free (struct dst_entry *dst)
void dst_confirm (struct dst_entry *dst)
void dst_negative_advice (struct dst_entry **dst_p)
void dst_link_failure (struct sk_buff *skb)
void dst_set_expires (struct dst_entry *dst, int timeout)
void dst_init (void)


Define Documentation

#define DST_GC_INC   (HZ/2)
 

Definition at line 22 of file dst.h.

Referenced by __dst_free(), and dst_run_gc().

#define DST_GC_MAX   (120*HZ)
 

Definition at line 23 of file dst.h.

Referenced by dst_run_gc().

#define DST_GC_MIN   (HZ/10)
 

Definition at line 21 of file dst.h.

Referenced by __dst_free().

#define DST_HOST   1
 

Definition at line 35 of file dst.h.

Referenced by ip_route_input_mc(), ip_route_input_slow(), ip_route_output_slow(), and tcp_update_metrics().

#define RT_CACHE_DEBUG   0
 

Definition at line 19 of file dst.h.


Function Documentation

void __dst_free struct dst_entry dst  ) 
 

Definition at line 120 of file dst.c.

References dst_entry::dev, dst_blackhole(), dst_discard(), dst_garbage_list, DST_GC_INC, DST_GC_MIN, dst_gc_timer, dst_gc_timer_expires, dst_gc_timer_inc, dst_lock, net_device::flags, dst_entry::input, dst_entry::next, dst_entry::obsolete, and dst_entry::output.

Referenced by dst_free().

00121 { 00122 spin_lock_bh(&dst_lock); 00123 00124 /* The first case (dev==NULL) is required, when 00125 protocol module is unloaded. 00126 */ 00127 if (dst->dev == NULL || !(dst->dev->flags&IFF_UP)) { 00128 dst->input = dst_discard; 00129 dst->output = dst_blackhole; 00130 } 00131 dst->obsolete = 2; 00132 dst->next = dst_garbage_list; 00133 dst_garbage_list = dst; 00134 if (dst_gc_timer_inc > DST_GC_INC) { 00135 dst_gc_timer_inc = DST_GC_INC; 00136 dst_gc_timer_expires = DST_GC_MIN; 00137 mod_timer(&dst_gc_timer, jiffies + dst_gc_timer_expires); 00138 } 00139 00140 spin_unlock_bh(&dst_lock); 00141 }

void* dst_alloc struct dst_ops ops  ) 
 

Definition at line 96 of file dst.c.

References dst_blackhole(), dst_discard(), dst_ops::entries, dst_ops::entry_size, dst_ops::gc, dst_ops::gc_thresh, and dst_ops::kmem_cachep.

Referenced by ip_route_input_mc(), ip_route_input_slow(), ip_route_output_slow(), and ip_rt_redirect().

00097 { 00098 struct dst_entry * dst; 00099 00100 if (ops->gc && atomic_read(&ops->entries) > ops->gc_thresh) { 00101 if (ops->gc()) 00102 return NULL; 00103 } 00104 dst = kmem_cache_alloc(ops->kmem_cachep, SLAB_ATOMIC); 00105 if (!dst) 00106 return NULL; 00107 memset(dst, 0, ops->entry_size); 00108 atomic_set(&dst->__refcnt, 0); 00109 dst->ops = ops; 00110 dst->lastuse = jiffies; 00111 dst->input = dst_discard; 00112 dst->output = dst_blackhole; 00113 #if RT_CACHE_DEBUG >= 2 00114 atomic_inc(&dst_total); 00115 #endif 00116 atomic_inc(&ops->entries); 00117 return dst; 00118 }

struct dst_entry* dst_clone struct dst_entry dst  )  [inline, static]
 

Definition at line 97 of file dst.h.

References dst_entry::__refcnt.

Referenced by __ip_vs_get_out_rt(), copy_skb_header(), dn_nsp_send(), ip_build_xmit(), ip_build_xmit_slow(), ip_forward_finish(), ip_fragment(), ip_queue_xmit(), ip_rt_dump(), ipmr_cache_report(), skb_clone(), tcp_make_synack(), and udp_sendmsg().

00098 { 00099 if (dst) 00100 atomic_inc(&dst->__refcnt); 00101 return dst; 00102 }

void dst_confirm struct dst_entry dst  )  [inline, static]
 

Definition at line 127 of file dst.h.

References neigh_confirm(), and dst_entry::neighbour.

Referenced by ip_rt_frag_needed(), ip_rt_redirect(), raw_sendmsg(), tcp_ack(), tcp_init_metrics(), tcp_rcv_state_process(), tcp_update_metrics(), and udp_sendmsg().

00128 { 00129 if (dst) 00130 neigh_confirm(dst->neighbour); 00131 }

void dst_destroy struct dst_entry dst  ) 
 

Definition at line 143 of file dst.c.

References dst_ops::destroy, dst_entry::dev, dev_put(), dst_ops::entries, dst_entry::hh, dst_ops::kmem_cachep, neigh_release(), dst_entry::neighbour, and dst_entry::ops.

Referenced by dst_free(), and dst_run_gc().

00144 { 00145 struct neighbour *neigh = dst->neighbour; 00146 struct hh_cache *hh = dst->hh; 00147 00148 dst->hh = NULL; 00149 if (hh && atomic_dec_and_test(&hh->hh_refcnt)) 00150 kfree(hh); 00151 00152 if (neigh) { 00153 dst->neighbour = NULL; 00154 neigh_release(neigh); 00155 } 00156 00157 atomic_dec(&dst->ops->entries); 00158 00159 if (dst->ops->destroy) 00160 dst->ops->destroy(dst); 00161 if (dst->dev) 00162 dev_put(dst->dev); 00163 #if RT_CACHE_DEBUG >= 2 00164 atomic_dec(&dst_total); 00165 #endif 00166 kmem_cache_free(dst->ops->kmem_cachep, dst); 00167 }

void dst_free struct dst_entry dst  )  [inline, static]
 

Definition at line 116 of file dst.h.

References __dst_free(), dst_entry::__refcnt, dst_destroy(), and dst_entry::obsolete.

Referenced by rt_drop(), and rt_free().

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 }

void dst_hold struct dst_entry dst  )  [inline, static]
 

Definition at line 91 of file dst.h.

References dst_entry::__refcnt.

Referenced by __ip_vs_dst_check(), ip_route_input(), ip_route_output_key(), ip_rt_redirect(), rt_intern_hash(), and sk_dst_get().

00092 { 00093 atomic_inc(&dst->__refcnt); 00094 }

void dst_init void   ) 
 

Definition at line 216 of file dst.c.

References dst_dev_notifier, and register_netdevice_notifier().

Referenced by net_dev_init().

00217 { 00218 register_netdevice_notifier(&dst_dev_notifier); 00219 }

void dst_link_failure struct sk_buff skb  )  [inline, static]
 

Definition at line 140 of file dst.h.

References sk_buff::dst, dst_ops::link_failure, and dst_entry::ops.

Referenced by arp_error_report(), ip_vs_bypass_xmit(), ip_vs_dr_xmit(), ip_vs_in_icmp(), ip_vs_nat_xmit(), ip_vs_tunnel_xmit(), ipgre_tunnel_xmit(), and ipip_tunnel_xmit().

00141 { 00142 struct dst_entry * dst = skb->dst; 00143 if (dst && dst->ops && dst->ops->link_failure) 00144 dst->ops->link_failure(skb); 00145 }

void dst_negative_advice struct dst_entry **  dst_p  )  [inline, static]
 

Definition at line 133 of file dst.h.

References dst_ops::negative_advice, and dst_entry::ops.

Referenced by tcp_write_timeout().

00134 { 00135 struct dst_entry * dst = *dst_p; 00136 if (dst && dst->ops->negative_advice) 00137 *dst_p = dst->ops->negative_advice(dst); 00138 }

void dst_release struct dst_entry dst  )  [inline, static]
 

Definition at line 105 of file dst.h.

References dst_entry::__refcnt.

Referenced by __ip_vs_dst_reset(), __ip_vs_dst_set(), __kfree_skb(), __sk_dst_reset(), __sk_dst_set(), dn_nsp_send(), inet_sock_destruct(), ip_forward_finish(), ip_getsockopt(), ip_route_me_harder(), ip_rt_dump(), ip_rt_put(), ip_vs_bypass_xmit(), ip_vs_dr_xmit(), ip_vs_in_icmp(), ip_vs_nat_xmit(), ip_vs_tunnel_xmit(), ipgre_err(), ipgre_rcv(), ipgre_tunnel_xmit(), ipip_err(), ipip_rcv(), ipip_tunnel_xmit(), ipmr_queue_xmit(), ipt_mirror_target(), ipv4_dst_check(), pneigh_enqueue(), route_mirror(), route_reverse(), send_reset(), tcp_v4_conn_request(), tcp_v4_send_synack(), and tcp_v4_syn_recv_sock().

00106 { 00107 if (dst) 00108 atomic_dec(&dst->__refcnt); 00109 }

void dst_set_expires struct dst_entry dst,
int  timeout
[inline, static]
 

Definition at line 147 of file dst.h.

References dst_entry::expires.

Referenced by ip_rt_frag_needed(), ip_rt_update_pmtu(), and ipv4_link_failure().

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 }


Generated on Wed Dec 1 21:25:34 2004 for Linux 2.4.23 Networking by doxygen 1.3.8