]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospf6d/ospf6_message.c
Merge pull request #5653 from slankdev/slankdev-bgpd-support-prefix-sid-srv6-l3vpn
[mirror_frr.git] / ospf6d / ospf6_message.c
index cd688bbf89b1f87c8c330b0b99c18343c18e6b18..da42a242522c068a46202e7bf32641e60fe9889e 100644 (file)
@@ -1505,10 +1505,8 @@ int ospf6_iobuf_size(unsigned int size)
        recvnew = XMALLOC(MTYPE_OSPF6_MESSAGE, size);
        sendnew = XMALLOC(MTYPE_OSPF6_MESSAGE, size);
 
-       if (recvbuf)
-               XFREE(MTYPE_OSPF6_MESSAGE, recvbuf);
-       if (sendbuf)
-               XFREE(MTYPE_OSPF6_MESSAGE, sendbuf);
+       XFREE(MTYPE_OSPF6_MESSAGE, recvbuf);
+       XFREE(MTYPE_OSPF6_MESSAGE, sendbuf);
        recvbuf = recvnew;
        sendbuf = sendnew;
        iobuflen = size;
@@ -1868,7 +1866,8 @@ int ospf6_dbdesc_send(struct thread *thread)
 int ospf6_dbdesc_send_newone(struct thread *thread)
 {
        struct ospf6_neighbor *on;
-       struct ospf6_lsa *lsa;
+       struct ospf6_lsa *lsa, *lsa_next;
+       const struct route_node *iterend;
        unsigned int size = 0;
 
        on = (struct ospf6_neighbor *)THREAD_ARG(thread);
@@ -1878,7 +1877,10 @@ int ospf6_dbdesc_send_newone(struct thread *thread)
           structure)
           so that ospf6_send_dbdesc () can send those LSAs */
        size = sizeof(struct ospf6_lsa_header) + sizeof(struct ospf6_dbdesc);
-       for (ALL_LSDB(on->summary_list, lsa)) {
+
+       for (iterend = ospf6_lsdb_head(on->summary_list, 0, 0, 0, &lsa); lsa;
+            lsa = lsa_next) {
+               lsa_next = ospf6_lsdb_next(iterend, lsa);
                if (size + sizeof(struct ospf6_lsa_header)
                    > ospf6_packet_max(on->ospf6_if)) {
                        ospf6_lsdb_lsa_unlock(lsa);
@@ -2021,7 +2023,8 @@ int ospf6_lsupdate_send_neighbor(struct thread *thread)
        struct ospf6_lsupdate *lsupdate;
        uint8_t *p;
        int lsa_cnt;
-       struct ospf6_lsa *lsa;
+       struct ospf6_lsa *lsa, *lsa_next;
+       const struct route_node *iterend;
 
        on = (struct ospf6_neighbor *)THREAD_ARG(thread);
        on->thread_send_lsupdate = (struct thread *)NULL;
@@ -2046,7 +2049,9 @@ int ospf6_lsupdate_send_neighbor(struct thread *thread)
 
        /* lsupdate_list lists those LSA which doesn't need to be
           retransmitted. remove those from the list */
-       for (ALL_LSDB(on->lsupdate_list, lsa)) {
+       for (iterend = ospf6_lsdb_head(on->lsupdate_list, 0, 0, 0, &lsa); lsa;
+            lsa = lsa_next) {
+               lsa_next = ospf6_lsdb_next(iterend, lsa);
                /* MTU check */
                if ((p - sendbuf + (unsigned int)OSPF6_LSA_SIZE(lsa->header))
                    > ospf6_packet_max(on->ospf6_if)) {
@@ -2076,7 +2081,7 @@ int ospf6_lsupdate_send_neighbor(struct thread *thread)
                p += OSPF6_LSA_SIZE(lsa->header);
                lsa_cnt++;
 
-               assert(lsa->lock == 2);
+               assert(lsa->lock == 1);
                ospf6_lsdb_remove(lsa, on->lsupdate_list);
        }
 
@@ -2204,7 +2209,8 @@ int ospf6_lsupdate_send_interface(struct thread *thread)
        struct ospf6_lsupdate *lsupdate;
        uint8_t *p;
        int lsa_cnt;
-       struct ospf6_lsa *lsa;
+       struct ospf6_lsa *lsa, *lsa_next;
+       const struct route_node *iterend;
 
        oi = (struct ospf6_interface *)THREAD_ARG(thread);
        oi->thread_send_lsupdate = (struct thread *)NULL;
@@ -2230,7 +2236,9 @@ int ospf6_lsupdate_send_interface(struct thread *thread)
        p = (uint8_t *)((caddr_t)lsupdate + sizeof(struct ospf6_lsupdate));
        lsa_cnt = 0;
 
-       for (ALL_LSDB(oi->lsupdate_list, lsa)) {
+       for (iterend = ospf6_lsdb_head(oi->lsupdate_list, 0, 0, 0, &lsa); lsa;
+            lsa = lsa_next) {
+               lsa_next = ospf6_lsdb_next(iterend, lsa);
                /* MTU check */
                if ((p - sendbuf + ((unsigned int)OSPF6_LSA_SIZE(lsa->header)))
                    > ospf6_packet_max(oi)) {
@@ -2265,7 +2273,7 @@ int ospf6_lsupdate_send_interface(struct thread *thread)
                p += OSPF6_LSA_SIZE(lsa->header);
                lsa_cnt++;
 
-               assert(lsa->lock == 2);
+               assert(lsa->lock == 1);
                ospf6_lsdb_remove(lsa, oi->lsupdate_list);
        }
 
@@ -2291,7 +2299,8 @@ int ospf6_lsack_send_neighbor(struct thread *thread)
        struct ospf6_neighbor *on;
        struct ospf6_header *oh;
        uint8_t *p;
-       struct ospf6_lsa *lsa;
+       struct ospf6_lsa *lsa, *lsa_next;
+       const struct route_node *iterend;
        int lsa_cnt = 0;
 
        on = (struct ospf6_neighbor *)THREAD_ARG(thread);
@@ -2314,7 +2323,9 @@ int ospf6_lsack_send_neighbor(struct thread *thread)
 
        p = (uint8_t *)((caddr_t)oh + sizeof(struct ospf6_header));
 
-       for (ALL_LSDB(on->lsack_list, lsa)) {
+       for (iterend = ospf6_lsdb_head(on->lsack_list, 0, 0, 0, &lsa); lsa;
+            lsa = lsa_next) {
+               lsa_next = ospf6_lsdb_next(iterend, lsa);
                /* MTU check */
                if (p - sendbuf + sizeof(struct ospf6_lsa_header)
                    > ospf6_packet_max(on->ospf6_if)) {
@@ -2342,7 +2353,7 @@ int ospf6_lsack_send_neighbor(struct thread *thread)
                memcpy(p, lsa->header, sizeof(struct ospf6_lsa_header));
                p += sizeof(struct ospf6_lsa_header);
 
-               assert(lsa->lock == 2);
+               assert(lsa->lock == 1);
                ospf6_lsdb_remove(lsa, on->lsack_list);
                lsa_cnt++;
        }
@@ -2369,7 +2380,8 @@ int ospf6_lsack_send_interface(struct thread *thread)
        struct ospf6_interface *oi;
        struct ospf6_header *oh;
        uint8_t *p;
-       struct ospf6_lsa *lsa;
+       struct ospf6_lsa *lsa, *lsa_next;
+       const struct route_node *iterend;
        int lsa_cnt = 0;
 
        oi = (struct ospf6_interface *)THREAD_ARG(thread);
@@ -2393,7 +2405,9 @@ int ospf6_lsack_send_interface(struct thread *thread)
 
        p = (uint8_t *)((caddr_t)oh + sizeof(struct ospf6_header));
 
-       for (ALL_LSDB(oi->lsack_list, lsa)) {
+       for (iterend = ospf6_lsdb_head(oi->lsack_list, 0, 0, 0, &lsa); lsa;
+            lsa = lsa_next) {
+               lsa_next = ospf6_lsdb_next(iterend, lsa);
                /* MTU check */
                if (p - sendbuf + sizeof(struct ospf6_lsa_header)
                    > ospf6_packet_max(oi)) {
@@ -2411,7 +2425,7 @@ int ospf6_lsack_send_interface(struct thread *thread)
                memcpy(p, lsa->header, sizeof(struct ospf6_lsa_header));
                p += sizeof(struct ospf6_lsa_header);
 
-               assert(lsa->lock == 2);
+               assert(lsa->lock == 1);
                ospf6_lsdb_remove(lsa, oi->lsack_list);
                lsa_cnt++;
        }