]> git.proxmox.com Git - mirror_frr.git/blobdiff - eigrpd/eigrp_fsm.c
Merge pull request #13345 from donaldsharp/pim_after_dark
[mirror_frr.git] / eigrpd / eigrp_fsm.c
index e43eca0e0dc68be1370179c6ad435b757a972ee2..6d8061e57232e3943d594f8c21cbffa56547c268 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * EIGRPd Finite State Machine (DUAL).
  * Copyright (C) 2013-2014
@@ -8,22 +9,6 @@
  *   Peter Orsag
  *   Peter Paluch
  *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * GNU Zebra is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
  * This file contains functions for executing logic of finite state machine
  *
  *                                +------------ +
@@ -68,8 +53,8 @@
  */
 
 #include <zebra.h>
-#include <thread.h>
 
+#include "frrevent.h"
 #include "prefix.h"
 #include "table.h"
 #include "memory.h"
@@ -77,6 +62,7 @@
 #include "linklist.h"
 #include "vty.h"
 
+#include "eigrpd/eigrp_types.h"
 #include "eigrpd/eigrp_structs.h"
 #include "eigrpd/eigrpd.h"
 #include "eigrpd/eigrp_interface.h"
@@ -88,6 +74,7 @@
 #include "eigrpd/eigrp_dump.h"
 #include "eigrpd/eigrp_topology.h"
 #include "eigrpd/eigrp_fsm.h"
+#include "eigrpd/eigrp_metric.h"
 
 /*
  * Prototypes
@@ -262,13 +249,13 @@ eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg)
 {
        // Loading base information from message
        // struct eigrp *eigrp = msg->eigrp;
-       struct eigrp_prefix_entry *prefix = msg->prefix;
-       struct eigrp_nexthop_entry *entry = msg->entry;
+       struct eigrp_prefix_descriptor *prefix = msg->prefix;
+       struct eigrp_route_descriptor *entry = msg->entry;
        uint8_t actual_state = prefix->state;
        enum metric_change change;
 
        if (entry == NULL) {
-               entry = eigrp_nexthop_entry_new();
+               entry = eigrp_route_descriptor_new();
                entry->adv_router = msg->adv_router;
                entry->ei = msg->adv_router->ei;
                entry->prefix = prefix;
@@ -286,7 +273,7 @@ eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg)
 
        switch (actual_state) {
        case EIGRP_FSM_STATE_PASSIVE: {
-               struct eigrp_nexthop_entry *head =
+               struct eigrp_route_descriptor *head =
                        listnode_head(prefix->entries);
 
                if (head->reported_distance < prefix->fdistance) {
@@ -307,7 +294,7 @@ eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg)
        }
        case EIGRP_FSM_STATE_ACTIVE_0: {
                if (msg->packet_type == EIGRP_OPC_REPLY) {
-                       struct eigrp_nexthop_entry *head =
+                       struct eigrp_route_descriptor *head =
                                listnode_head(prefix->entries);
 
                        listnode_delete(prefix->rij, entry->adv_router);
@@ -322,7 +309,7 @@ eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg)
                        return EIGRP_FSM_EVENT_LR_FCN;
                } else if (msg->packet_type == EIGRP_OPC_QUERY
                           && (entry->flags
-                              & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) {
+                              & EIGRP_ROUTE_DESCRIPTOR_SUCCESSOR_FLAG)) {
                        return EIGRP_FSM_EVENT_QACT;
                }
 
@@ -332,14 +319,14 @@ eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg)
        }
        case EIGRP_FSM_STATE_ACTIVE_1: {
                if (msg->packet_type == EIGRP_OPC_QUERY
-                   && (entry->flags & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) {
+                   && (entry->flags & EIGRP_ROUTE_DESCRIPTOR_SUCCESSOR_FLAG)) {
                        return EIGRP_FSM_EVENT_QACT;
                } else if (msg->packet_type == EIGRP_OPC_REPLY) {
                        listnode_delete(prefix->rij, entry->adv_router);
 
                        if (change == METRIC_INCREASE
                            && (entry->flags
-                               & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) {
+                               & EIGRP_ROUTE_DESCRIPTOR_SUCCESSOR_FLAG)) {
                                return EIGRP_FSM_EVENT_DINC;
                        } else if (prefix->rij->count) {
                                return EIGRP_FSM_KEEP_STATE;
@@ -350,7 +337,7 @@ eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg)
                } else if (msg->packet_type == EIGRP_OPC_UPDATE
                           && change == METRIC_INCREASE
                           && (entry->flags
-                              & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) {
+                              & EIGRP_ROUTE_DESCRIPTOR_SUCCESSOR_FLAG)) {
                        return EIGRP_FSM_EVENT_DINC;
                }
                return EIGRP_FSM_KEEP_STATE;
@@ -359,7 +346,7 @@ eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg)
        }
        case EIGRP_FSM_STATE_ACTIVE_2: {
                if (msg->packet_type == EIGRP_OPC_REPLY) {
-                       struct eigrp_nexthop_entry *head =
+                       struct eigrp_route_descriptor *head =
                                listnode_head(prefix->entries);
 
                        listnode_delete(prefix->rij, entry->adv_router);
@@ -385,7 +372,7 @@ eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg)
 
                        if (change == METRIC_INCREASE
                            && (entry->flags
-                               & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) {
+                               & EIGRP_ROUTE_DESCRIPTOR_SUCCESSOR_FLAG)) {
                                return EIGRP_FSM_EVENT_DINC;
                        } else if (prefix->rij->count) {
                                return EIGRP_FSM_KEEP_STATE;
@@ -396,7 +383,7 @@ eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg)
                } else if (msg->packet_type == EIGRP_OPC_UPDATE
                           && change == METRIC_INCREASE
                           && (entry->flags
-                              & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) {
+                              & EIGRP_ROUTE_DESCRIPTOR_SUCCESSOR_FLAG)) {
                        return EIGRP_FSM_EVENT_DINC;
                }
                return EIGRP_FSM_KEEP_STATE;
@@ -417,9 +404,9 @@ int eigrp_fsm_event(struct eigrp_fsm_action_message *msg)
        enum eigrp_fsm_events event = eigrp_get_fsm_event(msg);
 
        zlog_info(
-               "EIGRP AS: %d State: %s Event: %s Network: %s Packet Type: %s Reply RIJ Count: %d change: %s",
+               "EIGRP AS: %d State: %s Event: %s Network: %pI4 Packet Type: %s Reply RIJ Count: %d change: %s",
                msg->eigrp->AS, prefix_state2str(msg->prefix->state),
-               fsm_state2str(event), eigrp_topology_ip_string(msg->prefix),
+               fsm_state2str(event), &msg->prefix->destination->u.prefix4,
                packet_type2str(msg->packet_type), msg->prefix->rij->count,
                change2str(msg->change));
        (*(NSM[msg->prefix->state][event].func))(msg);
@@ -434,9 +421,9 @@ int eigrp_fsm_event(struct eigrp_fsm_action_message *msg)
 int eigrp_fsm_event_nq_fcn(struct eigrp_fsm_action_message *msg)
 {
        struct eigrp *eigrp = msg->eigrp;
-       struct eigrp_prefix_entry *prefix = msg->prefix;
+       struct eigrp_prefix_descriptor *prefix = msg->prefix;
        struct list *successors = eigrp_topology_get_successor(prefix);
-       struct eigrp_nexthop_entry *ne;
+       struct eigrp_route_descriptor *ne;
 
        assert(successors); // If this is NULL we have shit the bed, fun huh?
 
@@ -461,9 +448,9 @@ int eigrp_fsm_event_nq_fcn(struct eigrp_fsm_action_message *msg)
 int eigrp_fsm_event_q_fcn(struct eigrp_fsm_action_message *msg)
 {
        struct eigrp *eigrp = msg->eigrp;
-       struct eigrp_prefix_entry *prefix = msg->prefix;
+       struct eigrp_prefix_descriptor *prefix = msg->prefix;
        struct list *successors = eigrp_topology_get_successor(prefix);
-       struct eigrp_nexthop_entry *ne;
+       struct eigrp_route_descriptor *ne;
 
        assert(successors); // If this is NULL somebody poked us in the eye.
 
@@ -487,8 +474,8 @@ int eigrp_fsm_event_q_fcn(struct eigrp_fsm_action_message *msg)
 int eigrp_fsm_event_keep_state(struct eigrp_fsm_action_message *msg)
 {
        struct eigrp *eigrp = msg->eigrp;
-       struct eigrp_prefix_entry *prefix = msg->prefix;
-       struct eigrp_nexthop_entry *ne = listnode_head(prefix->entries);
+       struct eigrp_prefix_descriptor *prefix = msg->prefix;
+       struct eigrp_route_descriptor *ne = listnode_head(prefix->entries);
 
        if (prefix->state == EIGRP_FSM_STATE_PASSIVE) {
                if (!eigrp_metrics_is_same(prefix->reported_metric,
@@ -515,8 +502,8 @@ int eigrp_fsm_event_keep_state(struct eigrp_fsm_action_message *msg)
 int eigrp_fsm_event_lr(struct eigrp_fsm_action_message *msg)
 {
        struct eigrp *eigrp = msg->eigrp;
-       struct eigrp_prefix_entry *prefix = msg->prefix;
-       struct eigrp_nexthop_entry *ne = listnode_head(prefix->entries);
+       struct eigrp_prefix_descriptor *prefix = msg->prefix;
+       struct eigrp_route_descriptor *ne = listnode_head(prefix->entries);
 
        prefix->fdistance = prefix->distance = prefix->rdistance = ne->distance;
        prefix->reported_metric = ne->total_metric;
@@ -545,7 +532,7 @@ int eigrp_fsm_event_lr(struct eigrp_fsm_action_message *msg)
 int eigrp_fsm_event_dinc(struct eigrp_fsm_action_message *msg)
 {
        struct list *successors = eigrp_topology_get_successor(msg->prefix);
-       struct eigrp_nexthop_entry *ne;
+       struct eigrp_route_descriptor *ne;
 
        assert(successors); // Trump and his big hands
 
@@ -566,8 +553,8 @@ int eigrp_fsm_event_dinc(struct eigrp_fsm_action_message *msg)
 int eigrp_fsm_event_lr_fcs(struct eigrp_fsm_action_message *msg)
 {
        struct eigrp *eigrp = msg->eigrp;
-       struct eigrp_prefix_entry *prefix = msg->prefix;
-       struct eigrp_nexthop_entry *ne = listnode_head(prefix->entries);
+       struct eigrp_prefix_descriptor *prefix = msg->prefix;
+       struct eigrp_route_descriptor *ne = listnode_head(prefix->entries);
 
        prefix->state = EIGRP_FSM_STATE_PASSIVE;
        prefix->distance = prefix->rdistance = ne->distance;
@@ -598,8 +585,8 @@ int eigrp_fsm_event_lr_fcs(struct eigrp_fsm_action_message *msg)
 int eigrp_fsm_event_lr_fcn(struct eigrp_fsm_action_message *msg)
 {
        struct eigrp *eigrp = msg->eigrp;
-       struct eigrp_prefix_entry *prefix = msg->prefix;
-       struct eigrp_nexthop_entry *best_successor;
+       struct eigrp_prefix_descriptor *prefix = msg->prefix;
+       struct eigrp_route_descriptor *best_successor;
        struct list *successors = eigrp_topology_get_successor(prefix);
 
        assert(successors); // Routing without a stack
@@ -628,7 +615,7 @@ int eigrp_fsm_event_lr_fcn(struct eigrp_fsm_action_message *msg)
 int eigrp_fsm_event_qact(struct eigrp_fsm_action_message *msg)
 {
        struct list *successors = eigrp_topology_get_successor(msg->prefix);
-       struct eigrp_nexthop_entry *ne;
+       struct eigrp_route_descriptor *ne;
 
        assert(successors); // Cats and no Dogs