mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 00:41:20 +00:00
eigrpd: Cleanup list accessors
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
c1c32a7803
commit
695ff37bab
@ -204,8 +204,7 @@ int eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg)
|
||||
switch (actual_state) {
|
||||
case EIGRP_FSM_STATE_PASSIVE: {
|
||||
struct eigrp_neighbor_entry *head =
|
||||
(struct eigrp_neighbor_entry *)
|
||||
entry->prefix->entries->head->data;
|
||||
listnode_head(prefix->entries);
|
||||
|
||||
if (head->reported_distance < prefix->fdistance) {
|
||||
return EIGRP_FSM_KEEP_STATE;
|
||||
@ -226,8 +225,7 @@ int 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_neighbor_entry *head =
|
||||
(struct eigrp_neighbor_entry *)
|
||||
entry->prefix->entries->head->data;
|
||||
listnode_head(prefix->entries);
|
||||
|
||||
listnode_delete(prefix->rij, entry->adv_router);
|
||||
if (prefix->rij->count)
|
||||
@ -279,8 +277,7 @@ int 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_neighbor_entry *head =
|
||||
(struct eigrp_neighbor_entry *)
|
||||
prefix->entries->head->data;
|
||||
listnode_head(prefix->entries);
|
||||
|
||||
listnode_delete(prefix->rij, entry->adv_router);
|
||||
if (prefix->rij->count) {
|
||||
@ -350,16 +347,15 @@ 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 list *successors = eigrp_topology_get_successor(prefix);
|
||||
struct eigrp_neighbor_entry *ne;
|
||||
|
||||
assert(successors); // If this is NULL we have shit the bed, fun huh?
|
||||
|
||||
ne = listnode_head(successors);
|
||||
prefix->state = EIGRP_FSM_STATE_ACTIVE_1;
|
||||
prefix->rdistance = prefix->distance = prefix->fdistance =
|
||||
((struct eigrp_neighbor_entry *)successors->head->data)
|
||||
->distance;
|
||||
prefix->reported_metric =
|
||||
((struct eigrp_neighbor_entry *)successors->head->data)
|
||||
->total_metric;
|
||||
ne->distance;
|
||||
prefix->reported_metric = ne->total_metric;
|
||||
|
||||
if (eigrp_nbr_count_get()) {
|
||||
prefix->req_action |= EIGRP_FSM_NEED_QUERY;
|
||||
@ -379,16 +375,15 @@ 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 list *successors = eigrp_topology_get_successor(prefix);
|
||||
struct eigrp_neighbor_entry *ne;
|
||||
|
||||
assert(successors); // If this is NULL somebody poked us in the eye.
|
||||
|
||||
ne = listnode_head(successors);
|
||||
prefix->state = EIGRP_FSM_STATE_ACTIVE_3;
|
||||
prefix->rdistance = prefix->distance = prefix->fdistance =
|
||||
((struct eigrp_neighbor_entry *)successors->head->data)
|
||||
->distance;
|
||||
prefix->reported_metric =
|
||||
((struct eigrp_neighbor_entry *)successors->head->data)
|
||||
->total_metric;
|
||||
ne->distance;
|
||||
prefix->reported_metric = ne->total_metric;
|
||||
if (eigrp_nbr_count_get()) {
|
||||
prefix->req_action |= EIGRP_FSM_NEED_QUERY;
|
||||
listnode_add(eigrp->topology_changes_internalIPV4, prefix);
|
||||
@ -405,21 +400,15 @@ 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_prefix_entry *prefix = msg->prefix;
|
||||
struct eigrp_neighbor_entry *ne = listnode_head(prefix->entries);
|
||||
|
||||
if (prefix->state == EIGRP_FSM_STATE_PASSIVE) {
|
||||
if (!eigrp_metrics_is_same(prefix->reported_metric,
|
||||
((struct eigrp_neighbor_entry *)
|
||||
prefix->entries->head->data)
|
||||
->total_metric)) {
|
||||
ne->total_metric)) {
|
||||
prefix->rdistance = prefix->fdistance =
|
||||
prefix->distance =
|
||||
((struct eigrp_neighbor_entry *)
|
||||
prefix->entries->head->data)
|
||||
->distance;
|
||||
prefix->distance = ne->distance;
|
||||
prefix->reported_metric =
|
||||
((struct eigrp_neighbor_entry *)
|
||||
prefix->entries->head->data)
|
||||
->total_metric;
|
||||
ne->total_metric;
|
||||
if (msg->packet_type == EIGRP_OPC_QUERY)
|
||||
eigrp_send_reply(msg->adv_router, prefix);
|
||||
prefix->req_action |= EIGRP_FSM_NEED_UPDATE;
|
||||
@ -441,22 +430,20 @@ 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_neighbor_entry *ne = listnode_head(prefix->entries);
|
||||
|
||||
prefix->fdistance = prefix->distance = prefix->rdistance =
|
||||
((struct eigrp_neighbor_entry *)(prefix->entries->head->data))
|
||||
->distance;
|
||||
prefix->reported_metric =
|
||||
((struct eigrp_neighbor_entry *)(prefix->entries->head->data))
|
||||
->total_metric;
|
||||
ne->distance;
|
||||
prefix->reported_metric = ne->total_metric;
|
||||
|
||||
if (prefix->state == EIGRP_FSM_STATE_ACTIVE_3) {
|
||||
struct list *successors = eigrp_topology_get_successor(prefix);
|
||||
|
||||
assert(successors); // It's like Napolean and Waterloo
|
||||
|
||||
eigrp_send_reply(
|
||||
((struct eigrp_neighbor_entry *)successors->head->data)
|
||||
->adv_router,
|
||||
prefix);
|
||||
ne = listnode_head(successors);
|
||||
eigrp_send_reply(ne->adv_router,
|
||||
prefix);
|
||||
list_delete(successors);
|
||||
}
|
||||
|
||||
@ -473,15 +460,15 @@ 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_neighbor_entry *ne;
|
||||
|
||||
assert(successors); // Trump and his big hands
|
||||
|
||||
ne = listnode_head(successors);
|
||||
msg->prefix->state = msg->prefix->state == EIGRP_FSM_STATE_ACTIVE_1
|
||||
? EIGRP_FSM_STATE_ACTIVE_0
|
||||
: EIGRP_FSM_STATE_ACTIVE_2;
|
||||
msg->prefix->distance =
|
||||
((struct eigrp_neighbor_entry *)successors->head->data)
|
||||
->distance;
|
||||
msg->prefix->distance = ne->distance;
|
||||
if (!msg->prefix->rij->count)
|
||||
(*(NSM[msg->prefix->state][eigrp_get_fsm_event(msg)].func))(
|
||||
msg);
|
||||
@ -495,13 +482,11 @@ 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_neighbor_entry *ne = listnode_head(prefix->entries);
|
||||
|
||||
prefix->state = EIGRP_FSM_STATE_PASSIVE;
|
||||
prefix->distance = prefix->rdistance =
|
||||
((struct eigrp_neighbor_entry *)(prefix->entries->head->data))
|
||||
->distance;
|
||||
prefix->reported_metric =
|
||||
((struct eigrp_neighbor_entry *)(prefix->entries->head->data))
|
||||
->total_metric;
|
||||
prefix->distance = prefix->rdistance = ne->distance;
|
||||
prefix->reported_metric = ne->total_metric;
|
||||
prefix->fdistance = prefix->fdistance > prefix->distance
|
||||
? prefix->distance
|
||||
: prefix->fdistance;
|
||||
@ -510,11 +495,9 @@ int eigrp_fsm_event_lr_fcs(struct eigrp_fsm_action_message *msg)
|
||||
|
||||
assert(successors); // Having a spoon and all you need is a
|
||||
// knife
|
||||
|
||||
eigrp_send_reply(
|
||||
((struct eigrp_neighbor_entry *)successors->head->data)
|
||||
->adv_router,
|
||||
prefix);
|
||||
ne = listnode_head(successors);
|
||||
eigrp_send_reply(ne->adv_router,
|
||||
prefix);
|
||||
|
||||
list_delete(successors);
|
||||
}
|
||||
@ -531,6 +514,7 @@ 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_neighbor_entry *best_successor;
|
||||
struct list *successors = eigrp_topology_get_successor(prefix);
|
||||
|
||||
assert(successors); // Routing without a stack
|
||||
@ -538,8 +522,8 @@ int eigrp_fsm_event_lr_fcn(struct eigrp_fsm_action_message *msg)
|
||||
prefix->state = prefix->state == EIGRP_FSM_STATE_ACTIVE_0
|
||||
? EIGRP_FSM_STATE_ACTIVE_1
|
||||
: EIGRP_FSM_STATE_ACTIVE_3;
|
||||
struct eigrp_neighbor_entry *best_successor =
|
||||
((struct eigrp_neighbor_entry *)(successors->head->data));
|
||||
|
||||
best_successor = listnode_head(successors);
|
||||
prefix->rdistance = prefix->distance = best_successor->distance;
|
||||
prefix->reported_metric = best_successor->total_metric;
|
||||
|
||||
@ -559,13 +543,13 @@ 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_neighbor_entry *ne;
|
||||
|
||||
assert(successors); // Cats and no Dogs
|
||||
|
||||
ne = listnode_head(successors);
|
||||
msg->prefix->state = EIGRP_FSM_STATE_ACTIVE_2;
|
||||
msg->prefix->distance =
|
||||
((struct eigrp_neighbor_entry *)(successors->head->data))
|
||||
->distance;
|
||||
msg->prefix->distance = ne->distance;
|
||||
|
||||
list_delete(successors);
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user