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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
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>
30 static fib_entry_src_vft_t fib_entry_src_vft[FIB_SOURCE_MAX];
33 * Get the VFT for a given source. This is a combination of the source
34 * enum and the interposer flags
36 const fib_entry_src_vft_t*
37 fib_entry_src_get_vft (const fib_entry_src_t *esrc)
39 if (esrc->fes_entry_flags & FIB_ENTRY_FLAG_INTERPOSE)
41 return (&fib_entry_src_vft[FIB_SOURCE_INTERPOSE]);
44 return (&fib_entry_src_vft[esrc->fes_src]);
48 fib_entry_src_copy_default (const fib_entry_src_t *orig_src,
49 const fib_entry_t *fib_entry,
50 fib_entry_src_t *copy_src)
52 clib_memcpy(©_src->u, &orig_src->u, sizeof(copy_src->u));
56 fib_entry_src_register (fib_source_t source,
57 const fib_entry_src_vft_t *vft)
59 fib_entry_src_vft[source] = *vft;
61 if (NULL == fib_entry_src_vft[source].fesv_copy)
63 fib_entry_src_vft[source].fesv_copy = fib_entry_src_copy_default;
68 fib_entry_src_cmp_for_sort (void * v1,
71 fib_entry_src_t *esrc1 = v1, *esrc2 = v2;
73 return (esrc1->fes_src - esrc2->fes_src);
77 fib_entry_src_action_init (fib_entry_t *fib_entry,
79 fib_entry_flag_t flags)
81 fib_entry_src_t esrc = {
82 .fes_pl = FIB_NODE_INDEX_INVALID,
83 .fes_flags = FIB_ENTRY_SRC_FLAG_NONE,
85 .fes_entry_flags = flags,
88 FIB_ENTRY_SRC_VFT_INVOKE(&esrc, fesv_init, (&esrc));
90 vec_add1(fib_entry->fe_srcs, esrc);
91 vec_sort_with_function(fib_entry->fe_srcs,
92 fib_entry_src_cmp_for_sort);
95 static fib_entry_src_t *
96 fib_entry_src_find_i (const fib_entry_t *fib_entry,
101 fib_entry_src_t *esrc;
105 vec_foreach(esrc, fib_entry->fe_srcs)
107 if (esrc->fes_src == source)
124 static fib_entry_src_t *
125 fib_entry_src_find (const fib_entry_t *fib_entry,
129 return (fib_entry_src_find_i(fib_entry, source, NULL));
133 fib_entry_is_sourced (fib_node_index_t fib_entry_index,
136 fib_entry_t *fib_entry;
138 fib_entry = fib_entry_get(fib_entry_index);
140 return (NULL != fib_entry_src_find(fib_entry, source));
143 static fib_entry_src_t *
144 fib_entry_src_find_or_create (fib_entry_t *fib_entry,
146 fib_entry_flag_t flags)
148 fib_entry_src_t *esrc;
150 esrc = fib_entry_src_find(fib_entry, source);
154 fib_entry_src_action_init(fib_entry, source, flags);
157 return (fib_entry_src_find(fib_entry, source));
161 fib_entry_src_action_deinit (fib_entry_t *fib_entry,
165 fib_entry_src_t *esrc;
168 esrc = fib_entry_src_find_i(fib_entry, source, &index);
170 ASSERT(NULL != esrc);
172 FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_deinit, (esrc));
174 fib_path_ext_list_flush(&esrc->fes_path_exts);
175 vec_del1(fib_entry->fe_srcs, index);
178 fib_entry_src_cover_res_t
179 fib_entry_src_action_cover_change (fib_entry_t *fib_entry,
180 fib_entry_src_t *esrc)
182 FIB_ENTRY_SRC_VFT_INVOKE_AND_RETURN(esrc, fesv_cover_change,
185 fib_entry_src_cover_res_t res = {
187 .bw_reason = FIB_NODE_BW_REASON_FLAG_NONE,
192 fib_entry_src_cover_res_t
193 fib_entry_src_action_cover_update (fib_entry_t *fib_entry,
194 fib_entry_src_t *esrc)
196 FIB_ENTRY_SRC_VFT_INVOKE_AND_RETURN(esrc, fesv_cover_update,
199 fib_entry_src_cover_res_t res = {
201 .bw_reason = FIB_NODE_BW_REASON_FLAG_NONE,
206 typedef struct fib_entry_src_collect_forwarding_ctx_t_
208 load_balance_path_t *next_hops;
209 const fib_entry_t *fib_entry;
210 const fib_entry_src_t *esrc;
211 fib_forward_chain_type_t fct;
212 int n_recursive_constrained;
214 } fib_entry_src_collect_forwarding_ctx_t;
217 * @brief Determine whether this FIB entry should use a load-balance MAP
218 * to support PIC edge fast convergence
221 fib_entry_calc_lb_flags (fib_entry_src_collect_forwarding_ctx_t *ctx)
224 * We'll use a LB map if the path-list has multiple recursive paths.
225 * recursive paths implies BGP, and hence scale.
227 if (ctx->n_recursive_constrained > 1 &&
228 fib_path_list_is_popular(ctx->esrc->fes_pl))
230 return (LOAD_BALANCE_FLAG_USES_MAP);
232 return (LOAD_BALANCE_FLAG_NONE);
236 fib_entry_src_valid_out_label (mpls_label_t label)
238 return ((MPLS_LABEL_IS_REAL(label) ||
239 MPLS_LABEL_POP == label ||
240 MPLS_IETF_IPV4_EXPLICIT_NULL_LABEL == label ||
241 MPLS_IETF_IPV6_EXPLICIT_NULL_LABEL == label ||
242 MPLS_IETF_IMPLICIT_NULL_LABEL == label));
246 * @brief Turn the chain type requested by the client into the one they
249 fib_forward_chain_type_t
250 fib_entry_chain_type_fixup (const fib_entry_t *entry,
251 fib_forward_chain_type_t fct)
254 * The EOS chain is a tricky since one cannot know the adjacency
255 * to link to without knowing what the packets payload protocol
256 * will be once the label is popped.
258 fib_forward_chain_type_t dfct;
260 if (FIB_FORW_CHAIN_TYPE_MPLS_EOS != fct)
265 dfct = fib_entry_get_default_chain_type(entry);
267 if (FIB_FORW_CHAIN_TYPE_MPLS_EOS == dfct)
270 * If the entry being asked is a eos-MPLS label entry,
271 * then use the payload-protocol field, that we stashed there
272 * for just this purpose
274 return (fib_forw_chain_type_from_dpo_proto(
275 entry->fe_prefix.fp_payload_proto));
278 * else give them what this entry would be by default. i.e. if it's a v6
279 * entry, then the label its local labelled should be carrying v6 traffic.
280 * If it's a non-EOS label entry, then there are more labels and we want
287 fib_prefix_get_payload_proto (const fib_prefix_t *pfx)
289 switch (pfx->fp_proto)
291 case FIB_PROTOCOL_IP4:
292 return (DPO_PROTO_IP4);
293 case FIB_PROTOCOL_IP6:
294 return (DPO_PROTO_IP6);
295 case FIB_PROTOCOL_MPLS:
296 return (pfx->fp_payload_proto);
300 return (DPO_PROTO_IP4);
304 fib_entry_src_get_path_forwarding (fib_node_index_t path_index,
305 fib_entry_src_collect_forwarding_ctx_t *ctx)
307 load_balance_path_t *nh;
310 * no extension => no out-going label for this path. that's OK
311 * in the case of an IP or EOS chain, but not for non-EOS
315 case FIB_FORW_CHAIN_TYPE_UNICAST_IP4:
316 case FIB_FORW_CHAIN_TYPE_UNICAST_IP6:
317 case FIB_FORW_CHAIN_TYPE_MCAST_IP4:
318 case FIB_FORW_CHAIN_TYPE_MCAST_IP6:
319 case FIB_FORW_CHAIN_TYPE_BIER:
321 * EOS traffic with no label to stack, we need the IP Adj
323 vec_add2(ctx->next_hops, nh, 1);
325 nh->path_index = path_index;
326 nh->path_weight = fib_path_get_weight(path_index);
327 fib_path_contribute_forwarding(path_index, ctx->fct, &nh->path_dpo);
330 case FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS:
331 if (fib_path_is_exclusive(path_index) ||
332 fib_path_is_deag(path_index))
334 vec_add2(ctx->next_hops, nh, 1);
336 nh->path_index = path_index;
337 nh->path_weight = fib_path_get_weight(path_index);
338 fib_path_contribute_forwarding(path_index,
339 FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS,
343 case FIB_FORW_CHAIN_TYPE_MPLS_EOS:
346 * no label. we need a chain based on the payload. fixup.
348 vec_add2(ctx->next_hops, nh, 1);
350 nh->path_index = path_index;
351 nh->path_weight = fib_path_get_weight(path_index);
352 fib_path_contribute_forwarding(path_index,
353 fib_entry_chain_type_fixup(ctx->fib_entry,
356 fib_path_stack_mpls_disp(path_index,
357 fib_prefix_get_payload_proto(&ctx->fib_entry->fe_prefix),
358 FIB_MPLS_LSP_MODE_PIPE,
363 case FIB_FORW_CHAIN_TYPE_ETHERNET:
364 case FIB_FORW_CHAIN_TYPE_NSH:
370 static fib_path_list_walk_rc_t
371 fib_entry_src_collect_forwarding (fib_node_index_t pl_index,
372 fib_node_index_t path_index,
375 fib_entry_src_collect_forwarding_ctx_t *ctx;
376 fib_path_ext_t *path_ext;
380 n_nhs = vec_len(ctx->next_hops);
383 * if the path is not resolved, don't include it.
385 if (!fib_path_is_resolved(path_index))
387 return (FIB_PATH_LIST_WALK_CONTINUE);
390 if (fib_path_is_recursive_constrained(path_index))
392 ctx->n_recursive_constrained += 1;
394 if (0xffff == ctx->preference)
397 * not set a preference yet, so the first path we encounter
398 * sets the preference we are collecting.
400 ctx->preference = fib_path_get_preference(path_index);
402 else if (ctx->preference != fib_path_get_preference(path_index))
405 * this path does not belong to the same preference as the
406 * previous paths encountered. we are done now.
408 return (FIB_PATH_LIST_WALK_STOP);
412 * get the matching path-extension for the path being visited.
414 path_ext = fib_path_ext_list_find_by_path_index(&ctx->esrc->fes_path_exts,
417 if (NULL != path_ext)
419 switch (path_ext->fpe_type)
421 case FIB_PATH_EXT_MPLS:
422 if (fib_entry_src_valid_out_label(path_ext->fpe_label_stack[0].fml_value))
425 * found a matching extension. stack it to obtain the forwarding
426 * info for this path.
429 fib_path_ext_stack(path_ext,
431 fib_entry_chain_type_fixup(ctx->fib_entry,
437 fib_entry_src_get_path_forwarding(path_index, ctx);
440 case FIB_PATH_EXT_ADJ:
441 if (FIB_PATH_EXT_ADJ_FLAG_REFINES_COVER & path_ext->fpe_adj_flags)
443 fib_entry_src_get_path_forwarding(path_index, ctx);
447 * the path does not refine the cover, meaning that
448 * the adjacency doesdoes not match the sub-net on the link.
449 * So this path does not contribute forwarding.
456 fib_entry_src_get_path_forwarding(path_index, ctx);
460 * a this point 'ctx' has the DPO the path contributed, plus
461 * any labels from path extensions.
462 * check if there are any interpose sources that want to contribute
464 if (n_nhs < vec_len(ctx->next_hops))
467 * the path contributed a new choice.
469 const fib_entry_src_vft_t *vft;
471 vft = fib_entry_src_get_vft(ctx->esrc);
473 if (NULL != vft->fesv_contribute_interpose)
475 const dpo_id_t *interposer;
477 interposer = vft->fesv_contribute_interpose(ctx->esrc,
480 if (NULL != interposer)
482 dpo_id_t clone = DPO_INVALID;
484 dpo_mk_interpose(interposer,
485 &ctx->next_hops[n_nhs].path_dpo,
488 dpo_copy(&ctx->next_hops[n_nhs].path_dpo, &clone);
494 return (FIB_PATH_LIST_WALK_CONTINUE);
498 fib_entry_src_mk_lb (fib_entry_t *fib_entry,
499 const fib_entry_src_t *esrc,
500 fib_forward_chain_type_t fct,
503 dpo_proto_t lb_proto;
506 * If the entry has path extensions then we construct a load-balance
507 * by stacking the extensions on the forwarding chains of the paths.
508 * Otherwise we use the load-balance of the path-list
510 fib_entry_src_collect_forwarding_ctx_t ctx = {
512 .fib_entry = fib_entry,
514 .n_recursive_constrained = 0,
516 .preference = 0xffff,
520 * As an optimisation we allocate the vector of next-hops to be sized
521 * equal to the maximum nuber of paths we will need, which is also the
522 * most likely number we will need, since in most cases the paths are 'up'.
524 vec_validate(ctx.next_hops, fib_path_list_get_n_paths(esrc->fes_pl));
525 vec_reset_length(ctx.next_hops);
527 lb_proto = fib_forw_chain_type_to_dpo_proto(fct);
529 fib_path_list_walk(esrc->fes_pl,
530 fib_entry_src_collect_forwarding,
533 if (esrc->fes_entry_flags & FIB_ENTRY_FLAG_EXCLUSIVE)
536 * the client provided the DPO that the entry should link to.
537 * all entries must link to a LB, so if it is an LB already
538 * then we can use it.
540 if ((1 == vec_len(ctx.next_hops)) &&
541 (DPO_LOAD_BALANCE == ctx.next_hops[0].path_dpo.dpoi_type))
543 dpo_copy(dpo_lb, &ctx.next_hops[0].path_dpo);
544 dpo_reset(&ctx.next_hops[0].path_dpo);
549 if (!dpo_id_is_valid(dpo_lb))
554 if (esrc->fes_entry_flags & FIB_ENTRY_FLAG_MULTICAST)
559 MPLS_IS_REPLICATE | replicate_create(0, lb_proto));
563 fib_protocol_t flow_hash_proto;
564 flow_hash_config_t fhc;
567 * if the protocol for the LB we are building does not match that
568 * of the fib_entry (i.e. we are build the [n]EOS LB for an IPv[46]
569 * then the fib_index is not an index that relates to the table
570 * type we need. So get the default flow-hash config instead.
572 flow_hash_proto = dpo_proto_to_fib(lb_proto);
573 if (fib_entry->fe_prefix.fp_proto != flow_hash_proto)
575 fhc = fib_table_get_default_flow_hash_config(flow_hash_proto);
579 fhc = fib_table_get_flow_hash_config(fib_entry->fe_fib_index,
586 load_balance_create(0, lb_proto, fhc));
590 if (esrc->fes_entry_flags & FIB_ENTRY_FLAG_MULTICAST)
595 replicate_multipath_update(dpo_lb, ctx.next_hops);
599 load_balance_multipath_update(dpo_lb,
601 fib_entry_calc_lb_flags(&ctx));
602 vec_free(ctx.next_hops);
605 * if this entry is sourced by the uRPF-exempt source then we
606 * append the always present local0 interface (index 0) to the
607 * uRPF list so it is not empty. that way packets pass the loose check.
609 index_t ui = fib_path_list_get_urpf(esrc->fes_pl);
611 if ((fib_entry_is_sourced(fib_entry_get_index(fib_entry),
612 FIB_SOURCE_URPF_EXEMPT) ||
613 (esrc->fes_entry_flags & FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT))&&
614 (0 == fib_urpf_check_size(ui)))
617 * The uRPF list we get from the path-list is shared by all
618 * other users of the list, but the uRPF exemption applies
619 * only to this prefix. So we need our own list.
621 ui = fib_urpf_list_alloc_and_lock();
622 fib_urpf_list_append(ui, 0);
623 fib_urpf_list_bake(ui);
624 load_balance_set_urpf(dpo_lb->dpoi_index, ui);
625 fib_urpf_list_unlock(ui);
629 load_balance_set_urpf(dpo_lb->dpoi_index, ui);
631 load_balance_set_fib_entry_flags(dpo_lb->dpoi_index,
632 fib_entry_get_flags_i(fib_entry));
637 fib_entry_src_action_install (fib_entry_t *fib_entry,
641 * Install the forwarding chain for the given source into the forwarding
644 fib_forward_chain_type_t fct;
645 fib_entry_src_t *esrc;
648 fct = fib_entry_get_default_chain_type(fib_entry);
649 esrc = fib_entry_src_find(fib_entry, source);
652 * Every entry has its own load-balance object. All changes to the entry's
653 * forwarding result in an inplace modify of the load-balance. This means
654 * the load-balance object only needs to be added to the forwarding
655 * DB once, when it is created.
657 insert = !dpo_id_is_valid(&fib_entry->fe_lb);
659 fib_entry_src_mk_lb(fib_entry, esrc, fct, &fib_entry->fe_lb);
661 ASSERT(dpo_id_is_valid(&fib_entry->fe_lb));
662 FIB_ENTRY_DBG(fib_entry, "install: %d", fib_entry->fe_lb);
665 * insert the adj into the data-plane forwarding trie
669 fib_table_fwding_dpo_update(fib_entry->fe_fib_index,
670 &fib_entry->fe_prefix,
675 * if any of the other chain types are already created they will need
678 fib_entry_delegate_type_t fdt;
679 fib_entry_delegate_t *fed;
681 FOR_EACH_DELEGATE_CHAIN(fib_entry, fdt, fed,
683 fib_entry_src_mk_lb(fib_entry, esrc,
684 fib_entry_delegate_type_to_chain_type(fdt),
690 fib_entry_src_action_uninstall (fib_entry_t *fib_entry)
693 * uninstall the forwarding chain from the forwarding tables
695 FIB_ENTRY_DBG(fib_entry, "uninstall: %d",
696 fib_entry->fe_adj_index);
698 if (dpo_id_is_valid(&fib_entry->fe_lb))
700 fib_table_fwding_dpo_remove(
701 fib_entry->fe_fib_index,
702 &fib_entry->fe_prefix,
705 dpo_reset(&fib_entry->fe_lb);
710 fib_entry_recursive_loop_detect_i (fib_node_index_t path_list_index)
712 fib_node_index_t *entries = NULL;
714 fib_path_list_recursive_loop_detect(path_list_index, &entries);
720 * fib_entry_src_action_copy
722 * copy a source data from another entry to this one
725 fib_entry_src_action_copy (fib_entry_t *fib_entry,
726 const fib_entry_src_t *orig_src)
728 fib_entry_src_t *esrc;
730 esrc = fib_entry_src_find_or_create(fib_entry,
732 orig_src->fes_entry_flags);
734 FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_copy,
735 (orig_src, fib_entry, esrc));
737 fib_path_list_unlock(esrc->fes_pl);
740 * copy over all the data ...
742 esrc->fes_flags = orig_src->fes_flags;
743 esrc->fes_pl = orig_src->fes_pl;
748 esrc->fes_ref_count = 1;
749 esrc->fes_flags |= FIB_ENTRY_SRC_FLAG_INHERITED;
750 esrc->fes_flags &= ~(FIB_ENTRY_SRC_FLAG_ACTIVE |
751 FIB_ENTRY_SRC_FLAG_CONTRIBUTING);
752 esrc->fes_entry_flags &= ~FIB_ENTRY_FLAG_COVERED_INHERIT;
755 * the source owns a lock on the entry
757 fib_path_list_lock(esrc->fes_pl);
758 fib_entry_lock(fib_entry_get_index(fib_entry));
764 * fib_entry_src_action_update
766 * copy a source data from another entry to this one
768 static fib_entry_src_t *
769 fib_entry_src_action_update_from_cover (fib_entry_t *fib_entry,
770 const fib_entry_src_t *orig_src)
772 fib_entry_src_t *esrc;
774 esrc = fib_entry_src_find_or_create(fib_entry,
776 orig_src->fes_entry_flags);
779 * the source owns a lock on the entry
781 fib_path_list_unlock(esrc->fes_pl);
782 esrc->fes_pl = orig_src->fes_pl;
783 fib_path_list_lock(esrc->fes_pl);
788 static fib_table_walk_rc_t
789 fib_entry_src_covered_inherit_add_i (fib_entry_t *fib_entry,
790 const fib_entry_src_t *cover_src)
792 fib_entry_src_t *esrc;
794 esrc = fib_entry_src_find(fib_entry, cover_src->fes_src);
796 if (cover_src == esrc)
798 return (FIB_TABLE_WALK_CONTINUE);
804 * the covered entry already has this source.
806 if (esrc->fes_entry_flags & FIB_ENTRY_FLAG_COVERED_INHERIT)
809 * the covered source is itself a COVERED_INHERIT, i.e.
810 * it also pushes this source down the sub-tree.
811 * We consider this more specfic covered to be the owner
812 * of the sub-tree from this point down.
814 return (FIB_TABLE_WALK_SUB_TREE_STOP);
816 if (esrc->fes_flags & FIB_ENTRY_SRC_FLAG_INHERITED)
819 * The covered's source data has been inherited, presumably
820 * from this cover, i.e. this is a modify.
822 esrc = fib_entry_src_action_update_from_cover(fib_entry, cover_src);
823 fib_entry_source_change(fib_entry, esrc->fes_src, esrc->fes_src);
828 * The covered's source was not inherited and it is also
829 * not inherting. Nevertheless, it still owns the sub-tree from
832 return (FIB_TABLE_WALK_SUB_TREE_STOP);
838 * The covered does not have this source - add it.
840 fib_source_t best_source;
842 best_source = fib_entry_get_best_source(
843 fib_entry_get_index(fib_entry));
845 fib_entry_src_action_copy(fib_entry, cover_src);
846 fib_entry_source_change(fib_entry, best_source, cover_src->fes_src);
849 return (FIB_TABLE_WALK_CONTINUE);
852 static fib_table_walk_rc_t
853 fib_entry_src_covered_inherit_walk_add (fib_node_index_t fei,
856 return (fib_entry_src_covered_inherit_add_i(fib_entry_get(fei), ctx));
859 static fib_table_walk_rc_t
860 fib_entry_src_covered_inherit_walk_remove (fib_node_index_t fei,
863 fib_entry_src_t *cover_src, *esrc;
864 fib_entry_t *fib_entry;
866 fib_entry = fib_entry_get(fei);
869 esrc = fib_entry_src_find(fib_entry, cover_src->fes_src);
871 if (cover_src == esrc)
873 return (FIB_TABLE_WALK_CONTINUE);
879 * the covered entry already has this source.
881 if (esrc->fes_entry_flags & FIB_ENTRY_FLAG_COVERED_INHERIT)
884 * the covered source is itself a COVERED_INHERIT, i.e.
885 * it also pushes this source down the sub-tree.
886 * We consider this more specfic covered to be the owner
887 * of the sub-tree from this point down.
889 return (FIB_TABLE_WALK_SUB_TREE_STOP);
891 if (esrc->fes_flags & FIB_ENTRY_SRC_FLAG_INHERITED)
894 * The covered's source data has been inherited, presumably
897 fib_entry_src_flag_t remaining;
899 remaining = fib_entry_special_remove(fei, cover_src->fes_src);
901 ASSERT(FIB_ENTRY_SRC_FLAG_ADDED == remaining);
906 * The covered's source was not inherited and it is also
907 * not inherting. Nevertheless, it still owns the sub-tree from
910 return (FIB_TABLE_WALK_SUB_TREE_STOP);
916 * The covered does not have this source - that's an error,
917 * since it should have inherited, but there is nothing we can do
921 return (FIB_TABLE_WALK_CONTINUE);
925 fib_entry_src_inherit (const fib_entry_t *cover,
926 fib_entry_t *covered)
928 CLIB_UNUSED(fib_source_t source);
929 const fib_entry_src_t *src;
931 FOR_EACH_SRC_ADDED(cover, src, source,
933 if ((src->fes_entry_flags & FIB_ENTRY_FLAG_COVERED_INHERIT) ||
934 (src->fes_flags & FIB_ENTRY_SRC_FLAG_INHERITED))
936 fib_entry_src_covered_inherit_add_i(covered, src);
942 fib_entry_src_covered_inherit_add (fib_entry_t *fib_entry,
946 fib_entry_src_t *esrc;
948 esrc = fib_entry_src_find(fib_entry, source);
950 ASSERT(esrc->fes_flags & FIB_ENTRY_SRC_FLAG_ACTIVE);
952 if ((esrc->fes_entry_flags & FIB_ENTRY_FLAG_COVERED_INHERIT) ||
953 (esrc->fes_flags & FIB_ENTRY_SRC_FLAG_INHERITED))
955 fib_table_sub_tree_walk(fib_entry->fe_fib_index,
956 fib_entry->fe_prefix.fp_proto,
957 &fib_entry->fe_prefix,
958 fib_entry_src_covered_inherit_walk_add,
964 fib_entry_src_covered_inherit_remove (fib_entry_t *fib_entry,
965 fib_entry_src_t *esrc)
968 ASSERT(!(esrc->fes_flags & FIB_ENTRY_SRC_FLAG_ACTIVE));
970 if (esrc->fes_entry_flags & FIB_ENTRY_FLAG_COVERED_INHERIT)
972 fib_table_sub_tree_walk(fib_entry->fe_fib_index,
973 fib_entry->fe_prefix.fp_proto,
974 &fib_entry->fe_prefix,
975 fib_entry_src_covered_inherit_walk_remove,
981 fib_entry_src_action_activate (fib_entry_t *fib_entry,
985 int houston_we_are_go_for_install;
986 const fib_entry_src_vft_t *vft;
987 fib_entry_src_t *esrc;
989 esrc = fib_entry_src_find(fib_entry, source);
991 ASSERT(!(esrc->fes_flags & FIB_ENTRY_SRC_FLAG_ACTIVE));
992 ASSERT(esrc->fes_flags & FIB_ENTRY_SRC_FLAG_ADDED);
994 esrc->fes_flags |= (FIB_ENTRY_SRC_FLAG_ACTIVE |
995 FIB_ENTRY_SRC_FLAG_CONTRIBUTING);
996 vft = fib_entry_src_get_vft(esrc);
998 if (NULL != vft->fesv_activate)
1000 houston_we_are_go_for_install = vft->fesv_activate(esrc, fib_entry);
1005 * the source is not providing an activate function, we'll assume
1006 * therefore it has no objection to installing the entry
1008 houston_we_are_go_for_install = !0;
1012 * link to the path-list provided by the source, and go check
1013 * if that forms any loops in the graph.
1015 fib_entry->fe_parent = esrc->fes_pl;
1016 fib_entry->fe_sibling =
1017 fib_path_list_child_add(fib_entry->fe_parent,
1018 FIB_NODE_TYPE_ENTRY,
1019 fib_entry_get_index(fib_entry));
1021 fib_entry_recursive_loop_detect_i(fib_entry->fe_parent);
1023 FIB_ENTRY_DBG(fib_entry, "activate: %d",
1024 fib_entry->fe_parent);
1027 * If this source should push its state to covered prefixs, do that now.
1029 fib_entry_src_covered_inherit_add(fib_entry, source);
1031 if (0 != houston_we_are_go_for_install)
1033 fib_entry_src_action_install(fib_entry, source);
1037 fib_entry_src_action_uninstall(fib_entry);
1042 fib_entry_src_action_deactivate (fib_entry_t *fib_entry,
1043 fib_source_t source)
1046 fib_node_index_t path_list_index;
1047 fib_entry_src_t *esrc;
1049 esrc = fib_entry_src_find(fib_entry, source);
1051 ASSERT(esrc->fes_flags & FIB_ENTRY_SRC_FLAG_ACTIVE);
1053 FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_deactivate,
1056 esrc->fes_flags &= ~(FIB_ENTRY_SRC_FLAG_ACTIVE |
1057 FIB_ENTRY_SRC_FLAG_CONTRIBUTING);
1059 FIB_ENTRY_DBG(fib_entry, "deactivate: %d", fib_entry->fe_parent);
1062 * If this source should pull its state from covered prefixs, do that now.
1063 * If this source also has the INHERITED flag set then it has a cover
1064 * that wants to push down forwarding. We only want the covereds to see
1067 fib_entry_src_covered_inherit_remove(fib_entry, esrc);
1070 * un-link from an old path-list. Check for any loops this will clear
1072 path_list_index = fib_entry->fe_parent;
1073 fib_entry->fe_parent = FIB_NODE_INDEX_INVALID;
1075 fib_entry_recursive_loop_detect_i(path_list_index);
1078 * this will unlock the path-list, so it may be invalid thereafter.
1080 fib_path_list_child_remove(path_list_index, fib_entry->fe_sibling);
1081 fib_entry->fe_sibling = FIB_NODE_INDEX_INVALID;
1085 fib_entry_src_action_fwd_update (const fib_entry_t *fib_entry,
1086 fib_source_t source)
1088 fib_entry_src_t *esrc;
1090 vec_foreach(esrc, fib_entry->fe_srcs)
1092 FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_fwd_update,
1093 (esrc, fib_entry, source));
1098 fib_entry_src_action_reactivate (fib_entry_t *fib_entry,
1099 fib_source_t source)
1101 fib_node_index_t path_list_index;
1102 const fib_entry_src_vft_t *vft;
1103 fib_entry_src_t *esrc;
1104 int remain_installed;
1106 esrc = fib_entry_src_find(fib_entry, source);
1108 ASSERT(esrc->fes_flags & FIB_ENTRY_SRC_FLAG_ACTIVE);
1110 FIB_ENTRY_DBG(fib_entry, "reactivate: %d to %d",
1111 fib_entry->fe_parent,
1115 * call the source to reactive and get the go/no-go to remain installed
1117 vft = fib_entry_src_get_vft(esrc);
1119 if (NULL != vft->fesv_reactivate)
1121 remain_installed = vft->fesv_reactivate(esrc, fib_entry);
1125 remain_installed = 1;
1128 if (fib_entry->fe_parent != esrc->fes_pl)
1131 * un-link from an old path-list. Check for any loops this will clear
1133 path_list_index = fib_entry->fe_parent;
1134 fib_entry->fe_parent = FIB_NODE_INDEX_INVALID;
1137 * temporary lock so it doesn't get deleted when this entry is no
1140 fib_path_list_lock(path_list_index);
1143 * this entry is no longer a child. after unlinking check if any loops
1146 fib_path_list_child_remove(path_list_index,
1147 fib_entry->fe_sibling);
1149 fib_entry_recursive_loop_detect_i(path_list_index);
1152 * link to the path-list provided by the source, and go check
1153 * if that forms any loops in the graph.
1155 fib_entry->fe_parent = esrc->fes_pl;
1156 fib_entry->fe_sibling =
1157 fib_path_list_child_add(fib_entry->fe_parent,
1158 FIB_NODE_TYPE_ENTRY,
1159 fib_entry_get_index(fib_entry));
1161 fib_entry_recursive_loop_detect_i(fib_entry->fe_parent);
1162 fib_path_list_unlock(path_list_index);
1165 * If this source should push its state to covered prefixs, do that now.
1167 fib_entry_src_covered_inherit_add(fib_entry, source);
1170 if (!remain_installed)
1172 fib_entry_src_action_uninstall(fib_entry);
1176 fib_entry_src_action_install(fib_entry, source);
1178 fib_entry_src_action_fwd_update(fib_entry, source);
1182 fib_entry_src_action_installed (const fib_entry_t *fib_entry,
1183 fib_source_t source)
1185 fib_entry_src_t *esrc;
1187 esrc = fib_entry_src_find(fib_entry, source);
1189 FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_installed,
1192 fib_entry_src_action_fwd_update(fib_entry, source);
1196 * fib_entry_src_action_add
1198 * Adding a source can result in a new fib_entry being created, which
1199 * can inturn mean the pool is realloc'd and thus the entry passed as
1200 * an argument it also realloc'd
1201 * @return the original entry
1204 fib_entry_src_action_add (fib_entry_t *fib_entry,
1205 fib_source_t source,
1206 fib_entry_flag_t flags,
1207 const dpo_id_t *dpo)
1209 fib_node_index_t fib_entry_index;
1210 fib_entry_src_t *esrc;
1212 esrc = fib_entry_src_find_or_create(fib_entry, source, flags);
1214 ASSERT(esrc->fes_ref_count < 255);
1215 esrc->fes_ref_count++;
1217 if (flags != esrc->fes_entry_flags)
1219 FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_flags_change,
1220 (esrc, fib_entry, flags));
1222 esrc->fes_entry_flags = flags;
1224 if (1 != esrc->fes_ref_count)
1227 * we only want to add the source on the 0->1 transition
1233 * save variable so we can recover from a fib_entry realloc.
1235 fib_entry_index = fib_entry_get_index(fib_entry);
1237 FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_add,
1241 fib_entry_get_dpo_proto(fib_entry),
1244 fib_entry = fib_entry_get(fib_entry_index);
1246 esrc->fes_flags |= FIB_ENTRY_SRC_FLAG_ADDED;
1248 fib_path_list_lock(esrc->fes_pl);
1251 * the source owns a lock on the entry
1253 fib_entry_lock(fib_entry_get_index(fib_entry));
1259 * fib_entry_src_action_update
1261 * Adding a source can result in a new fib_entry being created, which
1262 * can inturn mean the pool is realloc'd and thus the entry passed as
1263 * an argument it also realloc'd
1264 * @return the original entry
1267 fib_entry_src_action_update (fib_entry_t *fib_entry,
1268 fib_source_t source,
1269 fib_entry_flag_t flags,
1270 const dpo_id_t *dpo)
1272 fib_node_index_t fib_entry_index, old_path_list_index;
1273 fib_entry_src_t *esrc;
1275 esrc = fib_entry_src_find_or_create(fib_entry, source, flags);
1279 return (fib_entry_src_action_add(fib_entry, source, flags, dpo));
1282 old_path_list_index = esrc->fes_pl;
1283 esrc->fes_entry_flags = flags;
1286 * save variable so we can recover from a fib_entry realloc.
1288 fib_entry_index = fib_entry_get_index(fib_entry);
1290 FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_add,
1294 fib_entry_get_dpo_proto(fib_entry),
1297 fib_entry = fib_entry_get(fib_entry_index);
1299 esrc->fes_flags |= FIB_ENTRY_SRC_FLAG_ADDED;
1301 fib_path_list_lock(esrc->fes_pl);
1302 fib_path_list_unlock(old_path_list_index);
1307 fib_entry_src_flag_t
1308 fib_entry_src_action_remove_or_update_inherit (fib_entry_t *fib_entry,
1309 fib_source_t source)
1311 fib_entry_src_t *esrc;
1313 esrc = fib_entry_src_find(fib_entry, source);
1316 return (FIB_ENTRY_SRC_FLAG_ACTIVE);
1318 if ((esrc->fes_entry_flags & FIB_ENTRY_FLAG_COVERED_INHERIT) &&
1319 (esrc->fes_flags & FIB_ENTRY_SRC_FLAG_INHERITED))
1321 fib_entry_src_t *cover_src;
1322 fib_node_index_t coveri;
1326 * this source was pushing inherited state, but so is its
1327 * cover. Now that this source is going away, we need to
1328 * pull the covers forwarding and use it to update the covereds.
1329 * Go grab the path-list from the cover, rather than start a walk from
1330 * the cover, so we don't recursively update this entry.
1332 coveri = fib_table_get_less_specific(fib_entry->fe_fib_index,
1333 &fib_entry->fe_prefix);
1336 * only the default route has itself as its own cover, but the
1337 * default route cannot have inherited from something else.
1339 ASSERT(coveri != fib_entry_get_index(fib_entry));
1341 cover = fib_entry_get(coveri);
1342 cover_src = fib_entry_src_find(cover, source);
1344 ASSERT(NULL != cover_src);
1346 esrc = fib_entry_src_action_update_from_cover(fib_entry, cover_src);
1347 esrc->fes_entry_flags &= ~FIB_ENTRY_FLAG_COVERED_INHERIT;
1350 * Now push the new state from the cover down to the covereds
1352 fib_entry_src_covered_inherit_add(fib_entry, source);
1354 return (esrc->fes_flags);
1358 return (fib_entry_src_action_remove(fib_entry, source));
1362 fib_entry_src_flag_t
1363 fib_entry_src_action_remove (fib_entry_t *fib_entry,
1364 fib_source_t source)
1367 fib_node_index_t old_path_list;
1368 fib_entry_src_flag_t sflags;
1369 fib_entry_src_t *esrc;
1371 esrc = fib_entry_src_find(fib_entry, source);
1374 return (FIB_ENTRY_SRC_FLAG_ACTIVE);
1376 esrc->fes_ref_count--;
1377 sflags = esrc->fes_flags;
1379 if (0 != esrc->fes_ref_count)
1382 * only remove the source on the 1->0 transisition
1387 if (esrc->fes_flags & FIB_ENTRY_SRC_FLAG_ACTIVE)
1389 fib_entry_src_action_deactivate(fib_entry, source);
1391 else if (esrc->fes_flags & FIB_ENTRY_SRC_FLAG_CONTRIBUTING)
1393 FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_deactivate,
1395 esrc->fes_flags &= ~FIB_ENTRY_SRC_FLAG_CONTRIBUTING;
1398 old_path_list = esrc->fes_pl;
1400 FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_remove, (esrc));
1402 fib_path_list_unlock(old_path_list);
1403 fib_entry_unlock(fib_entry_get_index(fib_entry));
1405 sflags &= ~FIB_ENTRY_SRC_FLAG_ADDED;
1406 fib_entry_src_action_deinit(fib_entry, source);
1412 * fib_route_attached_cross_table
1414 * Return true the the route is attached via an interface that
1415 * is not in the same table as the route
1418 fib_route_attached_cross_table (const fib_entry_t *fib_entry,
1419 const fib_route_path_t *rpath)
1422 * - All zeros next-hop
1423 * - a valid interface
1424 * - entry's fib index not equeal to interface's index
1426 if (ip46_address_is_zero(&rpath->frp_addr) &&
1427 (~0 != rpath->frp_sw_if_index) &&
1428 !(rpath->frp_flags & FIB_ROUTE_PATH_DVR) &&
1429 (fib_entry->fe_fib_index !=
1430 fib_table_get_index_for_sw_if_index(fib_entry_get_proto(fib_entry),
1431 rpath->frp_sw_if_index)))
1439 * Return true if the path is attached
1442 fib_path_is_attached (const fib_route_path_t *rpath)
1445 * DVR paths are not attached, since we are not playing the
1446 * L3 game with these
1448 if (rpath->frp_flags & FIB_ROUTE_PATH_DVR)
1454 * - All zeros next-hop
1455 * - a valid interface
1457 if (ip46_address_is_zero(&rpath->frp_addr) &&
1458 (~0 != rpath->frp_sw_if_index))
1462 else if (rpath->frp_flags & FIB_ROUTE_PATH_ATTACHED)
1469 fib_path_list_flags_t
1470 fib_entry_src_flags_2_path_list_flags (fib_entry_flag_t eflags)
1472 fib_path_list_flags_t plf = FIB_PATH_LIST_FLAG_NONE;
1474 if (eflags & FIB_ENTRY_FLAG_DROP)
1476 plf |= FIB_PATH_LIST_FLAG_DROP;
1478 if (eflags & FIB_ENTRY_FLAG_EXCLUSIVE)
1480 plf |= FIB_PATH_LIST_FLAG_EXCLUSIVE;
1482 if (eflags & FIB_ENTRY_FLAG_LOCAL)
1484 plf |= FIB_PATH_LIST_FLAG_LOCAL;
1491 fib_entry_flags_update (const fib_entry_t *fib_entry,
1492 const fib_route_path_t *rpath,
1493 fib_path_list_flags_t *pl_flags,
1494 fib_entry_src_t *esrc)
1496 if ((esrc->fes_src == FIB_SOURCE_API) ||
1497 (esrc->fes_src == FIB_SOURCE_CLI))
1499 if (fib_path_is_attached(rpath))
1501 esrc->fes_entry_flags |= FIB_ENTRY_FLAG_ATTACHED;
1505 esrc->fes_entry_flags &= ~FIB_ENTRY_FLAG_ATTACHED;
1507 if (rpath->frp_flags & FIB_ROUTE_PATH_DEAG)
1509 esrc->fes_entry_flags |= FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT;
1512 if (fib_route_attached_cross_table(fib_entry, rpath) &&
1513 !(esrc->fes_entry_flags & FIB_ENTRY_FLAG_NO_ATTACHED_EXPORT))
1515 esrc->fes_entry_flags |= FIB_ENTRY_FLAG_IMPORT;
1519 esrc->fes_entry_flags &= ~FIB_ENTRY_FLAG_IMPORT;
1524 * fib_entry_src_action_add
1526 * Adding a source can result in a new fib_entry being created, which
1527 * can inturn mean the pool is realloc'd and thus the entry passed as
1528 * an argument it also realloc'd
1532 fib_entry_src_action_path_add (fib_entry_t *fib_entry,
1533 fib_source_t source,
1534 fib_entry_flag_t flags,
1535 const fib_route_path_t *rpath)
1537 fib_node_index_t old_path_list, fib_entry_index;
1538 fib_path_list_flags_t pl_flags;
1539 fib_entry_src_t *esrc;
1542 * save variable so we can recover from a fib_entry realloc.
1544 fib_entry_index = fib_entry_get_index(fib_entry);
1546 esrc = fib_entry_src_find(fib_entry, source);
1550 fib_entry_src_action_add(fib_entry,
1554 fib_entry_get_dpo_proto(fib_entry)));
1555 esrc = fib_entry_src_find(fib_entry, source);
1559 * we are no doubt modifying a path-list. If the path-list
1560 * is shared, and hence not modifiable, then the index returned
1561 * will be for a different path-list. This FIB entry to needs
1562 * to maintain its lock appropriately.
1564 old_path_list = esrc->fes_pl;
1566 ASSERT(FIB_ENTRY_SRC_VFT_EXISTS(esrc, fesv_path_add));
1568 pl_flags = fib_entry_src_flags_2_path_list_flags(fib_entry_get_flags_i(fib_entry));
1569 fib_entry_flags_update(fib_entry, rpath, &pl_flags, esrc);
1571 FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_path_add,
1572 (esrc, fib_entry, pl_flags, rpath));
1573 fib_entry = fib_entry_get(fib_entry_index);
1575 fib_path_list_lock(esrc->fes_pl);
1576 fib_path_list_unlock(old_path_list);
1582 * fib_entry_src_action_swap
1584 * The source is providing new paths to replace the old ones.
1585 * Adding a source can result in a new fib_entry being created, which
1586 * can inturn mean the pool is realloc'd and thus the entry passed as
1587 * an argument it also realloc'd
1591 fib_entry_src_action_path_swap (fib_entry_t *fib_entry,
1592 fib_source_t source,
1593 fib_entry_flag_t flags,
1594 const fib_route_path_t *rpaths)
1596 fib_node_index_t old_path_list, fib_entry_index;
1597 fib_path_list_flags_t pl_flags;
1598 const fib_route_path_t *rpath;
1599 fib_entry_src_t *esrc;
1601 esrc = fib_entry_src_find(fib_entry, source);
1604 * save variable so we can recover from a fib_entry realloc.
1606 fib_entry_index = fib_entry_get_index(fib_entry);
1610 fib_entry = fib_entry_src_action_add(fib_entry,
1614 fib_entry_get_dpo_proto(fib_entry)));
1615 esrc = fib_entry_src_find(fib_entry, source);
1619 if (flags != esrc->fes_entry_flags)
1621 FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_flags_change,
1622 (esrc, fib_entry, flags));
1624 esrc->fes_entry_flags = flags;
1628 * swapping paths may create a new path-list (or may use an existing shared)
1629 * but we are certainly getting a different one. This FIB entry to needs
1630 * to maintain its lock appropriately.
1632 old_path_list = esrc->fes_pl;
1634 ASSERT(FIB_ENTRY_SRC_VFT_EXISTS(esrc, fesv_path_swap));
1636 pl_flags = fib_entry_src_flags_2_path_list_flags(flags);
1638 vec_foreach(rpath, rpaths)
1640 fib_entry_flags_update(fib_entry, rpath, &pl_flags, esrc);
1643 FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_path_swap,
1647 fib_entry = fib_entry_get(fib_entry_index);
1649 fib_path_list_lock(esrc->fes_pl);
1650 fib_path_list_unlock(old_path_list);
1655 fib_entry_src_flag_t
1656 fib_entry_src_action_path_remove (fib_entry_t *fib_entry,
1657 fib_source_t source,
1658 const fib_route_path_t *rpath)
1660 fib_path_list_flags_t pl_flags;
1661 fib_node_index_t old_path_list;
1662 fib_entry_src_t *esrc;
1664 esrc = fib_entry_src_find(fib_entry, source);
1666 ASSERT(NULL != esrc);
1667 ASSERT(esrc->fes_flags & FIB_ENTRY_SRC_FLAG_ADDED);
1670 * we no doubt modifying a path-list. If the path-list
1671 * is shared, and hence not modifiable, then the index returned
1672 * will be for a different path-list. This FIB entry to needs
1673 * to maintain its lock appropriately.
1675 old_path_list = esrc->fes_pl;
1677 ASSERT(FIB_ENTRY_SRC_VFT_EXISTS(esrc, fesv_path_remove));
1679 pl_flags = fib_entry_src_flags_2_path_list_flags(fib_entry_get_flags_i(fib_entry));
1680 fib_entry_flags_update(fib_entry, rpath, &pl_flags, esrc);
1682 FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_path_remove,
1683 (esrc, pl_flags, rpath));
1686 * lock the new path-list, unlock the old if it had one
1688 fib_path_list_unlock(old_path_list);
1690 if (FIB_NODE_INDEX_INVALID != esrc->fes_pl) {
1691 fib_path_list_lock(esrc->fes_pl);
1692 return (FIB_ENTRY_SRC_FLAG_ADDED);
1697 * no more paths left from this source
1699 fib_entry_src_action_remove_or_update_inherit(fib_entry, source);
1700 return (FIB_ENTRY_SRC_FLAG_NONE);
1705 fib_entry_src_format (fib_entry_t *fib_entry,
1706 fib_source_t source,
1709 fib_entry_src_t *esrc;
1711 esrc = fib_entry_src_find(fib_entry, source);
1713 FIB_ENTRY_SRC_VFT_INVOKE_AND_RETURN(esrc, fesv_format, (esrc, s));
1719 fib_entry_get_adj_for_source (fib_node_index_t fib_entry_index,
1720 fib_source_t source)
1722 fib_entry_t *fib_entry;
1723 fib_entry_src_t *esrc;
1725 if (FIB_NODE_INDEX_INVALID == fib_entry_index)
1726 return (ADJ_INDEX_INVALID);
1728 fib_entry = fib_entry_get(fib_entry_index);
1729 esrc = fib_entry_src_find(fib_entry, source);
1733 if (FIB_NODE_INDEX_INVALID != esrc->fes_pl)
1735 return (fib_path_list_get_adj(
1737 fib_entry_get_default_chain_type(fib_entry)));
1740 return (ADJ_INDEX_INVALID);
1744 fib_entry_get_dpo_for_source (fib_node_index_t fib_entry_index,
1745 fib_source_t source,
1748 fib_entry_t *fib_entry;
1749 fib_entry_src_t *esrc;
1751 if (FIB_NODE_INDEX_INVALID == fib_entry_index)
1754 fib_entry = fib_entry_get(fib_entry_index);
1755 esrc = fib_entry_src_find(fib_entry, source);
1759 if (FIB_NODE_INDEX_INVALID != esrc->fes_pl)
1761 fib_path_list_contribute_forwarding(
1763 fib_entry_get_default_chain_type(fib_entry),
1764 FIB_PATH_LIST_FWD_FLAG_NONE,
1767 return (dpo_id_is_valid(dpo));
1774 fib_entry_get_resolving_interface_for_source (fib_node_index_t entry_index,
1775 fib_source_t source)
1777 fib_entry_t *fib_entry;
1778 fib_entry_src_t *esrc;
1780 fib_entry = fib_entry_get(entry_index);
1782 esrc = fib_entry_src_find(fib_entry, source);
1786 if (FIB_NODE_INDEX_INVALID != esrc->fes_pl)
1788 return (fib_path_list_get_resolving_interface(esrc->fes_pl));
1795 fib_entry_get_flags_for_source (fib_node_index_t entry_index,
1796 fib_source_t source)
1798 fib_entry_t *fib_entry;
1799 fib_entry_src_t *esrc;
1801 fib_entry = fib_entry_get(entry_index);
1803 esrc = fib_entry_src_find(fib_entry, source);
1807 return (esrc->fes_entry_flags);
1810 return (FIB_ENTRY_FLAG_NONE);
1814 fib_entry_get_flags_i (const fib_entry_t *fib_entry)
1816 fib_entry_flag_t flags;
1819 * the vector of sources is deliberately arranged in priority order
1821 if (0 == vec_len(fib_entry->fe_srcs))
1823 flags = FIB_ENTRY_FLAG_NONE;
1827 fib_entry_src_t *esrc;
1829 esrc = vec_elt_at_index(fib_entry->fe_srcs, 0);
1830 flags = esrc->fes_entry_flags;
1837 fib_entry_set_source_data (fib_node_index_t fib_entry_index,
1838 fib_source_t source,
1841 fib_entry_t *fib_entry;
1842 fib_entry_src_t *esrc;
1844 fib_entry = fib_entry_get(fib_entry_index);
1845 esrc = fib_entry_src_find(fib_entry, source);
1849 FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_set_data,
1850 (esrc, fib_entry, data));
1855 fib_entry_get_source_data (fib_node_index_t fib_entry_index,
1856 fib_source_t source)
1858 fib_entry_t *fib_entry;
1859 fib_entry_src_t *esrc;
1861 fib_entry = fib_entry_get(fib_entry_index);
1862 esrc = fib_entry_src_find(fib_entry, source);
1866 FIB_ENTRY_SRC_VFT_INVOKE_AND_RETURN(esrc, fesv_get_data,
1873 fib_entry_src_module_init (void)
1875 fib_entry_src_rr_register();
1876 fib_entry_src_interface_register();
1877 fib_entry_src_interpose_register();
1878 fib_entry_src_default_route_register();
1879 fib_entry_src_special_register();
1880 fib_entry_src_api_register();
1881 fib_entry_src_adj_register();
1882 fib_entry_src_mpls_register();
1883 fib_entry_src_lisp_register();