-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrlfa.c
1851 lines (1607 loc) · 87.4 KB
/
rlfa.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* =====================================================================================
*
* Filename: rlfa.c
*
* Description: This file defined the routines to compute remote loop free alternates
*
* Version: 1.0
* Created: Thursday 07 September 2017 03:40:56 IST
* Revision: 1.0
* Compiler: gcc
*
* Author: Er. Abhishek Sagar, Networking Developer (AS), [email protected]
* Company: Brocade Communications(Jul 2012- Mar 2016), Current : Juniper Networks(Apr 2017 - Present)
*
* This file is part of the SPFComputation distribution (https://github.com/sachinites).
* Copyright (c) 2017 Abhishek Sagar.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* =====================================================================================
*/
#include <stdlib.h>
#include <stdio.h>
#include "rlfa.h"
#include "instance.h"
#include "spfutil.h"
#include "bitsop.h"
#include "spftrace.h"
#include "routes.h"
extern instance_t *instance;
extern int
instance_node_comparison_fn(void *_node, void *input_node_name);
void
clear_pq_nodes(node_t *S, LEVEL level){
unsigned int i = 0;
if(is_internal_nh_t_empty(S->pq_nodes[level][0]))
return;
for(i = 0; i < MAX_NXT_HOPS; i++){
init_internal_nh_t(S->pq_nodes[level][i]);
}
}
void
init_back_up_computation(node_t *S, LEVEL level){
singly_ll_node_t* list_node = NULL;
spf_result_t *res = NULL;
nh_type_t nh = NH_MAX;
unsigned int i = 0;
ll_t *spf_result = S->spf_run_result[level];
ITERATE_LIST_BEGIN(spf_result, list_node){
res = (spf_result_t *)list_node->data;
ITERATE_NH_TYPE_BEGIN(nh){
if(is_internal_nh_t_empty(res->node->backup_next_hop[level][nh][0]))
continue;
for(i=0; i < MAX_NXT_HOPS; i++){
init_internal_nh_t(res->node->backup_next_hop[level][nh][i]);
}
} ITERATE_NH_TYPE_END;
res->backup_requirement[level] = BACKUPS_REQUIRED;
} ITERATE_LIST_END;
clear_pq_nodes(S, level);
}
/*It should work for both broadcast and non-broadcast links*/
boolean
is_destination_impacted(node_t *S, edge_t *protected_link,
node_t *D, LEVEL level,
char impact_reason[],
boolean *mandatory_node_protection){
/*case 1 : Destination has only 1 next hop through protected_link, return TRUE*/
unsigned int nh_count = 0;
nh_type_t nh = NH_MAX;
internal_nh_t *primary_nh = NULL;
spf_result_t *D_res = NULL;
if(!IS_LEVEL_SET(protected_link->level, level)){
sprintf(impact_reason, "Dest %s Not in same level as protected link(%s)",
D->node_name, get_str_level(protected_link->level));
return FALSE;
}
/* If it is false, it dont mean anything, but if it is true then
* Destination MUST need to have node protection backup. In the rest of
* code we must check only for TRUE-ness of this variable. This variable
* is meant for Destination which has ECMP but yet those ECMPs fails to
* provide node protection to the node. For Dest which have only 1 Primary
* Nexthops, ofcourse they have to be happy with any type of protection (they are poor).
* Hence, this variable is not meant for Dest with 1 primary nexthops. The word
* MANDATORY means the destination do not needs link-only protecting backups (as they
* already have ECMP)*/
*mandatory_node_protection = FALSE;
if(!IS_LINK_PROTECTION_ENABLED(protected_link) &&
!IS_LINK_NODE_PROTECTION_ENABLED(protected_link)){
sprintf(impact_reason, "No protection enabled on the link");
return FALSE;
}
D_res = GET_SPF_RESULT((&S->spf_info), D, level);
if(D_res->backup_requirement[level] == NO_BACKUP_REQUIRED){
sprintf(impact_reason, "Dest %s has Independant primary nexthops", D->node_name);
return FALSE;
}
ITERATE_NH_TYPE_BEGIN(nh){
nh_count += get_nh_count(&(D_res->next_hop[nh][0]));
}ITERATE_NH_TYPE_END;
if(nh_count == 0){
sprintf(impact_reason, "Dest %s has no Primary Nexthops", D->node_name);
return FALSE;
}
if(nh_count == 1){
primary_nh = is_nh_list_empty2(&(D_res->next_hop[IPNH][0])) ? &(D_res->next_hop[LSPNH][0]):
&(D_res->next_hop[IPNH][0]);
if(primary_nh->oif != &protected_link->from){
sprintf(impact_reason, "Dest %s only primary nxt hop oif(%s) != protected_link(%s)",
D->node_name, primary_nh->oif->intf_name, protected_link->from.intf_name);
return FALSE;
}
sprintf(impact_reason, "Dest %s only primary nxt hop oif(%s) = protected_link(%s)",
D->node_name, primary_nh->oif->intf_name, protected_link->from.intf_name);
return TRUE;
}
if(nh_count > 1){
if(IS_LINK_PROTECTION_ENABLED(protected_link) &&
!IS_LINK_NODE_PROTECTION_ENABLED(protected_link)){
sprintf(impact_reason, "Dest %s has ECMP primary nxt hop count = %u AND Only LINK_PROTECTION Enabled",
D->node_name, nh_count);
return FALSE;/*ECMP case with only link protection*/
}
if(IS_LINK_NODE_PROTECTION_ENABLED(protected_link)){
sprintf(impact_reason, "Dest %s has dependant ECMP primary nxt hop count = %u,"
"LINK_NODE_PROTECTION Enabled. No only-link protecting backup needed",
D->node_name, nh_count);
*mandatory_node_protection = TRUE;
return TRUE;
}
}
assert(0);
return FALSE;
}
void
Compute_and_Store_Forward_SPF(node_t *spf_root,
LEVEL level){
spf_computation(spf_root, &spf_root->spf_info, level, FORWARD_RUN, 0);
}
void
Compute_PHYSICAL_Neighbor_SPFs(node_t *spf_root, LEVEL level){
node_t *nbr_node = NULL,
*pn_node = NULL;
edge_t *edge1 = NULL, *edge2 = NULL;
glthread_t glthread_head;
init_glthread(&glthread_head);
ITERATE_NODE_PHYSICAL_NBRS_BEGIN(spf_root, nbr_node, pn_node, edge1, edge2, level){
if(IS_GLTHREAD_LIST_EMPTY(&nbr_node->temp_thread)){
Compute_and_Store_Forward_SPF(nbr_node, level);
glthread_add_next(&glthread_head, &nbr_node->temp_thread);
}
} ITERATE_NODE_PHYSICAL_NBRS_END(spf_root, nbr_node, pn_node, level);
ITERATE_NODE_PHYSICAL_NBRS_BEGIN(spf_root, nbr_node, pn_node, edge1, edge2, level){
remove_glthread(&nbr_node->temp_thread);
} ITERATE_NODE_PHYSICAL_NBRS_END(spf_root, nbr_node, pn_node, level);
}
void
Compute_LOGICAL_Neighbor_SPFs(node_t *spf_root, LEVEL level){
node_t *nbr_node = NULL;
edge_t *edge1 = NULL;
glthread_t glthread_head;
init_glthread(&glthread_head);
ITERATE_NODE_LOGICAL_NBRS_BEGIN(spf_root, nbr_node, edge1, level){
if(IS_GLTHREAD_LIST_EMPTY(&nbr_node->temp_thread)){
Compute_and_Store_Forward_SPF(nbr_node, level);
glthread_add_next(&glthread_head, &nbr_node->temp_thread);
}
} ITERATE_NODE_LOGICAL_NBRS_END;
ITERATE_NODE_LOGICAL_NBRS_BEGIN(spf_root, nbr_node, edge1, level){
remove_glthread(&nbr_node->temp_thread);
} ITERATE_NODE_LOGICAL_NBRS_END;
}
static boolean
broadcast_node_protection_critera(node_t *S,
LEVEL level, edge_t *protected_link,
node_t *dest, node_t *nbr_node){
/* nbr_node Must be able to send traffic to dest by-passing all nodes directly
* attached to LAN segment of protected_link*/
/* This routine assumes all required SPF runs has been run*/
assert(is_broadcast_link(protected_link, level));
node_t *PN = protected_link->to.node;
node_t *PN_nbr = NULL;
edge_t *edge = NULL;
unsigned int d_nbr_node_to_dest = 0,
d_nbr_node_to_PN_nbr = 0,
d_PN_nbr_to_dest = 0;
d_nbr_node_to_dest = DIST_X_Y(nbr_node, dest, level);
ITERATE_NODE_LOGICAL_NBRS_BEGIN(PN, PN_nbr, edge, level){
d_nbr_node_to_PN_nbr = DIST_X_Y(nbr_node, PN_nbr, level);
d_PN_nbr_to_dest = DIST_X_Y(PN_nbr, dest, level);
if(d_nbr_node_to_dest < d_nbr_node_to_PN_nbr + d_PN_nbr_to_dest){
continue;
}
else{
return FALSE;
}
} ITERATE_NODE_LOGICAL_NBRS_END;
return TRUE;
}
/*-----------------------------------------------------------------------------
* This routine returns the set of routers in the extended p-space of 'node' wrt to
* 'edge'. Note that, 'edge' need not be directly connected edge of 'node'.
*-----------------------------------------------------------------------------*/
void
broadcast_compute_link_node_protecting_extended_p_space(node_t *S,
edge_t *protected_link,
LEVEL level){
/*Compute p space of all nbrs of node except protected_link->to.node
* and union it. Remove duplicates from union*/
node_t *nbr_node = NULL,
*PN = NULL,
*pn_node = NULL,
*P_node = NULL;
edge_t *edge1 = NULL, *edge2 = NULL;
singly_ll_node_t *list_node1 = NULL;
unsigned int d_nbr_to_p_node = 0,
d_nbr_to_S = 0,
d_S_to_p_node = 0,
d_nbr_to_PN = 0,
d_PN_to_p_node = 0,
d_S_to_nbr = 0,
d_S_to_PN = 0,
d_PN_to_nbr =0;
spf_result_t *spf_result_p_node = NULL;
if(!IS_LEVEL_SET(protected_link->level, level))
return;
internal_nh_t *rlfa = NULL;
assert(is_broadcast_link(protected_link, level));
boolean is_node_protection_enabled =
IS_LINK_NODE_PROTECTION_ENABLED(protected_link);
boolean is_link_protection_enabled =
IS_LINK_PROTECTION_ENABLED(protected_link);
#if 0/* Caller is suppose to run these SPF runs*/
/*run spf on self*/
Compute_and_Store_Forward_SPF(S, level);
/*Run SPF on all logical nbrs of S*/
Compute_PHYSICAL_Neighbor_SPFs(S, level);
#endif
/*iterate over entire network. Note that node->spf_run_result list
* carries all nodes of the network reachable from source at level l.
* We deem this list as the "entire network"*/
PN = protected_link->to.node;
ITERATE_LIST_BEGIN(S->spf_run_result[level], list_node1){
spf_result_p_node = (spf_result_t *)list_node1->data;
P_node = spf_result_p_node->node;
if(P_node == S || IS_OVERLOADED(P_node, level) ||
P_node == nbr_node) continue;
/* ToDo : RFC : Remote-LFA Node Protection and Manageability
* draft-ietf-rtgwg-rlfa-node-protection-13 - section 2.2.1*/
/* Testing ECMP equality : Nbr N should not have ECMP path to P_node
* which traverses the S----E link -- wonder criteria of selecting the
* P node via N automatically subsume this */
d_S_to_p_node = spf_result_p_node->spf_metric;
d_PN_to_p_node = DIST_X_Y(PN, P_node, level);
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Begin ext-pspace computation for S=%s, protected-link = %s, LEVEL = %s",
S->node_name, S->node_name, protected_link->from.intf_name, get_str_level(level)); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
ITERATE_NODE_PHYSICAL_NBRS_BEGIN(S, nbr_node, pn_node, edge1, edge2, level){
/*skip protected link itself */
if(edge1 == protected_link){
ITERATE_NODE_PHYSICAL_NBRS_CONTINUE(S, nbr_node, pn_node, level);
}
/*RFC 7490 section 5.4 : skip neighbors in computation of PQ nodes(extended p space)
* which are either overloaded or reachable through infinite metric*/
if(edge1->metric[level] >= INFINITE_METRIC){
ITERATE_NODE_PHYSICAL_NBRS_CONTINUE(S, nbr_node, pn_node, level);
}
if(IS_OVERLOADED(nbr_node, level)){
ITERATE_NODE_PHYSICAL_NBRS_CONTINUE(S, nbr_node, pn_node, level);
}
d_nbr_to_PN = DIST_X_Y(nbr_node, PN, level);
d_S_to_nbr = DIST_X_Y(S, nbr_node, level);
d_PN_to_nbr = DIST_X_Y(PN, nbr_node, level);
if(!(d_S_to_nbr < d_S_to_PN + d_PN_to_nbr)){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Nbr %s will not be considered for computing P-space,"
"nbr traverses protected link", S->node_name, nbr_node->node_name);
trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
ITERATE_NODE_PHYSICAL_NBRS_CONTINUE(S, nbr_node, pn_node, level);
}
d_nbr_to_p_node = DIST_X_Y(nbr_node, P_node, level);
if(is_node_protection_enabled == TRUE){
/*If node protection is enabled*/
d_PN_to_p_node = DIST_X_Y(PN, P_node, level);
/*Loop free inequality 1 : N should be Loop free wrt S and PN*/
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Testing inequality 1 : checking loop free wrt S = %s, Nbr = %s(oif = %s), P_node = %s",
S->node_name, S->node_name, nbr_node->node_name, edge1->from.intf_name, P_node->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
d_nbr_to_S = DIST_X_Y(nbr_node, S, level);
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : d_nbr_to_p_node(%u) < d_nbr_to_S(%u) + d_S_to_p_node(%u)",
S->node_name, d_nbr_to_p_node, d_nbr_to_S, d_S_to_p_node); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
if(!(d_nbr_to_p_node < d_nbr_to_S + d_S_to_p_node)){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : inequality 1 failed, Nbr = %s(oif = %s) is not loop free wrt S",
S->node_name, nbr_node->node_name, edge1->from.intf_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
continue;
}
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : above inequality 1 passed", S->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
/*Testing Downstream condition : P-node must be downstream node*/
if(!(d_nbr_to_p_node < d_S_to_p_node)){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Down Stream Inqequality failed : Nbr = %s(oif = %s), P_node = %s",
S->node_name, nbr_node->node_name, edge1->from.intf_name, P_node->node_name);
trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
ITERATE_NODE_PHYSICAL_NBRS_CONTINUE(S, nbr_node, pn_node, level);
}
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Testing node protection inequality for Broadcast link: S = %s, nbr = %s, P_node = %s, PN = %s",
S->node_name, S->node_name, nbr_node->node_name, P_node->node_name, PN->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
/*Node protection criteria for broadcast link should be : Nbr should be able to send traffic to P_node wihout
* passing through any node attached to broadcast segment*/
if(broadcast_node_protection_critera(S, level, protected_link, P_node, nbr_node) == TRUE){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Above node protection inequality passed", S->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
rlfa = get_next_hop_empty_slot(S->pq_nodes[level]);
rlfa->lfa_type = BROADCAST_NODE_PROTECTION_RLFA;
/*Check for link protection, nbr_node should be loop free wrt to PN*/
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Checking if potential P_node = %s provide broadcast link protection to S = %s, Nbr = %s(oif=%s)",
S->node_name, P_node->node_name, S->node_name, nbr_node->node_name, edge1->from.intf_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Checking if Nbr = %s(oif=%s) is loop free wrt to PN = %s",
S->node_name, nbr_node->node_name, edge1->from.intf_name, PN->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
/*For link protection, Nbr should be loop free wrt to PN*/
if(d_nbr_to_p_node < (d_nbr_to_PN + d_PN_to_p_node)){
rlfa->lfa_type = BROADCAST_LINK_AND_NODE_PROTECTION_RLFA;
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : P_node = %s provide node-link protection to S = %s, Nbr = %s(oif=%s)",
S->node_name, P_node->node_name, S->node_name, nbr_node->node_name, edge1->from.intf_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
}
rlfa->level = level;
rlfa->oif = &edge1->from;
rlfa->protected_link = &protected_link->from;
rlfa->node = NULL;
if(edge1->etype == UNICAST)
set_next_hop_gw_pfx(*rlfa, edge2->to.prefix[level]->prefix);
rlfa->nh_type = LSPNH;
rlfa->proxy_nbr = nbr_node;
rlfa->rlfa = P_node;
//rlfa->mpls_label_in = 1;
rlfa->root_metric = d_S_to_p_node;
rlfa->dest_metric = 0; /*Not known yet*/
rlfa->is_eligible = TRUE; /*Not known yet*/
ITERATE_NODE_PHYSICAL_NBRS_BREAK(S, nbr_node, pn_node, level);
}
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Above node protection inequality failed", S->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
if(is_link_protection_enabled == FALSE){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Link degradation is disabled, candidate P_node = %s"
" rejected to qualify as p-node for S = %s, Nbr = %s(oif=%s)",
S->node_name, P_node->node_name, S->node_name, nbr_node->node_name, edge1->from.intf_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
ITERATE_NODE_PHYSICAL_NBRS_CONTINUE(S, nbr_node, pn_node, level);
}
/*P_node could not provide node protection, check for link protection*/
if(is_link_protection_enabled == TRUE){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Checking if potential P_node = %s provide broadcast link protection to S = %s, Nbr = %s(oif=%s)",
S->node_name, P_node->node_name, S->node_name, nbr_node->node_name, edge1->from.intf_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Checking if Nbr = %s(oif=%s) is loop free wrt to PN = %s",
S->node_name, nbr_node->node_name, edge1->from.intf_name, PN->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
/*For link protection, Nbr should be loop free wrt to PN*/
if(d_nbr_to_p_node < (d_nbr_to_PN + d_PN_to_p_node)){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : P_node = %s provide link protection to S = %s, Nbr = %s(oif=%s)",
S->node_name, P_node->node_name, S->node_name, nbr_node->node_name, edge1->from.intf_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
rlfa = get_next_hop_empty_slot(S->pq_nodes[level]);
rlfa->level = level;
rlfa->oif = &edge1->from;
rlfa->protected_link = &protected_link->from;
rlfa->node = NULL;
if(edge1->etype == UNICAST)
set_next_hop_gw_pfx(*rlfa, edge2->to.prefix[level]->prefix);
rlfa->nh_type = LSPNH;
rlfa->lfa_type = BROADCAST_LINK_PROTECTION_RLFA;
rlfa->proxy_nbr = nbr_node;
rlfa->rlfa = P_node;
//rlfa->mpls_label_in = 1;
rlfa->root_metric = d_S_to_p_node;
rlfa->dest_metric = 0; /*Not known yet*/
rlfa->is_eligible = TRUE; /*Not known yet*/
ITERATE_NODE_PHYSICAL_NBRS_BREAK(S, nbr_node, pn_node, level);
}
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : candidate P_node = %s do not provide link protection"
" rejected to qualify as p-node for S = %s, Nbr = %s(oif=%s)",
S->node_name, P_node->node_name, S->node_name, nbr_node->node_name, edge1->from.intf_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
}
}else if(is_link_protection_enabled == TRUE){
if(d_nbr_to_p_node < (d_nbr_to_PN + d_PN_to_p_node)){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : P_node = %s provide link protection to S = %s, Nbr = %s(oif=%s)",
S->node_name, P_node->node_name, S->node_name, nbr_node->node_name, edge1->from.intf_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
rlfa = get_next_hop_empty_slot(S->pq_nodes[level]);
rlfa->level = level;
rlfa->oif = &edge1->from;
rlfa->protected_link = &protected_link->from;
rlfa->node = NULL;
if(edge1->etype == UNICAST)
set_next_hop_gw_pfx(*rlfa, edge2->to.prefix[level]->prefix);
rlfa->nh_type = LSPNH;
rlfa->lfa_type = BROADCAST_LINK_PROTECTION_RLFA;
rlfa->proxy_nbr = nbr_node;
rlfa->rlfa = P_node;
//rlfa->mpls_label_in = 1;
rlfa->root_metric = d_S_to_p_node;
rlfa->dest_metric = 0; /*Not known yet*/
rlfa->is_eligible = TRUE; /*Not known yet*/
}
}
else{
assert(0);
}
} ITERATE_NODE_PHYSICAL_NBRS_END(S, nbr_node, pn_node, level);
} ITERATE_LIST_END;
}
/*-----------------------------------------------------------------------------
* This routine returns the set of routers in the extended p-space of 'node' wrt to
* 'edge'. Note that, 'edge' need not be directly connected edge of 'node'.
*-----------------------------------------------------------------------------*/
void
p2p_compute_link_node_protecting_extended_p_space(node_t *S,
edge_t *protected_link,
LEVEL level){
/*Compute p space of all nbrs of node except protected_link->to.node
* and union it. Remove duplicates from union*/
node_t *nbr_node = NULL,
*E = NULL,
*pn_node = NULL,
*P_node = NULL;
edge_t *edge1 = NULL, *edge2 = NULL;
singly_ll_node_t *list_node1 = NULL;
internal_nh_t *rlfa = NULL;
unsigned int d_nbr_to_p_node = 0,
d_nbr_to_S = 0,
d_nbr_to_E = 0,
d_E_to_nbr =0,
d_E_to_p_node = 0,
d_S_to_p_node = 0,
d_S_to_nbr = 0,
d_S_to_E = 0;
spf_result_t *spf_result_p_node = NULL;
if(!IS_LEVEL_SET(protected_link->level, level))
return;
assert(!is_broadcast_link(protected_link, level));
boolean is_node_protection_enabled =
IS_LINK_NODE_PROTECTION_ENABLED(protected_link);
boolean is_link_protection_enabled =
IS_LINK_PROTECTION_ENABLED(protected_link);
#if 0 /*Caller suppose to run these SPF runs*/
/*run spf on self*/
Compute_and_Store_Forward_SPF(S, level);
/*Run SPF on all logical nbrs of S*/
Compute_PHYSICAL_Neighbor_SPFs(S, level);
#endif
/*iterate over entire network. Note that node->spf_run_result list
* carries all nodes of the network reachable from source at level l.
* We deem this list as the "entire network"*/
E = protected_link->to.node;
d_S_to_E = DIST_X_Y(S, E, level);
ITERATE_LIST_BEGIN(S->spf_run_result[level], list_node1){
spf_result_p_node = (spf_result_t *)list_node1->data;
P_node = spf_result_p_node->node;
if(P_node == S || IS_OVERLOADED(P_node, level) ||
P_node == nbr_node ||
P_node == E) /*RFC 7490, section 4.2*/
continue;
/* ToDo : RFC : Remote-LFA Node Protection and Manageability
* draft-ietf-rtgwg-rlfa-node-protection-13 - section 2.2.1*/
/* Testing ECMP equality : Nbr N should not have ECMP path to P_node
* which traverses the S----E link -- wonder criteria of selecting the
* P node via N automatically subsume this */
d_S_to_p_node = spf_result_p_node->spf_metric;
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Begin ext-pspace computation for S=%s, protected-link = %s, LEVEL = %s",
S->node_name, S->node_name, protected_link->from.intf_name, get_str_level(level)); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
ITERATE_NODE_PHYSICAL_NBRS_BEGIN(S, nbr_node, pn_node, edge1, edge2, level){
/*skip protected link itself */
if(edge1 == protected_link){
ITERATE_NODE_PHYSICAL_NBRS_CONTINUE(S, nbr_node, pn_node, level);
}
/*RFC 7490 section 5.4 : skip neighbors in computation of PQ nodes(extended p space)
* which are either overloaded or reachable through infinite metric*/
if(edge1->metric[level] >= INFINITE_METRIC){
ITERATE_NODE_PHYSICAL_NBRS_CONTINUE(S, nbr_node, pn_node, level);
}
if(IS_OVERLOADED(nbr_node, level)){
ITERATE_NODE_PHYSICAL_NBRS_CONTINUE(S, nbr_node, pn_node, level);
}
d_nbr_to_E = DIST_X_Y(nbr_node, E, level);
d_S_to_nbr = DIST_X_Y(S, nbr_node, level);
d_E_to_nbr = DIST_X_Y(E, nbr_node, level);
/* skip nbrs which are reachable from S from protected link*/
/* nbr should not be reachable via E. Examine
* only the node protecting nbrs since S need to establish the
* tunnel to P node and this tunnel should reach P via shortest path
* not passing through protected-link*/
if(!(d_S_to_nbr < d_S_to_E + d_E_to_nbr)){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Nbr %s will not be considered for computing P-space,"
"nbr traverses protected link", S->node_name, nbr_node->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
ITERATE_NODE_PHYSICAL_NBRS_CONTINUE(S, nbr_node, pn_node, level);
}
d_nbr_to_p_node = DIST_X_Y(nbr_node, P_node, level);
if(is_node_protection_enabled == TRUE){
/*If node protection is enabled*/
d_E_to_p_node = DIST_X_Y(E, P_node, level);
/*Loop free inequality 1 : N should be Loop free wrt S*/
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Testing inequality 1 : S = %s, Nbr = %s(oif = %s), P_node = %s",
S->node_name, S->node_name, nbr_node->node_name, edge1->from.intf_name, P_node->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
d_nbr_to_S = DIST_X_Y(nbr_node, S, level);
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : d_nbr_to_p_node(%u) < d_nbr_to_S(%u) + d_S_to_p_node(%u)",
S->node_name, d_nbr_to_p_node, d_nbr_to_S, d_S_to_p_node); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
if(!(d_nbr_to_p_node < d_nbr_to_S + d_S_to_p_node)){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : inequality 1 failed", S->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
ITERATE_NODE_PHYSICAL_NBRS_CONTINUE(S, nbr_node, pn_node, level);
}
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : above inequality 1 passed", S->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
/*Testing Downstream condition : P-node must be downstream node*/
if(!(d_nbr_to_p_node < d_S_to_p_node)){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Down Stream Inqequality failed : Nbr = %s(oif = %s), P_node = %s",
S->node_name, nbr_node->node_name, edge1->from.intf_name, P_node->node_name);
trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
ITERATE_NODE_PHYSICAL_NBRS_CONTINUE(S, nbr_node, pn_node, level);
}
/*condition for node protection RLFA - RFC :
* draft-ietf-rtgwg-rlfa-node-protection-13 - section 2.2.6.2*/
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Testing node protection inequality : S = %s, nbr = %s, P_node = %s, E = %s",
S->node_name, S->node_name, nbr_node->node_name, P_node->node_name, E->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : d_nbr_to_p_node(%u) < d_nbr_to_E(%u) + d_E_to_p_node(%u)",
S->node_name, d_nbr_to_p_node, d_nbr_to_E, d_E_to_p_node); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
if(d_nbr_to_p_node < (d_nbr_to_E + d_E_to_p_node)){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Above node protection inequality passed", S->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
/*Node has been added to extended p-space, no need to check for link protection
* as node-protecting node in extended pspace is automatically link protecting node for P2P links*/
{
rlfa = get_next_hop_empty_slot(S->pq_nodes[level]);
rlfa->level = level;
rlfa->oif = &edge1->from;
rlfa->protected_link = &protected_link->from;
rlfa->node = NULL;
if(edge1->etype == UNICAST)
set_next_hop_gw_pfx(*rlfa, edge2->to.prefix[level]->prefix);
rlfa->nh_type = LSPNH;
rlfa->lfa_type = LINK_AND_NODE_PROTECTION_RLFA;
rlfa->proxy_nbr = nbr_node;
rlfa->rlfa = P_node;
//rlfa->mpls_label_in = 1;
rlfa->root_metric = d_S_to_p_node;
rlfa->dest_metric = 0; /*Not known yet*/
rlfa->is_eligible = TRUE; /*Not known yet*/
}
ITERATE_NODE_PHYSICAL_NBRS_BREAK(S, nbr_node, pn_node, level);
}
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Above node protection inequality failed", S->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
if(is_link_protection_enabled == FALSE){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Link degradation is disabled, candidate P_node = %s"
" rejected to qualify as p-node for S = %s, Nbr = %s(oif=%s)",
S->node_name, P_node->node_name, S->node_name, nbr_node->node_name, edge1->from.intf_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
ITERATE_NODE_PHYSICAL_NBRS_CONTINUE(S, nbr_node, pn_node, level);
}
/*P_node could not provide node protection, check for link protection*/
if(is_link_protection_enabled == TRUE){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Checking if potential P_node = %s provide link protection to S = %s, Nbr = %s(oif=%s)",
S->node_name, P_node->node_name, S->node_name, nbr_node->node_name, edge1->from.intf_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
if(d_nbr_to_p_node < (d_nbr_to_S + protected_link->metric[level])){
{
rlfa = get_next_hop_empty_slot(S->pq_nodes[level]);
rlfa->level = level;
rlfa->oif = &edge1->from;
rlfa->protected_link = &protected_link->from;
rlfa->node = NULL;
if(edge1->etype == UNICAST)
set_next_hop_gw_pfx(*rlfa, edge2->to.prefix[level]->prefix);
rlfa->nh_type = LSPNH;
rlfa->lfa_type = LINK_PROTECTION_RLFA;
rlfa->proxy_nbr = nbr_node;
rlfa->rlfa = P_node;
//rlfa->mpls_label_in = 1;
rlfa->root_metric = d_S_to_p_node;
rlfa->dest_metric = 0; /*Not known yet*/
rlfa->is_eligible = TRUE; /*Not known yet*/
}
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : P_node = %s provide link protection to S = %s, Nbr = %s(oif=%s)",
S->node_name, P_node->node_name, S->node_name, nbr_node->node_name, edge1->from.intf_name);
trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
ITERATE_NODE_PHYSICAL_NBRS_BREAK(S, nbr_node, pn_node, level);
}
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : candidate P_node = %s do not provide link protection"
" rejected to qualify as p-node for S = %s, Nbr = %s(oif=%s)",
S->node_name, P_node->node_name, S->node_name, nbr_node->node_name, edge1->from.intf_name);
trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
}
}
} ITERATE_NODE_PHYSICAL_NBRS_END(S, nbr_node, pn_node, level);
} ITERATE_LIST_END;
}
void
broadcast_filter_select_pq_nodes_from_ex_pspace(node_t *S, edge_t *protected_link,
LEVEL level){
unsigned int d_p_to_E = 0,
d_p_to_D = 0,
d_E_to_D = 0,
i = 0;
char impact_reason[STRING_REASON_LEN];
node_t *E = protected_link->to.node;
internal_nh_t *p_node = NULL,
*rlfa = NULL;
spf_result_t *D_res = NULL;
singly_ll_node_t *list_node1 = NULL;
assert(is_broadcast_link(protected_link, level));
/*Compute reverse SPF for nodes S and E as roots*/
inverse_topology(instance, level);
Compute_and_Store_Forward_SPF(S, level);
Compute_and_Store_Forward_SPF(E, level);
inverse_topology(instance, level);
for( i = 0; i < MAX_NXT_HOPS; i++){
p_node = &S->pq_nodes[level][i];
if(is_empty_internal_nh(p_node))
break;
//assert(IS_BIT_SET(p_node->p_space_protection_type, LINK_NODE_PROTECTION));
/*For node protection, Run the Forward SPF run on PQ nodes*/
Compute_and_Store_Forward_SPF(p_node->rlfa, level);
/*Now inspect all Destinations which are impacted by the link*/
boolean is_dest_impacted = FALSE,
mandatory_node_protection = FALSE;
ITERATE_LIST_BEGIN(S->spf_run_result[level], list_node1){
is_dest_impacted = FALSE;
D_res = list_node1->data;
/* if RLFA's proxy nbr itself is a destination, then no need to find
* PQ node for such a destination. p_node->proxy_nbr will surely qualify to be
* LFA for such a destination*/
if(p_node->proxy_nbr == D_res->node)
continue;
/*If potential pq_node itself is a destination, then dont count
* such a pq_node, the proxy nbr of such a pq_node is guaranteed
* to be LFA*/
if(p_node->rlfa == D_res->node){
continue;
}
/*Check if this is impacted destination*/
memset(impact_reason, 0, STRING_REASON_LEN);
mandatory_node_protection = FALSE;
is_dest_impacted = is_destination_impacted(S, protected_link, D_res->node,
level, impact_reason, &mandatory_node_protection);
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Dest = %s Impact result = %s\n reason : %s", D_res->node->node_name,
is_dest_impacted ? "IMPACTED" : "NOT-IMPCATED", impact_reason); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
if(is_dest_impacted == FALSE) continue;
if(p_node->lfa_type == BROADCAST_LINK_PROTECTION_RLFA ||
p_node->lfa_type == BROADCAST_LINK_PROTECTION_RLFA_DOWNSTREAM){
/*This node cannot provide node protection, check only link protection
* p_node should be loop free wrt to PN*/
if(mandatory_node_protection == TRUE){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Pnode %s not considered for link protection RLFA as Dest %s has ECMP, failed to qualify as PQ node",
S->node_name, p_node->rlfa->node_name, D_res->node->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
continue;
}
d_p_to_E = DIST_X_Y(E, p_node->rlfa, level);
d_p_to_D = DIST_X_Y(p_node->rlfa, D_res->node, level);
d_E_to_D = DIST_X_Y(E, D_res->node, level);
if(!(d_p_to_D < d_p_to_E + d_E_to_D)){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Link protected p-node %s failed to qualify as link protection Q node",
S->node_name, p_node->rlfa->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
/*p node fails to provide link protection, this do not qualifies to be pq node*/
continue;
}
/*Doesnt matter if p_node qualifies node protection criteria, it will be link protecting only*/
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Link protected p-node %s qualify as link protection Q node",
S->node_name, p_node->rlfa->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
rlfa = get_next_hop_empty_slot(D_res->node->backup_next_hop[level][LSPNH]);
//(*(p_node->ref_count))++;
copy_internal_nh_t(*p_node, *rlfa);
rlfa->dest_metric = d_p_to_D;
continue;
}
/*Check if p_node provides node protection*/
if(broadcast_node_protection_critera(S, level, protected_link, D_res->node, p_node->rlfa) == TRUE){
/*This node provides node protection to Destination D*/
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Node protected p-node %s qualify as node protection Q node for for Dest %s",
S->node_name, p_node->rlfa->node_name, D_res->node->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
/*When tested for P nodes, node protecting p-nodes are automatically link protecting
* p nodes also for given Destination*/
rlfa = get_next_hop_empty_slot(D_res->node->backup_next_hop[level][LSPNH]);
//(*(p_node->ref_count))++;
copy_internal_nh_t(*p_node, *rlfa);
continue;
}
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Node protected p-node %s failed to qualify as node protection Q node for Dest %s",
S->node_name, p_node->rlfa->node_name, D_res->node->node_name);
trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
/*p_node fails to provide node protection, demote the p_node to LINK_PROTECTION
* if it provides atleast link protection to Destination D*/
if(mandatory_node_protection == TRUE){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Pnode %s not considered for link protection RLFA as Dest %s has ECMP, failed to qualify as PQ node",
S->node_name, p_node->rlfa->node_name, D_res->node->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
continue;
}
if(!IS_LINK_PROTECTION_ENABLED(protected_link)){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : node link degradation is not enabled", S->node_name);
trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
continue;
}
d_p_to_D = DIST_X_Y(p_node->rlfa, D_res->node, level);
d_p_to_E = DIST_X_Y(E, p_node->rlfa, level);
d_E_to_D = DIST_X_Y(E, D_res->node, level);
if(!(d_p_to_D < d_p_to_E + d_E_to_D)){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Node protected p-node %s failed to qualify as link protection Q node for Dest %s",
S->node_name, p_node->rlfa->node_name, D_res->node->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
continue;
}
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : Node protected p-node %s qualify as link protection Q node"
"Demoted from LINK_NODE_PROTECTION to LINK_PROTECTION PQ node for Dest %s",
S->node_name, p_node->rlfa->node_name, D_res->node->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
rlfa = get_next_hop_empty_slot(D_res->node->backup_next_hop[level][LSPNH]);
//(*(p_node->ref_count))++;
copy_internal_nh_t(*p_node, *rlfa);
rlfa->lfa_type = BROADCAST_LINK_PROTECTION_RLFA;
}ITERATE_LIST_END;
}
}
void
p2p_filter_select_pq_nodes_from_ex_pspace(node_t *S,
edge_t *protected_link,
LEVEL level){
unsigned int d_S_to_E = 0,
d_p_to_S = 0,
d_p_to_E = 0,
d_p_to_D = 0,
d_E_to_D = 0,
i = 0;
char impact_reason[STRING_REASON_LEN];
node_t *E = protected_link->to.node;
internal_nh_t *p_node = NULL,
*rlfa = NULL;
spf_result_t *D_res = NULL;
singly_ll_node_t *list_node1 = NULL;
assert(!is_broadcast_link(protected_link, level));
/*Compute reverse SPF for nodes S and E as roots*/
inverse_topology(instance, level);
Compute_and_Store_Forward_SPF(S, level);
Compute_and_Store_Forward_SPF(E, level);
inverse_topology(instance, level);
d_S_to_E = DIST_X_Y(E, S, level);
for( ; i < MAX_NXT_HOPS; i++){
p_node = &S->pq_nodes[level][i];
if(is_empty_internal_nh(p_node))
break;
/*This node cannot provide node protection, check only link protection*/
d_p_to_S = DIST_X_Y(S, p_node->rlfa, level);
d_p_to_E = DIST_X_Y(E, p_node->rlfa, level);
if(!(d_p_to_E < d_p_to_S + d_S_to_E)){
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : p-node %s failed to qualify as link protection Q node",
S->node_name, p_node->rlfa->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
/*p node fails to provide link protection, this do not qualifies to be pq node*/
p_node->is_eligible = FALSE;
continue;
}
#if 0
/*Doesnt matter if p_node qualifies node protection criteria, it will be link protecting only*/
#ifdef __ENABLE_TRACE__
sprintf(instance->traceopts->b, "Node : %s : p-node %s qualify as link protection Q node",
S->node_name, p_node->rlfa->node_name); trace(instance->traceopts, BACKUP_COMPUTATION_BIT);
#endif
#endif
}
for( i = 0; i < MAX_NXT_HOPS; i++){
p_node = &S->pq_nodes[level][i];
if(is_nh_list_empty2(p_node)) break;
if(p_node->is_eligible == FALSE) continue;
/*For node protection, Run the Forward SPF run on PQ nodes*/
Compute_and_Store_Forward_SPF(p_node->rlfa, level);
/*Now inspect all Destinations which are impacted by the link*/
boolean is_dest_impacted = FALSE,
mandatory_node_protection = FALSE;
d_p_to_E = DIST_X_Y(E, p_node->rlfa, level);
d_p_to_S = DIST_X_Y(S, p_node->rlfa, level);
ITERATE_LIST_BEGIN(S->spf_run_result[level], list_node1){
is_dest_impacted = FALSE;
D_res = list_node1->data;
/*if RLFA's proxy nbr itself is a destination, then no need to find
* PQ node for such a destination. p_node->proxy_nbr will surely quality to be
* LFA for such a destination*/
if(p_node->proxy_nbr == D_res->node)
continue;