diff options
Diffstat (limited to 'zebra/rib.h')
-rw-r--r-- | zebra/rib.h | 122 |
1 files changed, 42 insertions, 80 deletions
diff --git a/zebra/rib.h b/zebra/rib.h index 1dacc7f7..a916aa99 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -27,18 +27,10 @@ #include "prefix.h" #include "table.h" #include "queue.h" +#include "nexthop.h" #define DISTANCE_INFINITY 255 -/* Routing information base. */ - -union g_addr { - struct in_addr ipv4; -#ifdef HAVE_IPV6 - struct in6_addr ipv6; -#endif /* HAVE_IPV6 */ -}; - struct rib { /* Link list. */ @@ -73,6 +65,9 @@ struct rib /* Distance. */ u_char distance; + /* Tag */ + u_short tag; + /* Flags of this route. * This flag's definition is in lib/zebra.h ZEBRA_FLAG_* and is exposed * to clients via Zserv @@ -81,9 +76,10 @@ struct rib /* RIB internal status */ u_char status; -#define RIB_ENTRY_REMOVED (1 << 0) -#define RIB_ENTRY_CHANGED (1 << 1) -#define RIB_ENTRY_SELECTED_FIB (1 << 2) +#define RIB_ENTRY_REMOVED (1 << 0) + /* to simplify NHT logic when NHs change, instead of doing a NH by NH cmp */ +#define RIB_ENTRY_NEXTHOPS_CHANGED (1 << 1) +#define RIB_ENTRY_SELECTED_FIB (1 << 2) /* Nexthop information. */ u_char nexthop_num; @@ -186,6 +182,9 @@ struct static_route /* Administrative distance. */ u_char distance; + /* Tag */ + u_short tag; + /* Flag for this static route's type. */ u_char type; #define STATIC_IPV4_GATEWAY 1 @@ -207,50 +206,6 @@ struct static_route */ }; -enum nexthop_types_t -{ - NEXTHOP_TYPE_IFINDEX = 1, /* Directly connected. */ - NEXTHOP_TYPE_IFNAME, /* Interface route. */ - NEXTHOP_TYPE_IPV4, /* IPv4 nexthop. */ - NEXTHOP_TYPE_IPV4_IFINDEX, /* IPv4 nexthop with ifindex. */ - NEXTHOP_TYPE_IPV4_IFNAME, /* IPv4 nexthop with ifname. */ - NEXTHOP_TYPE_IPV6, /* IPv6 nexthop. */ - NEXTHOP_TYPE_IPV6_IFINDEX, /* IPv6 nexthop with ifindex. */ - NEXTHOP_TYPE_IPV6_IFNAME, /* IPv6 nexthop with ifname. */ - NEXTHOP_TYPE_BLACKHOLE, /* Null0 nexthop. */ -}; - -/* Nexthop structure. */ -struct nexthop -{ - struct nexthop *next; - struct nexthop *prev; - - /* Interface index. */ - char *ifname; - ifindex_t ifindex; - - enum nexthop_types_t 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. */ -#define NEXTHOP_FLAG_ONLINK (1 << 3) /* Nexthop should be installed onlink. */ - - /* Nexthop address */ - union g_addr gate; - union g_addr src; - - /* Nexthops obtained by recursive resolution. - * - * If the nexthop struct needs to be resolved recursively, - * NEXTHOP_FLAG_RECURSIVE will be set in flags and the nexthops - * obtained by recursive resolution will be added to `resolved'. - * Only one level of recursive resolution is currently supported. */ - struct nexthop *resolved; -}; - /* The following for loop allows to iterate over the nexthop * structure of routes. * @@ -297,15 +252,6 @@ struct nexthop : ((tnexthop) = (nexthop)->next)) \ : (((recursing) = 0),((tnexthop) = (tnexthop)->next))) -/* Structure holding nexthop & VRF identifier, - * used for applying the route-map. */ -struct nexthop_vrfid -{ - struct nexthop *nexthop; - vrf_id_t vrf_id; -}; - - #if defined (HAVE_RTADV) /* Structure which hold status of router advertisement. */ struct rtadv @@ -370,6 +316,9 @@ struct zebra_vrf #if defined (HAVE_RTADV) struct rtadv rtadv; #endif /* HAVE_RTADV */ + + /* Recursive Nexthop table */ + struct route_table *rnh_table[AFI_MAX]; }; /* @@ -425,15 +374,19 @@ extern void multicast_mode_ipv4_set (enum multicast_mode mode); extern enum multicast_mode multicast_mode_ipv4_get (void); extern const char *nexthop_type_to_str (enum nexthop_types_t nh_type); -extern struct nexthop *nexthop_ifindex_add (struct rib *, ifindex_t); -extern struct nexthop *nexthop_ifname_add (struct rib *, char *); -extern struct nexthop *nexthop_blackhole_add (struct rib *); -extern struct nexthop *nexthop_ipv4_add (struct rib *, struct in_addr *, - struct in_addr *); -extern struct nexthop *nexthop_ipv4_ifindex_add (struct rib *, - struct in_addr *, - struct in_addr *, - ifindex_t); +extern struct nexthop *rib_nexthop_ifindex_add (struct rib *, ifindex_t); +extern struct nexthop *rib_nexthop_ifname_add (struct rib *, char *); +extern struct nexthop *rib_nexthop_blackhole_add (struct rib *); +extern struct nexthop *rib_nexthop_ipv4_add (struct rib *, struct in_addr *, + struct in_addr *); +extern struct nexthop *rib_nexthop_ipv4_ifindex_add (struct rib *, + struct in_addr *, + struct in_addr *, + ifindex_t); + +extern void rib_nexthop_add (struct rib *rib, struct nexthop *nexthop); +extern void rib_copy_nexthops (struct rib *rib, struct nexthop *nexthop); + extern int nexthop_has_fib_child(struct nexthop *); extern void rib_lookup_and_dump (struct prefix_ipv4 *); extern void rib_lookup_and_pushup (struct prefix_ipv4 *); @@ -448,8 +401,11 @@ extern int rib_lookup_ipv4_route (struct prefix_ipv4 *, union sockunion *, #define ZEBRA_RIB_FOUND_CONNECTED 2 #define ZEBRA_RIB_NOTFOUND 3 -extern struct nexthop *nexthop_ipv6_add (struct rib *, struct in6_addr *); +extern struct nexthop *rib_nexthop_ipv6_add (struct rib *, struct in6_addr *); +extern struct nexthop *rib_nexthop_ipv6_ifindex_add (struct rib *rib, + struct in6_addr *ipv6, ifindex_t ifindex); +extern struct zebra_vrf *zebra_vrf_lookup (vrf_id_t vrf_id); extern struct zebra_vrf *zebra_vrf_alloc (vrf_id_t); extern struct route_table *zebra_vrf_table (afi_t, safi_t, vrf_id_t); extern struct route_table *zebra_vrf_static_table (afi_t, safi_t, vrf_id_t); @@ -469,7 +425,7 @@ extern int rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p, vrf_id_t, safi_t safi); extern struct rib *rib_match_ipv4_safi (struct in_addr addr, safi_t safi, - int skip_bgp, struct route_node **rn_out, + struct route_node **rn_out, vrf_id_t); extern struct rib *rib_match_ipv4_multicast (struct in_addr addr, struct route_node **rn_out, @@ -484,14 +440,17 @@ extern void rib_close_table (struct route_table *); extern void rib_close (void); extern void rib_init (void); extern unsigned long rib_score_proto (u_char proto); +struct zebra_t; +extern void rib_queue_add (struct zebra_t *zebra, struct route_node *rn); + extern int static_add_ipv4_safi (safi_t safi, struct prefix *p, struct in_addr *gate, - const char *ifname, u_char flags, u_char distance, + const char *ifname, u_char flags, u_short tag, u_char distance, vrf_id_t vrf_id); extern int static_delete_ipv4_safi (safi_t safi, struct prefix *p, struct in_addr *gate, - const char *ifname, u_char distance, vrf_id_t vrf_id); + const char *ifname, u_short tag, u_char distance, vrf_id_t vrf_id); extern int rib_add_ipv6 (int type, int flags, struct prefix_ipv6 *p, @@ -511,12 +470,15 @@ extern struct route_table *rib_table_ipv6; extern int static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, - const char *ifname, u_char flags, u_char distance, + const char *ifname, u_char flags, u_short tag, u_char distance, vrf_id_t vrf_id); extern int +rib_add_ipv6_multipath (struct prefix_ipv6 *, struct rib *, safi_t); + +extern int static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, - const char *ifname, u_char distance, vrf_id_t vrf_id); + const char *ifname, u_short tag, u_char distance, vrf_id_t vrf_id); extern int rib_gc_dest (struct route_node *rn); extern struct route_table *rib_tables_iter_next (rib_tables_iter_t *iter); |