MPLS Mcast
[vpp.git] / src / vnet / fib / fib_entry_src.c
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #include <vnet/adj/adj.h>
17 #include <vnet/dpo/load_balance.h>
18 #include <vnet/dpo/mpls_label_dpo.h>
19 #include <vnet/dpo/drop_dpo.h>
20 #include <vnet/dpo/replicate_dpo.h>
21
22 #include <vnet/fib/fib_entry_src.h>
23 #include <vnet/fib/fib_table.h>
24 #include <vnet/fib/fib_path_ext.h>
25 #include <vnet/fib/fib_urpf_list.h>
26
27 /*
28  * per-source type vft
29  */
30 static fib_entry_src_vft_t fib_entry_src_vft[FIB_SOURCE_MAX];
31
32 static fib_protocol_t
33 fib_entry_get_proto (const fib_entry_t * fib_entry)
34 {
35     return (fib_entry->fe_prefix.fp_proto);
36 }
37
38 void
39 fib_entry_src_register (fib_source_t source,
40                         const fib_entry_src_vft_t *vft)
41 {
42     fib_entry_src_vft[source] = *vft;
43 }
44
45 static int
46 fib_entry_src_cmp_for_sort (void * v1,
47                             void * v2)
48 {
49     fib_entry_src_t *esrc1 = v1, *esrc2 = v2;
50
51     return (esrc1->fes_src - esrc2->fes_src);
52 }
53
54 void
55 fib_entry_src_action_init (fib_entry_t *fib_entry,
56                            fib_source_t source)
57
58 {
59     fib_entry_src_t esrc = {
60         .fes_pl = FIB_NODE_INDEX_INVALID,
61         .fes_flags = FIB_ENTRY_SRC_FLAG_NONE,
62         .fes_src = source,
63     };
64
65     if (NULL != fib_entry_src_vft[source].fesv_init)
66     {
67         fib_entry_src_vft[source].fesv_init(&esrc);
68     }
69
70     vec_add1(fib_entry->fe_srcs, esrc);
71     vec_sort_with_function(fib_entry->fe_srcs,
72                            fib_entry_src_cmp_for_sort);
73 }
74
75 static fib_entry_src_t *
76 fib_entry_src_find (const fib_entry_t *fib_entry,
77                     fib_source_t source,
78                     u32 *index)
79
80 {
81     fib_entry_src_t *esrc;
82     int ii;
83
84     ii = 0;
85     vec_foreach(esrc, fib_entry->fe_srcs)
86     {
87         if (esrc->fes_src == source)
88         {
89             if (NULL != index)
90             {
91                 *index = ii;
92             }
93             return (esrc);
94         }
95         else
96         {
97             ii++;
98         }
99     }
100
101     return (NULL);
102 }
103
104 int
105 fib_entry_is_sourced (fib_node_index_t fib_entry_index,
106                       fib_source_t source)
107 {
108     fib_entry_t *fib_entry;
109
110     fib_entry = fib_entry_get(fib_entry_index);
111
112     return (NULL != fib_entry_src_find(fib_entry, source, NULL));
113 }
114
115 static fib_entry_src_t *
116 fib_entry_src_find_or_create (fib_entry_t *fib_entry,
117                               fib_source_t source,
118                               u32 *index)
119 {
120     fib_entry_src_t *esrc;
121
122     esrc = fib_entry_src_find(fib_entry, source, NULL);
123
124     if (NULL == esrc)
125     {
126         fib_entry_src_action_init(fib_entry, source);
127     }
128
129     return (fib_entry_src_find(fib_entry, source, NULL));
130 }
131
132 void
133 fib_entry_src_action_deinit (fib_entry_t *fib_entry,
134                              fib_source_t source)
135
136 {
137     fib_entry_src_t *esrc;
138     u32 index = ~0;
139
140     esrc = fib_entry_src_find(fib_entry, source, &index);
141
142     ASSERT(NULL != esrc);
143
144     if (NULL != fib_entry_src_vft[source].fesv_deinit)
145     {
146         fib_entry_src_vft[source].fesv_deinit(esrc);
147     }
148
149     vec_free(esrc->fes_path_exts);
150     vec_del1(fib_entry->fe_srcs, index);
151 }
152
153 fib_entry_src_cover_res_t
154 fib_entry_src_action_cover_change (fib_entry_t *fib_entry,
155                                    fib_source_t source)
156 {
157     if (NULL != fib_entry_src_vft[source].fesv_cover_change)
158     {
159         return (fib_entry_src_vft[source].fesv_cover_change(
160                     fib_entry_src_find(fib_entry, source, NULL),
161                     fib_entry));
162     }
163
164     fib_entry_src_cover_res_t res = {
165         .install = !0,
166         .bw_reason = FIB_NODE_BW_REASON_FLAG_NONE,
167     };
168     return (res);
169 }
170
171 fib_entry_src_cover_res_t
172 fib_entry_src_action_cover_update (fib_entry_t *fib_entry,
173                                    fib_source_t source)
174 {
175     if (NULL != fib_entry_src_vft[source].fesv_cover_update)
176     {
177         return (fib_entry_src_vft[source].fesv_cover_update(
178                     fib_entry_src_find(fib_entry, source, NULL),
179                     fib_entry));
180     }
181
182     fib_entry_src_cover_res_t res = {
183         .install = !0,
184         .bw_reason = FIB_NODE_BW_REASON_FLAG_NONE,
185     };
186     return (res);
187 }
188
189 typedef struct fib_entry_src_collect_forwarding_ctx_t_
190 {
191     load_balance_path_t * next_hops;
192     const fib_entry_t *fib_entry;
193     const fib_entry_src_t *esrc;
194     fib_forward_chain_type_t fct;
195     int is_recursive;
196 } fib_entry_src_collect_forwarding_ctx_t;
197
198 /**
199  * @brief Determine whether this FIB entry should use a load-balance MAP
200  * to support PIC edge fast convergence
201  */
202 load_balance_flags_t
203 fib_entry_calc_lb_flags (fib_entry_src_collect_forwarding_ctx_t *ctx)
204 {
205     /**
206      * We'll use a LB map is the path-list has recursive paths.
207      * recursive paths implies BGP, and hence scale.
208      */
209     if (ctx->is_recursive)
210     {
211         return (LOAD_BALANCE_FLAG_USES_MAP);
212     }
213     return (LOAD_BALANCE_FLAG_NONE);
214 }
215
216 static int
217 fib_entry_src_valid_out_label (mpls_label_t label)
218 {
219     return ((MPLS_LABEL_IS_REAL(label) ||
220              MPLS_IETF_IPV4_EXPLICIT_NULL_LABEL == label ||
221              MPLS_IETF_IPV6_EXPLICIT_NULL_LABEL == label ||
222              MPLS_IETF_IMPLICIT_NULL_LABEL == label));
223 }
224
225 /**
226  * @brief Turn the chain type requested by the client into the one they
227  * really wanted
228  */
229 fib_forward_chain_type_t
230 fib_entry_chain_type_fixup (const fib_entry_t *entry,
231                             fib_forward_chain_type_t fct)
232 {
233     /*
234      * The EOS chain is a tricky since one cannot know the adjacency
235      * to link to without knowing what the packets payload protocol
236      * will be once the label is popped.
237      */
238     fib_forward_chain_type_t dfct;
239
240     if (FIB_FORW_CHAIN_TYPE_MPLS_EOS != fct)
241     {
242         return (fct);
243     }
244
245     dfct = fib_entry_get_default_chain_type(entry);
246
247     if (FIB_FORW_CHAIN_TYPE_MPLS_EOS == dfct)
248     {
249         /*
250          * If the entry being asked is a eos-MPLS label entry,
251          * then use the payload-protocol field, that we stashed there
252          * for just this purpose
253          */
254         return (fib_forw_chain_type_from_dpo_proto(
255                     entry->fe_prefix.fp_payload_proto));
256     }
257     /*
258      * else give them what this entry would be by default. i.e. if it's a v6
259      * entry, then the label its local labelled should be carrying v6 traffic.
260      * If it's a non-EOS label entry, then there are more labels and we want
261      * a non-eos chain.
262      */
263     return (dfct);
264 }
265
266 static int
267 fib_entry_src_collect_forwarding (fib_node_index_t pl_index,
268                                   fib_node_index_t path_index,
269                                   void *arg)
270 {
271     fib_entry_src_collect_forwarding_ctx_t *ctx;
272     fib_path_ext_t *path_ext;
273     int have_path_ext;
274
275     ctx = arg;
276
277     /*
278      * if the path is not resolved, don't include it.
279      */
280     if (!fib_path_is_resolved(path_index))
281     {
282         return (!0);
283     }
284
285     if (fib_path_is_recursive(path_index))
286     {
287         ctx->is_recursive = 1;
288     }
289
290     /*
291      * get the matching path-extension for the path being visited.
292      */
293     have_path_ext = 0;
294     vec_foreach(path_ext, ctx->esrc->fes_path_exts)
295     {
296         if (path_ext->fpe_path_index == path_index)
297         {
298             have_path_ext = 1;
299             break;
300         }
301     }
302     
303     if (have_path_ext &&
304         fib_entry_src_valid_out_label(path_ext->fpe_label_stack[0]))
305     {
306         /*
307          * found a matching extension. stack it to obtain the forwarding
308          * info for this path.
309          */
310         ctx->next_hops =
311             fib_path_ext_stack(path_ext,
312                                ctx->fct,
313                                fib_entry_chain_type_fixup(ctx->fib_entry,
314                                                           ctx->fct),
315                                ctx->next_hops);
316     }
317     else
318     {
319         load_balance_path_t *nh;
320
321         /*
322          * no extension => no out-going label for this path. that's OK
323          * in the case of an IP or EOS chain, but not for non-EOS
324          */
325         switch (ctx->fct)
326         {
327         case FIB_FORW_CHAIN_TYPE_UNICAST_IP4:
328         case FIB_FORW_CHAIN_TYPE_UNICAST_IP6:
329         case FIB_FORW_CHAIN_TYPE_MCAST_IP4:
330         case FIB_FORW_CHAIN_TYPE_MCAST_IP6:
331             /*
332              * EOS traffic with no label to stack, we need the IP Adj
333              */
334             vec_add2(ctx->next_hops, nh, 1);
335
336             nh->path_index = path_index;
337             nh->path_weight = fib_path_get_weight(path_index);
338             fib_path_contribute_forwarding(path_index, ctx->fct, &nh->path_dpo);
339
340             break;
341         case FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS:
342             if (fib_path_is_exclusive(path_index) ||
343                 fib_path_is_deag(path_index))
344             {
345                 vec_add2(ctx->next_hops, nh, 1);
346
347                 nh->path_index = path_index;
348                 nh->path_weight = fib_path_get_weight(path_index);
349                 fib_path_contribute_forwarding(path_index,
350                                                FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS,
351                                                &nh->path_dpo);
352             }
353             break;
354         case FIB_FORW_CHAIN_TYPE_MPLS_EOS:
355         {
356             /*
357              * no label. we need a chain based on the payload. fixup.
358              */
359             vec_add2(ctx->next_hops, nh, 1);
360
361             nh->path_index = path_index;
362             nh->path_weight = fib_path_get_weight(path_index);
363             fib_path_contribute_forwarding(path_index,
364                                            fib_entry_chain_type_fixup(ctx->fib_entry,
365                                                                       ctx->fct),
366                                            &nh->path_dpo);
367             fib_path_stack_mpls_disp(path_index,
368                                      ctx->fib_entry->fe_prefix.fp_payload_proto,
369                                      &nh->path_dpo);
370
371             break;
372         }
373         case FIB_FORW_CHAIN_TYPE_ETHERNET:
374         case FIB_FORW_CHAIN_TYPE_NSH:
375             ASSERT(0);
376             break;
377         }
378     }
379
380     return (!0);
381 }
382
383 void
384 fib_entry_src_mk_lb (fib_entry_t *fib_entry,
385                      const fib_entry_src_t *esrc,
386                      fib_forward_chain_type_t fct,
387                      dpo_id_t *dpo_lb)
388 {
389     dpo_proto_t lb_proto;
390
391     /*
392      * If the entry has path extensions then we construct a load-balance
393      * by stacking the extensions on the forwarding chains of the paths.
394      * Otherwise we use the load-balance of the path-list
395      */
396     fib_entry_src_collect_forwarding_ctx_t ctx = {
397         .esrc = esrc,
398         .fib_entry = fib_entry,
399         .next_hops = NULL,
400         .is_recursive = 0,
401         .fct = fct,
402     };
403
404     /*
405      * As an optimisation we allocate the vector of next-hops to be sized
406      * equal to the maximum nuber of paths we will need, which is also the
407      * most likely number we will need, since in most cases the paths are 'up'.
408      */
409     vec_validate(ctx.next_hops, fib_path_list_get_n_paths(esrc->fes_pl));
410     vec_reset_length(ctx.next_hops);
411
412     lb_proto = fib_proto_to_dpo(fib_entry->fe_prefix.fp_proto);
413
414     fib_path_list_walk(esrc->fes_pl,
415                        fib_entry_src_collect_forwarding,
416                        &ctx);
417
418     if (esrc->fes_entry_flags & FIB_ENTRY_FLAG_EXCLUSIVE)
419     {
420         /*
421          * the client provided the DPO that the entry should link to.
422          * all entries must link to a LB, so if it is an LB already
423          * then we can use it.
424          */
425         if ((1 == vec_len(ctx.next_hops)) &&
426             (DPO_LOAD_BALANCE == ctx.next_hops[0].path_dpo.dpoi_type))
427         {
428             dpo_copy(dpo_lb, &ctx.next_hops[0].path_dpo);
429             dpo_reset(&ctx.next_hops[0].path_dpo);
430             return;
431         }
432     }
433
434     if (!dpo_id_is_valid(dpo_lb))
435     {
436         /*
437          * first time create
438          */
439         if (esrc->fes_entry_flags & FIB_ENTRY_FLAG_MULTICAST)
440         {
441             dpo_set(dpo_lb,
442                     DPO_REPLICATE,
443                     lb_proto,
444                     MPLS_IS_REPLICATE | replicate_create(0, lb_proto));
445         }
446         else
447         {
448             flow_hash_config_t fhc;
449
450             fhc = fib_table_get_flow_hash_config(fib_entry->fe_fib_index,
451                                                  dpo_proto_to_fib(lb_proto));
452             dpo_set(dpo_lb,
453                     DPO_LOAD_BALANCE,
454                     lb_proto,
455                     load_balance_create(0, lb_proto, fhc));
456         }
457     }
458
459     if (esrc->fes_entry_flags & FIB_ENTRY_FLAG_MULTICAST)
460     {
461         /*
462          * MPLS multicast
463          */
464         replicate_multipath_update(dpo_lb, ctx.next_hops);
465     }
466     else
467     {
468         load_balance_multipath_update(dpo_lb,
469                                       ctx.next_hops,
470                                       fib_entry_calc_lb_flags(&ctx));
471         vec_free(ctx.next_hops);
472
473         /*
474          * if this entry is sourced by the uRPF-exempt source then we
475          * append the always present local0 interface (index 0) to the
476          * uRPF list so it is not empty. that way packets pass the loose check.
477          */
478         index_t ui = fib_path_list_get_urpf(esrc->fes_pl);
479
480         if ((fib_entry_is_sourced(fib_entry_get_index(fib_entry),
481                                   FIB_SOURCE_URPF_EXEMPT) ||
482              (esrc->fes_entry_flags & FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT))&&
483             (0 == fib_urpf_check_size(ui)))
484         {
485             /*
486              * The uRPF list we get from the path-list is shared by all
487              * other users of the list, but the uRPF exemption applies
488              * only to this prefix. So we need our own list.
489              */
490             ui = fib_urpf_list_alloc_and_lock();
491             fib_urpf_list_append(ui, 0);
492             fib_urpf_list_bake(ui);
493             load_balance_set_urpf(dpo_lb->dpoi_index, ui);
494             fib_urpf_list_unlock(ui);
495         }
496         else
497         {
498             load_balance_set_urpf(dpo_lb->dpoi_index, ui);
499         }
500         load_balance_set_fib_entry_flags(dpo_lb->dpoi_index,
501                                          fib_entry_get_flags_i(fib_entry));
502     }
503 }
504
505 void
506 fib_entry_src_action_install (fib_entry_t *fib_entry,
507                               fib_source_t source)
508 {
509     /*
510      * Install the forwarding chain for the given source into the forwarding
511      * tables
512      */
513     fib_forward_chain_type_t fct;
514     fib_entry_src_t *esrc;
515     int insert;
516
517     fct = fib_entry_get_default_chain_type(fib_entry);
518     esrc = fib_entry_src_find(fib_entry, source, NULL);
519
520     /*
521      * Every entry has its own load-balance object. All changes to the entry's
522      * forwarding result in an inplace modify of the load-balance. This means
523      * the load-balance object only needs to be added to the forwarding
524      * DB once, when it is created.
525      */
526     insert = !dpo_id_is_valid(&fib_entry->fe_lb);
527
528     fib_entry_src_mk_lb(fib_entry, esrc, fct, &fib_entry->fe_lb);
529
530     ASSERT(dpo_id_is_valid(&fib_entry->fe_lb));
531     FIB_ENTRY_DBG(fib_entry, "install: %d", fib_entry->fe_lb);
532
533     /*
534      * insert the adj into the data-plane forwarding trie
535      */
536     if (insert)
537     {
538        fib_table_fwding_dpo_update(fib_entry->fe_fib_index,
539                                    &fib_entry->fe_prefix,
540                                    &fib_entry->fe_lb);
541     }
542
543     /*
544      * if any of the other chain types are already created they will need
545      * updating too
546      */
547     fib_entry_delegate_type_t fdt;
548     fib_entry_delegate_t *fed;
549
550     FOR_EACH_DELEGATE_CHAIN(fib_entry, fdt, fed,
551     {
552         fib_entry_src_mk_lb(fib_entry, esrc,
553                             fib_entry_delegate_type_to_chain_type(fdt),
554                             &fed->fd_dpo);
555     });
556 }
557
558 void
559 fib_entry_src_action_uninstall (fib_entry_t *fib_entry)
560 {
561     /*
562      * uninstall the forwarding chain from the forwarding tables
563      */
564     FIB_ENTRY_DBG(fib_entry, "uninstall: %d",
565                   fib_entry->fe_adj_index);
566
567     if (dpo_id_is_valid(&fib_entry->fe_lb))
568     {
569         fib_table_fwding_dpo_remove(
570             fib_entry->fe_fib_index,
571             &fib_entry->fe_prefix,
572             &fib_entry->fe_lb);
573
574         dpo_reset(&fib_entry->fe_lb);
575     }
576 }
577
578 static void
579 fib_entry_recursive_loop_detect_i (fib_node_index_t path_list_index)
580 {
581     fib_node_index_t *entries = NULL;
582
583     fib_path_list_recursive_loop_detect(path_list_index, &entries);
584
585     vec_free(entries);
586 }
587
588 void
589 fib_entry_src_action_activate (fib_entry_t *fib_entry,
590                                fib_source_t source)
591
592 {
593     int houston_we_are_go_for_install;
594     fib_entry_src_t *esrc;
595
596     esrc = fib_entry_src_find(fib_entry, source, NULL);
597
598     ASSERT(!(esrc->fes_flags & FIB_ENTRY_SRC_FLAG_ACTIVE));
599     ASSERT(esrc->fes_flags & FIB_ENTRY_SRC_FLAG_ADDED);
600
601     esrc->fes_flags |= FIB_ENTRY_SRC_FLAG_ACTIVE;
602
603     if (NULL != fib_entry_src_vft[source].fesv_activate)
604     {
605         houston_we_are_go_for_install =
606             fib_entry_src_vft[source].fesv_activate(esrc, fib_entry);
607     }
608     else
609     {
610         /*
611          * the source is not providing an activate function, we'll assume
612          * therefore it has no objection to installing the entry
613          */
614         houston_we_are_go_for_install = !0;
615     }
616
617     /*
618      * link to the path-list provided by the source, and go check
619      * if that forms any loops in the graph.
620      */
621     fib_entry->fe_parent = esrc->fes_pl;
622     fib_entry->fe_sibling =
623         fib_path_list_child_add(fib_entry->fe_parent,
624                                 FIB_NODE_TYPE_ENTRY,
625                                 fib_entry_get_index(fib_entry));
626
627     fib_entry_recursive_loop_detect_i(fib_entry->fe_parent);
628
629     FIB_ENTRY_DBG(fib_entry, "activate: %d",
630                   fib_entry->fe_parent);
631
632     if (0 != houston_we_are_go_for_install)
633     {
634         fib_entry_src_action_install(fib_entry, source);
635     }
636     else
637     {
638         fib_entry_src_action_uninstall(fib_entry);
639     }
640 }
641
642 void
643 fib_entry_src_action_deactivate (fib_entry_t *fib_entry,
644                                  fib_source_t source)
645
646 {
647     fib_node_index_t path_list_index;
648     fib_entry_src_t *esrc;
649
650     esrc = fib_entry_src_find(fib_entry, source, NULL);
651
652     ASSERT(esrc->fes_flags & FIB_ENTRY_SRC_FLAG_ACTIVE);
653
654     if (NULL != fib_entry_src_vft[source].fesv_deactivate)
655     {
656         fib_entry_src_vft[source].fesv_deactivate(esrc, fib_entry);
657     }
658
659     esrc->fes_flags &= ~FIB_ENTRY_SRC_FLAG_ACTIVE;
660
661     FIB_ENTRY_DBG(fib_entry, "deactivate: %d", fib_entry->fe_parent);
662
663     /*
664      * un-link from an old path-list. Check for any loops this will clear
665      */
666     path_list_index = fib_entry->fe_parent;
667     fib_entry->fe_parent = FIB_NODE_INDEX_INVALID;
668
669     fib_entry_recursive_loop_detect_i(path_list_index);
670
671     /*
672      * this will unlock the path-list, so it may be invalid thereafter.
673      */
674     fib_path_list_child_remove(path_list_index, fib_entry->fe_sibling);
675     fib_entry->fe_sibling = FIB_NODE_INDEX_INVALID;
676 }
677
678 static void
679 fib_entry_src_action_fwd_update (const fib_entry_t *fib_entry,
680                                  fib_source_t source)
681 {
682     fib_entry_src_t *esrc;
683
684     vec_foreach(esrc, fib_entry->fe_srcs)
685     {
686         if (NULL != fib_entry_src_vft[esrc->fes_src].fesv_fwd_update)
687         {
688             fib_entry_src_vft[esrc->fes_src].fesv_fwd_update(esrc,
689                                                              fib_entry,
690                                                              source);
691         }
692     }
693 }
694
695 void
696 fib_entry_src_action_reactivate (fib_entry_t *fib_entry,
697                                  fib_source_t source)
698 {
699     fib_node_index_t path_list_index;
700     fib_entry_src_t *esrc;
701
702     esrc = fib_entry_src_find(fib_entry, source, NULL);
703
704     ASSERT(esrc->fes_flags & FIB_ENTRY_SRC_FLAG_ACTIVE);
705
706     FIB_ENTRY_DBG(fib_entry, "reactivate: %d to %d",
707                   fib_entry->fe_parent,
708                   esrc->fes_pl);
709
710     if (fib_entry->fe_parent != esrc->fes_pl)
711     {
712         /*
713          * un-link from an old path-list. Check for any loops this will clear
714          */
715         path_list_index = fib_entry->fe_parent;
716         fib_entry->fe_parent = FIB_NODE_INDEX_INVALID;
717
718         /*
719          * temporary lock so it doesn't get deleted when this entry is no
720          * longer a child.
721          */
722         fib_path_list_lock(path_list_index);
723
724         /*
725          * this entry is no longer a child. after unlinking check if any loops
726          * were broken
727          */
728         fib_path_list_child_remove(path_list_index,
729                                    fib_entry->fe_sibling);
730
731         fib_entry_recursive_loop_detect_i(path_list_index);
732
733         /*
734          * link to the path-list provided by the source, and go check
735          * if that forms any loops in the graph.
736          */
737         fib_entry->fe_parent = esrc->fes_pl;
738         fib_entry->fe_sibling =
739             fib_path_list_child_add(fib_entry->fe_parent,
740                                     FIB_NODE_TYPE_ENTRY,
741                                     fib_entry_get_index(fib_entry));
742
743         fib_entry_recursive_loop_detect_i(fib_entry->fe_parent);
744         fib_path_list_unlock(path_list_index);
745     }
746     fib_entry_src_action_install(fib_entry, source);
747     fib_entry_src_action_fwd_update(fib_entry, source);
748 }
749
750 void
751 fib_entry_src_action_installed (const fib_entry_t *fib_entry,
752                                 fib_source_t source)
753 {
754     fib_entry_src_t *esrc;
755
756     esrc = fib_entry_src_find(fib_entry, source, NULL);
757
758     if (NULL != fib_entry_src_vft[source].fesv_installed)
759     {
760         fib_entry_src_vft[source].fesv_installed(esrc,
761                                                  fib_entry);
762     }
763
764     fib_entry_src_action_fwd_update(fib_entry, source);
765 }
766
767 /*
768  * fib_entry_src_action_add
769  *
770  * Adding a source can result in a new fib_entry being created, which
771  * can inturn mean the pool is realloc'd and thus the entry passed as
772  * an argument it also realloc'd
773  * @return the original entry
774  */
775 fib_entry_t *
776 fib_entry_src_action_add (fib_entry_t *fib_entry,
777                           fib_source_t source,
778                           fib_entry_flag_t flags,
779                           const dpo_id_t *dpo)
780 {
781     fib_node_index_t fib_entry_index;
782     fib_entry_src_t *esrc;
783
784     esrc = fib_entry_src_find_or_create(fib_entry, source, NULL);
785
786     esrc->fes_ref_count++;
787
788     if (1 != esrc->fes_ref_count)
789     {
790         /*
791          * we only want to add the source on the 0->1 transition
792          */
793         return (fib_entry);
794     }
795
796     esrc->fes_entry_flags = flags;
797
798     /*
799      * save variable so we can recover from a fib_entry realloc.
800      */
801     fib_entry_index = fib_entry_get_index(fib_entry);
802
803     if (NULL != fib_entry_src_vft[source].fesv_add)
804     {
805         fib_entry_src_vft[source].fesv_add(esrc,
806                                            fib_entry,
807                                            flags,
808                                            fib_entry_get_proto(fib_entry),
809                                            dpo);
810     }
811
812     fib_entry = fib_entry_get(fib_entry_index);
813
814     esrc->fes_flags |= FIB_ENTRY_SRC_FLAG_ADDED;
815
816     fib_path_list_lock(esrc->fes_pl);
817
818     /*
819      * the source owns a lock on the entry
820      */
821     fib_entry_lock(fib_entry_get_index(fib_entry));
822
823     return (fib_entry);
824 }
825
826 /*
827  * fib_entry_src_action_update
828  *
829  * Adding a source can result in a new fib_entry being created, which
830  * can inturn mean the pool is realloc'd and thus the entry passed as
831  * an argument it also realloc'd
832  * @return the original entry
833  */
834 fib_entry_t *
835 fib_entry_src_action_update (fib_entry_t *fib_entry,
836                              fib_source_t source,
837                              fib_entry_flag_t flags,
838                              const dpo_id_t *dpo)
839 {
840     fib_node_index_t fib_entry_index, old_path_list_index;
841     fib_entry_src_t *esrc;
842
843     esrc = fib_entry_src_find_or_create(fib_entry, source, NULL);
844
845     if (NULL == esrc)
846         return (fib_entry_src_action_add(fib_entry, source, flags, dpo));
847
848     old_path_list_index = esrc->fes_pl;
849     esrc->fes_entry_flags = flags;
850
851     /*
852      * save variable so we can recover from a fib_entry realloc.
853      */
854     fib_entry_index = fib_entry_get_index(fib_entry);
855
856     if (NULL != fib_entry_src_vft[source].fesv_add)
857     {
858         fib_entry_src_vft[source].fesv_add(esrc,
859                                            fib_entry,
860                                            flags,
861                                            fib_entry_get_proto(fib_entry),
862                                            dpo);
863     }
864
865     fib_entry = fib_entry_get(fib_entry_index);
866
867     esrc->fes_flags |= FIB_ENTRY_SRC_FLAG_ADDED;
868
869     fib_path_list_lock(esrc->fes_pl);
870     fib_path_list_unlock(old_path_list_index);
871
872     return (fib_entry);
873 }
874
875
876 fib_entry_src_flag_t
877 fib_entry_src_action_remove (fib_entry_t *fib_entry,
878                              fib_source_t source)
879
880 {
881     fib_node_index_t old_path_list;
882     fib_entry_src_flag_t sflags;
883     fib_entry_src_t *esrc;
884
885     esrc = fib_entry_src_find(fib_entry, source, NULL);
886
887     if (NULL == esrc)
888         return (FIB_ENTRY_SRC_FLAG_ACTIVE);
889
890     esrc->fes_ref_count--;
891     sflags = esrc->fes_flags;
892
893     if (0 != esrc->fes_ref_count)
894     {
895         /*
896          * only remove the source on the 1->0 transisition
897          */
898         return (sflags);
899     }
900
901     if (esrc->fes_flags & FIB_ENTRY_SRC_FLAG_ACTIVE)
902     {
903         fib_entry_src_action_deactivate(fib_entry, source);
904     }
905
906     old_path_list = esrc->fes_pl;
907
908     if (NULL != fib_entry_src_vft[source].fesv_remove)
909     {
910         fib_entry_src_vft[source].fesv_remove(esrc);
911     }
912
913     fib_path_list_unlock(old_path_list);
914     fib_entry_unlock(fib_entry_get_index(fib_entry));
915
916     sflags &= ~FIB_ENTRY_SRC_FLAG_ADDED;
917     fib_entry_src_action_deinit(fib_entry, source);
918
919     return (sflags);
920 }
921
922 /*
923  * fib_route_attached_cross_table
924  *
925  * Return true the the route is attached via an interface that
926  * is not in the same table as the route
927  */
928 static inline int
929 fib_route_attached_cross_table (const fib_entry_t *fib_entry,
930                                 const fib_route_path_t *rpath)
931 {
932     /*
933      * - All zeros next-hop
934      * - a valid interface
935      * - entry's fib index not equeal to interface's index
936      */
937     if (ip46_address_is_zero(&rpath->frp_addr) &&
938         (~0 != rpath->frp_sw_if_index) &&
939         (fib_entry->fe_fib_index != 
940          fib_table_get_index_for_sw_if_index(fib_entry_get_proto(fib_entry),
941                                              rpath->frp_sw_if_index)))
942     {
943         return (!0);
944     }
945     return (0);
946 }
947
948 /*
949  * fib_route_attached_cross_table
950  *
951  * Return true the the route is attached via an interface that
952  * is not in the same table as the route
953  */
954 static inline int
955 fib_path_is_attached (const fib_route_path_t *rpath)
956 {
957     /*
958      * - All zeros next-hop
959      * - a valid interface
960      */
961     if (ip46_address_is_zero(&rpath->frp_addr) &&
962         (~0 != rpath->frp_sw_if_index))
963     {
964         return (!0);
965     }
966     else if (rpath->frp_flags & FIB_ROUTE_PATH_ATTACHED)
967     {
968         return (!0);
969     }
970     return (0);
971 }
972
973 fib_path_list_flags_t
974 fib_entry_src_flags_2_path_list_flags (fib_entry_flag_t eflags)
975 {
976     fib_path_list_flags_t plf = FIB_PATH_LIST_FLAG_NONE;
977
978     if (eflags & FIB_ENTRY_FLAG_DROP)
979     {
980         plf |= FIB_PATH_LIST_FLAG_DROP;
981     }
982     if (eflags & FIB_ENTRY_FLAG_EXCLUSIVE)
983     {
984         plf |= FIB_PATH_LIST_FLAG_EXCLUSIVE;
985     }
986     if (eflags & FIB_ENTRY_FLAG_LOCAL)
987     {
988         plf |= FIB_PATH_LIST_FLAG_LOCAL;
989     }
990
991     return (plf);
992 }
993
994 static void
995 fib_entry_flags_update (const fib_entry_t *fib_entry,
996                         const fib_route_path_t *rpath,
997                         fib_path_list_flags_t *pl_flags,
998                         fib_entry_src_t *esrc)
999 {
1000     if ((esrc->fes_src == FIB_SOURCE_API) ||
1001         (esrc->fes_src == FIB_SOURCE_CLI))
1002     {
1003         if (fib_path_is_attached(rpath))
1004         {
1005             esrc->fes_entry_flags |= FIB_ENTRY_FLAG_ATTACHED;
1006         }
1007         else
1008         {
1009             esrc->fes_entry_flags &= ~FIB_ENTRY_FLAG_ATTACHED;
1010         }
1011     }
1012     if (fib_route_attached_cross_table(fib_entry, rpath))
1013     {
1014         esrc->fes_entry_flags |= FIB_ENTRY_FLAG_IMPORT;
1015     }
1016     else
1017     {
1018         esrc->fes_entry_flags &= ~FIB_ENTRY_FLAG_IMPORT;
1019     }
1020 }
1021
1022 /*
1023  * fib_entry_src_path_ext_add
1024  *
1025  * append a path extension to the entry's list
1026  */
1027 static void
1028 fib_entry_src_path_ext_append (fib_entry_src_t *esrc,
1029                                const fib_route_path_t *rpath)
1030 {
1031     if (NULL != rpath->frp_label_stack)
1032     {
1033         fib_path_ext_t *path_ext;
1034
1035         vec_add2(esrc->fes_path_exts, path_ext, 1);
1036
1037         fib_path_ext_init(path_ext, esrc->fes_pl, rpath);
1038     }
1039 }
1040
1041 /*
1042  * fib_entry_src_path_ext_insert
1043  *
1044  * insert, sorted, a path extension to the entry's list.
1045  * It's not strictly necessary in sort the path extensions, since each
1046  * extension has the path index to which it resolves. However, by being
1047  * sorted the load-balance produced has a deterministic order, not an order
1048  * based on the sequence of extension additions. this is a considerable benefit.
1049  */
1050 static void
1051 fib_entry_src_path_ext_insert (fib_entry_src_t *esrc,
1052                                const fib_route_path_t *rpath)
1053 {
1054     if (0 == vec_len(esrc->fes_path_exts))
1055         return (fib_entry_src_path_ext_append(esrc, rpath));
1056
1057     if (NULL != rpath->frp_label_stack)
1058     {
1059         fib_path_ext_t path_ext;
1060         int i = 0;
1061
1062         fib_path_ext_init(&path_ext, esrc->fes_pl, rpath);
1063
1064         while (i < vec_len(esrc->fes_path_exts) &&
1065                (fib_path_ext_cmp(&esrc->fes_path_exts[i], rpath) < 0))
1066         {
1067             i++;
1068         }
1069
1070         vec_insert_elts(esrc->fes_path_exts, &path_ext, 1, i);
1071     }
1072 }
1073
1074 /*
1075  * fib_entry_src_action_add
1076  *
1077  * Adding a source can result in a new fib_entry being created, which
1078  * can inturn mean the pool is realloc'd and thus the entry passed as
1079  * an argument it also realloc'd
1080  * @return the entry
1081  */
1082 fib_entry_t*
1083 fib_entry_src_action_path_add (fib_entry_t *fib_entry,
1084                                fib_source_t source,
1085                                fib_entry_flag_t flags,
1086                                const fib_route_path_t *rpath)
1087 {
1088     fib_node_index_t old_path_list, fib_entry_index;
1089     fib_path_list_flags_t pl_flags;
1090     fib_path_ext_t *path_ext;
1091     fib_entry_src_t *esrc;
1092
1093     /*
1094      * save variable so we can recover from a fib_entry realloc.
1095      */
1096     fib_entry_index = fib_entry_get_index(fib_entry);
1097
1098     esrc = fib_entry_src_find(fib_entry, source, NULL);
1099     if (NULL == esrc)
1100     {
1101         fib_entry =
1102             fib_entry_src_action_add(fib_entry,
1103                                      source,
1104                                      flags,
1105                                      drop_dpo_get(
1106                                          fib_proto_to_dpo(
1107                                              fib_entry_get_proto(fib_entry))));
1108         esrc = fib_entry_src_find(fib_entry, source, NULL);
1109     }
1110
1111     /*
1112      * we are no doubt modifying a path-list. If the path-list
1113      * is shared, and hence not modifiable, then the index returned
1114      * will be for a different path-list. This FIB entry to needs
1115      * to maintain its lock appropriately.
1116      */
1117     old_path_list = esrc->fes_pl;
1118
1119     ASSERT(NULL != fib_entry_src_vft[source].fesv_path_add);
1120
1121     pl_flags = fib_entry_src_flags_2_path_list_flags(fib_entry_get_flags_i(fib_entry));
1122     fib_entry_flags_update(fib_entry, rpath, &pl_flags, esrc);
1123
1124     fib_entry_src_vft[source].fesv_path_add(esrc, fib_entry, pl_flags, rpath);
1125     fib_entry = fib_entry_get(fib_entry_index);
1126
1127     /*
1128      * re-resolve all the path-extensions with the new path-list
1129      */
1130     vec_foreach(path_ext, esrc->fes_path_exts)
1131     {
1132         fib_path_ext_resolve(path_ext, esrc->fes_pl);
1133     }
1134     /*
1135      * if the path has a label we need to add a path extension
1136      */
1137     fib_entry_src_path_ext_insert(esrc, rpath);
1138
1139     fib_path_list_lock(esrc->fes_pl);
1140     fib_path_list_unlock(old_path_list);
1141
1142     return (fib_entry);
1143 }
1144
1145 /*
1146  * fib_entry_src_action_swap
1147  *
1148  * The source is providing new paths to replace the old ones.
1149  * Adding a source can result in a new fib_entry being created, which
1150  * can inturn mean the pool is realloc'd and thus the entry passed as
1151  * an argument it also realloc'd
1152  * @return the entry
1153  */
1154 fib_entry_t*
1155 fib_entry_src_action_path_swap (fib_entry_t *fib_entry,
1156                                 fib_source_t source,
1157                                 fib_entry_flag_t flags,                         
1158                                 const fib_route_path_t *rpaths)
1159 {
1160     fib_node_index_t old_path_list, fib_entry_index;
1161     fib_path_list_flags_t pl_flags;
1162     const fib_route_path_t *rpath;
1163     fib_path_ext_t *path_ext;
1164     fib_entry_src_t *esrc;
1165
1166     esrc = fib_entry_src_find(fib_entry, source, NULL);
1167
1168     /*
1169      * save variable so we can recover from a fib_entry realloc.
1170      */
1171     fib_entry_index = fib_entry_get_index(fib_entry);
1172
1173     if (NULL == esrc)
1174     {
1175         fib_entry = fib_entry_src_action_add(fib_entry,
1176                                              source,
1177                                              flags,
1178                                              drop_dpo_get(
1179                                                  fib_proto_to_dpo(
1180                                                      fib_entry_get_proto(fib_entry))));
1181         esrc = fib_entry_src_find(fib_entry, source, NULL);
1182     }
1183
1184     /*
1185      * swapping paths may create a new path-list (or may use an existing shared)
1186      * but we are certainly getting a different one. This FIB entry to needs
1187      * to maintain its lock appropriately.
1188      */
1189     old_path_list = esrc->fes_pl;
1190
1191     ASSERT(NULL != fib_entry_src_vft[source].fesv_path_swap);
1192
1193     pl_flags = fib_entry_src_flags_2_path_list_flags(flags);
1194
1195     vec_foreach(rpath, rpaths)
1196     {
1197         fib_entry_flags_update(fib_entry, rpath, &pl_flags, esrc);
1198     }
1199
1200     fib_entry_src_vft[source].fesv_path_swap(esrc,
1201                                              fib_entry,
1202                                              pl_flags,
1203                                              rpaths);
1204
1205     vec_foreach(path_ext, esrc->fes_path_exts)
1206     {
1207         vec_free(path_ext->fpe_label_stack);
1208     }
1209     vec_free(esrc->fes_path_exts);
1210
1211     vec_foreach(rpath, rpaths)
1212     {
1213         fib_entry_src_path_ext_append(esrc, rpath);
1214     }
1215
1216     fib_entry = fib_entry_get(fib_entry_index);
1217
1218     fib_path_list_lock(esrc->fes_pl);
1219     fib_path_list_unlock(old_path_list);
1220
1221     return (fib_entry);
1222 }
1223
1224 fib_entry_src_flag_t
1225 fib_entry_src_action_path_remove (fib_entry_t *fib_entry,
1226                                   fib_source_t source,
1227                                   const fib_route_path_t *rpath)
1228 {
1229     fib_path_list_flags_t pl_flags;
1230     fib_node_index_t old_path_list;
1231     fib_path_ext_t *path_ext;
1232     fib_entry_src_t *esrc;
1233
1234     esrc = fib_entry_src_find(fib_entry, source, NULL);
1235
1236     ASSERT(NULL != esrc);
1237     ASSERT(esrc->fes_flags & FIB_ENTRY_SRC_FLAG_ADDED);
1238
1239     /*
1240      * we no doubt modifying a path-list. If the path-list
1241      * is shared, and hence not modifiable, then the index returned
1242      * will be for a different path-list. This FIB entry to needs
1243      * to maintain its lock appropriately.
1244      */
1245     old_path_list = esrc->fes_pl;
1246
1247     ASSERT(NULL != fib_entry_src_vft[source].fesv_path_remove);
1248
1249     pl_flags = fib_entry_src_flags_2_path_list_flags(fib_entry_get_flags_i(fib_entry));
1250     fib_entry_flags_update(fib_entry, rpath, &pl_flags, esrc);
1251
1252     fib_entry_src_vft[source].fesv_path_remove(esrc, pl_flags, rpath);
1253     /*
1254      * find the matching path extension and remove it
1255      */
1256     vec_foreach(path_ext, esrc->fes_path_exts)
1257     {
1258         if (!fib_path_ext_cmp(path_ext, rpath))
1259         {
1260             /*
1261              * delete the element moving the remaining elements down 1 position.
1262              * this preserves the sorted order.
1263              */
1264             vec_free(path_ext->fpe_label_stack);
1265             vec_delete(esrc->fes_path_exts, 1, (path_ext - esrc->fes_path_exts));
1266             break;
1267         }
1268     }
1269     /*
1270      * re-resolve all the path-extensions with the new path-list
1271      */
1272     vec_foreach(path_ext, esrc->fes_path_exts)
1273     {
1274         fib_path_ext_resolve(path_ext, esrc->fes_pl);
1275     }
1276
1277     /*
1278      * lock the new path-list, unlock the old if it had one
1279      */
1280     fib_path_list_unlock(old_path_list);
1281
1282     if (FIB_NODE_INDEX_INVALID != esrc->fes_pl) {
1283         fib_path_list_lock(esrc->fes_pl);
1284         return (FIB_ENTRY_SRC_FLAG_ADDED);
1285     }
1286     else
1287     {
1288         /*
1289          * no more paths left from this source
1290          */
1291         fib_entry_src_action_remove(fib_entry, source);
1292         return (FIB_ENTRY_SRC_FLAG_NONE);
1293     }
1294 }
1295
1296 u8*
1297 fib_entry_src_format (fib_entry_t *fib_entry,
1298                       fib_source_t source,
1299                       u8* s)
1300 {
1301     fib_entry_src_t *esrc;
1302
1303     esrc = fib_entry_src_find(fib_entry, source, NULL);
1304
1305     if (NULL != fib_entry_src_vft[source].fesv_format)
1306     {
1307         return (fib_entry_src_vft[source].fesv_format(esrc, s));
1308     }
1309     return (s);
1310 }
1311
1312 adj_index_t
1313 fib_entry_get_adj_for_source (fib_node_index_t fib_entry_index,
1314                               fib_source_t source)
1315 {
1316     fib_entry_t *fib_entry;
1317     fib_entry_src_t *esrc;
1318
1319     if (FIB_NODE_INDEX_INVALID == fib_entry_index)
1320         return (ADJ_INDEX_INVALID);
1321
1322     fib_entry = fib_entry_get(fib_entry_index);
1323     esrc = fib_entry_src_find(fib_entry, source, NULL);
1324
1325     if (NULL != esrc)
1326     {
1327         if (FIB_NODE_INDEX_INVALID != esrc->fes_pl)
1328         {
1329             return (fib_path_list_get_adj(
1330                         esrc->fes_pl,
1331                         fib_entry_get_default_chain_type(fib_entry)));
1332         }
1333     }
1334     return (ADJ_INDEX_INVALID);
1335 }
1336
1337 const int
1338 fib_entry_get_dpo_for_source (fib_node_index_t fib_entry_index,
1339                               fib_source_t source,
1340                               dpo_id_t *dpo)
1341 {
1342     fib_entry_t *fib_entry;
1343     fib_entry_src_t *esrc;
1344
1345     if (FIB_NODE_INDEX_INVALID == fib_entry_index)
1346         return (0);
1347
1348     fib_entry = fib_entry_get(fib_entry_index);
1349     esrc = fib_entry_src_find(fib_entry, source, NULL);
1350
1351     if (NULL != esrc)
1352     {
1353         if (FIB_NODE_INDEX_INVALID != esrc->fes_pl)
1354         {
1355             fib_path_list_contribute_forwarding(
1356                 esrc->fes_pl,
1357                 fib_entry_get_default_chain_type(fib_entry),
1358                 dpo);
1359
1360             return (dpo_id_is_valid(dpo));
1361         }
1362     }
1363     return (0);
1364 }
1365
1366 u32
1367 fib_entry_get_resolving_interface_for_source (fib_node_index_t entry_index,
1368                                               fib_source_t source)
1369 {
1370     fib_entry_t *fib_entry;
1371     fib_entry_src_t *esrc;
1372
1373     fib_entry = fib_entry_get(entry_index);
1374
1375     esrc = fib_entry_src_find(fib_entry, source, NULL);
1376
1377     if (NULL != esrc)
1378     {
1379         if (FIB_NODE_INDEX_INVALID != esrc->fes_pl)
1380         {
1381             return (fib_path_list_get_resolving_interface(esrc->fes_pl));
1382         }
1383     }
1384     return (~0);
1385 }
1386
1387 fib_entry_flag_t
1388 fib_entry_get_flags_for_source (fib_node_index_t entry_index,
1389                                 fib_source_t source)
1390 {
1391     fib_entry_t *fib_entry;
1392     fib_entry_src_t *esrc;
1393
1394     fib_entry = fib_entry_get(entry_index);
1395
1396     esrc = fib_entry_src_find(fib_entry, source, NULL);
1397
1398     if (NULL != esrc)
1399     {
1400         return (esrc->fes_entry_flags);
1401     }
1402
1403     return (FIB_ENTRY_FLAG_NONE);
1404 }
1405
1406 fib_entry_flag_t
1407 fib_entry_get_flags_i (const fib_entry_t *fib_entry)
1408 {
1409     fib_entry_flag_t flags;
1410
1411     /*
1412      * the vector of sources is deliberately arranged in priority order
1413      */
1414     if (0 == vec_len(fib_entry->fe_srcs))
1415     {
1416         flags = FIB_ENTRY_FLAG_NONE;
1417     }
1418     else
1419     {
1420         fib_entry_src_t *esrc;
1421
1422         esrc = vec_elt_at_index(fib_entry->fe_srcs, 0);
1423         flags = esrc->fes_entry_flags;
1424     }
1425
1426     return (flags);
1427 }
1428
1429 void
1430 fib_entry_set_source_data (fib_node_index_t fib_entry_index,
1431                            fib_source_t source,
1432                            const void *data)
1433 {
1434     fib_entry_t *fib_entry;
1435     fib_entry_src_t *esrc;
1436
1437     fib_entry = fib_entry_get(fib_entry_index);
1438     esrc = fib_entry_src_find(fib_entry, source, NULL);
1439
1440     if (NULL != esrc &&
1441         NULL != fib_entry_src_vft[source].fesv_set_data)
1442     {
1443         fib_entry_src_vft[source].fesv_set_data(esrc, fib_entry, data);
1444     }
1445 }
1446
1447 const void*
1448 fib_entry_get_source_data (fib_node_index_t fib_entry_index,
1449                            fib_source_t source)
1450 {
1451     fib_entry_t *fib_entry;
1452     fib_entry_src_t *esrc;
1453
1454     fib_entry = fib_entry_get(fib_entry_index);
1455     esrc = fib_entry_src_find(fib_entry, source, NULL);
1456
1457     if (NULL != esrc &&
1458         NULL != fib_entry_src_vft[source].fesv_get_data)
1459     {
1460         return (fib_entry_src_vft[source].fesv_get_data(esrc, fib_entry));
1461     }
1462     return (NULL);
1463 }
1464
1465 void
1466 fib_entry_src_module_init (void)
1467 {
1468     fib_entry_src_rr_register();
1469     fib_entry_src_interface_register();
1470     fib_entry_src_default_route_register();
1471     fib_entry_src_special_register();
1472     fib_entry_src_api_register();
1473     fib_entry_src_adj_register();
1474     fib_entry_src_mpls_register();
1475     fib_entry_src_lisp_register();
1476 }