Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

ipv4/route.c File Reference

#include <linux/config.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <asm/bitops.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/socket.h>
#include <linux/sockios.h>
#include <linux/errno.h>
#include <linux/in.h>
#include <linux/inet.h>
#include <linux/netdevice.h>
#include <linux/proc_fs.h>
#include <linux/init.h>
#include <linux/skbuff.h>
#include <linux/rtnetlink.h>
#include <linux/inetdevice.h>
#include <linux/igmp.h>
#include <linux/pkt_sched.h>
#include <linux/mroute.h>
#include <linux/random.h>
#include <linux/jhash.h>
#include <net/protocol.h>
#include <net/ip.h>
#include <net/route.h>
#include <net/sock.h>
#include <net/ip_fib.h>
#include <net/arp.h>
#include <net/tcp.h>
#include <net/icmp.h>

Include dependency graph for ipv4/route.c:

Go to the source code of this file.

Defines

#define IP_MAX_MTU   0xFFF0
#define RT_GC_TIMEOUT   (300*HZ)
#define RTprint(a...)   printk(KERN_DEBUG a)

Functions

static void rt_run_flush (unsigned long dummy)
static struct dst_entryipv4_dst_check (struct dst_entry *dst, u32)
static struct dst_entryipv4_dst_reroute (struct dst_entry *dst, struct sk_buff *)
static struct dst_entryipv4_negative_advice (struct dst_entry *)
static void ipv4_link_failure (struct sk_buff *skb)
static int rt_garbage_collect (void)
static int rt_intern_hash (unsigned hash, struct rtable *rth, struct rtable **res)
static unsigned rt_hash_code (u32 daddr, u32 saddr, u8 tos)
static __inline__ void rt_free (struct rtable *rt)
static __inline__ void rt_drop (struct rtable *rt)
static __inline__ int rt_fast_clean (struct rtable *rth)
static __inline__ int rt_valuable (struct rtable *rth)
static __inline__ int rt_may_expire (struct rtable *rth, int tmo1, int tmo2)
static void rt_check_expire (unsigned long dummy)
void rt_cache_flush (int delay)
static void rt_secret_rebuild (unsigned long dummy)
static void rt_del (unsigned hash, struct rtable *rt)
void ip_rt_redirect (u32 old_gw, u32 daddr, u32 new_gw, u32 saddr, u8 tos, struct device *dev)
void ip_rt_send_redirect (struct sk_buff *skb)
static int ip_error (struct sk_buff *skb)
static __inline__ unsigned
short 
guess_mtu (unsigned short old_mtu)
unsigned short ip_rt_frag_needed (struct iphdr *iph, unsigned short new_mtu)
void ip_rt_update_pmtu (struct dst_entry *dst, unsigned mtu)
static int ip_rt_bug (struct sk_buff *skb)
void ip_rt_get_source (u8 *addr, struct rtable *rt)
static void rt_set_nexthop (struct rtable *rt, struct fib_result *res, u32 itag)
static int ip_route_input_mc (struct sk_buff *skb, u32 daddr, u32 saddr, u8 tos, struct device *dev, int our)
int ip_route_input_slow (struct sk_buff *skb, u32 daddr, u32 saddr, u8 tos, struct device *dev)
int ip_route_input (struct sk_buff *skb, u32 daddr, u32 saddr, u8 tos, struct device *dev)
int ip_route_output_slow (struct rtable **rp, u32 daddr, u32 saddr, u32 tos, int oif)
int ip_route_output (struct rtable **rp, u32 daddr, u32 saddr, u32 tos, int oif)
void ip_rt_multicast_event (struct in_device *in_dev)
 __initfunc (void ip_rt_init(void))

Variables

int ip_rt_min_delay = 2*HZ
int ip_rt_max_delay = 10*HZ
int ip_rt_gc_thresh = RT_HASH_DIVISOR
int ip_rt_max_size = RT_HASH_DIVISOR*16
int ip_rt_gc_timeout = RT_GC_TIMEOUT
int ip_rt_gc_interval = 60*HZ
int ip_rt_gc_min_interval = 5*HZ
int ip_rt_redirect_number = 9
int ip_rt_redirect_load = HZ/50
int ip_rt_redirect_silence = ((HZ/50) << (9+1))
int ip_rt_error_cost = HZ
int ip_rt_error_burst = 5*HZ
int ip_rt_gc_elasticity = 8
int ip_rt_mtu_expires = 10*60*HZ
int ip_rt_secret_interval = 10*60*HZ
static unsigned long rt_deadline = 0
static struct timer_list rt_flush_timer
static struct timer_list rt_periodic_timer
static struct timer_list rt_secret_timer
dst_ops ipv4_dst_ops
__u8 ip_tos2prio [16]
rtablert_hash_table [RT_HASH_DIVISOR]
static unsigned int rt_hash_rnd
static unsigned short mtu_plateau []


Define Documentation

#define IP_MAX_MTU   0xFFF0
 

Definition at line 99 of file ipv4/route.c.

Referenced by rt_set_nexthop().

#define RT_GC_TIMEOUT   (300*HZ)
 

Definition at line 101 of file ipv4/route.c.

Referenced by rt_garbage_collect().

#define RTprint a...   )     printk(KERN_DEBUG a)
 

Definition at line 120 of file ipv4/route.c.


Function Documentation

__initfunc void   ip_rt_init(void)  ) 
 

Definition at line 2042 of file ipv4/route.c.

References add_timer(), create_proc_entry(), timer_list::expires, timer_list::function, ip_fib_init(), ip_rt_gc_interval, ip_rt_secret_interval, jiffies, net_random(), proc_net_inode_operations, proc_net_register(), PROC_NET_RTCACHE, proc_dir_entry::read_proc, rt_check_expire(), rt_secret_rebuild(), and S_IFREG.

Here is the call graph for this function:

static __inline__ unsigned short guess_mtu unsigned short  old_mtu  )  [static]
 

Definition at line 857 of file ipv4/route.c.

Referenced by ip_rt_frag_needed().

static int ip_error struct sk_buff skb  )  [static]
 

Definition at line 814 of file ipv4/route.c.

References code, sk_buff::dst, EACCES, EHOSTUNREACH, EINVAL, ENETUNREACH, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, ICMP_NET_UNREACH, ICMP_PKT_FILTERED, icmp_send(), ip_rt_error_burst, ip_rt_error_cost, jiffies, now, and rtable::u.

Referenced by ip_route_input_slow().

Here is the call graph for this function:

int ip_route_input struct sk_buff skb,
u32  daddr,
u32  saddr,
u8  tos,
struct device *  dev
 

Definition at line 1378 of file ipv4/route.c.

References atomic_inc, sk_buff::dst, rt_key::dst, EINVAL, hash, rt_key::iif, ip_route_input_mc(), ip_route_input_slow(), IPTOS_TOS_MASK, jiffies, rtable::key, rt_key::oif, rt_hash_code(), rt_key::src, rt_key::tos, and rtable::u.

Referenced by arp_rcv(), ip_local_deliver(), ip_options_rcv_srr(), ip_rcv(), ipgre_err(), and ipip_err().

Here is the call graph for this function:

static int ip_route_input_mc struct sk_buff skb,
u32  daddr,
u32  saddr,
u8  tos,
struct device *  dev,
int  our
[static]
 

Definition at line 1033 of file ipv4/route.c.

References __constant_htons, atomic_set, sk_buff::dst, rt_key::dst, dst_alloc(), EINVAL, ENOBUFS, ETH_P_IP, fib_validate_source(), hash, rt_key::iif, inet_select_addr(), ip_local_deliver(), ip_mr_input(), ip_rt_bug(), rtable::key, loopback_dev, NULL, rt_key::oif, sk_buff::protocol, rtable::rt_dst, rtable::rt_flags, rtable::rt_gateway, rt_hash_code(), rtable::rt_iif, rt_intern_hash(), RT_SCOPE_LINK, rtable::rt_spec_dst, rtable::rt_src, rtable::rt_type, RTCF_LOCAL, RTCF_MULTICAST, RTN_MULTICAST, rt_key::src, rt_key::tos, rtable::u, and u32.

Referenced by ip_route_input().

Here is the call graph for this function:

int ip_route_input_slow struct sk_buff skb,
u32  daddr,
u32  saddr,
u8  tos,
struct device *  dev
 

Definition at line 1109 of file ipv4/route.c.

References __constant_htons, atomic_set, device, sk_buff::dst, rt_key::dst, dst_alloc(), EINVAL, ENOBUFS, ETH_P_IP, fib_result::fi, fib_lookup(), fib_info::fib_nhs, FIB_RES_DEV, FIB_RES_GW, FIB_RES_OIF, fib_rules_map_destination(), fib_rules_policy(), fib_select_multipath(), fib_validate_source(), hash, rt_key::iif, inet_addr_onlink(), inet_select_addr(), ip_error(), ip_forward(), ip_local_deliver(), ip_output(), ip_rt_bug(), KERN_CRIT, KERN_WARNING, rtable::key, loopback_dev, sk_buff::mac, net_ratelimit(), NULL, rt_key::oif, p, printk, sk_buff::protocol, result, rtable::rt_dst, rtable::rt_gateway, rt_hash_code(), rtable::rt_iif, rt_intern_hash(), RT_SCOPE_LINK, RT_SCOPE_UNIVERSE, rt_set_nexthop(), rtable::rt_spec_dst, rtable::rt_src, RTCF_BROADCAST, RTCF_DIRECTSRC, RTCF_DNAT, RTCF_DOREDIRECT, RTCF_FAST, RTCF_LOCAL, RTCF_MASQ, RTCF_NAT, RTN_BROADCAST, RTN_LOCAL, RTN_NAT, RTN_UNICAST, RTN_UNREACHABLE, rt_key::scope, rt_key::src, rt_key::tos, fib_result::type, rtable::u, u32, and xFFFFFFFF.

Referenced by ip_route_input().

Here is the call graph for this function:

int ip_route_output struct rtable **  rp,
u32  daddr,
u32  saddr,
u32  tos,
int  oif
 

Definition at line 1676 of file ipv4/route.c.

References atomic_inc, rt_key::dst, end_bh_atomic(), hash, rt_key::iif, ip_route_output_slow(), IPTOS_TOS_MASK, jiffies, rtable::key, rt_key::oif, rtable::rt_flags, rt_hash_code(), RTCF_TPROXY, RTO_ONLINK, RTO_TPROXY, rt_key::src, start_bh_atomic(), rt_key::tos, and rtable::u.

Referenced by arp_filter(), arp_req_delete(), arp_req_set(), icmp_reply(), icmp_send(), ip_fw_masquerade(), ip_masq_user_maddr(), ip_mc_find_dev(), ip_queue_xmit(), ip_route_connect(), ip_send_reply(), ipgre_err(), ipgre_tunnel_init(), ipgre_tunnel_xmit(), ipip6_tunnel_init(), ipip6_tunnel_xmit(), ipip_err(), ipip_tunnel_init(), ipip_tunnel_xmit(), ipmr_queue_xmit(), rarp_req_set(), raw_sendmsg(), tcp_v4_rebuild_header(), tcp_v4_send_synack(), tcp_v4_syn_recv_sock(), and udp_sendmsg().

Here is the call graph for this function:

int ip_route_output_slow struct rtable **  rp,
u32  daddr,
u32  saddr,
u32  tos,
int  oif
 

Definition at line 1433 of file ipv4/route.c.

References atomic_set, dev_get_by_index(), device, rt_key::dst, dst_alloc(), EINVAL, ENETUNREACH, ENOBUFS, ENODEV, fib_result::fi, fib_lookup(), fib_info::fib_nhs, FIB_RES_DEV, FIB_RES_PREFSRC, fib_select_default(), fib_select_multipath(), hash, htonl(), IFF_LOOPBACK, rt_key::iif, INADDR_LOOPBACK, inet_addr_type(), inet_select_addr(), ip_dev_find(), ip_local_deliver(), ip_mc_output(), ip_mr_input(), ip_output(), IPTOS_TOS_MASK, rtable::key, loopback_dev, NULL, rt_key::oif, fib_result::prefixlen, rtable::rt_dst, rtable::rt_gateway, rt_hash_code(), rtable::rt_iif, rt_intern_hash(), RT_SCOPE_HOST, RT_SCOPE_LINK, RT_SCOPE_UNIVERSE, rt_set_nexthop(), rtable::rt_spec_dst, rtable::rt_src, RTCF_BROADCAST, RTCF_LOCAL, RTCF_MULTICAST, RTCF_TPROXY, RTN_BROADCAST, RTN_LOCAL, RTN_MULTICAST, RTN_NAT, RTN_UNICAST, RTO_ONLINK, RTO_TPROXY, rt_key::scope, rt_key::src, rt_key::tos, fib_result::type, rtable::u, u32, and xFFFFFFFF.

Referenced by ip_route_output().

Here is the call graph for this function:

static int ip_rt_bug struct sk_buff skb  )  [static]
 

Definition at line 948 of file ipv4/route.c.

References sk_buff::dev, KERN_DEBUG, sk_buff::nh, and printk.

Referenced by ip_route_input_mc(), and ip_route_input_slow().

unsigned short ip_rt_frag_needed struct iphdr iph,
unsigned short  new_mtu
 

Definition at line 867 of file ipv4/route.c.

References rt_key::dst, guess_mtu(), hash, rt_key::iif, ip_rt_mtu_expires, IPTOS_TOS_MASK, rtable::key, mtu, ntohs(), rtable::rt_dst, rt_hash_code(), rtable::rt_src, RTAX_MTU, rt_key::src, rt_key::tos, u, rtable::u, u32, and u8.

Referenced by icmp_unreach().

Here is the call graph for this function:

void ip_rt_get_source u8 addr,
struct rtable rt
 

Definition at line 965 of file ipv4/route.c.

References fib_lookup(), FIB_RES_PREFSRC, rt_key::iif, inet_select_addr(), rtable::key, memcpy, rtable::rt_gateway, RT_SCOPE_UNIVERSE, rtable::rt_src, RTN_NAT, src, fib_result::type, rtable::u, and u32.

Referenced by ip_forward_options(), and ip_options_build().

Here is the call graph for this function:

void ip_rt_multicast_event struct in_device *  in_dev  ) 
 

Definition at line 1919 of file ipv4/route.c.

References rt_cache_flush().

Referenced by ip_mc_dec_group(), ip_mc_inc_group(), ip_mroute_setsockopt(), and vif_delete().

Here is the call graph for this function:

void ip_rt_redirect u32  old_gw,
u32  daddr,
u32  new_gw,
u32  saddr,
u8  tos,
struct device *  dev
 

Definition at line 630 of file ipv4/route.c.

References arp_bind_neighbour(), atomic_set, rt_key::dst, dst_alloc(), hash, rt_key::iif, inet_addr_onlink(), inet_addr_type(), ip_fib_check_default(), ip_rt_put(), IPTOS_TOS_MASK, jiffies, k, KERN_INFO, rtable::key, net_ratelimit(), ntohl(), NULL, rt_key::oif, printk, rt_del(), rt_drop(), rtable::rt_dst, rtable::rt_flags, rtable::rt_gateway, rt_hash_code(), rt_intern_hash(), rtable::rt_src, RTCF_REDIRECTED, RTN_UNICAST, rt_key::src, rt_key::tos, rtable::u, and u32.

Referenced by icmp_redirect().

Here is the call graph for this function:

void ip_rt_send_redirect struct sk_buff skb  ) 
 

Definition at line 776 of file ipv4/route.c.

References sk_buff::dst, ICMP_REDIR_HOST, ICMP_REDIRECT, icmp_send(), ip_rt_redirect_load, ip_rt_redirect_number, ip_rt_redirect_silence, jiffies, KERN_WARNING, net_ratelimit(), printk, rtable::rt_dst, rtable::rt_gateway, rtable::rt_iif, rtable::rt_src, and rtable::u.

Referenced by ip_forward().

Here is the call graph for this function:

void ip_rt_update_pmtu struct dst_entry dst,
unsigned  mtu
 

Definition at line 916 of file ipv4/route.c.

References ip_rt_mtu_expires, dst_entry::mxlock, dst_entry::pmtu, and RTAX_MTU.

Referenced by do_pmtu_discovery().

static struct dst_entry * ipv4_dst_check struct dst_entry dst,
u32 
[static]
 

Definition at line 925 of file ipv4/route.c.

References NULL.

static struct dst_entry * ipv4_dst_reroute struct dst_entry dst,
struct sk_buff
[static]
 

Definition at line 931 of file ipv4/route.c.

References NULL.

static void ipv4_link_failure struct sk_buff skb  )  [static]
 

Definition at line 937 of file ipv4/route.c.

References sk_buff::dst, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, icmp_send(), and rtable::u.

Here is the call graph for this function:

static struct dst_entry * ipv4_negative_advice struct dst_entry  )  [static]
 

Definition at line 739 of file ipv4/route.c.

References rt_key::dst, hash, ip_rt_put(), KERN_DEBUG, rtable::key, NULL, dst_entry::obsolete, rt_key::oif, printk, rt_del(), rtable::rt_dst, rtable::rt_flags, rt_hash_code(), RTCF_REDIRECTED, rt_key::src, rt_key::tos, and rtable::u.

Here is the call graph for this function:

void rt_cache_flush int  delay  ) 
 

Definition at line 365 of file ipv4/route.c.

References add_timer(), del_timer(), end_bh_atomic(), timer_list::expires, in_interrupt, ip_rt_max_delay, ip_rt_min_delay, jiffies, now, rt_deadline, rt_run_flush(), start_bh_atomic(), and user_mode.

Referenced by fib_disable_ip(), fib_flush(), fib_inetaddr_event(), fib_netdev_event(), fn_hash_delete(), fn_hash_insert(), ip_rt_multicast_event(), and rt_secret_rebuild().

Here is the call graph for this function:

static void rt_check_expire unsigned long  dummy  )  [static]
 

Definition at line 297 of file ipv4/route.c.

References add_timer(), timer_list::expires, ip_rt_gc_interval, ip_rt_gc_timeout, jiffies, now, NULL, rt_free(), RT_HASH_DIVISOR, rt_may_expire(), and rtable::u.

Referenced by __initfunc().

Here is the call graph for this function:

static void rt_del unsigned  hash,
struct rtable rt
[static]
 

Definition at line 614 of file ipv4/route.c.

References end_bh_atomic(), ip_rt_put(), rt_free(), start_bh_atomic(), and rtable::u.

Referenced by ip_rt_redirect(), and ipv4_negative_advice().

Here is the call graph for this function:

static __inline__ void rt_drop struct rtable rt  )  [static]
 

Definition at line 259 of file ipv4/route.c.

References ip_rt_put(), and rtable::u.

Referenced by ip_rt_redirect(), and rt_intern_hash().

Here is the call graph for this function:

static __inline__ int rt_fast_clean struct rtable rth  )  [static]
 

Definition at line 265 of file ipv4/route.c.

References rt_key::iif, rtable::key, rtable::rt_flags, RTCF_BROADCAST, RTCF_MULTICAST, and rtable::u.

Referenced by rt_may_expire().

static __inline__ void rt_free struct rtable rt  )  [static]
 

Definition at line 254 of file ipv4/route.c.

Referenced by rt_check_expire(), rt_del(), rt_garbage_collect(), and rt_run_flush().

static int rt_garbage_collect void   )  [static]
 

Definition at line 427 of file ipv4/route.c.

References atomic_read, end_bh_atomic(), dst_ops::entries, dst_ops::gc_thresh, in_interrupt, ip_rt_gc_elasticity, ip_rt_gc_min_interval, ip_rt_gc_timeout, ip_rt_max_size, jiffies, k, KERN_DEBUG, max, min, net_ratelimit(), now, NULL, printk, rt_free(), RT_GC_TIMEOUT, RT_HASH_DIVISOR, rt_may_expire(), start_bh_atomic(), and rtable::u.

Referenced by rt_intern_hash().

Here is the call graph for this function:

static unsigned rt_hash_code u32  daddr,
u32  saddr,
u8  tos
[static]
 

Definition at line 186 of file ipv4/route.c.

References jhash_3words(), rt_hash_rnd, u32, and xFF.

Referenced by ip_route_input(), ip_route_input_mc(), ip_route_input_slow(), ip_route_output(), ip_route_output_slow(), ip_rt_frag_needed(), ip_rt_redirect(), and ipv4_negative_advice().

Here is the call graph for this function:

static int rt_intern_hash unsigned  hash,
struct rtable rth,
struct rtable **  res
[static]
 

Definition at line 538 of file ipv4/route.c.

References arp_bind_neighbour(), atomic_inc<