summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eigrpd/eigrp_const.h5
-rw-r--r--eigrpd/eigrp_topology.c32
-rw-r--r--eigrpd/eigrp_topology.h2
3 files changed, 22 insertions, 17 deletions
diff --git a/eigrpd/eigrp_const.h b/eigrpd/eigrp_const.h
index a6282665e..a008891a5 100644
--- a/eigrpd/eigrp_const.h
+++ b/eigrpd/eigrp_const.h
@@ -94,6 +94,11 @@
#define EIGRP_MULTICAST_ADDRESS 0xe000000A /*224.0.0.10*/
#define EIGRP_MAX_METRIC 0xffffffffU /*4294967295*/
+enum metric_change {
+ METRIC_DECREASE,
+ METRIC_SAME,
+ METRIC_INCREASE
+};
#define DEFAULT_ROUTE ZEBRA_ROUTE_MAX
#define DEFAULT_ROUTE_TYPE(T) ((T) == DEFAULT_ROUTE)
diff --git a/eigrpd/eigrp_topology.c b/eigrpd/eigrp_topology.c
index ae1396eba..50d83430a 100644
--- a/eigrpd/eigrp_topology.c
+++ b/eigrpd/eigrp_topology.c
@@ -374,42 +374,42 @@ struct list *eigrp_neighbor_prefixes_lookup(struct eigrp *eigrp,
return prefixes;
}
-int eigrp_topology_update_distance(struct eigrp_fsm_action_message *msg)
+enum metric_change eigrp_topology_update_distance(struct eigrp_fsm_action_message *msg)
{
struct eigrp *eigrp = msg->eigrp;
struct eigrp_prefix_entry *prefix = msg->prefix;
struct eigrp_neighbor_entry *entry = msg->entry;
- int change = 0;
+ enum metric_change change = METRIC_SAME;
assert(entry);
struct TLV_IPv4_External_type *ext_data = NULL;
struct TLV_IPv4_Internal_type *int_data = NULL;
if (msg->data_type == EIGRP_TLV_IPv4_INT) {
+ u_int32_t new_reported_distance;
+
int_data = msg->data.ipv4_int_type;
if (eigrp_metrics_is_same(int_data->metric,
entry->reported_metric)) {
- return 0; // No change
+ return change; // No change
}
- change = entry->reported_distance
- < eigrp_calculate_metrics(
- eigrp, int_data->metric)
- ? 1
- : entry->reported_distance
- > eigrp_calculate_metrics(
- eigrp,
- int_data->metric)
- ? 2
- : 3; // Increase : Decrease : No
- // change
+
+ new_reported_distance = eigrp_calculate_metrics(eigrp,
+ int_data->metric);
+
+ if (entry->reported_distance < new_reported_distance)
+ change = METRIC_INCREASE;
+ else
+ change = METRIC_DECREASE;
+
entry->reported_metric = int_data->metric;
- entry->reported_distance =
+ entry->reported_distance = new_reported_distance;
eigrp_calculate_metrics(eigrp, int_data->metric);
entry->distance = eigrp_calculate_total_metrics(eigrp, entry);
} else {
ext_data = msg->data.ipv4_ext_data;
if (eigrp_metrics_is_same(ext_data->metric,
entry->reported_metric))
- return 0;
+ return change;
}
/*
* Move to correct position in list according to new distance
diff --git a/eigrpd/eigrp_topology.h b/eigrpd/eigrp_topology.h
index 1340c8210..0c9b5c60c 100644
--- a/eigrpd/eigrp_topology.h
+++ b/eigrpd/eigrp_topology.h
@@ -60,7 +60,7 @@ extern struct list *eigrp_neighbor_prefixes_lookup(struct eigrp *,
struct eigrp_neighbor *);
extern void eigrp_topology_update_all_node_flags(struct eigrp *);
extern void eigrp_topology_update_node_flags(struct eigrp_prefix_entry *);
-extern int eigrp_topology_update_distance(struct eigrp_fsm_action_message *);
+extern enum metric_change eigrp_topology_update_distance(struct eigrp_fsm_action_message *);
extern void eigrp_update_routing_table(struct eigrp_prefix_entry *);
extern void eigrp_topology_neighbor_down(struct eigrp *,
struct eigrp_neighbor *);