summaryrefslogtreecommitdiffstats
path: root/ospfd
diff options
context:
space:
mode:
authorGalaxyGorilla <sascha@netdef.org>2020-11-18 14:18:21 +0100
committerGalaxyGorilla <sascha@netdef.org>2021-01-19 16:32:13 +0100
commit669247b868b81722518001796f337539b02f0d7b (patch)
treed4c3bb622592beabed3da8b94e9e8fcbc1694c57 /ospfd
parenttests: Integrate unit tests for TI-LFA (diff)
downloadfrr-669247b868b81722518001796f337539b02f0d7b.tar.xz
frr-669247b868b81722518001796f337539b02f0d7b.zip
ospfd: enhance TI-LFA memory management
Signed-off-by: GalaxyGorilla <sascha@netdef.org>
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/ospf_route.c16
-rw-r--r--ospfd/ospf_ti_lfa.c31
2 files changed, 40 insertions, 7 deletions
diff --git a/ospfd/ospf_route.c b/ospfd/ospf_route.c
index 8079eeefe..7cfcaf14b 100644
--- a/ospfd/ospf_route.c
+++ b/ospfd/ospf_route.c
@@ -71,15 +71,31 @@ struct ospf_path *ospf_path_new(void)
static struct ospf_path *ospf_path_dup(struct ospf_path *path)
{
struct ospf_path *new;
+ int memsize;
new = ospf_path_new();
memcpy(new, path, sizeof(struct ospf_path));
+ /* optional TI-LFA backup paths */
+ if (path->srni.backup_label_stack) {
+ memsize = sizeof(struct mpls_label_stack)
+ + (sizeof(mpls_label_t)
+ * path->srni.backup_label_stack->num_labels);
+ new->srni.backup_label_stack =
+ XCALLOC(MTYPE_OSPF_PATH, memsize);
+ memcpy(new->srni.backup_label_stack,
+ path->srni.backup_label_stack, memsize);
+ }
+
return new;
}
void ospf_path_free(struct ospf_path *op)
{
+ /* optional TI-LFA backup paths */
+ if (op->srni.backup_label_stack)
+ XFREE(MTYPE_OSPF_PATH, op->srni.backup_label_stack);
+
XFREE(MTYPE_OSPF_PATH, op);
}
diff --git a/ospfd/ospf_ti_lfa.c b/ospfd/ospf_ti_lfa.c
index 0830b82f6..838b2378d 100644
--- a/ospfd/ospf_ti_lfa.c
+++ b/ospfd/ospf_ti_lfa.c
@@ -634,8 +634,28 @@ void ospf_ti_lfa_insert_backup_paths(struct ospf_area *area,
continue;
}
- path->srni.backup_label_stack = q_space->label_stack;
- path->srni.backup_nexthop = q_space->nexthop;
+ /* If there's a backup label stack, insert it*/
+ if (q_space->label_stack) {
+ /* Init the backup path data in path */
+ path->srni.backup_label_stack = XCALLOC(
+ MTYPE_OSPF_PATH,
+ sizeof(struct mpls_label_stack)
+ + sizeof(mpls_label_t)
+ * q_space->label_stack
+ ->num_labels);
+
+ /* Copy over the label stack */
+ path->srni.backup_label_stack->num_labels =
+ q_space->label_stack->num_labels;
+ memcpy(path->srni.backup_label_stack->label,
+ q_space->label_stack->label,
+ sizeof(mpls_label_t)
+ * q_space->label_stack
+ ->num_labels);
+
+ /* Set the backup nexthop too */
+ path->srni.backup_nexthop = q_space->nexthop;
+ }
if (path->srni.backup_label_stack) {
mpls_label2str(q_space->label_stack->num_labels,
@@ -665,13 +685,10 @@ void ospf_ti_lfa_free_p_spaces(struct ospf_area *area)
while ((q_space = q_spaces_pop(p_space->q_spaces))) {
ospf_spf_cleanup(q_space->root, q_space->vertex_list);
- /*
- * TODO: label stack is used for route installation
- * XFREE(MTYPE_OSPF_Q_SPACE, q_space->label_stack);
- */
-
+ XFREE(MTYPE_OSPF_Q_SPACE, q_space->label_stack);
XFREE(MTYPE_OSPF_Q_SPACE, q_space);
}
+
ospf_spf_cleanup(p_space->root, p_space->vertex_list);
ospf_spf_cleanup(p_space->pc_spf, p_space->pc_vertex_list);
XFREE(MTYPE_OSPF_P_SPACE, p_space->protected_resource);