#include "vrf.h"
#include "vty.h"
+#include "zebra/zebra_router.h"
#include "zebra/debug.h"
#include "zebra/zapi_msg.h"
#include "zebra/rib.h"
#include "zebra/zebra_mpls.h"
#include "zebra/zebra_vxlan.h"
#include "zebra/zebra_netns_notify.h"
+#include "zebra/zebra_routemap.h"
extern struct zebra_t zebrad;
static int zebra_vrf_disable(struct vrf *vrf)
{
struct zebra_vrf *zvrf = vrf->info;
- struct route_table *table;
struct interface *ifp;
afi_t afi;
safi_t safi;
/* Cleanup (free) routing tables and NHT tables. */
for (afi = AFI_IP; afi <= AFI_IP6; afi++) {
- void *table_info;
-
- for (safi = SAFI_UNICAST; safi <= SAFI_MULTICAST; safi++) {
- table = zvrf->table[afi][safi];
- table_info = table->info;
- route_table_finish(table);
- XFREE(MTYPE_RIB_TABLE_INFO, table_info);
+ /*
+ * Set the table pointer to NULL as that
+ * we no-longer need a copy of it, nor do we
+ * own this data, the zebra_router structure
+ * owns these tables. Once we've cleaned up the
+ * table, see rib_close_table above
+ * we no-longer need this pointer.
+ */
+ for (safi = SAFI_UNICAST; safi <= SAFI_MULTICAST; safi++)
zvrf->table[afi][safi] = NULL;
- }
route_table_finish(zvrf->rnh_table[afi]);
zvrf->rnh_table[afi] = NULL;
for (safi = SAFI_UNICAST; safi <= SAFI_MULTICAST; safi++) {
table = zvrf->table[afi][safi];
if (table) {
- table_info = table->info;
+ table_info = route_table_get_info(table);
route_table_finish(table);
XFREE(MTYPE_RIB_TABLE_INFO, table_info);
}
assert(!zvrf->table[afi][safi]);
- if (afi == AFI_IP6)
- table = srcdest_table_init();
- else
- table = route_table_init();
+ table = zebra_router_get_table(zvrf, zvrf->table_id, afi, safi);
+
table->cleanup = zebra_rtable_node_cleanup;
zvrf->table[afi][safi] = table;
+ XFREE(MTYPE_RIB_TABLE_INFO, table->info);
info = XCALLOC(MTYPE_RIB_TABLE_INFO, sizeof(*info));
info->zvrf = zvrf;
info->afi = afi;
info->safi = safi;
- table->info = info;
+ route_table_set_info(table, info);
}
/* Allocate new zebra VRF. */
vrf_id_t vrf_id)
{
struct zebra_vrf *zvrf;
- struct zebra_ns *zns;
zvrf = vrf_info_lookup(vrf_id);
if (!zvrf)
return NULL;
- zns = zvrf->zns;
-
if (afi >= AFI_MAX)
return NULL;
* so in all cases, it does not use specific table
* so it is possible to configure tables in this VRF
*/
- return zebra_ns_get_table(zns, zvrf, table_id, afi);
+ return zebra_router_get_table(zvrf, table_id, afi,
+ SAFI_UNICAST);
}
}
if (zvrf_id(zvrf) == VRF_DEFAULT) {
if (zvrf->l3vni)
vty_out(vty, "vni %u\n", zvrf->l3vni);
- vty_out(vty, "!\n");
} else {
vty_frame(vty, "vrf %s\n", zvrf_name(zvrf));
if (zvrf->l3vni)
? " prefix-routes-only"
: "");
zebra_ns_config_write(vty, (struct ns *)vrf->ns_ctxt);
-
}
+ zebra_routemap_config_write_protocol(vty, zvrf);
+
if (zvrf_id(zvrf) != VRF_DEFAULT)
vty_endframe(vty, " exit-vrf\n!\n");
+ else
+ vty_out(vty, "!\n");
}
return 0;
}