{ MTYPE_STATIC_IPV4, "Static IPv4 route" },
{ MTYPE_STATIC_IPV6, "Static IPv6 route" },
{ MTYPE_RIB_DEST, "RIB destination" },
+ { MTYPE_RIB_TABLE_INFO, "RIB table info" },
{ -1, NULL },
};
struct route_table *stable[AFI_MAX][SAFI_MAX];
};
+/*
+ * rib_table_info_t
+ *
+ * Structure that is hung off of a route_table that holds information about
+ * the table.
+ */
+typedef struct rib_table_info_t_
+{
+
+ /*
+ * Back pointer to vrf.
+ */
+ struct vrf *vrf;
+ afi_t afi;
+ safi_t safi;
+
+} rib_table_info_t;
+
extern struct nexthop *nexthop_ifindex_add (struct rib *, unsigned int);
extern struct nexthop *nexthop_ifname_add (struct rib *, char *);
extern struct nexthop *nexthop_blackhole_add (struct rib *);
* Inline functions.
*/
+/*
+ * rib_table_info
+ */
+static inline rib_table_info_t *
+rib_table_info (struct route_table *table)
+{
+ return (rib_table_info_t *) table->info;
+}
+
/*
* rib_dest_from_rnode
*/
return dest->rnode->table;
}
+/*
+ * rib_dest_vrf
+ */
+static inline struct vrf *
+rib_dest_vrf (rib_dest_t *dest)
+{
+ return rib_table_info (rib_dest_table (dest))->vrf;
+}
+
#endif /*_ZEBRA_RIB_H */
/* Vector for routing table. */
static vector vrf_vector;
+/*
+ * vrf_table_create
+ */
+static void
+vrf_table_create (struct vrf *vrf, afi_t afi, safi_t safi)
+{
+ rib_table_info_t *info;
+ struct route_table *table;
+
+ assert (!vrf->table[afi][safi]);
+
+ table = route_table_init ();
+ vrf->table[afi][safi] = table;
+
+ info = XCALLOC (MTYPE_RIB_TABLE_INFO, sizeof (*info));
+ info->vrf = vrf;
+ info->afi = afi;
+ info->safi = safi;
+ table->info = info;
+}
+
/* Allocate new VRF. */
static struct vrf *
vrf_alloc (const char *name)
vrf->name = XSTRDUP (MTYPE_VRF_NAME, name);
/* Allocate routing table and static table. */
- vrf->table[AFI_IP][SAFI_UNICAST] = route_table_init ();
- vrf->table[AFI_IP6][SAFI_UNICAST] = route_table_init ();
+ vrf_table_create (vrf, AFI_IP, SAFI_UNICAST);
+ vrf_table_create (vrf, AFI_IP6, SAFI_UNICAST);
vrf->stable[AFI_IP][SAFI_UNICAST] = route_table_init ();
vrf->stable[AFI_IP6][SAFI_UNICAST] = route_table_init ();
- vrf->table[AFI_IP][SAFI_MULTICAST] = route_table_init ();
- vrf->table[AFI_IP6][SAFI_MULTICAST] = route_table_init ();
+ vrf_table_create (vrf, AFI_IP, SAFI_MULTICAST);
+ vrf_table_create (vrf, AFI_IP6, SAFI_MULTICAST);
vrf->stable[AFI_IP][SAFI_MULTICAST] = route_table_init ();
vrf->stable[AFI_IP6][SAFI_MULTICAST] = route_table_init ();