]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospf6d/ospf6_lsdb.c
Merge pull request #5653 from slankdev/slankdev-bgpd-support-prefix-sid-srv6-l3vpn
[mirror_frr.git] / ospf6d / ospf6_lsdb.c
index 152702391b6a3891dc92cf3318da419829a2c15c..0a9f1c6f7ced9bfa0f7c4add1a35754aa33078d9 100644 (file)
@@ -39,10 +39,6 @@ struct ospf6_lsdb *ospf6_lsdb_create(void *data)
        struct ospf6_lsdb *lsdb;
 
        lsdb = XCALLOC(MTYPE_OSPF6_LSDB, sizeof(struct ospf6_lsdb));
-       if (lsdb == NULL) {
-               zlog_warn("Can't malloc lsdb");
-               return NULL;
-       }
        memset(lsdb, 0, sizeof(struct ospf6_lsdb));
 
        lsdb->data = data;
@@ -173,8 +169,8 @@ void ospf6_lsdb_remove(struct ospf6_lsa *lsa, struct ospf6_lsdb *lsdb)
        ospf6_lsdb_count_assert(lsdb);
 }
 
-struct ospf6_lsa *ospf6_lsdb_lookup(u_int16_t type, u_int32_t id,
-                                   u_int32_t adv_router,
+struct ospf6_lsa *ospf6_lsdb_lookup(uint16_t type, uint32_t id,
+                                   uint32_t adv_router,
                                    struct ospf6_lsdb *lsdb)
 {
        struct route_node *node;
@@ -196,8 +192,8 @@ struct ospf6_lsa *ospf6_lsdb_lookup(u_int16_t type, u_int32_t id,
        return (struct ospf6_lsa *)node->info;
 }
 
-struct ospf6_lsa *ospf6_lsdb_lookup_next(u_int16_t type, u_int32_t id,
-                                        u_int32_t adv_router,
+struct ospf6_lsa *ospf6_lsdb_lookup_next(uint16_t type, uint32_t id,
+                                        uint32_t adv_router,
                                         struct ospf6_lsdb *lsdb)
 {
        struct route_node *node;
@@ -302,13 +298,17 @@ struct ospf6_lsa *ospf6_lsdb_next(const struct route_node *iterend,
 
 void ospf6_lsdb_remove_all(struct ospf6_lsdb *lsdb)
 {
-       struct ospf6_lsa *lsa;
+       struct ospf6_lsa *lsa, *lsa_next;
+       const struct route_node *iterend;
 
        if (lsdb == NULL)
                return;
 
-       for (ALL_LSDB(lsdb, lsa))
+       for (iterend = ospf6_lsdb_head(lsdb, 0, 0, 0, &lsa); lsa;
+            lsa = lsa_next) {
+               lsa_next = ospf6_lsdb_next(iterend, lsa);
                ospf6_lsdb_remove(lsa, lsdb);
+       }
 }
 
 void ospf6_lsdb_lsa_unlock(struct ospf6_lsa *lsa)
@@ -323,9 +323,12 @@ void ospf6_lsdb_lsa_unlock(struct ospf6_lsa *lsa)
 int ospf6_lsdb_maxage_remover(struct ospf6_lsdb *lsdb)
 {
        int reschedule = 0;
-       struct ospf6_lsa *lsa;
+       struct ospf6_lsa *lsa, *lsa_next;
+       const struct route_node *iterend;
 
-       for (ALL_LSDB(lsdb, lsa)) {
+       for (iterend = ospf6_lsdb_head(lsdb, 0, 0, 0, &lsa); lsa;
+            lsa = lsa_next) {
+               lsa_next = ospf6_lsdb_next(iterend, lsa);
                if (!OSPF6_LSA_IS_MAXAGE(lsa))
                        continue;
                if (lsa->retrans_count != 0) {
@@ -355,7 +358,7 @@ int ospf6_lsdb_maxage_remover(struct ospf6_lsdb *lsdb)
 }
 
 void ospf6_lsdb_show(struct vty *vty, enum ospf_lsdb_show_level level,
-                    u_int16_t *type, u_int32_t *id, u_int32_t *adv_router,
+                    uint16_t *type, uint32_t *id, uint32_t *adv_router,
                     struct ospf6_lsdb *lsdb)
 {
        struct ospf6_lsa *lsa;
@@ -392,8 +395,7 @@ void ospf6_lsdb_show(struct vty *vty, enum ospf_lsdb_show_level level,
                ospf6_lsa_show_summary_header(vty);
 
        end = ospf6_lsdb_head(lsdb, !!type + !!(type && adv_router),
-                             type ? *type : 0,
-                             adv_router ? *adv_router : 0,
+                             type ? *type : 0, adv_router ? *adv_router : 0,
                              &lsa);
        while (lsa) {
                if ((!adv_router || lsa->header->adv_router == *adv_router)
@@ -404,11 +406,11 @@ void ospf6_lsdb_show(struct vty *vty, enum ospf_lsdb_show_level level,
        }
 }
 
-u_int32_t ospf6_new_ls_id(u_int16_t type, u_int32_t adv_router,
-                         struct ospf6_lsdb *lsdb)
+uint32_t ospf6_new_ls_id(uint16_t type, uint32_t adv_router,
+                        struct ospf6_lsdb *lsdb)
 {
        struct ospf6_lsa *lsa;
-       u_int32_t id = 1, tmp_id;
+       uint32_t id = 1, tmp_id;
 
        /* This routine is curently invoked only for Inter-Prefix LSAs for
         * non-summarized routes (no area/range).
@@ -425,13 +427,13 @@ u_int32_t ospf6_new_ls_id(u_int16_t type, u_int32_t adv_router,
                id++;
        }
 
-       return ((u_int32_t)htonl(id));
+       return ((uint32_t)htonl(id));
 }
 
 /* Decide new LS sequence number to originate.
    note return value is network byte order */
-u_int32_t ospf6_new_ls_seqnum(u_int16_t type, u_int32_t id,
-                             u_int32_t adv_router, struct ospf6_lsdb *lsdb)
+uint32_t ospf6_new_ls_seqnum(uint16_t type, uint32_t id, uint32_t adv_router,
+                            struct ospf6_lsdb *lsdb)
 {
        struct ospf6_lsa *lsa;
        signed long seqnum = 0;
@@ -443,5 +445,5 @@ u_int32_t ospf6_new_ls_seqnum(u_int16_t type, u_int32_t id,
        else
                seqnum = (signed long)ntohl(lsa->header->seqnum) + 1;
 
-       return ((u_int32_t)htonl(seqnum));
+       return ((uint32_t)htonl(seqnum));
 }