]> git.proxmox.com Git - mirror_frr.git/blob - eigrpd/eigrp_fsm.c
Merge pull request #1382 from donaldsharp/eigrp_loop
[mirror_frr.git] / eigrpd / eigrp_fsm.c
1 /*
2 * EIGRPd Finite State Machine (DUAL).
3 * Copyright (C) 2013-2014
4 * Authors:
5 * Donnie Savage
6 * Jan Janovic
7 * Matej Perina
8 * Peter Orsag
9 * Peter Paluch
10 *
11 * This file is part of GNU Zebra.
12 *
13 * GNU Zebra is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2, or (at your option) any
16 * later version.
17 *
18 * GNU Zebra is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; see the file COPYING; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 *
27 * This file contains functions for executing logic of finite state machine
28 *
29 * +------------ +
30 * | (7) |
31 * | v
32 * +=====================================+
33 * | |
34 * | Passive |
35 * | |
36 * +=====================================+
37 * ^ | ^ ^ ^ |
38 * (3)| | (1)| | (1)| |
39 * | (0)| | (3)| | (2)|
40 * | | | | | +---------------+
41 * | | | | | \
42 * +--------+ | | | +-----------------+ \
43 * / / / | \ \
44 * / / / +----+ \ \
45 * | | | | | |
46 * | v | | | v
47 * +===========+ (6) +===========+ +===========+ (6) +===========+
48 * | |------->| | (5) | |-------->| |
49 * | | (4) | |------>| | (4) | |
50 * | ACTIVE 0 |<-------| ACTIVE 1 | | ACTIVE 2 |<--------| ACTIVE 3
51 * |
52 * +--| | +--| | +--| | +--| |
53 * | +===========+ | +===========+ | +===========+ |
54 * +===========+
55 * | ^ |(5) | ^ | ^ ^ | ^
56 * | | +---------|------|------------|----+ | | |
57 * +-------+ +------+ +---------+ +---------+
58 * (7) (7) (7) (7)
59 *
60 * 0- input event other than query from successor, FC not satisfied
61 * 1- last reply, FD is reset
62 * 2- query from successor, FC not satisfied
63 * 3- last reply, FC satisfied with current value of FDij
64 * 4- distance increase while in active state
65 * 5- query from successor while in active state
66 * 6- last reply, FC not satisfied with current value of FDij
67 * 7- state not changed, usually by receiving not last reply
68 */
69
70 #include <thread.h>
71 #include <zebra.h>
72
73 #include "prefix.h"
74 #include "table.h"
75 #include "memory.h"
76 #include "log.h"
77 #include "linklist.h"
78 #include "vty.h"
79
80 #include "eigrpd/eigrp_structs.h"
81 #include "eigrpd/eigrpd.h"
82 #include "eigrpd/eigrp_interface.h"
83 #include "eigrpd/eigrp_neighbor.h"
84 #include "eigrpd/eigrp_packet.h"
85 #include "eigrpd/eigrp_zebra.h"
86 #include "eigrpd/eigrp_vty.h"
87 #include "eigrpd/eigrp_network.h"
88 #include "eigrpd/eigrp_dump.h"
89 #include "eigrpd/eigrp_topology.h"
90 #include "eigrpd/eigrp_fsm.h"
91
92 /*
93 * Prototypes
94 */
95 int eigrp_fsm_event_keep_state(struct eigrp_fsm_action_message *);
96 int eigrp_fsm_event_nq_fcn(struct eigrp_fsm_action_message *);
97 int eigrp_fsm_event_q_fcn(struct eigrp_fsm_action_message *);
98 int eigrp_fsm_event_lr(struct eigrp_fsm_action_message *);
99 int eigrp_fsm_event_dinc(struct eigrp_fsm_action_message *);
100 int eigrp_fsm_event_lr_fcs(struct eigrp_fsm_action_message *);
101 int eigrp_fsm_event_lr_fcn(struct eigrp_fsm_action_message *);
102 int eigrp_fsm_event_qact(struct eigrp_fsm_action_message *);
103
104 //---------------------------------------------------------------------
105
106 /*
107 * NSM - field of fields of struct containing one function each.
108 * Which function is used depends on actual state of FSM and occurred
109 * event(arrow in diagram). Usage:
110 * NSM[actual/starting state][occurred event].func
111 * Functions are should be executed within separate thread.
112 */
113 struct {
114 int (*func)(struct eigrp_fsm_action_message *);
115 } NSM[EIGRP_FSM_STATE_MAX][EIGRP_FSM_EVENT_MAX] = {
116 {
117 // PASSIVE STATE
118 {eigrp_fsm_event_nq_fcn}, /* Event 0 */
119 {eigrp_fsm_event_keep_state}, /* Event 1 */
120 {eigrp_fsm_event_q_fcn}, /* Event 2 */
121 {eigrp_fsm_event_keep_state}, /* Event 3 */
122 {eigrp_fsm_event_keep_state}, /* Event 4 */
123 {eigrp_fsm_event_keep_state}, /* Event 5 */
124 {eigrp_fsm_event_keep_state}, /* Event 6 */
125 {eigrp_fsm_event_keep_state}, /* Event 7 */
126 },
127 {
128 // Active 0 state
129 {eigrp_fsm_event_keep_state}, /* Event 0 */
130 {eigrp_fsm_event_keep_state}, /* Event 1 */
131 {eigrp_fsm_event_keep_state}, /* Event 2 */
132 {eigrp_fsm_event_lr_fcs}, /* Event 3 */
133 {eigrp_fsm_event_keep_state}, /* Event 4 */
134 {eigrp_fsm_event_qact}, /* Event 5 */
135 {eigrp_fsm_event_lr_fcn}, /* Event 6 */
136 {eigrp_fsm_event_keep_state}, /* Event 7 */
137 },
138 {
139 // Active 1 state
140 {eigrp_fsm_event_keep_state}, /* Event 0 */
141 {eigrp_fsm_event_lr}, /* Event 1 */
142 {eigrp_fsm_event_keep_state}, /* Event 2 */
143 {eigrp_fsm_event_keep_state}, /* Event 3 */
144 {eigrp_fsm_event_dinc}, /* Event 4 */
145 {eigrp_fsm_event_qact}, /* Event 5 */
146 {eigrp_fsm_event_keep_state}, /* Event 6 */
147 {eigrp_fsm_event_keep_state}, /* Event 7 */
148 },
149 {
150 // Active 2 state
151 {eigrp_fsm_event_keep_state}, /* Event 0 */
152 {eigrp_fsm_event_keep_state}, /* Event 1 */
153 {eigrp_fsm_event_keep_state}, /* Event 2 */
154 {eigrp_fsm_event_lr_fcs}, /* Event 3 */
155 {eigrp_fsm_event_keep_state}, /* Event 4 */
156 {eigrp_fsm_event_keep_state}, /* Event 5 */
157 {eigrp_fsm_event_lr_fcn}, /* Event 6 */
158 {eigrp_fsm_event_keep_state}, /* Event 7 */
159 },
160 {
161 // Active 3 state
162 {eigrp_fsm_event_keep_state}, /* Event 0 */
163 {eigrp_fsm_event_lr}, /* Event 1 */
164 {eigrp_fsm_event_keep_state}, /* Event 2 */
165 {eigrp_fsm_event_keep_state}, /* Event 3 */
166 {eigrp_fsm_event_dinc}, /* Event 4 */
167 {eigrp_fsm_event_keep_state}, /* Event 5 */
168 {eigrp_fsm_event_keep_state}, /* Event 6 */
169 {eigrp_fsm_event_keep_state}, /* Event 7 */
170 },
171 };
172
173 static const char *packet_type2str(u_char packet_type)
174 {
175 if (packet_type == EIGRP_OPC_UPDATE)
176 return "Update";
177 if (packet_type == EIGRP_OPC_REQUEST)
178 return "Request";
179 if (packet_type == EIGRP_OPC_QUERY)
180 return "Query";
181 if (packet_type == EIGRP_OPC_REPLY)
182 return "Reply";
183 if (packet_type == EIGRP_OPC_HELLO)
184 return "Hello";
185 if (packet_type == EIGRP_OPC_IPXSAP)
186 return "IPXSAP";
187 if (packet_type == EIGRP_OPC_ACK)
188 return "Ack";
189 if (packet_type == EIGRP_OPC_SIAQUERY)
190 return "SIA Query";
191 if (packet_type == EIGRP_OPC_SIAREPLY)
192 return "SIA Reply";
193
194 return "Unknown";
195 }
196
197 static const char *prefix_state2str(enum eigrp_fsm_states state)
198 {
199 switch (state) {
200 case EIGRP_FSM_STATE_PASSIVE:
201 return "Passive";
202 case EIGRP_FSM_STATE_ACTIVE_0:
203 return "Active oij0";
204 case EIGRP_FSM_STATE_ACTIVE_1:
205 return "Active oij1";
206 case EIGRP_FSM_STATE_ACTIVE_2:
207 return "Active oij2";
208 case EIGRP_FSM_STATE_ACTIVE_3:
209 return "Active oij3";
210 }
211
212 return "Unknown";
213 }
214
215 static const char *fsm_state2str(enum eigrp_fsm_events event)
216 {
217 switch (event) {
218 case EIGRP_FSM_KEEP_STATE:
219 return "Keep State Event";
220 case EIGRP_FSM_EVENT_NQ_FCN:
221 return "Non Query Event Feasability not satisfied";
222 case EIGRP_FSM_EVENT_LR:
223 return "Last Reply Event";
224 case EIGRP_FSM_EVENT_Q_FCN:
225 return "Query Event Feasability not satisified";
226 case EIGRP_FSM_EVENT_LR_FCS:
227 return "Last Reply Event Feasability satisified";
228 case EIGRP_FSM_EVENT_DINC:
229 return "Distance Increase Event";
230 case EIGRP_FSM_EVENT_QACT:
231 return "Query from Successor while in active state";
232 case EIGRP_FSM_EVENT_LR_FCN:
233 return "Last Reply Event, Feasibility not satisfied";
234 };
235
236 return "Unknown";
237 }
238
239 static const char *change2str(enum metric_change change)
240 {
241 switch (change) {
242 case METRIC_DECREASE:
243 return "Decrease";
244 case METRIC_SAME:
245 return "Same";
246 case METRIC_INCREASE:
247 return "Increase";
248 }
249
250 return "Unknown";
251 }
252 /*
253 * Main function in which are make decisions which event occurred.
254 * msg - argument of type struct eigrp_fsm_action_message contain
255 * details about what happen
256 *
257 * Return number of occurred event (arrow in diagram).
258 *
259 */
260 static enum eigrp_fsm_events eigrp_get_fsm_event(
261 struct eigrp_fsm_action_message *msg)
262 {
263 // Loading base information from message
264 // struct eigrp *eigrp = msg->eigrp;
265 struct eigrp_prefix_entry *prefix = msg->prefix;
266 struct eigrp_nexthop_entry *entry = msg->entry;
267 u_char actual_state = prefix->state;
268 enum metric_change change;
269
270 if (entry == NULL) {
271 entry = eigrp_nexthop_entry_new();
272 entry->adv_router = msg->adv_router;
273 entry->ei = msg->adv_router->ei;
274 entry->prefix = prefix;
275 msg->entry = entry;
276 }
277
278 /*
279 * Calculate resultant metrics and insert to correct position
280 * in entries list
281 */
282 change = eigrp_topology_update_distance(msg);
283
284 /* Store for display later */
285 msg->change = change;
286
287 switch (actual_state) {
288 case EIGRP_FSM_STATE_PASSIVE: {
289 struct eigrp_nexthop_entry *head =
290 listnode_head(prefix->entries);
291
292 if (head->reported_distance < prefix->fdistance) {
293 return EIGRP_FSM_KEEP_STATE;
294 }
295 /*
296 * if best entry doesn't satisfy feasibility condition it means
297 * move to active state
298 * dependently if it was query from successor
299 */
300 if (msg->packet_type == EIGRP_OPC_QUERY) {
301 return EIGRP_FSM_EVENT_Q_FCN;
302 } else {
303 return EIGRP_FSM_EVENT_NQ_FCN;
304 }
305
306 break;
307 }
308 case EIGRP_FSM_STATE_ACTIVE_0: {
309 if (msg->packet_type == EIGRP_OPC_REPLY) {
310 struct eigrp_nexthop_entry *head =
311 listnode_head(prefix->entries);
312
313 listnode_delete(prefix->rij, entry->adv_router);
314 if (prefix->rij->count)
315 return EIGRP_FSM_KEEP_STATE;
316
317 zlog_info("All reply received\n");
318 if (head->reported_distance
319 < prefix->fdistance) {
320 return EIGRP_FSM_EVENT_LR_FCS;
321 }
322
323 return EIGRP_FSM_EVENT_LR_FCN;
324 } else if (msg->packet_type == EIGRP_OPC_QUERY
325 && (entry->flags
326 & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) {
327 return EIGRP_FSM_EVENT_QACT;
328 }
329
330 return EIGRP_FSM_KEEP_STATE;
331
332 break;
333 }
334 case EIGRP_FSM_STATE_ACTIVE_1: {
335 if (msg->packet_type == EIGRP_OPC_QUERY
336 && (entry->flags & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) {
337 return EIGRP_FSM_EVENT_QACT;
338 } else if (msg->packet_type == EIGRP_OPC_REPLY) {
339 listnode_delete(prefix->rij, entry->adv_router);
340
341 if (change == METRIC_INCREASE
342 && (entry->flags
343 & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) {
344 return EIGRP_FSM_EVENT_DINC;
345 } else if (prefix->rij->count) {
346 return EIGRP_FSM_KEEP_STATE;
347 } else {
348 zlog_info("All reply received\n");
349 return EIGRP_FSM_EVENT_LR;
350 }
351 } else if (msg->packet_type == EIGRP_OPC_UPDATE
352 && change == METRIC_INCREASE
353 && (entry->flags
354 & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) {
355 return EIGRP_FSM_EVENT_DINC;
356 }
357 return EIGRP_FSM_KEEP_STATE;
358
359 break;
360 }
361 case EIGRP_FSM_STATE_ACTIVE_2: {
362 if (msg->packet_type == EIGRP_OPC_REPLY) {
363 struct eigrp_nexthop_entry *head =
364 listnode_head(prefix->entries);
365
366 listnode_delete(prefix->rij, entry->adv_router);
367 if (prefix->rij->count) {
368 return EIGRP_FSM_KEEP_STATE;
369 } else {
370 zlog_info("All reply received\n");
371 if (head->reported_distance
372 < prefix->fdistance) {
373 return EIGRP_FSM_EVENT_LR_FCS;
374 }
375
376 return EIGRP_FSM_EVENT_LR_FCN;
377 }
378 }
379 return EIGRP_FSM_KEEP_STATE;
380
381 break;
382 }
383 case EIGRP_FSM_STATE_ACTIVE_3: {
384 if (msg->packet_type == EIGRP_OPC_REPLY) {
385 listnode_delete(prefix->rij, entry->adv_router);
386
387 if (change == METRIC_INCREASE
388 && (entry->flags
389 & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) {
390 return EIGRP_FSM_EVENT_DINC;
391 } else if (prefix->rij->count) {
392 return EIGRP_FSM_KEEP_STATE;
393 } else {
394 zlog_info("All reply received\n");
395 return EIGRP_FSM_EVENT_LR;
396 }
397 } else if (msg->packet_type == EIGRP_OPC_UPDATE
398 && change == METRIC_INCREASE
399 && (entry->flags
400 & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) {
401 return EIGRP_FSM_EVENT_DINC;
402 }
403 return EIGRP_FSM_KEEP_STATE;
404
405 break;
406 }
407 }
408
409 return EIGRP_FSM_KEEP_STATE;
410 }
411
412 /*
413 * Function made to execute in separate thread.
414 * Load argument from thread and execute proper NSM function
415 */
416 int eigrp_fsm_event(struct eigrp_fsm_action_message *msg)
417 {
418 enum eigrp_fsm_events event = eigrp_get_fsm_event(msg);
419
420 zlog_info("EIGRP AS: %d State: %s Event: %s Network: %s Packet Type: %s Reply RIJ Count: %d change: %s",
421 msg->eigrp->AS, prefix_state2str(msg->prefix->state),
422 fsm_state2str(event),
423 eigrp_topology_ip_string(msg->prefix),
424 packet_type2str(msg->packet_type),
425 msg->prefix->rij->count,
426 change2str(msg->change));
427 (*(NSM[msg->prefix->state][event].func))(msg);
428
429 return 1;
430 }
431
432 /*
433 * Function of event 0.
434 *
435 */
436 int eigrp_fsm_event_nq_fcn(struct eigrp_fsm_action_message *msg)
437 {
438 struct eigrp *eigrp = msg->eigrp;
439 struct eigrp_prefix_entry *prefix = msg->prefix;
440 struct list *successors = eigrp_topology_get_successor(prefix);
441 struct eigrp_nexthop_entry *ne;
442
443 assert(successors); // If this is NULL we have shit the bed, fun huh?
444
445 ne = listnode_head(successors);
446 prefix->state = EIGRP_FSM_STATE_ACTIVE_1;
447 prefix->rdistance = prefix->distance = prefix->fdistance =
448 ne->distance;
449 prefix->reported_metric = ne->total_metric;
450
451 if (eigrp_nbr_count_get()) {
452 prefix->req_action |= EIGRP_FSM_NEED_QUERY;
453 listnode_add(eigrp->topology_changes_internalIPV4, prefix);
454 } else {
455 eigrp_fsm_event_lr(msg); // in the case that there are no more
456 // neighbors left
457 }
458
459 list_delete_and_null(&successors);
460
461 return 1;
462 }
463
464 int eigrp_fsm_event_q_fcn(struct eigrp_fsm_action_message *msg)
465 {
466 struct eigrp *eigrp = msg->eigrp;
467 struct eigrp_prefix_entry *prefix = msg->prefix;
468 struct list *successors = eigrp_topology_get_successor(prefix);
469 struct eigrp_nexthop_entry *ne;
470
471 assert(successors); // If this is NULL somebody poked us in the eye.
472
473 ne = listnode_head(successors);
474 prefix->state = EIGRP_FSM_STATE_ACTIVE_3;
475 prefix->rdistance = prefix->distance = prefix->fdistance =
476 ne->distance;
477 prefix->reported_metric = ne->total_metric;
478 if (eigrp_nbr_count_get()) {
479 prefix->req_action |= EIGRP_FSM_NEED_QUERY;
480 listnode_add(eigrp->topology_changes_internalIPV4, prefix);
481 } else {
482 eigrp_fsm_event_lr(msg); // in the case that there are no more
483 // neighbors left
484 }
485
486 list_delete_and_null(&successors);
487
488 return 1;
489 }
490
491 int eigrp_fsm_event_keep_state(struct eigrp_fsm_action_message *msg)
492 {
493 struct eigrp_prefix_entry *prefix = msg->prefix;
494 struct eigrp_nexthop_entry *ne = listnode_head(prefix->entries);
495
496 if (prefix->state == EIGRP_FSM_STATE_PASSIVE) {
497 if (!eigrp_metrics_is_same(prefix->reported_metric,
498 ne->total_metric)) {
499 prefix->rdistance = prefix->fdistance =
500 prefix->distance = ne->distance;
501 prefix->reported_metric =
502 ne->total_metric;
503 if (msg->packet_type == EIGRP_OPC_QUERY)
504 eigrp_send_reply(msg->adv_router, prefix);
505 prefix->req_action |= EIGRP_FSM_NEED_UPDATE;
506 listnode_add(
507 (eigrp_lookup())->topology_changes_internalIPV4,
508 prefix);
509 }
510 eigrp_topology_update_node_flags(prefix);
511 eigrp_update_routing_table(prefix);
512 }
513
514 if (msg->packet_type == EIGRP_OPC_QUERY)
515 eigrp_send_reply(msg->adv_router, prefix);
516
517 return 1;
518 }
519
520 int eigrp_fsm_event_lr(struct eigrp_fsm_action_message *msg)
521 {
522 struct eigrp *eigrp = msg->eigrp;
523 struct eigrp_prefix_entry *prefix = msg->prefix;
524 struct eigrp_nexthop_entry *ne = listnode_head(prefix->entries);
525
526 prefix->fdistance = prefix->distance = prefix->rdistance =
527 ne->distance;
528 prefix->reported_metric = ne->total_metric;
529
530 if (prefix->state == EIGRP_FSM_STATE_ACTIVE_3) {
531 struct list *successors = eigrp_topology_get_successor(prefix);
532
533 assert(successors); // It's like Napolean and Waterloo
534
535 ne = listnode_head(successors);
536 eigrp_send_reply(ne->adv_router,
537 prefix);
538 list_delete_and_null(&successors);
539 }
540
541 prefix->state = EIGRP_FSM_STATE_PASSIVE;
542 prefix->req_action |= EIGRP_FSM_NEED_UPDATE;
543 listnode_add(eigrp->topology_changes_internalIPV4, prefix);
544 eigrp_topology_update_node_flags(prefix);
545 eigrp_update_routing_table(prefix);
546 eigrp_update_topology_table_prefix(eigrp->topology_table, prefix);
547
548 return 1;
549 }
550
551 int eigrp_fsm_event_dinc(struct eigrp_fsm_action_message *msg)
552 {
553 struct list *successors = eigrp_topology_get_successor(msg->prefix);
554 struct eigrp_nexthop_entry *ne;
555
556 assert(successors); // Trump and his big hands
557
558 ne = listnode_head(successors);
559 msg->prefix->state = msg->prefix->state == EIGRP_FSM_STATE_ACTIVE_1
560 ? EIGRP_FSM_STATE_ACTIVE_0
561 : EIGRP_FSM_STATE_ACTIVE_2;
562 msg->prefix->distance = ne->distance;
563 if (!msg->prefix->rij->count)
564 (*(NSM[msg->prefix->state][eigrp_get_fsm_event(msg)].func))(
565 msg);
566
567
568 list_delete_and_null(&successors);
569 return 1;
570 }
571
572 int eigrp_fsm_event_lr_fcs(struct eigrp_fsm_action_message *msg)
573 {
574 struct eigrp *eigrp = msg->eigrp;
575 struct eigrp_prefix_entry *prefix = msg->prefix;
576 struct eigrp_nexthop_entry *ne = listnode_head(prefix->entries);
577
578 prefix->state = EIGRP_FSM_STATE_PASSIVE;
579 prefix->distance = prefix->rdistance = ne->distance;
580 prefix->reported_metric = ne->total_metric;
581 prefix->fdistance = prefix->fdistance > prefix->distance
582 ? prefix->distance
583 : prefix->fdistance;
584 if (prefix->state == EIGRP_FSM_STATE_ACTIVE_2) {
585 struct list *successors = eigrp_topology_get_successor(prefix);
586
587 assert(successors); // Having a spoon and all you need is a
588 // knife
589 ne = listnode_head(successors);
590 eigrp_send_reply(ne->adv_router,
591 prefix);
592
593 list_delete_and_null(&successors);
594 }
595 prefix->req_action |= EIGRP_FSM_NEED_UPDATE;
596 listnode_add(eigrp->topology_changes_internalIPV4, prefix);
597 eigrp_topology_update_node_flags(prefix);
598 eigrp_update_routing_table(prefix);
599 eigrp_update_topology_table_prefix(eigrp->topology_table, prefix);
600
601 return 1;
602 }
603
604 int eigrp_fsm_event_lr_fcn(struct eigrp_fsm_action_message *msg)
605 {
606 struct eigrp *eigrp = msg->eigrp;
607 struct eigrp_prefix_entry *prefix = msg->prefix;
608 struct eigrp_nexthop_entry *best_successor;
609 struct list *successors = eigrp_topology_get_successor(prefix);
610
611 assert(successors); // Routing without a stack
612
613 prefix->state = prefix->state == EIGRP_FSM_STATE_ACTIVE_0
614 ? EIGRP_FSM_STATE_ACTIVE_1
615 : EIGRP_FSM_STATE_ACTIVE_3;
616
617 best_successor = listnode_head(successors);
618 prefix->rdistance = prefix->distance = best_successor->distance;
619 prefix->reported_metric = best_successor->total_metric;
620
621 if (eigrp_nbr_count_get()) {
622 prefix->req_action |= EIGRP_FSM_NEED_QUERY;
623 listnode_add(eigrp->topology_changes_internalIPV4, prefix);
624 } else {
625 eigrp_fsm_event_lr(msg); // in the case that there are no more
626 // neighbors left
627 }
628
629 list_delete_and_null(&successors);
630
631 return 1;
632 }
633
634 int eigrp_fsm_event_qact(struct eigrp_fsm_action_message *msg)
635 {
636 struct list *successors = eigrp_topology_get_successor(msg->prefix);
637 struct eigrp_nexthop_entry *ne;
638
639 assert(successors); // Cats and no Dogs
640
641 ne = listnode_head(successors);
642 msg->prefix->state = EIGRP_FSM_STATE_ACTIVE_2;
643 msg->prefix->distance = ne->distance;
644
645 list_delete_and_null(&successors);
646 return 1;
647 }