]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfd/ospf_opaque.c
OSPFd: Correct style 2nd round
[mirror_frr.git] / ospfd / ospf_opaque.c
index 292d5e818609fa06fd57ca08f503ee62df187058..d3f41fe86a6a29179fa084faf38d8c899a9fae23 100644 (file)
@@ -75,6 +75,7 @@ static void ospf_opaque_funclist_init(void);
 static void ospf_opaque_funclist_term(void);
 static void free_opaque_info_per_type(void *val);
 static void free_opaque_info_per_id(void *val);
+static void free_opaque_info_owner(void *val);
 static int ospf_opaque_lsa_install_hook(struct ospf_lsa *lsa);
 static int ospf_opaque_lsa_delete_hook(struct ospf_lsa *lsa);
 
@@ -93,7 +94,6 @@ void ospf_opaque_init(void)
        if (ospf_router_info_init() != 0)
                exit(1);
 
-       /* Force Extended Prefix/Link to Type 10 */
        if (ospf_ext_init() != 0)
                exit(1);
 
@@ -123,6 +123,15 @@ void ospf_opaque_term(void)
        return;
 }
 
+void ospf_opaque_finish(void)
+{
+       ospf_router_info_finish();
+
+       ospf_ext_finish();
+
+       ospf_sr_finish();
+}
+
 int ospf_opaque_type9_lsa_init(struct ospf_interface *oi)
 {
        if (oi->opaque_lsa_self != NULL)
@@ -431,9 +440,11 @@ void ospf_delete_opaque_functab(u_char lsa_type, u_char opaque_type)
                        if (functab->opaque_type == opaque_type) {
                                /* Cleanup internal control information, if it
                                 * still remains. */
-                               if (functab->oipt != NULL)
+                               if (functab->oipt != NULL) {
                                        free_opaque_info_per_type(
                                                functab->oipt);
+                                       free_opaque_info_owner(functab->oipt);
+                               }
 
                                /* Dequeue listnode entry from the list. */
                                listnode_delete(funclist, functab);
@@ -564,6 +575,7 @@ register_opaque_info_per_type(struct ospf_opaque_functab *functab,
                top = ospf_lookup_by_vrf_id(new->vrf_id);
                if (new->area != NULL && (top = new->area->ospf) == NULL) {
                        free_opaque_info_per_type((void *)oipt);
+                       free_opaque_info_owner(oipt);
                        oipt = NULL;
                        goto out; /* This case may not exist. */
                }
@@ -575,6 +587,7 @@ register_opaque_info_per_type(struct ospf_opaque_functab *functab,
                        "register_opaque_info_per_type: Unexpected LSA-type(%u)",
                        new->data->type);
                free_opaque_info_per_type((void *)oipt);
+               free_opaque_info_owner(oipt);
                oipt = NULL;
                goto out; /* This case may not exist. */
        }
@@ -592,45 +605,53 @@ out:
        return oipt;
 }
 
-static void free_opaque_info_per_type(void *val)
+/* Remove "oipt" from its owner's self-originated LSA list. */
+static void free_opaque_info_owner(void *val)
 {
        struct opaque_info_per_type *oipt = (struct opaque_info_per_type *)val;
-       struct opaque_info_per_id *oipi;
-       struct ospf_lsa *lsa;
-       struct listnode *node, *nnode;
 
-       /* Control information per opaque-id may still exist. */
-       for (ALL_LIST_ELEMENTS(oipt->id_list, node, nnode, oipi)) {
-               if ((lsa = oipi->lsa) == NULL)
-                       continue;
-               if (IS_LSA_MAXAGE(lsa))
-                       continue;
-               ospf_opaque_lsa_flush_schedule(lsa);
-       }
-
-       /* Remove "oipt" from its owner's self-originated LSA list. */
        switch (oipt->lsa_type) {
        case OSPF_OPAQUE_LINK_LSA: {
                struct ospf_interface *oi =
                        (struct ospf_interface *)(oipt->owner);
+
                listnode_delete(oi->opaque_lsa_self, oipt);
                break;
        }
        case OSPF_OPAQUE_AREA_LSA: {
                struct ospf_area *area = (struct ospf_area *)(oipt->owner);
+
                listnode_delete(area->opaque_lsa_self, oipt);
                break;
        }
        case OSPF_OPAQUE_AS_LSA: {
                struct ospf *top = (struct ospf *)(oipt->owner);
+
                listnode_delete(top->opaque_lsa_self, oipt);
                break;
        }
        default:
-               zlog_warn("free_opaque_info_per_type: Unexpected LSA-type(%u)",
-                         oipt->lsa_type);
+               zlog_warn("%s: Unexpected LSA-type(%u)", __func__,
+                       oipt->lsa_type);
                break; /* This case may not exist. */
        }
+}
+
+static void free_opaque_info_per_type(void *val)
+{
+       struct opaque_info_per_type *oipt = (struct opaque_info_per_type *)val;
+       struct opaque_info_per_id *oipi;
+       struct ospf_lsa *lsa;
+       struct listnode *node, *nnode;
+
+       /* Control information per opaque-id may still exist. */
+       for (ALL_LIST_ELEMENTS(oipt->id_list, node, nnode, oipi)) {
+               if ((lsa = oipi->lsa) == NULL)
+                       continue;
+               if (IS_LSA_MAXAGE(lsa))
+                       continue;
+               ospf_opaque_lsa_flush_schedule(lsa);
+       }
 
        OSPF_TIMER_OFF(oipt->t_opaque_lsa_self);
        list_delete_and_null(&oipt->id_list);
@@ -1805,7 +1826,7 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent,
                        lsa_type, delay,
                        GET_OPAQUE_TYPE(ntohl(lsa->data->id.s_addr)));
 
-       OSPF_OPAQUE_TIMER_ON(oipt->t_opaque_lsa_self, func, oipt, delay * 1000);
+       OSPF_OPAQUE_TIMER_ON(oipt->t_opaque_lsa_self, func, oipt, delay);
 
 out:
        return;