mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 05:31:17 +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) {
|
switch (actual_state) {
|
||||||
case EIGRP_FSM_STATE_PASSIVE: {
|
case EIGRP_FSM_STATE_PASSIVE: {
|
||||||
struct eigrp_neighbor_entry *head =
|
struct eigrp_neighbor_entry *head =
|
||||||
(struct eigrp_neighbor_entry *)
|
listnode_head(prefix->entries);
|
||||||
entry->prefix->entries->head->data;
|
|
||||||
|
|
||||||
if (head->reported_distance < prefix->fdistance) {
|
if (head->reported_distance < prefix->fdistance) {
|
||||||
return EIGRP_FSM_KEEP_STATE;
|
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: {
|
case EIGRP_FSM_STATE_ACTIVE_0: {
|
||||||
if (msg->packet_type == EIGRP_OPC_REPLY) {
|
if (msg->packet_type == EIGRP_OPC_REPLY) {
|
||||||
struct eigrp_neighbor_entry *head =
|
struct eigrp_neighbor_entry *head =
|
||||||
(struct eigrp_neighbor_entry *)
|
listnode_head(prefix->entries);
|
||||||
entry->prefix->entries->head->data;
|
|
||||||
|
|
||||||
listnode_delete(prefix->rij, entry->adv_router);
|
listnode_delete(prefix->rij, entry->adv_router);
|
||||||
if (prefix->rij->count)
|
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: {
|
case EIGRP_FSM_STATE_ACTIVE_2: {
|
||||||
if (msg->packet_type == EIGRP_OPC_REPLY) {
|
if (msg->packet_type == EIGRP_OPC_REPLY) {
|
||||||
struct eigrp_neighbor_entry *head =
|
struct eigrp_neighbor_entry *head =
|
||||||
(struct eigrp_neighbor_entry *)
|
listnode_head(prefix->entries);
|
||||||
prefix->entries->head->data;
|
|
||||||
|
|
||||||
listnode_delete(prefix->rij, entry->adv_router);
|
listnode_delete(prefix->rij, entry->adv_router);
|
||||||
if (prefix->rij->count) {
|
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 *eigrp = msg->eigrp;
|
||||||
struct eigrp_prefix_entry *prefix = msg->prefix;
|
struct eigrp_prefix_entry *prefix = msg->prefix;
|
||||||
struct list *successors = eigrp_topology_get_successor(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?
|
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->state = EIGRP_FSM_STATE_ACTIVE_1;
|
||||||
prefix->rdistance = prefix->distance = prefix->fdistance =
|
prefix->rdistance = prefix->distance = prefix->fdistance =
|
||||||
((struct eigrp_neighbor_entry *)successors->head->data)
|
ne->distance;
|
||||||
->distance;
|
prefix->reported_metric = ne->total_metric;
|
||||||
prefix->reported_metric =
|
|
||||||
((struct eigrp_neighbor_entry *)successors->head->data)
|
|
||||||
->total_metric;
|
|
||||||
|
|
||||||
if (eigrp_nbr_count_get()) {
|
if (eigrp_nbr_count_get()) {
|
||||||
prefix->req_action |= EIGRP_FSM_NEED_QUERY;
|
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 *eigrp = msg->eigrp;
|
||||||
struct eigrp_prefix_entry *prefix = msg->prefix;
|
struct eigrp_prefix_entry *prefix = msg->prefix;
|
||||||
struct list *successors = eigrp_topology_get_successor(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.
|
assert(successors); // If this is NULL somebody poked us in the eye.
|
||||||
|
|
||||||
|
ne = listnode_head(successors);
|
||||||
prefix->state = EIGRP_FSM_STATE_ACTIVE_3;
|
prefix->state = EIGRP_FSM_STATE_ACTIVE_3;
|
||||||
prefix->rdistance = prefix->distance = prefix->fdistance =
|
prefix->rdistance = prefix->distance = prefix->fdistance =
|
||||||
((struct eigrp_neighbor_entry *)successors->head->data)
|
ne->distance;
|
||||||
->distance;
|
prefix->reported_metric = ne->total_metric;
|
||||||
prefix->reported_metric =
|
|
||||||
((struct eigrp_neighbor_entry *)successors->head->data)
|
|
||||||
->total_metric;
|
|
||||||
if (eigrp_nbr_count_get()) {
|
if (eigrp_nbr_count_get()) {
|
||||||
prefix->req_action |= EIGRP_FSM_NEED_QUERY;
|
prefix->req_action |= EIGRP_FSM_NEED_QUERY;
|
||||||
listnode_add(eigrp->topology_changes_internalIPV4, prefix);
|
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)
|
int eigrp_fsm_event_keep_state(struct eigrp_fsm_action_message *msg)
|
||||||
{
|
{
|
||||||
struct eigrp_prefix_entry *prefix = msg->prefix;
|
struct eigrp_prefix_entry *prefix = msg->prefix;
|
||||||
|
struct eigrp_neighbor_entry *ne = listnode_head(prefix->entries);
|
||||||
|
|
||||||
if (prefix->state == EIGRP_FSM_STATE_PASSIVE) {
|
if (prefix->state == EIGRP_FSM_STATE_PASSIVE) {
|
||||||
if (!eigrp_metrics_is_same(prefix->reported_metric,
|
if (!eigrp_metrics_is_same(prefix->reported_metric,
|
||||||
((struct eigrp_neighbor_entry *)
|
ne->total_metric)) {
|
||||||
prefix->entries->head->data)
|
|
||||||
->total_metric)) {
|
|
||||||
prefix->rdistance = prefix->fdistance =
|
prefix->rdistance = prefix->fdistance =
|
||||||
prefix->distance =
|
prefix->distance = ne->distance;
|
||||||
((struct eigrp_neighbor_entry *)
|
|
||||||
prefix->entries->head->data)
|
|
||||||
->distance;
|
|
||||||
prefix->reported_metric =
|
prefix->reported_metric =
|
||||||
((struct eigrp_neighbor_entry *)
|
ne->total_metric;
|
||||||
prefix->entries->head->data)
|
|
||||||
->total_metric;
|
|
||||||
if (msg->packet_type == EIGRP_OPC_QUERY)
|
if (msg->packet_type == EIGRP_OPC_QUERY)
|
||||||
eigrp_send_reply(msg->adv_router, prefix);
|
eigrp_send_reply(msg->adv_router, prefix);
|
||||||
prefix->req_action |= EIGRP_FSM_NEED_UPDATE;
|
prefix->req_action |= EIGRP_FSM_NEED_UPDATE;
|
||||||
@ -441,21 +430,19 @@ int eigrp_fsm_event_lr(struct eigrp_fsm_action_message *msg)
|
|||||||
{
|
{
|
||||||
struct eigrp *eigrp = msg->eigrp;
|
struct eigrp *eigrp = msg->eigrp;
|
||||||
struct eigrp_prefix_entry *prefix = msg->prefix;
|
struct eigrp_prefix_entry *prefix = msg->prefix;
|
||||||
|
struct eigrp_neighbor_entry *ne = listnode_head(prefix->entries);
|
||||||
|
|
||||||
prefix->fdistance = prefix->distance = prefix->rdistance =
|
prefix->fdistance = prefix->distance = prefix->rdistance =
|
||||||
((struct eigrp_neighbor_entry *)(prefix->entries->head->data))
|
ne->distance;
|
||||||
->distance;
|
prefix->reported_metric = ne->total_metric;
|
||||||
prefix->reported_metric =
|
|
||||||
((struct eigrp_neighbor_entry *)(prefix->entries->head->data))
|
|
||||||
->total_metric;
|
|
||||||
|
|
||||||
if (prefix->state == EIGRP_FSM_STATE_ACTIVE_3) {
|
if (prefix->state == EIGRP_FSM_STATE_ACTIVE_3) {
|
||||||
struct list *successors = eigrp_topology_get_successor(prefix);
|
struct list *successors = eigrp_topology_get_successor(prefix);
|
||||||
|
|
||||||
assert(successors); // It's like Napolean and Waterloo
|
assert(successors); // It's like Napolean and Waterloo
|
||||||
|
|
||||||
eigrp_send_reply(
|
ne = listnode_head(successors);
|
||||||
((struct eigrp_neighbor_entry *)successors->head->data)
|
eigrp_send_reply(ne->adv_router,
|
||||||
->adv_router,
|
|
||||||
prefix);
|
prefix);
|
||||||
list_delete(successors);
|
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)
|
int eigrp_fsm_event_dinc(struct eigrp_fsm_action_message *msg)
|
||||||
{
|
{
|
||||||
struct list *successors = eigrp_topology_get_successor(msg->prefix);
|
struct list *successors = eigrp_topology_get_successor(msg->prefix);
|
||||||
|
struct eigrp_neighbor_entry *ne;
|
||||||
|
|
||||||
assert(successors); // Trump and his big hands
|
assert(successors); // Trump and his big hands
|
||||||
|
|
||||||
|
ne = listnode_head(successors);
|
||||||
msg->prefix->state = msg->prefix->state == EIGRP_FSM_STATE_ACTIVE_1
|
msg->prefix->state = msg->prefix->state == EIGRP_FSM_STATE_ACTIVE_1
|
||||||
? EIGRP_FSM_STATE_ACTIVE_0
|
? EIGRP_FSM_STATE_ACTIVE_0
|
||||||
: EIGRP_FSM_STATE_ACTIVE_2;
|
: EIGRP_FSM_STATE_ACTIVE_2;
|
||||||
msg->prefix->distance =
|
msg->prefix->distance = ne->distance;
|
||||||
((struct eigrp_neighbor_entry *)successors->head->data)
|
|
||||||
->distance;
|
|
||||||
if (!msg->prefix->rij->count)
|
if (!msg->prefix->rij->count)
|
||||||
(*(NSM[msg->prefix->state][eigrp_get_fsm_event(msg)].func))(
|
(*(NSM[msg->prefix->state][eigrp_get_fsm_event(msg)].func))(
|
||||||
msg);
|
msg);
|
||||||
@ -495,13 +482,11 @@ int eigrp_fsm_event_lr_fcs(struct eigrp_fsm_action_message *msg)
|
|||||||
{
|
{
|
||||||
struct eigrp *eigrp = msg->eigrp;
|
struct eigrp *eigrp = msg->eigrp;
|
||||||
struct eigrp_prefix_entry *prefix = msg->prefix;
|
struct eigrp_prefix_entry *prefix = msg->prefix;
|
||||||
|
struct eigrp_neighbor_entry *ne = listnode_head(prefix->entries);
|
||||||
|
|
||||||
prefix->state = EIGRP_FSM_STATE_PASSIVE;
|
prefix->state = EIGRP_FSM_STATE_PASSIVE;
|
||||||
prefix->distance = prefix->rdistance =
|
prefix->distance = prefix->rdistance = ne->distance;
|
||||||
((struct eigrp_neighbor_entry *)(prefix->entries->head->data))
|
prefix->reported_metric = ne->total_metric;
|
||||||
->distance;
|
|
||||||
prefix->reported_metric =
|
|
||||||
((struct eigrp_neighbor_entry *)(prefix->entries->head->data))
|
|
||||||
->total_metric;
|
|
||||||
prefix->fdistance = prefix->fdistance > prefix->distance
|
prefix->fdistance = prefix->fdistance > prefix->distance
|
||||||
? prefix->distance
|
? prefix->distance
|
||||||
: prefix->fdistance;
|
: prefix->fdistance;
|
||||||
@ -510,10 +495,8 @@ int eigrp_fsm_event_lr_fcs(struct eigrp_fsm_action_message *msg)
|
|||||||
|
|
||||||
assert(successors); // Having a spoon and all you need is a
|
assert(successors); // Having a spoon and all you need is a
|
||||||
// knife
|
// knife
|
||||||
|
ne = listnode_head(successors);
|
||||||
eigrp_send_reply(
|
eigrp_send_reply(ne->adv_router,
|
||||||
((struct eigrp_neighbor_entry *)successors->head->data)
|
|
||||||
->adv_router,
|
|
||||||
prefix);
|
prefix);
|
||||||
|
|
||||||
list_delete(successors);
|
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 *eigrp = msg->eigrp;
|
||||||
struct eigrp_prefix_entry *prefix = msg->prefix;
|
struct eigrp_prefix_entry *prefix = msg->prefix;
|
||||||
|
struct eigrp_neighbor_entry *best_successor;
|
||||||
struct list *successors = eigrp_topology_get_successor(prefix);
|
struct list *successors = eigrp_topology_get_successor(prefix);
|
||||||
|
|
||||||
assert(successors); // Routing without a stack
|
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
|
prefix->state = prefix->state == EIGRP_FSM_STATE_ACTIVE_0
|
||||||
? EIGRP_FSM_STATE_ACTIVE_1
|
? EIGRP_FSM_STATE_ACTIVE_1
|
||||||
: EIGRP_FSM_STATE_ACTIVE_3;
|
: 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->rdistance = prefix->distance = best_successor->distance;
|
||||||
prefix->reported_metric = best_successor->total_metric;
|
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)
|
int eigrp_fsm_event_qact(struct eigrp_fsm_action_message *msg)
|
||||||
{
|
{
|
||||||
struct list *successors = eigrp_topology_get_successor(msg->prefix);
|
struct list *successors = eigrp_topology_get_successor(msg->prefix);
|
||||||
|
struct eigrp_neighbor_entry *ne;
|
||||||
|
|
||||||
assert(successors); // Cats and no Dogs
|
assert(successors); // Cats and no Dogs
|
||||||
|
|
||||||
|
ne = listnode_head(successors);
|
||||||
msg->prefix->state = EIGRP_FSM_STATE_ACTIVE_2;
|
msg->prefix->state = EIGRP_FSM_STATE_ACTIVE_2;
|
||||||
msg->prefix->distance =
|
msg->prefix->distance = ne->distance;
|
||||||
((struct eigrp_neighbor_entry *)(successors->head->data))
|
|
||||||
->distance;
|
|
||||||
|
|
||||||
list_delete(successors);
|
list_delete(successors);
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user