]> git.puffer.fish Git - matthieu/frr.git/commitdiff
eigrpd: Fix an issue found with metric change
authorDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 28 Oct 2017 22:45:08 +0000 (18:45 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 28 Oct 2017 22:45:08 +0000 (18:45 -0400)
A past commit modified the change value to an enum
but did not bother to fix all the places where
change was used.  Fix this.

Additionally add some more output to the fsm prefix
string about the change.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
eigrpd/eigrp_fsm.c
eigrpd/eigrp_structs.h

index 44fdbf7d1b37d87719fea4c88dfb3bcb9f36162b..b4978bc06f7ee3e3d3059707fbec42292b4524af 100644 (file)
@@ -235,6 +235,20 @@ static const char *fsm_state2str(enum eigrp_fsm_events event)
 
        return "Unknown";
 }
+
+static const char *change2str(enum metric_change change)
+{
+       switch (change) {
+       case METRIC_DECREASE:
+               return "Decrease";
+       case METRIC_SAME:
+               return "Same";
+       case METRIC_INCREASE:
+               return "Increase";
+       }
+
+       return "Unknown";
+}
 /*
  * Main function in which are make decisions which event occurred.
  * msg - argument of type struct eigrp_fsm_action_message contain
@@ -267,6 +281,9 @@ static enum eigrp_fsm_events eigrp_get_fsm_event(
         */
        change = eigrp_topology_update_distance(msg);
 
+       /* Store for display later */
+       msg->change = change;
+
        switch (actual_state) {
        case EIGRP_FSM_STATE_PASSIVE: {
                struct eigrp_nexthop_entry *head =
@@ -331,7 +348,8 @@ static enum eigrp_fsm_events eigrp_get_fsm_event(
                                zlog_info("All reply received\n");
                                return EIGRP_FSM_EVENT_LR;
                        }
-               } else if (msg->packet_type == EIGRP_OPC_UPDATE && change == 1
+               } else if (msg->packet_type == EIGRP_OPC_UPDATE
+                          && change == METRIC_INCREASE
                           && (entry->flags
                               & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) {
                        return EIGRP_FSM_EVENT_DINC;
@@ -376,7 +394,8 @@ static enum eigrp_fsm_events eigrp_get_fsm_event(
                                zlog_info("All reply received\n");
                                return EIGRP_FSM_EVENT_LR;
                        }
-               } else if (msg->packet_type == EIGRP_OPC_UPDATE && change == 1
+               } else if (msg->packet_type == EIGRP_OPC_UPDATE
+                          && change == METRIC_INCREASE
                           && (entry->flags
                               & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) {
                        return EIGRP_FSM_EVENT_DINC;
@@ -398,12 +417,13 @@ 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",
+       zlog_info("EIGRP AS: %d State: %s Event: %s Network: %s 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),
                  packet_type2str(msg->packet_type),
-                 msg->prefix->rij->count);
+                 msg->prefix->rij->count,
+                 change2str(msg->change));
        (*(NSM[msg->prefix->state][event].func))(msg);
 
        return 1;
index 324181c21ea5448c85e9ff0de0ee2a58e7ce73f2..aae56c8ffe41a8f91c55dc4fc0556216ad04b449 100644 (file)
@@ -499,6 +499,7 @@ struct eigrp_fsm_action_message {
        struct eigrp_prefix_entry *prefix;
        msg_data_t data_type; // internal or external tlv type
        struct eigrp_metrics metrics;
+       enum metric_change change;
 };
 
 #endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */