There are three types of routing structures:
1,neigh_table{} structure and neighbour{} structure
The stored and native physically adjacent host address information table, often referred to as a neighbor child node, refers to the local computer adjacent to the
One-hop machine, where neigh_table{} as a data structure linked list to represent neighbour{} representing adjacent machine nodes
2, the routing rules of the storage, to determine the arrival of a network address must go through the route, using Fib_table to express
3, the caching mechanism of routing address is provided, which is expressed by using rtable linked list.
neigh_table structure
struct neigh_table
{
struct neigh_table *next;
int family;
int entry_size;
int Key_len;
__u32 (*hash) (const void *pkey, const struct net_device *);
Int (*constructor) (struct neighbour *);
Int (*pconstructor) (struct pneigh_entry *);
void (*pdestructor) (struct pneigh_entry *);
void (*proxy_redo) (struct sk_buff *skb);
Char *id;
struct neigh_parms parms;
int gc_interval;
int gc_thresh1;
int gc_thresh2;
int gc_thresh3;
unsigned long last_flush;
struct Timer_list gc_timer;
struct Timer_list proxy_timer;
struct Sk_buff_head proxy_queue;
atomic_t entries;
rwlock_t lock;
unsigned long last_rand;
struct Kmem_cache *kmem_cachep;
struct Neigh_statistics *stats;
struct neighbour **hash_buckets;
unsigned int hash_mask;
__u32 Hash_rnd;
unsigned int hash_chain_gc;
struct Pneigh_entry **phash_buckets;
#ifdef CONFIG_PROC_FS
struct Proc_dir_entry *pde;
#endif
};
struct Proc_dir_entry *pde
This member was added to Linux 2.6 with support for the proc file system, but I didn't find the proc file system
Information that is directly related to neighbor nodes is estimated to provide routing information to the user state along with other structures, possibly
is the output to the/proc/net/route inside.
struct neigh_table *next; The next neighbor table, which is actually the next machine where the ARP message arrives.
int family;//address family, for Ethernet is af_inet
int entry_size; The entry length, which is the size of a neighbor structure, is initialized to sizeof (neighbour) +4 (4 is the length of an IP address)
The hash key value length, which is the length of the IP address, is 4
int Key_len;
__u32 (*hash) (const void *pkey, const struct net_device *); Constructs a hash function that stores and retrieves the neighbour of this neigh_table
Allow the upper limit of the neighbor, depending on the type of network, size will vary, such as class C address, neighbor limit should be less than 255
int GC_THRESH3
Hash array, in which the neighbors, in a neigh_table, can have a maximum of 32 neighbour structure of the linked list.
struct neighbour **hash_buckets;
int entries//number of neighbors in the entire neigh_table
unsigned int hash_mask; Mask for hash array size
neighbour structure
struct neighbour
{
struct neighbour *next;
struct neigh_table *tbl;
struct Neigh_parms *parms;
struct Net_device *dev;
unsigned long used;