summaryrefslogtreecommitdiff
path: root/zebra/redistribute.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/redistribute.c')
-rw-r--r--zebra/redistribute.c114
1 files changed, 57 insertions, 57 deletions
diff --git a/zebra/redistribute.c b/zebra/redistribute.c
index 2de0917a7e..66dc5b4b5f 100644
--- a/zebra/redistribute.c
+++ b/zebra/redistribute.c
@@ -35,10 +35,10 @@
/* array holding redistribute info about table redistribution */
/* bit AFI is set if that AFI is redistributing routes from this table */
-static int zebra_import_table_used[AFI_MAX][ZEBRA_KERNEL_TABLE_MAX];
-static uint32_t zebra_import_table_distance[AFI_MAX][ZEBRA_KERNEL_TABLE_MAX];
+static int zebra_import_table_used[AFI_MAX][SAFI_MAX][ZEBRA_KERNEL_TABLE_MAX];
+static uint32_t zebra_import_table_distance[AFI_MAX][SAFI_MAX][ZEBRA_KERNEL_TABLE_MAX];
-int is_zebra_import_table_enabled(afi_t afi, vrf_id_t vrf_id, uint32_t table_id)
+int is_zebra_import_table_enabled(afi_t afi, safi_t safi, vrf_id_t vrf_id, uint32_t table_id)
{
/*
* Make sure that what we are called with actualy makes sense
@@ -46,9 +46,12 @@ int is_zebra_import_table_enabled(afi_t afi, vrf_id_t vrf_id, uint32_t table_id)
if (afi == AFI_MAX)
return 0;
+ if (safi == SAFI_MAX)
+ return 0;
+
if (is_zebra_valid_kernel_table(table_id) &&
table_id < ZEBRA_KERNEL_TABLE_MAX)
- return zebra_import_table_used[afi][table_id];
+ return zebra_import_table_used[afi][safi][table_id];
return 0;
}
@@ -687,7 +690,7 @@ void zebra_interface_vrf_update_add(struct interface *ifp, vrf_id_t old_vrf_id)
}
}
-int zebra_add_import_table_entry(struct zebra_vrf *zvrf, struct route_node *rn,
+int zebra_add_import_table_entry(struct zebra_vrf *zvrf, safi_t safi, struct route_node *rn,
struct route_entry *re, const char *rmap_name)
{
struct route_entry *newre;
@@ -705,7 +708,7 @@ int zebra_add_import_table_entry(struct zebra_vrf *zvrf, struct route_node *rn,
if (ret != RMAP_PERMITMATCH) {
UNSET_FLAG(re->flags, ZEBRA_FLAG_SELECTED);
- zebra_del_import_table_entry(zvrf, rn, re);
+ zebra_del_import_table_entry(zvrf, safi, rn, re);
return 0;
}
@@ -724,26 +727,26 @@ int zebra_add_import_table_entry(struct zebra_vrf *zvrf, struct route_node *rn,
if (same) {
UNSET_FLAG(same->flags, ZEBRA_FLAG_SELECTED);
- zebra_del_import_table_entry(zvrf, rn, same);
+ zebra_del_import_table_entry(zvrf, safi, rn, same);
}
UNSET_FLAG(re->flags, ZEBRA_FLAG_RR_USE_DISTANCE);
- newre = zebra_rib_route_entry_new(
- 0, ZEBRA_ROUTE_TABLE, re->table, re->flags, re->nhe_id,
- zvrf->table_id, re->metric, re->mtu,
- zebra_import_table_distance[afi][re->table], re->tag);
+ newre = zebra_rib_route_entry_new(0, ZEBRA_ROUTE_TABLE, re->table, re->flags, re->nhe_id,
+ zvrf->table_id, re->metric, re->mtu,
+ zebra_import_table_distance[afi][safi][re->table],
+ re->tag);
ng = nexthop_group_new();
copy_nexthops(&ng->nexthop, re->nhe->nhg.nexthop, NULL);
- rib_add_multipath(afi, SAFI_UNICAST, &p, NULL, newre, ng, false);
+ rib_add_multipath(afi, safi, &p, NULL, newre, ng, false);
nexthop_group_delete(&ng);
return 0;
}
-int zebra_del_import_table_entry(struct zebra_vrf *zvrf, struct route_node *rn,
+int zebra_del_import_table_entry(struct zebra_vrf *zvrf, safi_t safi, struct route_node *rn,
struct route_entry *re)
{
struct prefix p;
@@ -752,17 +755,16 @@ int zebra_del_import_table_entry(struct zebra_vrf *zvrf, struct route_node *rn,
afi = family2afi(rn->p.family);
prefix_copy(&p, &rn->p);
- rib_delete(afi, SAFI_UNICAST, zvrf->vrf->vrf_id, ZEBRA_ROUTE_TABLE,
- re->table, re->flags, &p, NULL, re->nhe->nhg.nexthop,
- re->nhe_id, zvrf->table_id, re->metric, re->distance,
+ rib_delete(afi, safi, zvrf->vrf->vrf_id, ZEBRA_ROUTE_TABLE, re->table, re->flags, &p, NULL,
+ re->nhe->nhg.nexthop, re->nhe_id, zvrf->table_id, re->metric, re->distance,
false);
return 0;
}
/* Assuming no one calls this with the main routing table */
-int zebra_import_table(afi_t afi, vrf_id_t vrf_id, uint32_t table_id,
- uint32_t distance, const char *rmap_name, int add)
+int zebra_import_table(afi_t afi, safi_t safi, vrf_id_t vrf_id, uint32_t table_id,
+ uint32_t distance, const char *rmap_name, bool add)
{
struct route_table *table;
struct route_entry *re;
@@ -776,38 +778,39 @@ int zebra_import_table(afi_t afi, vrf_id_t vrf_id, uint32_t table_id,
if (afi >= AFI_MAX)
return -1;
+ if (safi >= SAFI_MAX)
+ return -1;
+
+ /* Always import from the URIB sub-table */
table = zebra_vrf_get_table_with_table_id(afi, SAFI_UNICAST, vrf_id,
table_id);
if (table == NULL) {
return 0;
} else if (IS_ZEBRA_DEBUG_RIB) {
- zlog_debug("%s routes from table %d",
- add ? "Importing" : "Unimporting", table_id);
+ zlog_debug("%s routes from table %d into %s", add ? "Importing" : "Unimporting",
+ table_id, safi2str(safi));
}
if (add) {
if (rmap_name)
- zebra_add_import_table_route_map(afi, rmap_name,
- table_id);
+ zebra_add_import_table_route_map(afi, safi, rmap_name, table_id);
else {
- rmap_name =
- zebra_get_import_table_route_map(afi, table_id);
+ rmap_name = zebra_get_import_table_route_map(afi, safi, table_id);
if (rmap_name) {
- zebra_del_import_table_route_map(afi, table_id);
+ zebra_del_import_table_route_map(afi, safi, table_id);
rmap_name = NULL;
}
}
- zebra_import_table_used[afi][table_id] = 1;
- zebra_import_table_distance[afi][table_id] = distance;
+ zebra_import_table_used[afi][safi][table_id] = 1;
+ zebra_import_table_distance[afi][safi][table_id] = distance;
} else {
- zebra_import_table_used[afi][table_id] = 0;
- zebra_import_table_distance[afi][table_id] =
- ZEBRA_TABLE_DISTANCE_DEFAULT;
+ zebra_import_table_used[afi][safi][table_id] = 0;
+ zebra_import_table_distance[afi][safi][table_id] = ZEBRA_TABLE_DISTANCE_DEFAULT;
- rmap_name = zebra_get_import_table_route_map(afi, table_id);
+ rmap_name = zebra_get_import_table_route_map(afi, safi, table_id);
if (rmap_name) {
- zebra_del_import_table_route_map(afi, table_id);
+ zebra_del_import_table_route_map(afi, safi, table_id);
rmap_name = NULL;
}
}
@@ -831,10 +834,9 @@ int zebra_import_table(afi_t afi, vrf_id_t vrf_id, uint32_t table_id,
if (((afi == AFI_IP) && (rn->p.family == AF_INET))
|| ((afi == AFI_IP6) && (rn->p.family == AF_INET6))) {
if (add)
- zebra_add_import_table_entry(zvrf, rn, re,
- rmap_name);
+ zebra_add_import_table_entry(zvrf, safi, rn, re, rmap_name);
else
- zebra_del_import_table_entry(zvrf, rn, re);
+ zebra_del_import_table_entry(zvrf, safi, rn, re);
}
}
return 0;
@@ -844,26 +846,27 @@ int zebra_import_table_config(struct vty *vty, vrf_id_t vrf_id)
{
int i;
afi_t afi;
+ safi_t safi;
int write = 0;
char afi_str[AFI_MAX][10] = {"", "ip", "ipv6", "ethernet"};
const char *rmap_name;
- for (afi = AFI_IP; afi < AFI_MAX; afi++) {
+ FOREACH_AFI_SAFI (afi, safi) {
for (i = 1; i < ZEBRA_KERNEL_TABLE_MAX; i++) {
- if (!is_zebra_import_table_enabled(afi, vrf_id, i))
+ if (!is_zebra_import_table_enabled(afi, safi, vrf_id, i))
continue;
- if (zebra_import_table_distance[afi][i]
- != ZEBRA_TABLE_DISTANCE_DEFAULT) {
- vty_out(vty, "%s import-table %d distance %d",
- afi_str[afi], i,
- zebra_import_table_distance[afi][i]);
+ if (zebra_import_table_distance[afi][safi][i] !=
+ ZEBRA_TABLE_DISTANCE_DEFAULT) {
+ vty_out(vty, "%s import-table %d %sdistance %d", afi_str[afi], i,
+ (safi == SAFI_MULTICAST ? "mrib " : ""),
+ zebra_import_table_distance[afi][safi][i]);
} else {
- vty_out(vty, "%s import-table %d", afi_str[afi],
- i);
+ vty_out(vty, "%s import-table %d%s", afi_str[afi], i,
+ (safi == SAFI_MULTICAST ? " mrib" : ""));
}
- rmap_name = zebra_get_import_table_route_map(afi, i);
+ rmap_name = zebra_get_import_table_route_map(afi, safi, i);
if (rmap_name)
vty_out(vty, " route-map %s", rmap_name);
@@ -875,21 +878,19 @@ int zebra_import_table_config(struct vty *vty, vrf_id_t vrf_id)
return write;
}
-static void zebra_import_table_rm_update_vrf_afi(struct zebra_vrf *zvrf,
- afi_t afi, int table_id,
- const char *rmap)
+static void zebra_import_table_rm_update_vrf_afi(struct zebra_vrf *zvrf, afi_t afi, safi_t safi,
+ int table_id, const char *rmap)
{
struct route_table *table;
struct route_entry *re;
struct route_node *rn;
const char *rmap_name;
- rmap_name = zebra_get_import_table_route_map(afi, table_id);
+ rmap_name = zebra_get_import_table_route_map(afi, safi, table_id);
if ((!rmap_name) || (strcmp(rmap_name, rmap) != 0))
return;
- table = zebra_vrf_get_table_with_table_id(afi, SAFI_UNICAST,
- zvrf->vrf->vrf_id, table_id);
+ table = zebra_vrf_get_table_with_table_id(afi, safi, zvrf->vrf->vrf_id, table_id);
if (!table) {
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug("%s: Table id=%d not found", __func__,
@@ -916,7 +917,7 @@ static void zebra_import_table_rm_update_vrf_afi(struct zebra_vrf *zvrf,
if (((afi == AFI_IP) && (rn->p.family == AF_INET))
|| ((afi == AFI_IP6) && (rn->p.family == AF_INET6)))
- zebra_add_import_table_entry(zvrf, rn, re, rmap_name);
+ zebra_add_import_table_entry(zvrf, safi, rn, re, rmap_name);
}
return;
@@ -926,16 +927,15 @@ static void zebra_import_table_rm_update_vrf(struct zebra_vrf *zvrf,
const char *rmap)
{
afi_t afi;
+ safi_t safi;
int i;
- for (afi = AFI_IP; afi < AFI_MAX; afi++) {
+ FOREACH_AFI_SAFI (afi, safi) {
for (i = 1; i < ZEBRA_KERNEL_TABLE_MAX; i++) {
- if (!is_zebra_import_table_enabled(
- afi, zvrf->vrf->vrf_id, i))
+ if (!is_zebra_import_table_enabled(afi, safi, zvrf->vrf->vrf_id, i))
continue;
- zebra_import_table_rm_update_vrf_afi(zvrf, afi, i,
- rmap);
+ zebra_import_table_rm_update_vrf_afi(zvrf, afi, safi, i, rmap);
}
}
}