FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
fib_entry_src.c
Go to the documentation of this file.
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>
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>
27 
28 /*
29  * per-source type vft
30  */
32 
33 /**
34  * Get the VFT for a given source. This is a combination of the source
35  * enum and the interposer flags
36  */
39 {
41 
43 
45  {
47  }
48 
49  return (&fib_entry_src_bh_vft[bh]);
50 }
51 
52 static void
54  const fib_entry_t *fib_entry,
55  fib_entry_src_t *copy_src)
56 {
57  clib_memcpy(&copy_src->u, &orig_src->u, sizeof(copy_src->u));
58 }
59 
60 void
62  const fib_entry_src_vft_t *vft)
63 {
64  fib_entry_src_bh_vft[bh] = *vft;
65 
66  if (NULL == fib_entry_src_bh_vft[bh].fesv_copy)
67  {
69  }
70 }
71 
72 static int
74  void * v2)
75 {
76  fib_entry_src_t *esrc1 = v1, *esrc2 = v2;
77 
78  return (fib_source_get_prio(esrc1->fes_src) -
79  fib_source_get_prio(esrc2->fes_src));
80 }
81 
82 static void
84  fib_source_t source,
86 {
87  fib_entry_src_t esrc = {
89  .fes_flags = FIB_ENTRY_SRC_FLAG_NONE,
90  .fes_src = source,
91  .fes_entry_flags = flags,
92  };
93 
94  FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, &esrc, fesv_init, (&esrc));
95 
96  vec_add1(fib_entry->fe_srcs, esrc);
99 }
100 
101 static fib_entry_src_t *
103  fib_source_t source,
104  u32 *index)
105 
106 {
107  fib_entry_src_t *esrc;
108  int ii;
109 
110  ii = 0;
111  vec_foreach(esrc, fib_entry->fe_srcs)
112  {
113  if (esrc->fes_src == source)
114  {
115  if (NULL != index)
116  {
117  *index = ii;
118  }
119  return (esrc);
120  }
121  else
122  {
123  ii++;
124  }
125  }
126 
127  return (NULL);
128 }
129 
131 fib_entry_src_find (const fib_entry_t *fib_entry,
132  fib_source_t source)
133 
134 {
135  return (fib_entry_src_find_i(fib_entry, source, NULL));
136 }
137 
138 int
140  fib_source_t source)
141 {
142  fib_entry_t *fib_entry;
143 
144  fib_entry = fib_entry_get(fib_entry_index);
145 
146  return (NULL != fib_entry_src_find(fib_entry, source));
147 }
148 
149 int
151  fib_source_t source)
152 {
153  fib_entry_t *fib_entry;
154  fib_entry_src_t *esrc;
155 
156  fib_entry = fib_entry_get(fib_entry_index);
157 
158  esrc = fib_entry_src_find(fib_entry, source);
159 
160  if (NULL == esrc)
161  {
162  return (0);
163  }
164  else
165  {
166  return (!!(esrc->fes_flags & FIB_ENTRY_SRC_FLAG_STALE));
167  }
168 }
169 
170 void
172  fib_source_t source)
173 {
174  fib_entry_t *fib_entry;
175  fib_entry_src_t *esrc;
176 
177  fib_entry = fib_entry_get(fib_entry_index);
178 
179  esrc = fib_entry_src_find(fib_entry, source);
180 
181  if (NULL != esrc)
182  {
184  }
185 }
186 
187 static fib_entry_src_t *
189  fib_source_t source,
191 {
192  fib_entry_src_t *esrc;
193 
194  esrc = fib_entry_src_find(fib_entry, source);
195 
196  if (NULL == esrc)
197  {
198  fib_entry_src_action_init(fib_entry, source, flags);
199  }
200 
201  return (fib_entry_src_find(fib_entry, source));
202 }
203 
204 static void
206  fib_source_t source)
207 
208 {
209  fib_entry_src_t *esrc;
210  u32 index = ~0;
211 
212  esrc = fib_entry_src_find_i(fib_entry, source, &index);
213 
214  ASSERT(NULL != esrc);
215 
216  FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_deinit, (esrc));
217 
219  vec_del1(fib_entry->fe_srcs, index);
220  vec_sort_with_function(fib_entry->fe_srcs,
222 }
223 
226  fib_entry_src_t *esrc)
227 {
228  FIB_ENTRY_SRC_VFT_INVOKE_AND_RETURN(esrc, fesv_cover_change,
229  (esrc, fib_entry));
230 
232  .install = !0,
233  .bw_reason = FIB_NODE_BW_REASON_FLAG_NONE,
234  };
235  return (res);
236 }
237 
240  fib_entry_src_t *esrc)
241 {
242  FIB_ENTRY_SRC_VFT_INVOKE_AND_RETURN(esrc, fesv_cover_update,
243  (esrc, fib_entry));
244 
246  .install = !0,
247  .bw_reason = FIB_NODE_BW_REASON_FLAG_NONE,
248  };
249  return (res);
250 }
251 
253 {
261 
262 /**
263  * @brief Determine whether this FIB entry should use a load-balance MAP
264  * to support PIC edge fast convergence
265  */
268  const fib_entry_src_t *esrc)
269 {
270  /**
271  * We'll use a LB map if the path-list has multiple recursive paths.
272  * recursive paths implies BGP, and hence scale.
273  */
274  if (ctx->n_recursive_constrained > 1 &&
276  {
278  }
279  return (LOAD_BALANCE_FLAG_NONE);
280 }
281 
282 static int
284 {
285  return ((MPLS_LABEL_IS_REAL(label) ||
286  MPLS_LABEL_POP == label ||
290 }
291 
292 /**
293  * @brief Turn the chain type requested by the client into the one they
294  * really wanted
295  */
299 {
300  /*
301  * The EOS chain is a tricky since one cannot know the adjacency
302  * to link to without knowing what the packets payload protocol
303  * will be once the label is popped.
304  */
306 
307  if (FIB_FORW_CHAIN_TYPE_MPLS_EOS != fct)
308  {
309  return (fct);
310  }
311 
312  dfct = fib_entry_get_default_chain_type(entry);
313 
314  if (FIB_FORW_CHAIN_TYPE_MPLS_EOS == dfct)
315  {
316  /*
317  * If the entry being asked is a eos-MPLS label entry,
318  * then use the payload-protocol field, that we stashed there
319  * for just this purpose
320  */
322  entry->fe_prefix.fp_payload_proto));
323  }
324  /*
325  * else give them what this entry would be by default. i.e. if it's a v6
326  * entry, then the label its local labelled should be carrying v6 traffic.
327  * If it's a non-EOS label entry, then there are more labels and we want
328  * a non-eos chain.
329  */
330  return (dfct);
331 }
332 
333 static dpo_proto_t
335 {
336  switch (pfx->fp_proto)
337  {
338  case FIB_PROTOCOL_IP4:
339  return (DPO_PROTO_IP4);
340  case FIB_PROTOCOL_IP6:
341  return (DPO_PROTO_IP6);
342  case FIB_PROTOCOL_MPLS:
343  return (pfx->fp_payload_proto);
344  }
345 
346  ASSERT(0);
347  return (DPO_PROTO_IP4);
348 }
349 
350 static void
353 {
355 
356  /*
357  * no extension => no out-going label for this path. that's OK
358  * in the case of an IP or EOS chain, but not for non-EOS
359  */
360  switch (ctx->fct)
361  {
367  /*
368  * EOS traffic with no label to stack, we need the IP Adj
369  */
370  vec_add2(ctx->next_hops, nh, 1);
371 
372  nh->path_index = path_index;
373  nh->path_weight = fib_path_get_weight(path_index);
374  fib_path_contribute_forwarding(path_index, ctx->fct, &nh->path_dpo);
375 
376  break;
378  if (fib_path_is_exclusive(path_index) ||
379  fib_path_is_deag(path_index))
380  {
381  vec_add2(ctx->next_hops, nh, 1);
382 
383  nh->path_index = path_index;
384  nh->path_weight = fib_path_get_weight(path_index);
387  &nh->path_dpo);
388  }
389  break;
391  {
392  /*
393  * no label. we need a chain based on the payload. fixup.
394  */
395  vec_add2(ctx->next_hops, nh, 1);
396 
397  nh->path_index = path_index;
398  nh->path_weight = fib_path_get_weight(path_index);
400  fib_entry_chain_type_fixup(ctx->fib_entry,
401  ctx->fct),
402  &nh->path_dpo);
403  fib_path_stack_mpls_disp(path_index,
404  fib_prefix_get_payload_proto(&ctx->fib_entry->fe_prefix),
406  &nh->path_dpo);
407 
408  break;
409  }
412  ASSERT(0);
413  break;
414  }
415 }
416 
419  fib_node_index_t path_index,
420  void *arg)
421 {
423  const fib_entry_src_t *esrc;
424  fib_path_ext_t *path_ext;
425  u32 n_nhs;
426 
427  ctx = arg;
428  n_nhs = vec_len(ctx->next_hops);
429 
430  /*
431  * walk the paths and extension of the best non-interpose source
432  */
433  esrc = &ctx->fib_entry->fe_srcs[ctx->end_source_index];
434 
435  /*
436  * if the path is not resolved, don't include it.
437  */
438  if (!fib_path_is_resolved(path_index))
439  {
441  }
442 
443  if (fib_path_is_recursive_constrained(path_index))
444  {
445  ctx->n_recursive_constrained += 1;
446  }
447  if (0xffff == ctx->preference)
448  {
449  /*
450  * not set a preference yet, so the first path we encounter
451  * sets the preference we are collecting.
452  */
453  ctx->preference = fib_path_get_preference(path_index);
454  }
455  else if (ctx->preference != fib_path_get_preference(path_index))
456  {
457  /*
458  * this path does not belong to the same preference as the
459  * previous paths encountered. we are done now.
460  */
461  return (FIB_PATH_LIST_WALK_STOP);
462  }
463 
464  /*
465  * get the matching path-extension for the path being visited.
466  */
468  path_index);
469 
470  if (NULL != path_ext)
471  {
472  switch (path_ext->fpe_type)
473  {
474  case FIB_PATH_EXT_MPLS:
475  if (fib_entry_src_valid_out_label(path_ext->fpe_label_stack[0].fml_value))
476  {
477  /*
478  * found a matching extension. stack it to obtain the forwarding
479  * info for this path.
480  */
481  ctx->next_hops =
482  fib_path_ext_stack(path_ext,
483  ctx->fct,
484  fib_entry_chain_type_fixup(ctx->fib_entry,
485  ctx->fct),
486  ctx->next_hops);
487  }
488  else
489  {
491  }
492  break;
493  case FIB_PATH_EXT_ADJ:
495  {
497  }
498  /*
499  * else
500  * the path does not refine the cover, meaning that
501  * the adjacency does/does not match the sub-net on the link.
502  * So this path does not contribute forwarding.
503  */
504  break;
505  }
506  }
507  else
508  {
510  }
511 
512  /*
513  * a this point 'ctx' has the DPO the path contributed, plus
514  * any labels from path extensions.
515  * check if there are any interpose sources that want to contribute
516  */
517  if (n_nhs < vec_len(ctx->next_hops))
518  {
519  /*
520  * the path contributed a new choice.
521  */
522  const fib_entry_src_vft_t *vft;
523 
524  /*
525  * roll up the sources that are interposes
526  */
527  i32 index;
528 
529  for (index = ctx->end_source_index;
530  index >= ctx->start_source_index;
531  index--)
532  {
533  const dpo_id_t *interposer;
534 
535  esrc = &ctx->fib_entry->fe_srcs[index];
536  vft = fib_entry_src_get_vft(esrc);
537 
540  continue;
541 
543  interposer = vft->fesv_contribute_interpose(esrc, ctx->fib_entry);
544 
545  if (NULL != interposer)
546  {
547  dpo_id_t clone = DPO_INVALID;
548 
549  dpo_mk_interpose(interposer,
550  &ctx->next_hops[n_nhs].path_dpo,
551  &clone);
552 
553  dpo_copy(&ctx->next_hops[n_nhs].path_dpo, &clone);
554  dpo_reset(&clone);
555  }
556  }
557  }
558 
560 }
561 
562 void
564  fib_source_t source,
566  dpo_id_t *dpo_lb)
567 {
568  const fib_entry_src_t *esrc;
569  dpo_proto_t lb_proto;
570  u32 start, end;
571 
572  /*
573  * The source passed here is the 'best', i.e. the one the client
574  * wants. however, if it's an interpose then it does not contribute
575  * the forwarding, the next best source that is not an interpose does.
576  * So roll down the sources, to find the best non-interpose
577  */
578  vec_foreach_index (start, fib_entry->fe_srcs)
579  {
580  if (source == fib_entry->fe_srcs[start].fes_src)
581  break;
582  }
583  for (end = start; end < vec_len (fib_entry->fe_srcs); end++)
584  {
585  if (!(fib_entry->fe_srcs[end].fes_entry_flags &
587  (fib_entry->fe_srcs[end].fes_flags &
589  break;
590  }
591  if (end == vec_len(fib_entry->fe_srcs))
592  {
593  /* didn't find any contributing non-interpose sources */
594  end = start;
595  }
596 
597  esrc = &fib_entry->fe_srcs[end];
598 
599  /*
600  * If the entry has path extensions then we construct a load-balance
601  * by stacking the extensions on the forwarding chains of the paths.
602  * Otherwise we use the load-balance of the path-list
603  */
605  .fib_entry = fib_entry,
606  .next_hops = NULL,
607  .n_recursive_constrained = 0,
608  .fct = fct,
609  .preference = 0xffff,
610  .start_source_index = start,
611  .end_source_index = end,
612  };
613 
614  /*
615  * As an optimisation we allocate the vector of next-hops to be sized
616  * equal to the maximum number of paths we will need, which is also the
617  * most likely number we will need, since in most cases the paths are 'up'.
618  */
620  vec_reset_length(ctx.next_hops);
621 
622  lb_proto = fib_forw_chain_type_to_dpo_proto(fct);
623 
626  &ctx);
627 
629  {
630  /*
631  * the client provided the DPO that the entry should link to.
632  * all entries must link to a LB, so if it is an LB already
633  * then we can use it.
634  */
635  if ((1 == vec_len(ctx.next_hops)) &&
636  (DPO_LOAD_BALANCE == ctx.next_hops[0].path_dpo.dpoi_type))
637  {
638  dpo_copy(dpo_lb, &ctx.next_hops[0].path_dpo);
639  dpo_reset(&ctx.next_hops[0].path_dpo);
640  return;
641  }
642  }
643 
644  if (!dpo_id_is_valid(dpo_lb))
645  {
646  /*
647  * first time create
648  */
650  {
651  dpo_set(dpo_lb,
653  lb_proto,
654  MPLS_IS_REPLICATE | replicate_create(0, lb_proto));
655  }
656  else
657  {
658  fib_protocol_t flow_hash_proto;
659  flow_hash_config_t fhc;
660 
661  /*
662  * if the protocol for the LB we are building does not match that
663  * of the fib_entry (i.e. we are build the [n]EOS LB for an IPv[46]
664  * then the fib_index is not an index that relates to the table
665  * type we need. So get the default flow-hash config instead.
666  */
667  flow_hash_proto = dpo_proto_to_fib(lb_proto);
668  if (fib_entry->fe_prefix.fp_proto != flow_hash_proto)
669  {
670  fhc = fib_table_get_default_flow_hash_config(flow_hash_proto);
671  }
672  else
673  {
675  flow_hash_proto);
676  }
677 
678  dpo_set(dpo_lb,
680  lb_proto,
681  load_balance_create(0, lb_proto, fhc));
682  }
683  }
684 
686  {
687  /*
688  * MPLS multicast
689  */
690  replicate_multipath_update(dpo_lb, ctx.next_hops);
691  }
692  else
693  {
695  ctx.next_hops,
696  fib_entry_calc_lb_flags(&ctx, esrc));
697  vec_free(ctx.next_hops);
698 
699  /*
700  * if this entry is sourced by the uRPF-exempt source then we
701  * append the always present local0 interface (index 0) to the
702  * uRPF list so it is not empty. that way packets pass the loose check.
703  */
705 
709  (0 == fib_urpf_check_size(ui)))
710  {
711  /*
712  * The uRPF list we get from the path-list is shared by all
713  * other users of the list, but the uRPF exemption applies
714  * only to this prefix. So we need our own list.
715  */
717  fib_urpf_list_append(ui, 0);
718  fib_urpf_list_bake(ui);
719  load_balance_set_urpf(dpo_lb->dpoi_index, ui);
721  }
722  else
723  {
724  load_balance_set_urpf(dpo_lb->dpoi_index, ui);
725  }
727  fib_entry_get_flags_i(fib_entry));
728  }
729 }
730 
731 void
733  fib_source_t source)
734 {
735  /*
736  * Install the forwarding chain for the given source into the forwarding
737  * tables
738  */
740  int insert;
741 
742  fct = fib_entry_get_default_chain_type(fib_entry);
743 
744  /*
745  * Every entry has its own load-balance object. All changes to the entry's
746  * forwarding result in an inplace modify of the load-balance. This means
747  * the load-balance object only needs to be added to the forwarding
748  * DB once, when it is created.
749  */
750  insert = !dpo_id_is_valid(&fib_entry->fe_lb);
751 
752  fib_entry_src_mk_lb(fib_entry, source, fct, &fib_entry->fe_lb);
753 
754  ASSERT(dpo_id_is_valid(&fib_entry->fe_lb));
755  FIB_ENTRY_DBG(fib_entry, "install: %d", fib_entry->fe_lb);
756 
757  /*
758  * insert the adj into the data-plane forwarding trie
759  */
760  if (insert)
761  {
763  &fib_entry->fe_prefix,
764  &fib_entry->fe_lb);
765  }
766 
767  /*
768  * if any of the other chain types are already created they will need
769  * updating too
770  */
773 
774  FOR_EACH_DELEGATE_CHAIN(fib_entry, fdt, fed,
775  {
776  fib_entry_src_mk_lb(fib_entry, source,
778  &fed->fd_dpo);
779  });
780 }
781 
782 void
784 {
785  /*
786  * uninstall the forwarding chain from the forwarding tables
787  */
788  FIB_ENTRY_DBG(fib_entry, "uninstall");
789 
790  if (dpo_id_is_valid(&fib_entry->fe_lb))
791  {
793  fib_entry->fe_fib_index,
794  &fib_entry->fe_prefix,
795  &fib_entry->fe_lb);
796 
797  dpo_reset(&fib_entry->fe_lb);
798  }
799 }
800 
801 static void
803 {
804  fib_node_index_t *entries = NULL;
805 
806  fib_path_list_recursive_loop_detect(path_list_index, &entries);
807 
808  vec_free(entries);
809 }
810 
811 /*
812  * fib_entry_src_action_copy
813  *
814  * copy a source data from another entry to this one
815  */
816 static fib_entry_t *
818  const fib_entry_src_t *orig_src)
819 {
820  fib_entry_src_t *esrc;
821 
822  esrc = fib_entry_src_find_or_create(fib_entry,
823  orig_src->fes_src,
824  orig_src->fes_entry_flags);
825 
826  FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_copy,
827  (orig_src, fib_entry, esrc));
828 
830 
831  /*
832  * copy over all the data ...
833  */
834  esrc->fes_flags = orig_src->fes_flags;
835  esrc->fes_pl = orig_src->fes_pl;
836 
837  /*
838  * ... then update
839  */
840  esrc->fes_ref_count = 1;
845 
846  /*
847  * the source owns a lock on the entry
848  */
849  fib_path_list_lock(esrc->fes_pl);
851 
852  return (fib_entry);
853 }
854 
855 /*
856  * fib_entry_src_action_update
857  *
858  * copy a source data from another entry to this one
859  */
860 static fib_entry_src_t *
862  const fib_entry_src_t *orig_src)
863 {
864  fib_entry_src_t *esrc;
865 
866  esrc = fib_entry_src_find_or_create(fib_entry,
867  orig_src->fes_src,
868  orig_src->fes_entry_flags);
869 
870  /*
871  * the source owns a lock on the entry
872  */
874  esrc->fes_pl = orig_src->fes_pl;
875  fib_path_list_lock(esrc->fes_pl);
876 
877  return (esrc);
878 }
879 
880 static fib_table_walk_rc_t
882  const fib_entry_src_t *cover_src)
883 {
884  fib_entry_src_t *esrc;
885 
886  esrc = fib_entry_src_find(fib_entry, cover_src->fes_src);
887 
888  if (cover_src == esrc)
889  {
890  return (FIB_TABLE_WALK_CONTINUE);
891  }
892 
893  if (NULL != esrc)
894  {
895  /*
896  * the covered entry already has this source.
897  */
899  {
900  /*
901  * the covered source is itself a COVERED_INHERIT, i.e.
902  * it also pushes this source down the sub-tree.
903  * We consider this more specific covered to be the owner
904  * of the sub-tree from this point down.
905  */
907  }
909  {
910  /*
911  * The covered's source data has been inherited, presumably
912  * from this cover, i.e. this is a modify.
913  */
914  esrc = fib_entry_src_action_update_from_cover(fib_entry, cover_src);
915  fib_entry_source_change(fib_entry, esrc->fes_src, esrc->fes_src);
916  }
917  else
918  {
919  /*
920  * The covered's source was not inherited and it is also
921  * not inheriting. Nevertheless, it still owns the sub-tree from
922  * this point down.
923  */
925  }
926  }
927  else
928  {
929  /*
930  * The covered does not have this source - add it.
931  */
932  fib_source_t best_source;
933 
934  best_source = fib_entry_get_best_source(
935  fib_entry_get_index(fib_entry));
936 
937  fib_entry_src_action_copy(fib_entry, cover_src);
938  fib_entry_source_change(fib_entry, best_source, cover_src->fes_src);
939 
940  }
941  return (FIB_TABLE_WALK_CONTINUE);
942 }
943 
944 static fib_table_walk_rc_t
946  void *ctx)
947 {
949 }
950 
951 static fib_table_walk_rc_t
953  void *ctx)
954 {
955  fib_entry_src_t *cover_src, *esrc;
956  fib_entry_t *fib_entry;
957 
958  fib_entry = fib_entry_get(fei);
959 
960  cover_src = ctx;
961  esrc = fib_entry_src_find(fib_entry, cover_src->fes_src);
962 
963  if (cover_src == esrc)
964  {
965  return (FIB_TABLE_WALK_CONTINUE);
966  }
967 
968  if (NULL != esrc)
969  {
970  /*
971  * the covered entry already has this source.
972  */
974  {
975  /*
976  * the covered source is itself a COVERED_INHERIT, i.e.
977  * it also pushes this source down the sub-tree.
978  * We consider this more specific covered to be the owner
979  * of the sub-tree from this point down.
980  */
982  }
984  {
985  /*
986  * The covered's source data has been inherited, presumably
987  * from this cover
988  */
989  fib_entry_src_flag_t remaining;
990 
991  remaining = fib_entry_special_remove(fei, cover_src->fes_src);
992 
993  ASSERT(FIB_ENTRY_SRC_FLAG_ADDED == remaining);
994  }
995  else
996  {
997  /*
998  * The covered's source was not inherited and it is also
999  * not inheriting. Nevertheless, it still owns the sub-tree from
1000  * this point down.
1001  */
1003  }
1004  }
1005  else
1006  {
1007  /*
1008  * The covered does not have this source - that's an error,
1009  * since it should have inherited, but there is nothing we can do
1010  * about it now.
1011  */
1012  }
1013  return (FIB_TABLE_WALK_CONTINUE);
1014 }
1015 
1016 void
1018  fib_entry_t *covered)
1019 {
1020  CLIB_UNUSED(fib_source_t source);
1021  const fib_entry_src_t *src;
1022 
1023  FOR_EACH_SRC_ADDED(cover, src, source,
1024  ({
1025  if ((src->fes_entry_flags & FIB_ENTRY_FLAG_COVERED_INHERIT) ||
1026  (src->fes_flags & FIB_ENTRY_SRC_FLAG_INHERITED))
1027  {
1028  fib_entry_src_covered_inherit_add_i(covered, src);
1029  }
1030  }))
1031 }
1032 
1033 static void
1035  fib_source_t source)
1036 
1037 {
1038  fib_entry_src_t *esrc;
1039 
1040  esrc = fib_entry_src_find(fib_entry, source);
1041 
1043 
1046  {
1048  fib_entry->fe_prefix.fp_proto,
1049  &fib_entry->fe_prefix,
1051  esrc);
1052  }
1053 }
1054 
1055 static void
1057  fib_entry_src_t *esrc)
1058 
1059 {
1061 
1063  {
1065  fib_entry->fe_prefix.fp_proto,
1066  &fib_entry->fe_prefix,
1068  esrc);
1069  }
1070 }
1071 
1072 void
1074  fib_source_t source)
1075 
1076 {
1077  int houston_we_are_go_for_install;
1078  const fib_entry_src_vft_t *vft;
1079  fib_entry_src_t *esrc;
1080 
1081  esrc = fib_entry_src_find(fib_entry, source);
1082 
1085 
1088  vft = fib_entry_src_get_vft(esrc);
1089 
1090  if (NULL != vft->fesv_activate)
1091  {
1092  houston_we_are_go_for_install = vft->fesv_activate(esrc, fib_entry);
1093  }
1094  else
1095  {
1096  /*
1097  * the source is not providing an activate function, we'll assume
1098  * therefore it has no objection to installing the entry
1099  */
1100  houston_we_are_go_for_install = !0;
1101  }
1102 
1103  /*
1104  * link to the path-list provided by the source, and go check
1105  * if that forms any loops in the graph.
1106  */
1107  fib_entry->fe_parent = esrc->fes_pl;
1108  fib_entry->fe_sibling =
1111  fib_entry_get_index(fib_entry));
1112 
1114 
1115  FIB_ENTRY_DBG(fib_entry, "activate: %d",
1116  fib_entry->fe_parent);
1117 
1118  /*
1119  * If this source should push its state to covered prefixs, do that now.
1120  */
1121  fib_entry_src_covered_inherit_add(fib_entry, source);
1122 
1123  if (0 != houston_we_are_go_for_install)
1124  {
1125  fib_entry_src_action_install(fib_entry, source);
1126  }
1127  else
1128  {
1129  fib_entry_src_action_uninstall(fib_entry);
1130  }
1131 }
1132 
1133 void
1135  fib_source_t source)
1136 
1137 {
1138  fib_node_index_t path_list_index;
1139  fib_entry_src_t *esrc;
1140 
1141  esrc = fib_entry_src_find(fib_entry, source);
1142 
1144 
1145  FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_deactivate,
1146  (esrc, fib_entry));
1147 
1150 
1151  FIB_ENTRY_DBG(fib_entry, "deactivate: %d", fib_entry->fe_parent);
1152 
1153  /*
1154  * If this source should pull its state from covered prefixs, do that now.
1155  * If this source also has the INHERITED flag set then it has a cover
1156  * that wants to push down forwarding. We only want the covereds to see
1157  * one update.
1158  */
1159  fib_entry_src_covered_inherit_remove(fib_entry, esrc);
1160 
1161  /*
1162  * un-link from an old path-list. Check for any loops this will clear
1163  */
1164  path_list_index = fib_entry->fe_parent;
1165  fib_entry->fe_parent = FIB_NODE_INDEX_INVALID;
1166 
1167  fib_entry_recursive_loop_detect_i(path_list_index);
1168 
1169  /*
1170  * this will unlock the path-list, so it may be invalid thereafter.
1171  */
1172  fib_path_list_child_remove(path_list_index, fib_entry->fe_sibling);
1173  fib_entry->fe_sibling = FIB_NODE_INDEX_INVALID;
1174 }
1175 
1176 static void
1178  fib_source_t source)
1179 {
1180  fib_entry_src_t *esrc;
1181 
1182  vec_foreach(esrc, fib_entry->fe_srcs)
1183  {
1184  FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_fwd_update,
1185  (esrc, fib_entry, source));
1186  }
1187 }
1188 
1189 void
1191  fib_source_t source)
1192 {
1193  fib_node_index_t path_list_index;
1194  const fib_entry_src_vft_t *vft;
1195  fib_entry_src_t *esrc;
1196  int remain_installed;
1197 
1198  esrc = fib_entry_src_find(fib_entry, source);
1199 
1201 
1202  FIB_ENTRY_DBG(fib_entry, "reactivate: %d to %d",
1203  fib_entry->fe_parent,
1204  esrc->fes_pl);
1205 
1206  /*
1207  * call the source to reactive and get the go/no-go to remain installed
1208  */
1209  vft = fib_entry_src_get_vft(esrc);
1210 
1211  if (NULL != vft->fesv_reactivate)
1212  {
1213  remain_installed = vft->fesv_reactivate(esrc, fib_entry);
1214  }
1215  else
1216  {
1217  remain_installed = 1;
1218  }
1219 
1220  if (fib_entry->fe_parent != esrc->fes_pl)
1221  {
1222  /*
1223  * un-link from an old path-list. Check for any loops this will clear
1224  */
1225  path_list_index = fib_entry->fe_parent;
1226  fib_entry->fe_parent = FIB_NODE_INDEX_INVALID;
1227 
1228  /*
1229  * temporary lock so it doesn't get deleted when this entry is no
1230  * longer a child.
1231  */
1232  fib_path_list_lock(path_list_index);
1233 
1234  /*
1235  * this entry is no longer a child. after unlinking check if any loops
1236  * were broken
1237  */
1238  fib_path_list_child_remove(path_list_index,
1239  fib_entry->fe_sibling);
1240 
1241  fib_entry_recursive_loop_detect_i(path_list_index);
1242 
1243  /*
1244  * link to the path-list provided by the source, and go check
1245  * if that forms any loops in the graph.
1246  */
1247  fib_entry->fe_parent = esrc->fes_pl;
1248  fib_entry->fe_sibling =
1251  fib_entry_get_index(fib_entry));
1252 
1254  fib_path_list_unlock(path_list_index);
1255 
1256  /*
1257  * If this source should push its state to covered prefixs, do that now.
1258  */
1259  fib_entry_src_covered_inherit_add(fib_entry, source);
1260  }
1261 
1262  if (!remain_installed)
1263  {
1264  fib_entry_src_action_uninstall(fib_entry);
1265  }
1266  else
1267  {
1268  fib_entry_src_action_install(fib_entry, source);
1269  }
1270  fib_entry_src_action_fwd_update(fib_entry, source);
1271 }
1272 
1273 fib_entry_t *
1275  fib_source_t source)
1276 {
1277  fib_entry_src_t *esrc;
1278 
1279  esrc = fib_entry_src_find(fib_entry, source);
1280 
1281  FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_installed,
1282  (esrc, fib_entry));
1283 
1284  fib_entry_src_action_fwd_update(fib_entry, source);
1285 
1286  return (fib_entry);
1287 }
1288 
1289 /*
1290  * fib_entry_src_action_add
1291  *
1292  * Adding a source can result in a new fib_entry being created, which
1293  * can inturn mean the pool is realloc'd and thus the entry passed as
1294  * an argument it also realloc'd
1295  * @return the original entry
1296  */
1297 fib_entry_t *
1299  fib_source_t source,
1301  const dpo_id_t *dpo)
1302 {
1303  fib_entry_src_t *esrc;
1304 
1305  esrc = fib_entry_src_find_or_create(fib_entry, source, flags);
1306 
1307  ASSERT(esrc->fes_ref_count < 255);
1308  esrc->fes_ref_count++;
1309 
1310  if (flags != esrc->fes_entry_flags)
1311  {
1312  FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_flags_change,
1313  (esrc, fib_entry, flags));
1314  }
1315  esrc->fes_entry_flags = flags;
1316 
1317  if (1 != esrc->fes_ref_count)
1318  {
1319  /*
1320  * we only want to add the source on the 0->1 transition
1321  */
1322  return (fib_entry);
1323  }
1324 
1325  FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_add,
1326  (esrc,
1327  fib_entry,
1328  flags,
1329  fib_entry_get_dpo_proto(fib_entry),
1330  dpo));
1331 
1333 
1334  fib_path_list_lock(esrc->fes_pl);
1335 
1336  /*
1337  * the source owns a lock on the entry
1338  */
1339  fib_entry_lock(fib_entry_get_index(fib_entry));
1340 
1341  return (fib_entry);
1342 }
1343 
1344 /*
1345  * fib_entry_src_action_update
1346  *
1347  * Adding a source can result in a new fib_entry being created, which
1348  * can inturn mean the pool is realloc'd and thus the entry passed as
1349  * an argument it also realloc'd
1350  * @return the original entry
1351  */
1352 fib_entry_t *
1354  fib_source_t source,
1356  const dpo_id_t *dpo)
1357 {
1358  fib_node_index_t old_path_list_index;
1359  fib_entry_src_t *esrc;
1360 
1361  esrc = fib_entry_src_find_or_create(fib_entry, source, flags);
1362 
1363  if (NULL == esrc)
1364  {
1365  return (fib_entry_src_action_add(fib_entry, source, flags, dpo));
1366  }
1367 
1368  old_path_list_index = esrc->fes_pl;
1369  esrc->fes_entry_flags = flags;
1370 
1371  FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_add,
1372  (esrc,
1373  fib_entry,
1374  flags,
1375  fib_entry_get_dpo_proto(fib_entry),
1376  dpo));
1377 
1379 
1380  fib_path_list_lock(esrc->fes_pl);
1381  fib_path_list_unlock(old_path_list_index);
1382 
1383  return (fib_entry);
1384 }
1385 
1388  fib_source_t source)
1389 {
1390  fib_entry_src_t *esrc;
1391 
1392  esrc = fib_entry_src_find(fib_entry, source);
1393 
1394  if (NULL == esrc)
1395  return (FIB_ENTRY_SRC_FLAG_ACTIVE);
1396 
1399  {
1400  fib_entry_src_t *cover_src;
1401  fib_node_index_t coveri;
1402  fib_entry_t *cover;
1403 
1404  /*
1405  * this source was pushing inherited state, but so is its
1406  * cover. Now that this source is going away, we need to
1407  * pull the covers forwarding and use it to update the covereds.
1408  * Go grab the path-list from the cover, rather than start a walk from
1409  * the cover, so we don't recursively update this entry.
1410  */
1411  coveri = fib_table_get_less_specific(fib_entry->fe_fib_index,
1412  &fib_entry->fe_prefix);
1413 
1414  /*
1415  * only the default route has itself as its own cover, but the
1416  * default route cannot have inherited from something else.
1417  */
1418  ASSERT(coveri != fib_entry_get_index(fib_entry));
1419 
1420  cover = fib_entry_get(coveri);
1421  cover_src = fib_entry_src_find(cover, source);
1422 
1423  ASSERT(NULL != cover_src);
1424 
1425  esrc = fib_entry_src_action_update_from_cover(fib_entry, cover_src);
1427 
1428  /*
1429  * Now push the new state from the cover down to the covereds
1430  */
1431  fib_entry_src_covered_inherit_add(fib_entry, source);
1432 
1433  return (esrc->fes_flags);
1434  }
1435  else
1436  {
1437  return (fib_entry_src_action_remove(fib_entry, source));
1438  }
1439 }
1440 
1443  fib_source_t source)
1444 
1445 {
1446  fib_node_index_t old_path_list;
1447  fib_entry_src_flag_t sflags;
1448  fib_entry_src_t *esrc;
1449 
1450  esrc = fib_entry_src_find(fib_entry, source);
1451 
1452  if (NULL == esrc)
1453  return (FIB_ENTRY_SRC_FLAG_ACTIVE);
1454 
1455  esrc->fes_ref_count--;
1456  sflags = esrc->fes_flags;
1457 
1458  if (0 != esrc->fes_ref_count)
1459  {
1460  /*
1461  * only remove the source on the 1->0 transisition
1462  */
1463  return (sflags);
1464  }
1465 
1467  {
1468  fib_entry_src_action_deactivate(fib_entry, source);
1469  }
1470  else if (esrc->fes_flags & FIB_ENTRY_SRC_FLAG_CONTRIBUTING)
1471  {
1472  FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_deactivate,
1473  (esrc, fib_entry));
1475  }
1476 
1477  old_path_list = esrc->fes_pl;
1478 
1479  FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_remove, (esrc));
1480 
1481  fib_path_list_unlock(old_path_list);
1483 
1484  sflags &= ~FIB_ENTRY_SRC_FLAG_ADDED;
1485  fib_entry_src_action_deinit(fib_entry, source);
1486 
1487  return (sflags);
1488 }
1489 
1490 /*
1491  * fib_route_attached_cross_table
1492  *
1493  * Return true the the route is attached via an interface that
1494  * is not in the same table as the route
1495  */
1496 static inline int
1498  const fib_route_path_t *rpath)
1499 {
1500  const fib_prefix_t *pfx = &fib_entry->fe_prefix;
1501 
1502  switch (pfx->fp_proto)
1503  {
1504  case FIB_PROTOCOL_MPLS:
1505  /* MPLS routes are never imported/exported */
1506  return (0);
1507  case FIB_PROTOCOL_IP6:
1508  /* Ignore link local addresses these also can't be imported/exported */
1510  {
1511  return (!0);
1512  }
1513  break;
1514  case FIB_PROTOCOL_IP4:
1515  break;
1516  }
1517 
1518  /*
1519  * an attached path and entry's fib index not equal to interface's index
1520  */
1521  if (fib_route_path_is_attached(rpath) &&
1522  fib_entry->fe_fib_index !=
1524  rpath->frp_sw_if_index))
1525  {
1526  return (!0);
1527  }
1528  return (0);
1529 }
1530 
1533 {
1535 
1536  if (eflags & FIB_ENTRY_FLAG_DROP)
1537  {
1538  plf |= FIB_PATH_LIST_FLAG_DROP;
1539  }
1540  if (eflags & FIB_ENTRY_FLAG_EXCLUSIVE)
1541  {
1543  }
1544  if (eflags & FIB_ENTRY_FLAG_LOCAL)
1545  {
1546  plf |= FIB_PATH_LIST_FLAG_LOCAL;
1547  }
1548 
1549  return (plf);
1550 }
1551 
1552 static void
1554  const fib_route_path_t *rpaths,
1555  fib_path_list_flags_t *pl_flags,
1556  fib_entry_src_t *esrc)
1557 {
1558  const fib_route_path_t *rpath;
1559 
1560  vec_foreach(rpath, rpaths)
1561  {
1562  if ((esrc->fes_src == FIB_SOURCE_API) ||
1563  (esrc->fes_src == FIB_SOURCE_CLI))
1564  {
1565  if (fib_route_path_is_attached(rpath))
1566  {
1568  }
1569  else
1570  {
1572  }
1573  if (rpath->frp_flags & FIB_ROUTE_PATH_DEAG)
1574  {
1576  }
1577  }
1578  if (fib_route_attached_cross_table(fib_entry, rpath) &&
1580  {
1582  }
1583  else
1584  {
1586  }
1587  }
1588 }
1589 
1590 /*
1591  * fib_entry_src_action_add
1592  *
1593  * Adding a source can result in a new fib_entry being created, which
1594  * can inturn mean the pool is realloc'd and thus the entry passed as
1595  * an argument it also realloc'd
1596  * @return the entry
1597  */
1598 fib_entry_t*
1600  fib_source_t source,
1602  const fib_route_path_t *rpaths)
1603 {
1604  fib_node_index_t old_path_list;
1605  fib_path_list_flags_t pl_flags;
1606  fib_entry_src_t *esrc;
1607 
1608  esrc = fib_entry_src_find(fib_entry, source);
1609  if (NULL == esrc)
1610  {
1611  const dpo_id_t *dpo;
1612 
1614  dpo = &rpaths->dpo;
1615  } else {
1616  dpo = drop_dpo_get(fib_entry_get_dpo_proto(fib_entry));
1617  }
1618 
1619  fib_entry =
1620  fib_entry_src_action_add(fib_entry,
1621  source,
1622  flags,
1623  dpo);
1624  esrc = fib_entry_src_find(fib_entry, source);
1625  }
1626 
1627  /*
1628  * we are no doubt modifying a path-list. If the path-list
1629  * is shared, and hence not modifiable, then the index returned
1630  * will be for a different path-list. This FIB entry to needs
1631  * to maintain its lock appropriately.
1632  */
1633  old_path_list = esrc->fes_pl;
1634 
1635  ASSERT(FIB_ENTRY_SRC_VFT_EXISTS(esrc, fesv_path_add));
1636 
1638  fib_entry_flags_update(fib_entry, rpaths, &pl_flags, esrc);
1639 
1640  FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_path_add,
1641  (esrc, fib_entry, pl_flags, rpaths));
1642 
1643  fib_path_list_lock(esrc->fes_pl);
1644  fib_path_list_unlock(old_path_list);
1645 
1646  return (fib_entry);
1647 }
1648 
1649 /*
1650  * fib_entry_src_action_swap
1651  *
1652  * The source is providing new paths to replace the old ones.
1653  * Adding a source can result in a new fib_entry being created, which
1654  * can inturn mean the pool is realloc'd and thus the entry passed as
1655  * an argument it also realloc'd
1656  * @return the entry
1657  */
1658 fib_entry_t*
1660  fib_source_t source,
1662  const fib_route_path_t *rpaths)
1663 {
1664  fib_node_index_t old_path_list;
1665  fib_path_list_flags_t pl_flags;
1666  fib_entry_src_t *esrc;
1667 
1668  esrc = fib_entry_src_find(fib_entry, source);
1669 
1670  if (NULL == esrc)
1671  {
1672  const dpo_id_t *dpo;
1673 
1675  dpo = &rpaths->dpo;
1676  } else {
1677  dpo = drop_dpo_get(fib_entry_get_dpo_proto(fib_entry));
1678  }
1679 
1680  fib_entry = fib_entry_src_action_add(fib_entry,
1681  source,
1682  flags,
1683  dpo);
1684  esrc = fib_entry_src_find(fib_entry, source);
1685  }
1686  else
1687  {
1688  if (flags != esrc->fes_entry_flags)
1689  {
1690  FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_flags_change,
1691  (esrc, fib_entry, flags));
1692  }
1693  esrc->fes_entry_flags = flags;
1694  }
1695 
1696  /*
1697  * swapping paths may create a new path-list (or may use an existing shared)
1698  * but we are certainly getting a different one. This FIB entry to needs
1699  * to maintain its lock appropriately.
1700  */
1701  old_path_list = esrc->fes_pl;
1702 
1703  ASSERT(FIB_ENTRY_SRC_VFT_EXISTS(esrc, fesv_path_swap));
1704 
1706 
1707  fib_entry_flags_update(fib_entry, rpaths, &pl_flags, esrc);
1708 
1709  FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_path_swap,
1710  (esrc, fib_entry,
1711  pl_flags, rpaths));
1712 
1713  fib_path_list_lock(esrc->fes_pl);
1714  fib_path_list_unlock(old_path_list);
1715 
1716  return (fib_entry);
1717 }
1718 
1721  fib_source_t source,
1722  const fib_route_path_t *rpaths)
1723 {
1724  fib_path_list_flags_t pl_flags;
1725  fib_node_index_t old_path_list;
1726  fib_entry_src_t *esrc;
1727 
1728  esrc = fib_entry_src_find(fib_entry, source);
1729 
1730  ASSERT(NULL != esrc);
1732 
1733  /*
1734  * we no doubt modifying a path-list. If the path-list
1735  * is shared, and hence not modifiable, then the index returned
1736  * will be for a different path-list. This FIB entry to needs
1737  * to maintain its lock appropriately.
1738  */
1739  old_path_list = esrc->fes_pl;
1740 
1741  ASSERT(FIB_ENTRY_SRC_VFT_EXISTS(esrc, fesv_path_remove));
1742 
1744  fib_entry_flags_update(fib_entry, rpaths, &pl_flags, esrc);
1745 
1746  FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_path_remove,
1747  (esrc, pl_flags, rpaths));
1748 
1749  /*
1750  * lock the new path-list, unlock the old if it had one
1751  */
1752  fib_path_list_unlock(old_path_list);
1753 
1754  if (FIB_NODE_INDEX_INVALID != esrc->fes_pl) {
1755  fib_path_list_lock(esrc->fes_pl);
1756  return (FIB_ENTRY_SRC_FLAG_ADDED);
1757  }
1758  else
1759  {
1760  /*
1761  * no more paths left from this source
1762  */
1764  return (FIB_ENTRY_SRC_FLAG_NONE);
1765  }
1766 }
1767 
1768 u8*
1770  fib_source_t source,
1771  u8* s)
1772 {
1773  fib_entry_src_t *esrc;
1774 
1775  esrc = fib_entry_src_find(fib_entry, source);
1776 
1777  FIB_ENTRY_SRC_VFT_INVOKE_AND_RETURN(esrc, fesv_format, (esrc, s));
1778 
1779  return (s);
1780 }
1781 
1784  fib_source_t source)
1785 {
1786  fib_entry_t *fib_entry;
1787  fib_entry_src_t *esrc;
1788 
1789  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
1790  return (ADJ_INDEX_INVALID);
1791 
1792  fib_entry = fib_entry_get(fib_entry_index);
1793  esrc = fib_entry_src_find(fib_entry, source);
1794 
1795  if (NULL != esrc)
1796  {
1797  if (FIB_NODE_INDEX_INVALID != esrc->fes_pl)
1798  {
1799  return (fib_path_list_get_adj(
1800  esrc->fes_pl,
1801  fib_entry_get_default_chain_type(fib_entry)));
1802  }
1803  }
1804  return (ADJ_INDEX_INVALID);
1805 }
1806 
1807 const int
1809  fib_source_t source,
1810  dpo_id_t *dpo)
1811 {
1812  fib_entry_t *fib_entry;
1813  fib_entry_src_t *esrc;
1814 
1815  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
1816  return (0);
1817 
1818  fib_entry = fib_entry_get(fib_entry_index);
1819  esrc = fib_entry_src_find(fib_entry, source);
1820 
1821  if (NULL != esrc)
1822  {
1823  if (FIB_NODE_INDEX_INVALID != esrc->fes_pl)
1824  {
1826  esrc->fes_pl,
1829  dpo);
1830 
1831  return (dpo_id_is_valid(dpo));
1832  }
1833  }
1834  return (0);
1835 }
1836 
1837 u32
1839  fib_source_t source)
1840 {
1841  fib_entry_t *fib_entry;
1842  fib_entry_src_t *esrc;
1843 
1844  fib_entry = fib_entry_get(entry_index);
1845 
1846  esrc = fib_entry_src_find(fib_entry, source);
1847 
1848  if (NULL != esrc)
1849  {
1850  if (FIB_NODE_INDEX_INVALID != esrc->fes_pl)
1851  {
1853  }
1854  }
1855  return (~0);
1856 }
1857 
1860  fib_source_t source)
1861 {
1862  fib_entry_t *fib_entry;
1863  fib_entry_src_t *esrc;
1864 
1865  fib_entry = fib_entry_get(entry_index);
1866 
1867  esrc = fib_entry_src_find(fib_entry, source);
1868 
1869  if (NULL != esrc)
1870  {
1871  return (esrc->fes_entry_flags);
1872  }
1873 
1874  return (FIB_ENTRY_FLAG_NONE);
1875 }
1876 
1879 {
1880  /* the vector of sources is deliberately arranged in priority order */
1881  if (0 == vec_len(fib_entry->fe_srcs))
1882  return (FIB_SOURCE_INVALID);
1883  return (vec_elt(fib_entry->fe_srcs, 0).fes_src);
1884 }
1885 
1888 {
1889  /* the vector of sources is deliberately arranged in priority order */
1890  if (0 == vec_len(fib_entry->fe_srcs))
1891  return (FIB_ENTRY_FLAG_NONE);
1892  return (vec_elt(fib_entry->fe_srcs, 0).fes_entry_flags);
1893 }
1894 
1895 void
1897  fib_source_t source,
1898  const void *data)
1899 {
1900  fib_entry_t *fib_entry;
1901  fib_entry_src_t *esrc;
1902 
1903  fib_entry = fib_entry_get(fib_entry_index);
1904  esrc = fib_entry_src_find(fib_entry, source);
1905 
1906  if (NULL != esrc)
1907  {
1908  FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_set_data,
1909  (esrc, fib_entry, data));
1910  }
1911 }
1912 
1913 const void*
1915  fib_source_t source)
1916 {
1917  fib_entry_t *fib_entry;
1918  fib_entry_src_t *esrc;
1919 
1920  fib_entry = fib_entry_get(fib_entry_index);
1921  esrc = fib_entry_src_find(fib_entry, source);
1922 
1923  if (NULL != esrc)
1924  {
1925  FIB_ENTRY_SRC_VFT_INVOKE_AND_RETURN(esrc, fesv_get_data,
1926  (esrc, fib_entry));
1927  }
1928  return (NULL);
1929 }
1930 
1931 void
1933 {
1943 }
load_balance.h
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
fib_entry_src_collect_forwarding_ctx_t_::fib_entry
const fib_entry_t * fib_entry
Definition: fib_entry_src.c:255
FIB_NODE_TYPE_ENTRY
@ FIB_NODE_TYPE_ENTRY
Definition: fib_node.h:33
fib_entry_unlock
void fib_entry_unlock(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1679
ip6_address_is_link_local_unicast
static uword ip6_address_is_link_local_unicast(const ip6_address_t *a)
Definition: ip6_packet.h:253
fib_entry_src_action_path_swap
fib_entry_t * fib_entry_src_action_path_swap(fib_entry_t *fib_entry, fib_source_t source, fib_entry_flag_t flags, const fib_route_path_t *rpaths)
Definition: fib_entry_src.c:1659
fib_entry_get_adj_for_source
adj_index_t fib_entry_get_adj_for_source(fib_node_index_t fib_entry_index, fib_source_t source)
Definition: fib_entry_src.c:1783
fib_entry_get_flags_i
fib_entry_flag_t fib_entry_get_flags_i(const fib_entry_t *fib_entry)
Definition: fib_entry_src.c:1887
fib_entry_src_t_::u
union fib_entry_src_t_::@292 u
Source specific info.
adj.h
FIB_PATH_LIST_FLAG_DROP
@ FIB_PATH_LIST_FLAG_DROP
Definition: fib_path_list.h:82
fib_entry_mark
void fib_entry_mark(fib_node_index_t fib_entry_index, fib_source_t source)
Definition: fib_entry_src.c:171
fib_entry_src_cover_res_t_
Result from a cover update/change.
Definition: fib_entry_src.h:91
fib_entry_src_action_fwd_update
static void fib_entry_src_action_fwd_update(const fib_entry_t *fib_entry, fib_source_t source)
Definition: fib_entry_src.c:1177
dpo_id_t_::dpoi_index
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:190
DPO_INVALID
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
Definition: dpo.h:204
label
u32 label
Definition: fib_types.api:25
fib_entry_src_mk_lb
void fib_entry_src_mk_lb(fib_entry_t *fib_entry, fib_source_t source, fib_forward_chain_type_t fct, dpo_id_t *dpo_lb)
Definition: fib_entry_src.c:563
fib_entry_is_marked
int fib_entry_is_marked(fib_node_index_t fib_entry_index, fib_source_t source)
Definition: fib_entry_src.c:150
fib_entry_delegate_type_to_chain_type
fib_forward_chain_type_t fib_entry_delegate_type_to_chain_type(fib_entry_delegate_type_t fdt)
Definition: fib_entry_delegate.c:160
fib_path_list_is_popular
int fib_path_list_is_popular(fib_node_index_t path_list_index)
Definition: fib_path_list.c:657
fib_entry_src_action_install
void fib_entry_src_action_install(fib_entry_t *fib_entry, fib_source_t source)
Definition: fib_entry_src.c:732
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
fib_entry_src_covered_inherit_add_i
static fib_table_walk_rc_t fib_entry_src_covered_inherit_add_i(fib_entry_t *fib_entry, const fib_entry_src_t *cover_src)
Definition: fib_entry_src.c:881
FIB_NODE_BW_REASON_FLAG_NONE
@ FIB_NODE_BW_REASON_FLAG_NONE
Definition: fib_node.h:155
fib_entry_t_
An entry in a FIB table.
Definition: fib_entry.h:305
dpo_proto_t
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
ADJ_INDEX_INVALID
#define ADJ_INDEX_INVALID
Invalid ADJ index - used when no adj is known likewise blazoned capitals INVALID speak volumes where ...
Definition: adj_types.h:36
fib_urpf_check_size
static int fib_urpf_check_size(index_t ui)
Data-Plane function to check the size of an uRPF list, (i.e.
Definition: fib_urpf_list.h:137
fib_source_get_behaviour
fib_source_behaviour_t fib_source_get_behaviour(fib_source_t src)
Definition: fib_source.c:58
fib_table_sub_tree_walk
void fib_table_sub_tree_walk(u32 fib_index, fib_protocol_t proto, const fib_prefix_t *root, fib_table_walk_fn_t fn, void *ctx)
Walk all entries in a sub-tree FIB table.
Definition: fib_table.c:1300
fib_entry_src_cmp_for_sort
static int fib_entry_src_cmp_for_sort(void *v1, void *v2)
Definition: fib_entry_src.c:73
fib_table_get_default_flow_hash_config
flow_hash_config_t fib_table_get_default_flow_hash_config(fib_protocol_t proto)
Get the flow hash configured used by the protocol.
Definition: fib_table.c:1030
fib_path_ext_stack
load_balance_path_t * fib_path_ext_stack(fib_path_ext_t *path_ext, fib_forward_chain_type_t child_fct, fib_forward_chain_type_t imp_null_fct, load_balance_path_t *nhs)
Definition: fib_path_ext.c:165
fib_entry_src_collect_forwarding_ctx_t_
Definition: fib_entry_src.c:252
FIB_FORW_CHAIN_TYPE_MPLS_EOS
@ FIB_FORW_CHAIN_TYPE_MPLS_EOS
Contribute an object that is to be used to forward end-of-stack MPLS packets.
Definition: fib_types.h:128
fib_entry_src_get_vft
const fib_entry_src_vft_t * fib_entry_src_get_vft(const fib_entry_src_t *esrc)
Get the VFT for a given source.
Definition: fib_entry_src.c:38
fib_entry_src_adj_register
void fib_entry_src_adj_register(void)
Definition: fib_entry_src_adj.c:426
FIB_ENTRY_SRC_FLAG_ACTIVE
@ FIB_ENTRY_SRC_FLAG_ACTIVE
Definition: fib_entry.h:180
fib_path_list_get_urpf
index_t fib_path_list_get_urpf(fib_node_index_t path_list_index)
Return the the child the RPF list pre-built for this path list.
Definition: fib_path_list.c:449
FIB_ENTRY_SRC_FLAG_STALE
@ FIB_ENTRY_SRC_FLAG_STALE
Definition: fib_entry.h:181
FIB_ENTRY_FLAG_ATTACHED
@ FIB_ENTRY_FLAG_ATTACHED
Definition: fib_entry.h:114
FIB_ENTRY_SRC_VFT_EXISTS
#define FIB_ENTRY_SRC_VFT_EXISTS(esrc, func)
Definition: fib_entry_src.h:251
fib_entry_src_t_
Information related to the source of a FIB entry.
Definition: fib_entry.h:197
fib_entry_src_lisp_register
void fib_entry_src_lisp_register(void)
Definition: fib_entry_src_lisp.c:130
load_balance_create
index_t load_balance_create(u32 n_buckets, dpo_proto_t lb_proto, flow_hash_config_t fhc)
Definition: load_balance.c:266
FIB_NODE_INDEX_INVALID
#define FIB_NODE_INDEX_INVALID
Definition: fib_types.h:30
fib_table.h
fib_path_list_walk_rc_t
enum fib_path_list_walk_rc_t_ fib_path_list_walk_rc_t
return code to control pat-hlist walk
FIB_FORW_CHAIN_TYPE_MCAST_IP4
@ FIB_FORW_CHAIN_TYPE_MCAST_IP4
Contribute an object that is to be used to forward IP4 packets.
Definition: fib_types.h:132
fib_entry_delegate.h
FIB_PATH_LIST_FLAG_LOCAL
@ FIB_PATH_LIST_FLAG_LOCAL
Definition: fib_path_list.h:83
load_balance_set_urpf
void load_balance_set_urpf(index_t lbi, index_t urpf)
Definition: load_balance.c:337
fib_entry_src_action_reactivate
void fib_entry_src_action_reactivate(fib_entry_t *fib_entry, fib_source_t source)
Definition: fib_entry_src.c:1190
u16
unsigned short u16
Definition: types.h:57
MPLS_IETF_IMPLICIT_NULL_LABEL
#define MPLS_IETF_IMPLICIT_NULL_LABEL
Definition: mpls_types.h:30
fib_entry_src_collect_forwarding
static fib_path_list_walk_rc_t fib_entry_src_collect_forwarding(fib_node_index_t pl_index, fib_node_index_t path_index, void *arg)
Definition: fib_entry_src.c:418
entries
u32 entries
Definition: flowhash_template.h:362
fib_entry_t_::fe_parent
fib_node_index_t fe_parent
the path-list for which this entry is a child.
Definition: fib_entry.h:342
FIB_FORW_CHAIN_TYPE_ETHERNET
@ FIB_FORW_CHAIN_TYPE_ETHERNET
Contribute an object that is to be used to forward Ethernet packets.
Definition: fib_types.h:140
fib_route_path_is_attached
int fib_route_path_is_attached(const fib_route_path_t *rpath)
Definition: fib_types.c:760
fib_entry_src_collect_forwarding_ctx_t_::preference
u16 preference
Definition: fib_entry_src.c:259
fib_path_list_get_resolving_interface
u32 fib_path_list_get_resolving_interface(fib_node_index_t path_list_index)
Definition: fib_path_list.c:611
fib_entry_src_action_path_remove
fib_entry_src_flag_t fib_entry_src_action_path_remove(fib_entry_t *fib_entry, fib_source_t source, const fib_route_path_t *rpaths)
Definition: fib_entry_src.c:1720
fib_route_path_t_::frp_sw_if_index
u32 frp_sw_if_index
The interface.
Definition: fib_types.h:545
FIB_ENTRY_SRC_VFT_INVOKE
#define FIB_ENTRY_SRC_VFT_INVOKE(_fe, esrc, func, args)
Definition: fib_entry_src.h:229
fib_entry_src_inherit
void fib_entry_src_inherit(const fib_entry_t *cover, fib_entry_t *covered)
Definition: fib_entry_src.c:1017
fib_path_stack_mpls_disp
void fib_path_stack_mpls_disp(fib_node_index_t path_index, dpo_proto_t payload_proto, fib_mpls_lsp_mode_t mode, dpo_id_t *dpo)
Definition: fib_path.c:2356
FIB_PATH_LIST_FLAG_NONE
@ FIB_PATH_LIST_FLAG_NONE
Definition: fib_path_list.h:80
fib_path_ext_list_flush
void fib_path_ext_list_flush(fib_path_ext_list_t *list)
Definition: fib_path_ext.c:448
FIB_ENTRY_FLAG_EXCLUSIVE
@ FIB_ENTRY_FLAG_EXCLUSIVE
Definition: fib_entry.h:116
fib_entry_src_action_update_from_cover
static fib_entry_src_t * fib_entry_src_action_update_from_cover(fib_entry_t *fib_entry, const fib_entry_src_t *orig_src)
Definition: fib_entry_src.c:861
fib_entry_src_action_remove_or_update_inherit
fib_entry_src_flag_t fib_entry_src_action_remove_or_update_inherit(fib_entry_t *fib_entry, fib_source_t source)
Definition: fib_entry_src.c:1387
FIB_ENTRY_FLAG_INTERPOSE
@ FIB_ENTRY_FLAG_INTERPOSE
Definition: fib_entry.h:123
drop_dpo.h
fib_path_is_recursive_constrained
int fib_path_is_recursive_constrained(fib_node_index_t path_index)
Definition: fib_path.c:2655
replicate_dpo.h
fib_entry_src_vft_t_::fesv_reactivate
fib_entry_src_reactivate_t fesv_reactivate
Definition: fib_entry_src.h:200
load_balance_set_fib_entry_flags
void load_balance_set_fib_entry_flags(index_t lbi, fib_entry_flag_t flags)
Definition: load_balance.c:326
FIB_SOURCE_URPF_EXEMPT
@ FIB_SOURCE_URPF_EXEMPT
uRPF bypass/exemption.
Definition: fib_source.h:127
fib_path_list_get_n_paths
u32 fib_path_list_get_n_paths(fib_node_index_t path_list_index)
Definition: fib_path_list.c:595
FIB_ENTRY_SRC_FLAG_INHERITED
@ FIB_ENTRY_SRC_FLAG_INHERITED
Definition: fib_entry.h:182
fib_entry_src_action_uninstall
void fib_entry_src_action_uninstall(fib_entry_t *fib_entry)
Definition: fib_entry_src.c:783
i32
signed int i32
Definition: types.h:77
fib_entry_src_t_::fes_path_exts
fib_path_ext_list_t fes_path_exts
A vector of path extensions.
Definition: fib_entry.h:201
fib_entry_src_collect_forwarding_ctx_t
struct fib_entry_src_collect_forwarding_ctx_t_ fib_entry_src_collect_forwarding_ctx_t
fib_path_list_flags_t
enum fib_path_list_flags_t_ fib_path_list_flags_t
load_balance_multipath_update
void load_balance_multipath_update(const dpo_id_t *dpo, const load_balance_path_t *raw_nhs, load_balance_flags_t flags)
Definition: load_balance.c:629
fib_entry_src_covered_inherit_add
static void fib_entry_src_covered_inherit_add(fib_entry_t *fib_entry, fib_source_t source)
Definition: fib_entry_src.c:1034
FIB_FORW_CHAIN_TYPE_NSH
@ FIB_FORW_CHAIN_TYPE_NSH
Contribute an object that is to be used to forward NSH packets.
Definition: fib_types.h:146
vec_elt
#define vec_elt(v, i)
Get vector value at index i.
Definition: vec_bootstrap.h:210
FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT
@ FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT
Definition: fib_entry.h:120
fib_table_fwding_dpo_update
void fib_table_fwding_dpo_update(u32 fib_index, const fib_prefix_t *prefix, const dpo_id_t *dpo)
Add or update an entry in the FIB's forwarding table.
Definition: fib_table.c:253
FIB_FORW_CHAIN_TYPE_UNICAST_IP4
@ FIB_FORW_CHAIN_TYPE_UNICAST_IP4
Contribute an object that is to be used to forward IP4 packets.
Definition: fib_types.h:108
fib_path_list_unlock
void fib_path_list_unlock(fib_node_index_t path_list_index)
Definition: fib_path_list.c:1357
fib_path_get_preference
u16 fib_path_get_preference(fib_node_index_t path_index)
Definition: fib_path.c:2252
fib_entry_src.h
fib_entry_t_::fe_sibling
u32 fe_sibling
index of this entry in the parent's child list.
Definition: fib_entry.h:348
fib_entry_src_vft_t_
Virtual function table each FIB entry source will register.
Definition: fib_entry_src.h:195
MPLS_LABEL_POP
#define MPLS_LABEL_POP
A value that is explicit about the end of the LSP.
Definition: mpls_types.h:56
fib_entry_recursive_loop_detect_i
static void fib_entry_recursive_loop_detect_i(fib_node_index_t path_list_index)
Definition: fib_entry_src.c:802
fib_entry_src_find
fib_entry_src_t * fib_entry_src_find(const fib_entry_t *fib_entry, fib_source_t source)
Definition: fib_entry_src.c:131
fib_entry_src_covered_inherit_walk_remove
static fib_table_walk_rc_t fib_entry_src_covered_inherit_walk_remove(fib_node_index_t fei, void *ctx)
Definition: fib_entry_src.c:952
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
fib_entry_flag_t
enum fib_entry_flag_t_ fib_entry_flag_t
FIB_ENTRY_FLAG_MULTICAST
@ FIB_ENTRY_FLAG_MULTICAST
Definition: fib_entry.h:121
fib_entry_set_source_data
void fib_entry_set_source_data(fib_node_index_t fib_entry_index, fib_source_t source, const void *data)
Definition: fib_entry_src.c:1896
fib_entry_calc_lb_flags
static load_balance_flags_t fib_entry_calc_lb_flags(fib_entry_src_collect_forwarding_ctx_t *ctx, const fib_entry_src_t *esrc)
Determine whether this FIB entry should use a load-balance MAP to support PIC edge fast convergence.
Definition: fib_entry_src.c:267
fib_entry_t_::fe_fib_index
u32 fe_fib_index
The index of the FIB table this entry is in.
Definition: fib_entry.h:318
MPLS_IS_REPLICATE
#define MPLS_IS_REPLICATE
The top bit of the index, which is the result of the MPLS lookup is used to determine if the DPO is a...
Definition: mpls_types.h:66
vec_add2
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:644
fib_entry_t_::fe_srcs
fib_entry_src_t * fe_srcs
Vector of source infos.
Definition: fib_entry.h:337
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
fib_path_list_get_adj
adj_index_t fib_path_list_get_adj(fib_node_index_t path_list_index, fib_forward_chain_type_t type)
Definition: fib_path_list.c:1242
FIB_SOURCE_INVALID
@ FIB_SOURCE_INVALID
An invalid source This is not a real source, so don't use it to source a prefix.
Definition: fib_source.h:35
fib_forward_chain_type_t
enum fib_forward_chain_type_t_ fib_forward_chain_type_t
FIB output chain type.
fib_entry_lock
void fib_entry_lock(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1669
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
fib_forw_chain_type_to_dpo_proto
dpo_proto_t fib_forw_chain_type_to_dpo_proto(fib_forward_chain_type_t fct)
Convert from a chain type to the DPO proto it will install.
Definition: fib_types.c:516
fib_entry_src_collect_forwarding_ctx_t_::end_source_index
i32 end_source_index
Definition: fib_entry_src.c:256
fib_entry_get_flags_for_source
fib_entry_flag_t fib_entry_get_flags_for_source(fib_node_index_t entry_index, fib_source_t source)
Definition: fib_entry_src.c:1859
load_balance_flags_t
enum load_balance_flags_t_ load_balance_flags_t
FIB_ENTRY_SRC_FLAG_NONE
@ FIB_ENTRY_SRC_FLAG_NONE
Definition: fib_entry.h:177
FIB_SOURCE_BH_MAX
#define FIB_SOURCE_BH_MAX
Definition: fib_source.h:236
end
f64 end
end of the time range
Definition: mactime.api:44
flow_hash_config_t
enum flow_hash_config_t_ flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
FIB_ENTRY_FLAG_NONE
@ FIB_ENTRY_FLAG_NONE
Definition: fib_entry.h:112
index_t
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:43
fib_source_get_prio
u16 fib_source_get_prio(fib_source_t src)
Definition: fib_source.c:49
fib_entry_src_action_copy
static fib_entry_t * fib_entry_src_action_copy(fib_entry_t *fib_entry, const fib_entry_src_t *orig_src)
Definition: fib_entry_src.c:817
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
vec_foreach_index
#define vec_foreach_index(var, v)
Iterate over vector indices.
Definition: vec_bootstrap.h:220
LOAD_BALANCE_FLAG_NONE
@ LOAD_BALANCE_FLAG_NONE
Definition: load_balance.h:96
fib_entry_get_index
fib_node_index_t fib_entry_get_index(const fib_entry_t *fib_entry)
Definition: fib_entry.c:63
LOAD_BALANCE_FLAG_USES_MAP
@ LOAD_BALANCE_FLAG_USES_MAP
Definition: load_balance.h:97
fib_entry_src_action_add
fib_entry_t * fib_entry_src_action_add(fib_entry_t *fib_entry, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Definition: fib_entry_src.c:1298
fib_entry_src_t_::fes_ref_count
u8 fes_ref_count
1 bytes ref count.
Definition: fib_entry.h:228
dpo_id_is_valid
static int dpo_id_is_valid(const dpo_id_t *dpoi)
Return true if the DPO object is valid, i.e.
Definition: dpo.h:216
fib_entry_get_source_i
fib_source_t fib_entry_get_source_i(const fib_entry_t *fib_entry)
Definition: fib_entry_src.c:1878
fib_path_is_exclusive
int fib_path_is_exclusive(fib_node_index_t path_index)
Definition: fib_path.c:2667
FIB_ROUTE_PATH_DEAG
@ FIB_ROUTE_PATH_DEAG
A path that resolves via another table.
Definition: fib_types.h:389
fib_entry_flags_update
static void fib_entry_flags_update(const fib_entry_t *fib_entry, const fib_route_path_t *rpaths, fib_path_list_flags_t *pl_flags, fib_entry_src_t *esrc)
Definition: fib_entry_src.c:1553
fib_entry_src_action_remove
fib_entry_src_flag_t fib_entry_src_action_remove(fib_entry_t *fib_entry, fib_source_t source)
Definition: fib_entry_src.c:1442
replicate_create
index_t replicate_create(u32 n_buckets, dpo_proto_t rep_proto)
Definition: replicate_dpo.c:192
fib_entry_src_action_activate
void fib_entry_src_action_activate(fib_entry_t *fib_entry, fib_source_t source)
Definition: fib_entry_src.c:1073
fib_entry_src_flag_t
enum fib_entry_src_flag_t_ fib_entry_src_flag_t
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
fib_prefix_t_::fp_payload_proto
dpo_proto_t fp_payload_proto
This protocol determines the payload protocol of packets that will be forwarded by this entry once th...
Definition: fib_types.h:235
fib_prefix_get_payload_proto
static dpo_proto_t fib_prefix_get_payload_proto(const fib_prefix_t *pfx)
Definition: fib_entry_src.c:334
fib_entry_src_valid_out_label
static int fib_entry_src_valid_out_label(mpls_label_t label)
Definition: fib_entry_src.c:283
src
vl_api_address_t src
Definition: gre.api:54
fib_path_contribute_forwarding
void fib_path_contribute_forwarding(fib_node_index_t path_index, fib_forward_chain_type_t fct, dpo_id_t *dpo)
Definition: fib_path.c:2417
nh
vl_api_fib_path_nh_t nh
Definition: fib_types.api:126
fib_path_ext_list_find_by_path_index
fib_path_ext_t * fib_path_ext_list_find_by_path_index(const fib_path_ext_list_t *list, fib_node_index_t path_index)
Definition: fib_path_ext.c:326
FIB_ENTRY_DBG
#define FIB_ENTRY_DBG(_e, _fmt, _args...)
Definition: fib_entry_src.h:28
fib_protocol_t
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
fib_entry_get_resolving_interface_for_source
u32 fib_entry_get_resolving_interface_for_source(fib_node_index_t entry_index, fib_source_t source)
Definition: fib_entry_src.c:1838
fib_entry_src_action_init
static void fib_entry_src_action_init(fib_entry_t *fib_entry, fib_source_t source, fib_entry_flag_t flags)
Definition: fib_entry_src.c:83
n_nhs
u8 n_nhs
Definition: gbp.api:312
fib_source_behaviour_t
enum fib_source_behaviour_t_ fib_source_behaviour_t
Each source has a defined behaviour that controls how entries behave that have that source.
fib_path_list_child_add
u32 fib_path_list_child_add(fib_node_index_t path_list_index, fib_node_type_t child_type, fib_node_index_t child_index)
Definition: fib_path_list.c:1296
FIB_SOURCE_BH_INTERPOSE
@ FIB_SOURCE_BH_INTERPOSE
interpose
Definition: fib_source.h:223
fib_path_list_contribute_forwarding
void fib_path_list_contribute_forwarding(fib_node_index_t path_list_index, fib_forward_chain_type_t fct, fib_path_list_fwd_flags_t flags, dpo_id_t *dpo)
Definition: fib_path_list.c:1211
FIB_ENTRY_FLAG_DROP
@ FIB_ENTRY_FLAG_DROP
Definition: fib_entry.h:115
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
MPLS_IETF_IPV6_EXPLICIT_NULL_LABEL
#define MPLS_IETF_IPV6_EXPLICIT_NULL_LABEL
Definition: mpls_types.h:29
fib_entry_src_action_path_add
fib_entry_t * fib_entry_src_action_path_add(fib_entry_t *fib_entry, fib_source_t source, fib_entry_flag_t flags, const fib_route_path_t *rpaths)
Definition: fib_entry_src.c:1599
FIB_ENTRY_FLAG_LOCAL
@ FIB_ENTRY_FLAG_LOCAL
Definition: fib_entry.h:117
fib_path_is_deag
int fib_path_is_deag(fib_node_index_t path_index)
Definition: fib_path.c:2677
FIB_PATH_LIST_WALK_STOP
@ FIB_PATH_LIST_WALK_STOP
Definition: fib_types.h:637
fib_entry_get_default_chain_type
fib_forward_chain_type_t fib_entry_get_default_chain_type(const fib_entry_t *fib_entry)
Definition: fib_entry.c:81
fib_prefix_t_::fp_addr
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:225
FIB_PATH_LIST_WALK_CONTINUE
@ FIB_PATH_LIST_WALK_CONTINUE
Definition: fib_types.h:638
fib_entry_src_action_installed
fib_entry_t * fib_entry_src_action_installed(fib_entry_t *fib_entry, fib_source_t source)
Definition: fib_entry_src.c:1274
fib_entry_src_format
u8 * fib_entry_src_format(fib_entry_t *fib_entry, fib_source_t source, u8 *s)
Definition: fib_entry_src.c:1769
FIB_TABLE_WALK_SUB_TREE_STOP
@ FIB_TABLE_WALK_SUB_TREE_STOP
Do no traverse down this sub-tree.
Definition: fib_table.h:920
data
u8 data[128]
Definition: ipsec_types.api:95
fib_table_get_flow_hash_config
flow_hash_config_t fib_table_get_flow_hash_config(u32 fib_index, fib_protocol_t proto)
Get the flow hash configured used by the table.
Definition: fib_table.c:1019
fib_entry_delegate_type_t
enum fib_entry_delegate_type_t_ fib_entry_delegate_type_t
Delegate types.
DPO_LOAD_BALANCE
@ DPO_LOAD_BALANCE
load-balancing over a choice of [un]equal cost paths
Definition: dpo.h:104
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
FIB_PATH_EXT_MPLS
@ FIB_PATH_EXT_MPLS
An MPLS extension that maintains the path's outgoing labels,.
Definition: fib_path_ext.h:31
index
u32 index
Definition: flow_types.api:221
fib_entry_src_simple_register
void fib_entry_src_simple_register(void)
Definition: fib_entry_src_simple.c:74
dpo_copy
void dpo_copy(dpo_id_t *dst, const dpo_id_t *src)
atomic copy a data-plane object.
Definition: dpo.c:264
fib_entry_src_action_deinit
static void fib_entry_src_action_deinit(fib_entry_t *fib_entry, fib_source_t source)
Definition: fib_entry_src.c:205
FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS
@ FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS
Contribute an object that is to be used to forward non-end-of-stack MPLS packets.
Definition: fib_types.h:117
fib_entry_src_covered_inherit_remove
static void fib_entry_src_covered_inherit_remove(fib_entry_t *fib_entry, fib_entry_src_t *esrc)
Definition: fib_entry_src.c:1056
fib_route_path_t_::frp_flags
fib_route_path_flags_t frp_flags
flags on the path
Definition: fib_types.h:609
FIB_ENTRY_FLAG_COVERED_INHERIT
@ FIB_ENTRY_FLAG_COVERED_INHERIT
Definition: fib_entry.h:122
fib_path_ext_t_::fpe_type
fib_path_ext_type_t fpe_type
The type of path extension.
Definition: fib_path_ext.h:126
fib_entry_get
fib_entry_t * fib_entry_get(fib_node_index_t index)
Definition: fib_entry.c:51
dpo_proto_to_fib
fib_protocol_t dpo_proto_to_fib(dpo_proto_t dpo_proto)
Definition: fib_types.c:359
fib_entry_src_action_update
fib_entry_t * fib_entry_src_action_update(fib_entry_t *fib_entry, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Definition: fib_entry_src.c:1353
fib_entry_src_action_deactivate
void fib_entry_src_action_deactivate(fib_entry_t *fib_entry, fib_source_t source)
Definition: fib_entry_src.c:1134
fib_entry_src_action_cover_change
fib_entry_src_cover_res_t fib_entry_src_action_cover_change(fib_entry_t *fib_entry, fib_entry_src_t *esrc)
Definition: fib_entry_src.c:225
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
fib_path_list_walk
void fib_path_list_walk(fib_node_index_t path_list_index, fib_path_list_walk_fn_t func, void *ctx)
Definition: fib_path_list.c:1382
mpls_label_dpo.h
fib_route_path_t_::dpo
dpo_id_t dpo
Exclusive DPO.
Definition: fib_types.h:564
FIB_PROTOCOL_MPLS
@ FIB_PROTOCOL_MPLS
Definition: fib_types.h:38
fib_table_get_index_for_sw_if_index
u32 fib_table_get_index_for_sw_if_index(fib_protocol_t proto, u32 sw_if_index)
Get the index of the FIB bound to the interface.
Definition: fib_table.c:1003
DPO_PROTO_IP6
@ DPO_PROTO_IP6
Definition: dpo.h:65
fib_urpf_list_append
void fib_urpf_list_append(index_t ui, u32 sw_if_index)
Append another interface to the list.
Definition: fib_urpf_list.c:100
fib_entry_is_sourced
int fib_entry_is_sourced(fib_node_index_t fib_entry_index, fib_source_t source)
Definition: fib_entry_src.c:139
fib_entry_t_::fe_lb
dpo_id_t fe_lb
The load-balance used for forwarding.
Definition: fib_entry.h:331
fib_forw_chain_type_from_dpo_proto
fib_forward_chain_type_t fib_forw_chain_type_from_dpo_proto(dpo_proto_t proto)
Convert from a payload-protocol to a chain type.
Definition: fib_types.c:427
u32
unsigned int u32
Definition: types.h:88
FOR_EACH_SRC_ADDED
#define FOR_EACH_SRC_ADDED(_entry, _src, _source, action)
Definition: fib_entry_src.h:218
fib_urpf_list.h
fib_entry_src_t_::fes_src
fib_source_t fes_src
Which source this info block is for.
Definition: fib_entry.h:216
fib_entry_src_covered_inherit_walk_add
static fib_table_walk_rc_t fib_entry_src_covered_inherit_walk_add(fib_node_index_t fei, void *ctx)
Definition: fib_entry_src.c:945
fib_table_walk_rc_t
enum fib_table_walk_rc_t_ fib_table_walk_rc_t
return code controlling how a table walk proceeds
fib_entry_src_rr_register
void fib_entry_src_rr_register(void)
Definition: fib_entry_src_rr.c:318
FIB_PROTOCOL_IP6
@ FIB_PROTOCOL_IP6
Definition: fib_types.h:37
fib_route_path_t_
A representation of a path as described by a route producer.
Definition: fib_types.h:500
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
fib_path_is_resolved
int fib_path_is_resolved(fib_node_index_t path_index)
Definition: fib_path.c:2687
FIB_SOURCE_CLI
@ FIB_SOURCE_CLI
From the CLI.
Definition: fib_source.h:79
fib_entry_src_collect_forwarding_ctx_t_::n_recursive_constrained
int n_recursive_constrained
Definition: fib_entry_src.c:258
FIB_SOURCE_API
@ FIB_SOURCE_API
From the control plane API.
Definition: fib_source.h:75
fib_entry_source_change
void fib_entry_source_change(fib_entry_t *fib_entry, fib_source_t old_source, fib_source_t new_source)
Definition: fib_entry.c:861
FIB_FORW_CHAIN_TYPE_BIER
@ FIB_FORW_CHAIN_TYPE_BIER
Contribute an object that is to be used to forward BIER packets.
Definition: fib_types.h:121
fib_route_attached_cross_table
static int fib_route_attached_cross_table(const fib_entry_t *fib_entry, const fib_route_path_t *rpath)
Definition: fib_entry_src.c:1497
fib_prefix_t_::fp_proto
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:211
fib_entry_get_dpo_for_source
const int fib_entry_get_dpo_for_source(fib_node_index_t fib_entry_index, fib_source_t source, dpo_id_t *dpo)
Definition: fib_entry_src.c:1808
fib_path_list_child_remove
void fib_path_list_child_remove(fib_node_index_t path_list_index, u32 si)
Definition: fib_path_list.c:1335
FIB_FORW_CHAIN_TYPE_MCAST_IP6
@ FIB_FORW_CHAIN_TYPE_MCAST_IP6
Contribute an object that is to be used to forward IP6 packets.
Definition: fib_types.h:136
fib_entry_src_interpose_register
void fib_entry_src_interpose_register(void)
Definition: fib_entry_src_interpose.c:381
vec_sort_with_function
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:1097
fib_entry_src_module_init
void fib_entry_src_module_init(void)
Definition: fib_entry_src.c:1932
fib_entry_get_source_data
const void * fib_entry_get_source_data(fib_node_index_t fib_entry_index, fib_source_t source)
Definition: fib_entry_src.c:1914
fib_entry_get_dpo_proto
dpo_proto_t fib_entry_get_dpo_proto(const fib_entry_t *fib_entry)
Definition: fib_entry.c:75
adj_index_t
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
FIB_TABLE_WALK_CONTINUE
@ FIB_TABLE_WALK_CONTINUE
Continue on to the next entry.
Definition: fib_table.h:916
fib_path_list_lock
void fib_path_list_lock(fib_node_index_t path_list_index)
Definition: fib_path_list.c:1344
drop_dpo_get
const dpo_id_t * drop_dpo_get(dpo_proto_t proto)
Definition: drop_dpo.c:25
fib_entry_t_::fe_prefix
const fib_prefix_t fe_prefix
The prefix of the route.
Definition: fib_entry.h:314
u8
unsigned char u8
Definition: types.h:56
fib_urpf_list_alloc_and_lock
index_t fib_urpf_list_alloc_and_lock(void)
Definition: fib_urpf_list.c:55
FIB_PATH_EXT_ADJ_FLAG_REFINES_COVER
@ FIB_PATH_EXT_ADJ_FLAG_REFINES_COVER
Definition: fib_path_ext.h:50
fib_entry_src_t_::fes_entry_flags
fib_entry_flag_t fes_entry_flags
Flags the source contributes to the entry.
Definition: fib_entry.h:211
fib_path_ext_t_::fpe_adj_flags
fib_path_ext_adj_flags_t fpe_adj_flags
For an ADJ type extension.
Definition: fib_path_ext.h:114
fib_entry_src_action_cover_update
fib_entry_src_cover_res_t fib_entry_src_action_cover_update(fib_entry_t *fib_entry, fib_entry_src_t *esrc)
Definition: fib_entry_src.c:239
fib_path_ext_t_
A path extension is a per-entry addition to the forwarding information when packets are sent for that...
Definition: fib_path_ext.h:98
MPLS_IETF_IPV4_EXPLICIT_NULL_LABEL
#define MPLS_IETF_IPV4_EXPLICIT_NULL_LABEL
Definition: mpls_types.h:27
fib_entry_src_t_::fes_flags
fib_entry_src_flag_t fes_flags
Flags on the source.
Definition: fib_entry.h:221
fib_entry_src_vft_t_::fesv_activate
fib_entry_src_activate_t fesv_activate
Definition: fib_entry_src.h:198
FIB_PATH_LIST_FWD_FLAG_NONE
@ FIB_PATH_LIST_FWD_FLAG_NONE
Definition: fib_path_list.h:142
DPO_PROTO_IP4
@ DPO_PROTO_IP4
Definition: dpo.h:64
fib_entry_src_copy_default
static void fib_entry_src_copy_default(const fib_entry_src_t *orig_src, const fib_entry_t *fib_entry, fib_entry_src_t *copy_src)
Definition: fib_entry_src.c:53
fib_table_get_less_specific
fib_node_index_t fib_table_get_less_specific(u32 fib_index, const fib_prefix_t *prefix)
Get the less specific (covering) prefix.
Definition: fib_table.c:133
fib_entry_src_find_or_create
static fib_entry_src_t * fib_entry_src_find_or_create(fib_entry_t *fib_entry, fib_source_t source, fib_entry_flag_t flags)
Definition: fib_entry_src.c:188
fib_entry_src_vft_t_::fesv_copy
fib_entry_src_copy_t fesv_copy
Definition: fib_entry_src.h:215
MPLS_LABEL_IS_REAL
#define MPLS_LABEL_IS_REAL(_lbl)
Definition: mpls_types.h:58
fib_entry_special_remove
fib_entry_src_flag_t fib_entry_special_remove(fib_node_index_t fib_entry_index, fib_source_t source)
Definition: fib_entry.c:1099
dpo_id_t_
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:172
fib_source_t
enum fib_source_t_ fib_source_t
The different sources that can create a route.
mpls_label_t
u32 mpls_label_t
A label value only, i.e.
Definition: packet.h:26
fib_entry_src_api_register
void fib_entry_src_api_register(void)
Definition: fib_entry_src_api.c:163
fib_entry_src_behaviour_register
void fib_entry_src_behaviour_register(fib_source_behaviour_t bh, const fib_entry_src_vft_t *vft)
Definition: fib_entry_src.c:61
dpo_mk_interpose
void dpo_mk_interpose(const dpo_id_t *original, const dpo_id_t *parent, dpo_id_t *clone)
Make an interpose DPO from an original.
Definition: dpo.c:360
fib_table_fwding_dpo_remove
void fib_table_fwding_dpo_remove(u32 fib_index, const fib_prefix_t *prefix, const dpo_id_t *dpo)
remove an entry in the FIB's forwarding table
Definition: fib_table.c:280
FIB_PATH_LIST_FLAG_EXCLUSIVE
@ FIB_PATH_LIST_FLAG_EXCLUSIVE
Definition: fib_path_list.h:84
FIB_ENTRY_SRC_FLAG_ADDED
@ FIB_ENTRY_SRC_FLAG_ADDED
Definition: fib_entry.h:178
fib_path_ext.h
FIB_FORW_CHAIN_TYPE_UNICAST_IP6
@ FIB_FORW_CHAIN_TYPE_UNICAST_IP6
Contribute an object that is to be used to forward IP6 packets.
Definition: fib_types.h:112
dpo_set
void dpo_set(dpo_id_t *dpo, dpo_type_t type, dpo_proto_t proto, index_t index)
Set/create a DPO ID The DPO will be locked.
Definition: dpo.c:188
fib_urpf_list_bake
void fib_urpf_list_bake(index_t ui)
Convert the uRPF list from the itf set obtained during the walk to a unique list.
Definition: fib_urpf_list.c:144
fib_entry_delegate_t_
A Delagate is a means to implmenet the Delagation design pattern; the extension of an objects functio...
Definition: fib_entry_delegate.h:99
fib_entry_src_cover_res_t_::install
u16 install
Definition: fib_entry_src.h:92
fib_entry_src_collect_forwarding_ctx_t_::start_source_index
i32 start_source_index
Definition: fib_entry_src.c:256
FIB_MPLS_LSP_MODE_PIPE
@ FIB_MPLS_LSP_MODE_PIPE
Pipe Mode - the default.
Definition: fib_types.h:434
fib_path_get_weight
u16 fib_path_get_weight(fib_node_index_t path_index)
Definition: fib_path.c:2240
fib_entry_src_drop_register
void fib_entry_src_drop_register(void)
Definition: fib_entry_src_drop.c:53
FIB_PATH_EXT_ADJ
@ FIB_PATH_EXT_ADJ
A adj-source extension indicating the path's refinement criteria result.
Definition: fib_path_ext.h:36
fib_entry_get_proto
fib_protocol_t fib_entry_get_proto(const fib_entry_t *fib_entry)
Definition: fib_entry.c:69
fib_entry_src_t_::fes_pl
fib_node_index_t fes_pl
The path-list created by the source.
Definition: fib_entry.h:206
load_balance_path_t_
One path from an [EU]CMP set that the client wants to add to a load-balance object.
Definition: load_balance.h:62
replicate_multipath_update
void replicate_multipath_update(const dpo_id_t *dpo, load_balance_path_t *next_hops)
Definition: replicate_dpo.c:318
fib_entry_chain_type_fixup
fib_forward_chain_type_t fib_entry_chain_type_fixup(const fib_entry_t *entry, fib_forward_chain_type_t fct)
Turn the chain type requested by the client into the one they really wanted.
Definition: fib_entry_src.c:297
fib_entry_src_flags_2_path_list_flags
fib_path_list_flags_t fib_entry_src_flags_2_path_list_flags(fib_entry_flag_t eflags)
Definition: fib_entry_src.c:1532
dpo_reset
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
Definition: dpo.c:234
fib_entry_src_interface_register
void fib_entry_src_interface_register(void)
Definition: fib_entry_src_interface.c:256
fib_entry_src_mpls_register
void fib_entry_src_mpls_register(void)
Definition: fib_entry_src_mpls.c:194
fib_entry_src_collect_forwarding_ctx_t_::fct
fib_forward_chain_type_t fct
Definition: fib_entry_src.c:257
fib_prefix_t_
Aggregate type for a prefix.
Definition: fib_types.h:202
fib_path_list_recursive_loop_detect
int fib_path_list_recursive_loop_detect(fib_node_index_t path_list_index, fib_node_index_t **entry_indicies)
Definition: fib_path_list.c:1252
fib_urpf_list_unlock
void fib_urpf_list_unlock(index_t ui)
Definition: fib_urpf_list.c:68
fib_entry_get_best_source
fib_source_t fib_entry_get_best_source(fib_node_index_t entry_index)
Definition: fib_entry.c:1505
FOR_EACH_DELEGATE_CHAIN
#define FOR_EACH_DELEGATE_CHAIN(_entry, _fdt, _fed, _body)
Definition: fib_entry_delegate.h:61
fib_entry_delegate_t_::fd_dpo
dpo_id_t fd_dpo
Valid for the forwarding chain delegates.
Definition: fib_entry_delegate.h:123
FIB_ENTRY_SRC_FLAG_CONTRIBUTING
@ FIB_ENTRY_SRC_FLAG_CONTRIBUTING
Definition: fib_entry.h:179
vec_del1
#define vec_del1(v, i)
Delete the element at index I.
Definition: vec.h:896
fib_entry_src_collect_forwarding_ctx_t_::next_hops
load_balance_path_t * next_hops
Definition: fib_entry_src.c:254
fib_entry_src_get_path_forwarding
static void fib_entry_src_get_path_forwarding(fib_node_index_t path_index, fib_entry_src_collect_forwarding_ctx_t *ctx)
Definition: fib_entry_src.c:351
FIB_ENTRY_SRC_VFT_INVOKE_AND_RETURN
#define FIB_ENTRY_SRC_VFT_INVOKE_AND_RETURN(esrc, func, args)
Definition: fib_entry_src.h:241
fib_entry_src_vft_t_::fesv_contribute_interpose
fib_entry_src_contribute_interpose_t fesv_contribute_interpose
Definition: fib_entry_src.h:213
fib_entry_src_find_i
static fib_entry_src_t * fib_entry_src_find_i(const fib_entry_t *fib_entry, fib_source_t source, u32 *index)
Definition: fib_entry_src.c:102
FIB_ENTRY_FLAG_IMPORT
@ FIB_ENTRY_FLAG_IMPORT
Definition: fib_entry.h:118
DPO_REPLICATE
@ DPO_REPLICATE
Definition: dpo.h:105
fib_entry_src_bh_vft
static fib_entry_src_vft_t fib_entry_src_bh_vft[FIB_SOURCE_BH_MAX]
Definition: fib_entry_src.c:31
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105
FIB_ENTRY_FLAG_NO_ATTACHED_EXPORT
@ FIB_ENTRY_FLAG_NO_ATTACHED_EXPORT
Definition: fib_entry.h:119