diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-05-15 15:05:00 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-05-15 15:05:00 -0700 |
commit | d798c27bfa776ac437b33981e66aecc1485df12d (patch) | |
tree | 0998d03c892f2f4be9c9b8a09511c112bf906d79 | |
parent | b805b43fde589feee4823145e1dc7b5ac5d4f080 (diff) | |
download | quagga-d798c27bfa776ac437b33981e66aecc1485df12d.tar.bz2 quagga-d798c27bfa776ac437b33981e66aecc1485df12d.tar.xz |
Rearrange RIB structures to save memory
The RIB data structures have lots of "holes" due to compiler alignment.
Since Quagga has to deal with large route tables, rearrange the elements
to save space.
-rw-r--r-- | zebra/rib.h | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/zebra/rib.h b/zebra/rib.h index 9621f2c8..f3572ffa 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -38,10 +38,6 @@ union g_addr { struct rib { - /* Status Flags for the *route_node*, but kept in the head RIB.. */ - u_char rn_status; -#define RIB_ROUTE_QUEUED (1 << 0) - /* Link list. */ struct rib *next; struct rib *prev; @@ -49,20 +45,24 @@ struct rib /* Nexthop structure */ struct nexthop *nexthop; - /* Refrence count. */ + /* Reference count. */ unsigned long refcnt; /* Uptime. */ time_t uptime; - /* Type fo this route. */ - int type; + /* Metric */ + u_int32_t metric; /* Which routing table */ - int table; + u_int32_t table; - /* Metric */ - u_int32_t metric; + /* Type for this route. < ZEBRA_ROUTE_MAX */ + u_int8_t type; + + /* Status Flags for the *route_node*, but kept in the head RIB.. */ + u_char rn_status; +#define RIB_ROUTE_QUEUED (1 << 0) /* Distance. */ u_char distance; @@ -90,6 +90,13 @@ struct static_ipv4 struct static_ipv4 *prev; struct static_ipv4 *next; + /* Nexthop value. */ + union + { + struct in_addr ipv4; + char *ifname; + } gate; + /* Administrative distance. */ u_char distance; @@ -99,13 +106,6 @@ struct static_ipv4 #define STATIC_IPV4_IFNAME 2 #define STATIC_IPV4_BLACKHOLE 3 - /* Nexthop value. */ - union - { - struct in_addr ipv4; - char *ifname; - } gate; - /* bit flags */ u_char flags; /* @@ -122,6 +122,10 @@ struct static_ipv6 struct static_ipv6 *prev; struct static_ipv6 *next; + /* Nexthop value. */ + struct in6_addr ipv6; + char *ifname; + /* Administrative distance. */ u_char distance; @@ -130,11 +134,6 @@ struct static_ipv6 #define STATIC_IPV6_GATEWAY 1 #define STATIC_IPV6_GATEWAY_IFNAME 2 #define STATIC_IPV6_IFNAME 3 - - /* Nexthop value. */ - struct in6_addr ipv6; - char *ifname; - /* bit flags */ u_char flags; /* @@ -166,22 +165,24 @@ struct nexthop /* Interface index. */ char *ifname; unsigned int ifindex; + + /* Nexthop address or interface name. */ + union g_addr gate; + + unsigned int rifindex; + union g_addr rgate; + union g_addr src; - enum nexthop_types_t type; +/* Really enum nexthop_types_t but safe space */ + u_char type; u_char flags; #define NEXTHOP_FLAG_ACTIVE (1 << 0) /* This nexthop is alive. */ #define NEXTHOP_FLAG_FIB (1 << 1) /* FIB nexthop. */ #define NEXTHOP_FLAG_RECURSIVE (1 << 2) /* Recursive nexthop. */ - /* Nexthop address or interface name. */ - union g_addr gate; - /* Recursive lookup nexthop. */ u_char rtype; - unsigned int rifindex; - union g_addr rgate; - union g_addr src; }; /* Routing table instance. */ |