This section describesically about the basic concepts of IP routes and internal data structures. Linux is routed to maintain three data structures, a route for nodes directly physically with this node, other two cases for adjacent to other indirect nodes. The former is called Neighbor Table, which saves the type of device and protocol to each node, Linux uses the ARP protocol to maintain the table. Each of these entries are Soft State. LINUX uses the latter routing table to maintain the IP address: Forward Infomation Base (FIB) saves routing information to all serdant nodes. And another smaller and faster Route Cache, saving frequently used routing information. When the system is going out, it first checks if the route exists in the route cache. If not, check the FIB. If you find it, put this entry into the Route Cache, and then return. The entries in the FIB generally do not change, unless the router is restarted, or the entry in the route cache will be removed from the route cache in the route cache if the entries in the router are restarted or Down. 138 #ifndef CONFIG_IP_MULTIPLE_TABLES139 140 extern struct fib_table * local_table; 141 extern struct fib_table * main_table; 169 #else / * CONFIG_IP_MULTIPLE_TABLES * / 170 #define local_table (fib_tables [RT_TABLE_LOCAL]) 171 #define main_table (fib_tables [RT_TABLE_MAIN]) ¢ local_table, main_table It is a global pointer variable to access the FIB table. FIB TABLE FIB_TABLE Structure: INT (* TB_Functions) () - Points a function that manipulates the table (Lookup, Delete, Insert, etc.), which is set by Fn_hash_Function () when the system is initialized. Unsigned char TB_DATA [0] - points to the correlated FIB HASH TABLE pointer. Unsigned char TB_ID-TABLE IDENTIFIER, for local_table is 255, which is 254 for main_table. UNSIGNED TB_STAMPNETMASK TABLE FN_HASH Structure: In Net / IPv4 / Fib_hash.c- This structure contains pointers to Individual Zones and organizes according to Netmask. (Each Zone corresponds to a specific network mask, so there are 32 all zero = 33. Struct fn_zone * fn_zones [33] - pointing to the pointer array of Zone Entry, fn_zone [0] points to the 0x8000, fn_zone [1] points to 0x8000, Fn_Zone [32] points to zone 0xfffff. Struct fn_zone * fn_zone_list: Point to the first non-empty zone, if 0xfffFFFFFFFFFFFFFFF is NTRY.
Network Zone FN_ZONE Structure: NET / IPv4 / Fib_hash.c, this structure contains Hash information and pointers to the Hash Table node. Each NetMask corresponds to one. Struct fn_zone * fz_next-points to the next zone in the Hash structure (for example, fz_next may be fn_hash-> fn_zone [27]. struct fib_node ** fn_hash-pointer to a hash Table of .. nodes for this zone int fz_nent-the number of entries (nodes) in this zone int fx_divisor-the number of buckets in the hash table associated with this zone; there are 16 buckets in the table for most zones (except the first zone -0000 - the loopback device). U32 FZ_HASHMASK - A Mask for Entering The Hash Table of Nodes; 15 (0x0F) for MOST ZONES, 0 for zone 0). Int FZ_ORDER - THE INDEX OF THIS ZONE IN THEENT FN_HASH STRUCTURE (0 TO 32 FZ_MASK - THE ZONE NETMASK Defined AS ~ ((1 << (32-FZ_ORDER)) - 1); for Example, THE FIRST (ZERO) Element IS 1 Shifted Left 32 Minus 0 Times (0x10000), Minus 1 (0xfffff), and complement (0x0000). The Second Element Has a Netmask of 0x8000, The next 0xc000, the next oxe000, 0xF0000, 0xF8000, And So On To The Last (32D) Element Whos e mask is oxffff.network node information fab_node structure - NET / IPv4 / FIB_HASH.C - This structure contains uniquely specific information for an address set, and a pointer to universal properties (such as devices and protocols). struct fib_node * fn_next - pointer to the next node struct fib_info * fn_info -. pointer to more information about this node (that is shared by many nodes) fn_key_t fn_key -. hash table key - the least significant 8 bits of the destination address (or 0 for the loopback device). Other Fields Include Specific Information About this node (like fn_tos and fn_state).