diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-08-16 04:09:55 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-08-16 04:38:17 +0200 |
commit | 9294886309bea92b3726d9415cfc73661434a081 (patch) | |
tree | a4537acd8df4e27c6543b32b0fd9d3cd942f000f /eigrpd/eigrp_topology.c | |
parent | Merge pull request #983 from opensourcerouting/vtysh-watchfrr-no-conf (diff) | |
download | frr-9294886309bea92b3726d9415cfc73661434a081.tar.xz frr-9294886309bea92b3726d9415cfc73661434a081.zip |
eigrpd: cleanup eigrp_topology_update_distance
Cleanup eigrp_topology_update_distance to
return an enum of whether or not the metric
has changed or not.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'eigrpd/eigrp_topology.c')
-rw-r--r-- | eigrpd/eigrp_topology.c | 32 |
1 files changed, 16 insertions, 16 deletions
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 |