summaryrefslogtreecommitdiff
path: root/zebra/zebra_vrf.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-08-27 10:43:37 -0400
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-10-24 06:52:07 -0400
commit89272910f738c05ba7986e7d91c14dc0eb1f6ba6 (patch)
treebbf83ea49b2b84b0264e763c656f21158d1c2670 /zebra/zebra_vrf.c
parent82d6d6e9be004cd8dbe88b0603f6420fcd80a0a5 (diff)
zebra: Start breakup of zns into zrouter and zns
The `struct zebra_ns` data structure is being used for both router information as well as support for the vrf backend( as appropriate ). This is a confusing state. Start the movement of `struct zebra_ns` into 2 things `struct zebra_router` and `struct zebra_ns`. In this new regime `struct zebra_router` is purely for handling data about the router. It has no knowledge of the underlying representation of the Data Plane. `struct zebra_ns` becomes a linux specific bit of code that allows us to handle the vrf backend and is allowed to have knowledge about underlying data plane constructs. When someone implements a *bsd backend the zebra_vrf data structure will need to be abstracted to take advantage of this instead of relying on zebra_ns. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'zebra/zebra_vrf.c')
-rw-r--r--zebra/zebra_vrf.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c
index a1692d3c3e..e98a533609 100644
--- a/zebra/zebra_vrf.c
+++ b/zebra/zebra_vrf.c
@@ -28,6 +28,7 @@
#include "vrf.h"
#include "vty.h"
+#include "zebra/zebra_router.h"
#include "zebra/debug.h"
#include "zebra/zapi_msg.h"
#include "zebra/rib.h"
@@ -144,7 +145,6 @@ static int zebra_vrf_enable(struct vrf *vrf)
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;
@@ -202,15 +202,16 @@ static int zebra_vrf_disable(struct vrf *vrf)
/* 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 = route_table_get_info(table);
- 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;
@@ -374,10 +375,8 @@ static void zebra_vrf_table_create(struct zebra_vrf *zvrf, afi_t afi,
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;
@@ -442,14 +441,11 @@ struct route_table *zebra_vrf_other_route_table(afi_t afi, uint32_t table_id,
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;
@@ -461,7 +457,8 @@ struct route_table *zebra_vrf_other_route_table(afi_t afi, uint32_t table_id,
* 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);
}
}