]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospf6d/ospf6_neighbor.c
Merge pull request #5081 from pguibert6WIND/show_brief_doc
[mirror_frr.git] / ospf6d / ospf6_neighbor.c
index 542a24bfc94b411316696dda2e894d54bfd52ad8..4318db52252d2033a94ecfe164be2c86361707c9 100644 (file)
@@ -59,10 +59,14 @@ int ospf6_neighbor_cmp(void *va, void *vb)
 {
        struct ospf6_neighbor *ona = (struct ospf6_neighbor *)va;
        struct ospf6_neighbor *onb = (struct ospf6_neighbor *)vb;
-       return (ntohl(ona->router_id) < ntohl(onb->router_id) ? -1 : 1);
+
+       if (ona->router_id == onb->router_id)
+               return 0;
+
+       return (ntohl(ona->router_id) < ntohl(onb->router_id)) ? -1 : 1;
 }
 
-struct ospf6_neighbor *ospf6_neighbor_lookup(u_int32_t router_id,
+struct ospf6_neighbor *ospf6_neighbor_lookup(uint32_t router_id,
                                             struct ospf6_interface *oi)
 {
        struct listnode *n;
@@ -76,20 +80,13 @@ struct ospf6_neighbor *ospf6_neighbor_lookup(u_int32_t router_id,
 }
 
 /* create ospf6_neighbor */
-struct ospf6_neighbor *ospf6_neighbor_create(u_int32_t router_id,
+struct ospf6_neighbor *ospf6_neighbor_create(uint32_t router_id,
                                             struct ospf6_interface *oi)
 {
        struct ospf6_neighbor *on;
        char buf[16];
 
-       on = (struct ospf6_neighbor *)XMALLOC(MTYPE_OSPF6_NEIGHBOR,
-                                             sizeof(struct ospf6_neighbor));
-       if (on == NULL) {
-               zlog_warn("neighbor: malloc failed");
-               return NULL;
-       }
-
-       memset(on, 0, sizeof(struct ospf6_neighbor));
+       on = XCALLOC(MTYPE_OSPF6_NEIGHBOR, sizeof(struct ospf6_neighbor));
        inet_ntop(AF_INET, &router_id, buf, sizeof(buf));
        snprintf(on->name, sizeof(on->name), "%s%%%s", buf,
                 oi->interface->name);
@@ -115,11 +112,15 @@ struct ospf6_neighbor *ospf6_neighbor_create(u_int32_t router_id,
 
 void ospf6_neighbor_delete(struct ospf6_neighbor *on)
 {
-       struct ospf6_lsa *lsa;
+       struct ospf6_lsa *lsa, *lsa_next;
+       const struct route_node *iterend;
 
        ospf6_lsdb_remove_all(on->summary_list);
        ospf6_lsdb_remove_all(on->request_list);
-       for (ALL_LSDB(on->retrans_list, lsa)) {
+
+       for (iterend = ospf6_lsdb_head(on->retrans_list, 0, 0, 0, &lsa); lsa;
+            lsa = lsa_next) {
+               lsa_next = ospf6_lsdb_next(iterend, lsa);
                ospf6_decrement_retrans_count(lsa);
                ospf6_lsdb_remove(lsa, on->retrans_list);
        }
@@ -147,10 +148,10 @@ void ospf6_neighbor_delete(struct ospf6_neighbor *on)
        XFREE(MTYPE_OSPF6_NEIGHBOR, on);
 }
 
-static void ospf6_neighbor_state_change(u_char next_state,
+static void ospf6_neighbor_state_change(uint8_t next_state,
                                        struct ospf6_neighbor *on, int event)
 {
-       u_char prev_state;
+       uint8_t prev_state;
 
        prev_state = on->state;
        on->state = next_state;
@@ -188,10 +189,14 @@ static void ospf6_neighbor_state_change(u_char next_state,
                        OSPF6_NETWORK_LSA_SCHEDULE(on->ospf6_if);
                        OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(on->ospf6_if);
                }
+               if (next_state == OSPF6_NEIGHBOR_FULL)
+                       on->ospf6_if->area->intra_prefix_originate = 1;
+
                OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(on->ospf6_if->area);
 
-               if (prev_state == OSPF6_NEIGHBOR_LOADING
-                   && next_state == OSPF6_NEIGHBOR_FULL) {
+               if ((prev_state == OSPF6_NEIGHBOR_LOADING ||
+                    prev_state == OSPF6_NEIGHBOR_EXCHANGE) &&
+                   next_state == OSPF6_NEIGHBOR_FULL) {
                        OSPF6_AS_EXTERN_LSA_SCHEDULE(on->ospf6_if);
                        on->ospf6_if->area->full_nbrs++;
                }
@@ -286,7 +291,8 @@ int twoway_received(struct thread *thread)
 int negotiation_done(struct thread *thread)
 {
        struct ospf6_neighbor *on;
-       struct ospf6_lsa *lsa;
+       struct ospf6_lsa *lsa, *lsa_next;
+       const struct route_node *iterend;
 
        on = (struct ospf6_neighbor *)THREAD_ARG(thread);
        assert(on);
@@ -300,7 +306,10 @@ int negotiation_done(struct thread *thread)
        /* clear ls-list */
        ospf6_lsdb_remove_all(on->summary_list);
        ospf6_lsdb_remove_all(on->request_list);
-       for (ALL_LSDB(on->retrans_list, lsa)) {
+
+       for (iterend = ospf6_lsdb_head(on->retrans_list, 0, 0, 0, &lsa); lsa;
+            lsa = lsa_next) {
+               lsa_next = ospf6_lsdb_next(iterend, lsa);
                ospf6_decrement_retrans_count(lsa);
                ospf6_lsdb_remove(lsa, on->retrans_list);
        }
@@ -494,7 +503,8 @@ int seqnumber_mismatch(struct thread *thread)
 int bad_lsreq(struct thread *thread)
 {
        struct ospf6_neighbor *on;
-       struct ospf6_lsa *lsa;
+       struct ospf6_lsa *lsa, *lsa_next;
+       const struct route_node *iterend;
 
        on = (struct ospf6_neighbor *)THREAD_ARG(thread);
        assert(on);
@@ -513,7 +523,10 @@ int bad_lsreq(struct thread *thread)
 
        ospf6_lsdb_remove_all(on->summary_list);
        ospf6_lsdb_remove_all(on->request_list);
-       for (ALL_LSDB(on->retrans_list, lsa)) {
+
+       for (iterend = ospf6_lsdb_head(on->retrans_list, 0, 0, 0, &lsa); lsa;
+            lsa = lsa_next) {
+               lsa_next = ospf6_lsdb_next(iterend, lsa);
                ospf6_decrement_retrans_count(lsa);
                ospf6_lsdb_remove(lsa, on->retrans_list);
        }
@@ -531,7 +544,8 @@ int bad_lsreq(struct thread *thread)
 int oneway_received(struct thread *thread)
 {
        struct ospf6_neighbor *on;
-       struct ospf6_lsa *lsa;
+       struct ospf6_lsa *lsa, *lsa_next;
+       const struct route_node *iterend;
 
        on = (struct ospf6_neighbor *)THREAD_ARG(thread);
        assert(on);
@@ -548,7 +562,9 @@ int oneway_received(struct thread *thread)
 
        ospf6_lsdb_remove_all(on->summary_list);
        ospf6_lsdb_remove_all(on->request_list);
-       for (ALL_LSDB(on->retrans_list, lsa)) {
+       for (iterend = ospf6_lsdb_head(on->retrans_list, 0, 0, 0, &lsa); lsa;
+            lsa = lsa_next) {
+               lsa_next = ospf6_lsdb_next(iterend, lsa);
                ospf6_decrement_retrans_count(lsa);
                ospf6_lsdb_remove(lsa, on->retrans_list);
        }
@@ -617,7 +633,7 @@ static void ospf6_neighbor_show(struct vty *vty, struct ospf6_neighbor *on)
        snprintf(deadtime, sizeof(deadtime), "%02ld:%02ld:%02ld", h, m, s);
 
        /* Neighbor State */
-       if (if_is_pointopoint(on->ospf6_if->interface))
+       if (on->ospf6_if->type == OSPF_IFTYPE_POINTOPOINT)
                snprintf(nstate, sizeof(nstate), "PointToPoint");
        else {
                if (on->router_id == on->drouter)
@@ -705,7 +721,7 @@ static void ospf6_neighbor_show_detail(struct vty *vty,
                (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT) ? "More " : ""),
                (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT) ? "Master"
                                                                 : "Slave"),
-               (u_long)ntohl(on->dbdesc_seqnum));
+               (unsigned long)ntohl(on->dbdesc_seqnum));
 
        vty_out(vty, "    Summary-List: %d LSAs\n", on->summary_list->count);
        for (ALL_LSDB(on->summary_list, lsa))
@@ -823,7 +839,7 @@ DEFUN (show_ipv6_ospf6_neighbor_one,
        struct ospf6_area *oa;
        struct listnode *i, *j, *k;
        void (*showfunc)(struct vty *, struct ospf6_neighbor *);
-       u_int32_t router_id;
+       uint32_t router_id;
 
        OSPF6_CMD_CHECK_RUNNING();
        showfunc = ospf6_neighbor_show_detail;
@@ -906,7 +922,7 @@ DEFUN (no_debug_ospf6,
        DEBUG_STR
        OSPF6_STR)
 {
-       u_int i;
+       unsigned int i;
        struct ospf6_lsa_handler *handler = NULL;
 
        OSPF6_DEBUG_ABR_OFF();
@@ -921,7 +937,7 @@ DEFUN (no_debug_ospf6,
                handler = vector_slot(ospf6_lsa_handler_vector, i);
 
                if (handler != NULL) {
-                       UNSET_FLAG(handler->debug, OSPF6_LSA_DEBUG);
+                       UNSET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG);
                }
        }