]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: Minor memory fixes
authorGalaxyGorilla <sascha@netdef.org>
Tue, 24 Nov 2020 15:40:23 +0000 (15:40 +0000)
committerGalaxyGorilla <sascha@netdef.org>
Tue, 19 Jan 2021 15:32:13 +0000 (15:32 +0000)
Signed-off-by: GalaxyGorilla <sascha@netdef.org>
ospfd/ospf_spf.c
ospfd/ospf_ti_lfa.c

index cacf858cf267ce40452199930bf40d7bcd1f5503..080256e5a79d16d54e22721a85fd5be6a4ce162d 100644 (file)
@@ -1244,6 +1244,8 @@ static uint16_t get_reverse_distance(struct vertex *v,
        struct router_lsa_link *w_link;
        uint16_t distance = 0;
 
+       assert(w_lsa && w_lsa->data);
+
        p = ((uint8_t *)w_lsa->data) + OSPF_LSA_HEADER_SIZE + 4;
        lim = ((uint8_t *)w_lsa->data) + ntohs(w_lsa->data->length);
 
@@ -1268,7 +1270,8 @@ static uint16_t get_reverse_distance(struct vertex *v,
        if (distance == 0)
                distance = ntohs(l->m[0].metric);
 
-       zlog_debug("%s: reversed distance is %u", __func__, distance);
+       if (IS_DEBUG_OSPF_EVENT)
+               zlog_debug("%s: reversed distance is %u", __func__, distance);
 
        return distance;
 }
index e75922df14dd9e37ae3a101a806324bcf376c716..4a0186bfb917ab4bbb76d9b602bf583a3d85faf2 100644 (file)
@@ -128,6 +128,9 @@ static void ospf_ti_lfa_find_q_node(struct vertex *pc_node,
        p_node = ospf_spf_vertex_find(pc_node->id, p_space->vertex_list);
        q_node = ospf_spf_vertex_find(pc_node->id, q_space->vertex_list);
 
+       /* The Q node is always present. */
+       assert(q_node);
+
        q_space->q_node_info->type = OSPF_TI_LFA_UNDEFINED_NODE;
 
        if (p_node && q_node) {
@@ -1040,10 +1043,11 @@ void ospf_ti_lfa_insert_backup_paths(struct ospf_area *area,
                        }
 
                        if (path->srni.backup_label_stack) {
-                               mpls_label2str(q_space->label_stack->num_labels,
-                                              q_space->label_stack->label,
-                                              label_buf, MPLS_LABEL_STRLEN,
-                                              true);
+                               mpls_label2str(
+                                       path->srni.backup_label_stack
+                                               ->num_labels,
+                                       path->srni.backup_label_stack->label,
+                                       label_buf, MPLS_LABEL_STRLEN, true);
                                if (IS_DEBUG_OSPF_TI_LFA)
                                        zlog_debug(
                                                "%s: inserted backup path %s for prefix %pFX, router id %pI4 and nexthop %pI4.",