From: Donald Sharp Date: Wed, 5 Apr 2017 23:24:56 +0000 (-0400) Subject: eigrpd: Cleanup Bit Field handling X-Git-Tag: reindent-master-before~197^2~22 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=9f56205cc5b15653444ec3bdafc2c8daecf9b3cc;p=matthieu%2Ffrr.git eigrpd: Cleanup Bit Field handling Cleanup the Bit field handling for whether or not entries are installed or not. Signed-off-by: Donald Sharp --- diff --git a/eigrpd/eigrp_const.h b/eigrpd/eigrp_const.h index a1d09e684c..b779329652 100644 --- a/eigrpd/eigrp_const.h +++ b/eigrpd/eigrp_const.h @@ -127,10 +127,10 @@ #define EIGRP_TOPOLOGY_TYPE_REMOTE_EXTERNAL 2 // Remote external network /*EIGRP TT entry flags*/ -#define EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG 1 -#define EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG 2 -#define EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG 4 -#define EIGRP_NEIGHBOR_ENTRY_EXTERNAL_FLAG 8 +#define EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG (1 << 0) +#define EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG (1 << 1) +#define EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG (1 << 2) +#define EIGRP_NEIGHBOR_ENTRY_EXTERNAL_FLAG (1 << 3) /*EIGRP FSM state count, event count*/ #define EIGRP_FSM_STATE_MAX 5 diff --git a/eigrpd/eigrp_topology.c b/eigrpd/eigrp_topology.c index 32758b0408..ef0a5eb6ea 100644 --- a/eigrpd/eigrp_topology.c +++ b/eigrpd/eigrp_topology.c @@ -143,8 +143,7 @@ eigrp_prefix_entry_new() new = XCALLOC(MTYPE_EIGRP_PREFIX_ENTRY, sizeof(struct eigrp_prefix_entry)); new->entries = list_new(); new->rij = list_new(); - new->entries->cmp = (int - (*)(void *, void *)) eigrp_neighbor_entry_cmp; + new->entries->cmp = (int (*)(void *, void *))eigrp_neighbor_entry_cmp; new->distance = new->fdistance = new->rdistance = EIGRP_MAX_METRIC; new->destination_ipv4 = NULL; new->destination_ipv6 = NULL; @@ -352,22 +351,6 @@ eigrp_topology_get_successor(struct eigrp_prefix_entry *table_node) return successors; } -/*extern struct eigrp_neighbor_entry * - eigrp_topology_get_fsuccessor (struct eigrp_prefix_entry *table_node) - { - struct eigrp_neighbor_entry *data; - struct listnode *node, *nnode; - for (ALL_LIST_ELEMENTS (table_node->entries, node, nnode, data)) - { - if ((data->flags & EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG) == 1) - { - return data; - } - } - - return NULL; - }*/ - struct eigrp_neighbor_entry * eigrp_prefix_entry_lookup(struct list *entries, struct eigrp_neighbor *nbr) { @@ -480,17 +463,18 @@ eigrp_topology_update_node_flags(struct eigrp_prefix_entry *dest) if ((entry->distance <= (u_int64_t)(dest->distance*eigrp->variance)) && entry->distance != EIGRP_MAX_METRIC) // is successor { entry->flags |= EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG; - entry->flags &= 0xfd; // 1111 1101 set fs flag to zero + entry->flags &= ~EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG; } else if (entry->reported_distance < dest->fdistance) // is feasible successor { entry->flags |= EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG; - entry->flags &= 0xfe; // 1111 1110 set successor flag to zero + entry->flags &= ~EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG; } else { - entry->flags &= 0xfc; // 1111 1100 set successor and fs flag to zero - } + entry->flags &= ~EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG; + entry->flags &= ~EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG; + } } } @@ -507,13 +491,13 @@ eigrp_update_routing_table(struct eigrp_prefix_entry * prefix) if (!(entry->flags & EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG)) { eigrp_zebra_route_add(prefix->destination_ipv4, entry); - entry->flags += EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG; + entry->flags |= EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG; } } else if (entry->flags & EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG) { eigrp_zebra_route_delete(prefix->destination_ipv4, entry); - entry->flags -= EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG; + entry->flags &= ~EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG; } } } @@ -572,23 +556,3 @@ eigrp_update_topology_table_prefix(struct list * table, struct eigrp_prefix_entr eigrp_prefix_entry_delete(table,prefix); } } -/*int - eigrp_topology_get_successor_count (struct eigrp_prefix_entry *prefix) - { - - struct listnode *node; - struct eigrp_neighbor_entry *entry; - - int count = 0; - - for (ALL_LIST_ELEMENTS_RO (prefix->entries,node,entry)) - { - if ((entry->flags & EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG) == EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG) - { - count ++; - } - } - - return count; - } - */