FD.io VPP  v17.01.1-3-gc6833f8
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 
21 #include <vnet/fib/fib_entry_src.h>
22 #include <vnet/fib/fib_table.h>
23 #include <vnet/fib/fib_path_ext.h>
24 #include <vnet/fib/fib_urpf_list.h>
25 
26 /*
27  * per-source type vft
28  */
29 static fib_entry_src_vft_t fib_entry_src_vft[FIB_SOURCE_MAX];
30 
31 static fib_protocol_t
32 fib_entry_get_proto (const fib_entry_t * fib_entry)
33 {
34  return (fib_entry->fe_prefix.fp_proto);
35 }
36 
37 void
39  const fib_entry_src_vft_t *vft)
40 {
41  fib_entry_src_vft[source] = *vft;
42 }
43 
44 static int
46  void * v2)
47 {
48  fib_entry_src_t *esrc1 = v1, *esrc2 = v2;
49 
50  return (esrc1->fes_src - esrc2->fes_src);
51 }
52 
53 void
55  fib_source_t source)
56 
57 {
58  fib_entry_src_t esrc = {
60  .fes_flags = FIB_ENTRY_SRC_FLAG_NONE,
61  .fes_src = source,
62  };
63 
64  if (NULL != fib_entry_src_vft[source].fesv_init)
65  {
66  fib_entry_src_vft[source].fesv_init(&esrc);
67  }
68 
69  vec_add1(fib_entry->fe_srcs, esrc);
72 }
73 
74 static fib_entry_src_t *
75 fib_entry_src_find (const fib_entry_t *fib_entry,
76  fib_source_t source,
77  u32 *index)
78 
79 {
80  fib_entry_src_t *esrc;
81  int ii;
82 
83  ii = 0;
84  vec_foreach(esrc, fib_entry->fe_srcs)
85  {
86  if (esrc->fes_src == source)
87  {
88  if (NULL != index)
89  {
90  *index = ii;
91  }
92  return (esrc);
93  }
94  else
95  {
96  ii++;
97  }
98  }
99 
100  return (NULL);
101 }
102 
103 int
105  fib_source_t source)
106 {
107  fib_entry_t *fib_entry;
108 
109  fib_entry = fib_entry_get(fib_entry_index);
110 
111  return (NULL != fib_entry_src_find(fib_entry, source, NULL));
112 }
113 
114 static fib_entry_src_t *
116  fib_source_t source,
117  u32 *index)
118 {
119  fib_entry_src_t *esrc;
120 
121  esrc = fib_entry_src_find(fib_entry, source, NULL);
122 
123  if (NULL == esrc)
124  {
125  fib_entry_src_action_init(fib_entry, source);
126  }
127 
128  return (fib_entry_src_find(fib_entry, source, NULL));
129 }
130 
131 void
133  fib_source_t source)
134 
135 {
136  fib_entry_src_t *esrc;
137  u32 index = ~0;
138 
139  esrc = fib_entry_src_find(fib_entry, source, &index);
140 
141  ASSERT(NULL != esrc);
142 
143  if (NULL != fib_entry_src_vft[source].fesv_deinit)
144  {
145  fib_entry_src_vft[source].fesv_deinit(esrc);
146  }
147 
148  vec_free(esrc->fes_path_exts);
149  vec_del1(fib_entry->fe_srcs, index);
150 }
151 
154  fib_source_t source)
155 {
156  if (NULL != fib_entry_src_vft[source].fesv_cover_change)
157  {
158  return (fib_entry_src_vft[source].fesv_cover_change(
159  fib_entry_src_find(fib_entry, source, NULL),
160  fib_entry));
161  }
162 
164  .install = !0,
165  .bw_reason = FIB_NODE_BW_REASON_FLAG_NONE,
166  };
167  return (res);
168 }
169 
172  fib_source_t source)
173 {
174  if (NULL != fib_entry_src_vft[source].fesv_cover_update)
175  {
176  return (fib_entry_src_vft[source].fesv_cover_update(
177  fib_entry_src_find(fib_entry, source, NULL),
178  fib_entry));
179  }
180 
182  .install = !0,
183  .bw_reason = FIB_NODE_BW_REASON_FLAG_NONE,
184  };
185  return (res);
186 }
187 
189 {
196 
197 /**
198  * @brief Determine whether this FIB entry should use a load-balance MAP
199  * to support PIC edge fast convergence
200  */
203 {
204  /**
205  * We'll use a LB map is the path-list has recursive paths.
206  * recursive paths implies BGP, and hence scale.
207  */
208  if (ctx->is_recursive)
209  {
211  }
212  return (LOAD_BALANCE_FLAG_NONE);
213 }
214 
215 static int
217 {
218  return ((MPLS_LABEL_IS_REAL(label) ||
222 }
223 
224 /**
225  * @brief Turn the chain type requested by the client into the one they
226  * really wanted
227  */
231 {
233 
234  /*
235  * The EOS chain is a tricky since one cannot know the adjacency
236  * to link to without knowing what the packets payload protocol
237  * will be once the label is popped.
238  */
240 
241  dfct = fib_entry_get_default_chain_type(entry);
242 
243  if (FIB_FORW_CHAIN_TYPE_MPLS_EOS == dfct)
244  {
245  /*
246  * If the entry being asked is a eos-MPLS label entry,
247  * then use the payload-protocol field, that we stashed there
248  * for just this purpose
249  */
251  entry->fe_prefix.fp_payload_proto));
252  }
253  /*
254  * else give them what this entry would be by default. i.e. if it's a v6
255  * entry, then the label its local labelled should be carrying v6 traffic.
256  * If it's a non-EOS label entry, then there are more labels and we want
257  * a non-eos chain.
258  */
259  return (dfct);
260 }
261 
262 static int
264  fib_node_index_t path_index,
265  void *arg)
266 {
268  fib_path_ext_t *path_ext;
269 
270  ctx = arg;
271 
272  /*
273  * if the path is not resolved, don't include it.
274  */
275  if (!fib_path_is_resolved(path_index))
276  {
277  return (!0);
278  }
279 
280  if (fib_path_is_recursive(path_index))
281  {
282  ctx->is_recursive = 1;
283  }
284 
285  /*
286  * get the matching path-extension for the path being visited.
287  */
288  vec_foreach(path_ext, ctx->esrc->fes_path_exts)
289  {
290  if (path_ext->fpe_path_index == path_index)
291  break;
292  }
293 
294  if (NULL != path_ext &&
295  path_ext->fpe_path_index == path_index &&
296  fib_entry_src_valid_out_label(path_ext->fpe_label_stack[0]))
297  {
298  /*
299  * found a matching extension. stack it to obtain the forwarding
300  * info for this path.
301  */
302  ctx->next_hops = fib_path_ext_stack(path_ext, ctx->fib_entry, ctx->fct, ctx->next_hops);
303  }
304  else
305  {
307 
308  /*
309  * no extension => no out-going label for this path. that's OK
310  * in the case of an IP or EOS chain, but not for non-EOS
311  */
312  switch (ctx->fct)
313  {
316  /*
317  * EOS traffic with no label to stack, we need the IP Adj
318  */
319  vec_add2(ctx->next_hops, nh, 1);
320 
321  nh->path_index = path_index;
322  nh->path_weight = fib_path_get_weight(path_index);
323  fib_path_contribute_forwarding(path_index, ctx->fct, &nh->path_dpo);
324 
325  break;
327  if (fib_path_is_exclusive(path_index) ||
328  fib_path_is_deag(path_index))
329  {
330  vec_add2(ctx->next_hops, nh, 1);
331 
332  nh->path_index = path_index;
333  nh->path_weight = fib_path_get_weight(path_index);
336  &nh->path_dpo);
337  }
338  break;
340  {
341  /*
342  * no label. we need a chain based on the payload. fixup.
343  */
344  vec_add2(ctx->next_hops, nh, 1);
345 
346  nh->path_index = path_index;
347  nh->path_weight = fib_path_get_weight(path_index);
350  ctx->fct),
351  &nh->path_dpo);
352 
353  break;
354  }
356  ASSERT(0);
357  break;
358  }
359  }
360 
361  return (!0);
362 }
363 
364 void
366  const fib_entry_src_t *esrc,
368  dpo_id_t *dpo_lb)
369 {
370  dpo_proto_t lb_proto;
371 
372  /*
373  * If the entry has path extensions then we construct a load-balance
374  * by stacking the extensions on the forwarding chains of the paths.
375  * Otherwise we use the load-balance of the path-list
376  */
378  .esrc = esrc,
379  .fib_entry = fib_entry,
380  .next_hops = NULL,
381  .is_recursive = 0,
382  .fct = fct,
383  };
384 
385  /*
386  * As an optimisation we allocate the vector of next-hops to be sized
387  * equal to the maximum nuber of paths we will need, which is also the
388  * most likely number we will need, since in most cases the paths are 'up'.
389  */
392 
393  lb_proto = fib_proto_to_dpo(fib_entry->fe_prefix.fp_proto);
394 
397  &ctx);
398 
400  {
401  /*
402  * the client provided the DPO that the entry should link to.
403  * all entries must link to a LB, so if it is an LB already
404  * then we can use it.
405  */
406  if ((1 == vec_len(ctx.next_hops)) &&
408  {
409  dpo_copy(dpo_lb, &ctx.next_hops[0].path_dpo);
410  dpo_reset(&ctx.next_hops[0].path_dpo);
411  return;
412  }
413  }
414 
415  if (!dpo_id_is_valid(dpo_lb))
416  {
417  /*
418  * first time create
419  */
420  flow_hash_config_t fhc;
421 
423  dpo_proto_to_fib(lb_proto));
424  dpo_set(dpo_lb,
426  lb_proto,
427  load_balance_create(0, lb_proto, fhc));
428  }
429 
431  ctx.next_hops,
433  vec_free(ctx.next_hops);
434 
435  /*
436  * if this entry is sourced by the uRPF-exempt source then we
437  * append the always present local0 interface (index 0) to the
438  * uRPF list so it is not empty. that way packets pass the loose check.
439  */
441 
444  (0 == fib_urpf_check_size(ui)))
445  {
446  /*
447  * The uRPF list we get from the path-list is shared by all
448  * other users of the list, but the uRPF exemption applies
449  * only to this prefix. So we need our own list.
450  */
452  fib_urpf_list_append(ui, 0);
453  fib_urpf_list_bake(ui);
454  load_balance_set_urpf(dpo_lb->dpoi_index, ui);
456  }
457  else
458  {
459  load_balance_set_urpf(dpo_lb->dpoi_index, ui);
460  }
461 }
462 
463 void
465  fib_source_t source)
466 {
467  /*
468  * Install the forwarding chain for the given source into the forwarding
469  * tables
470  */
473  int insert;
474 
475  fct = fib_entry_get_default_chain_type(fib_entry);
476  esrc = fib_entry_src_find(fib_entry, source, NULL);
477 
478  /*
479  * Every entry has its own load-balance object. All changes to the entry's
480  * forwarding result in an inplace modify of the load-balance. This means
481  * the load-balance object only needs to be added to the forwarding
482  * DB once, when it is created.
483  */
484  insert = !dpo_id_is_valid(&fib_entry->fe_lb);
485 
486  fib_entry_src_mk_lb(fib_entry, esrc, fct, &fib_entry->fe_lb);
487 
488  ASSERT(dpo_id_is_valid(&fib_entry->fe_lb));
489  FIB_ENTRY_DBG(fib_entry, "install: %d", fib_entry->fe_lb);
490 
491  /*
492  * insert the adj into the data-plane forwarding trie
493  */
494  if (insert)
495  {
497  &fib_entry->fe_prefix,
498  &fib_entry->fe_lb);
499  }
500 
501  /*
502  * if any of the other chain types are already created they will need
503  * updating too
504  */
507 
508  FOR_EACH_DELEGATE_CHAIN(fib_entry, fdt, fed,
509  {
510  fib_entry_src_mk_lb(fib_entry, esrc,
512  &fed->fd_dpo);
513  });
514 }
515 
516 void
518 {
519  /*
520  * uninstall the forwarding chain from the forwarding tables
521  */
522  FIB_ENTRY_DBG(fib_entry, "uninstall: %d",
523  fib_entry->fe_adj_index);
524 
525  if (dpo_id_is_valid(&fib_entry->fe_lb))
526  {
528  fib_entry->fe_fib_index,
529  &fib_entry->fe_prefix,
530  &fib_entry->fe_lb);
531 
532  dpo_reset(&fib_entry->fe_lb);
533  }
534 }
535 
536 static void
538 {
539  fib_node_index_t *entries = NULL;
540 
541  fib_path_list_recursive_loop_detect(path_list_index, &entries);
542 
543  vec_free(entries);
544 }
545 
546 void
548  fib_source_t source)
549 
550 {
551  int houston_we_are_go_for_install;
553 
554  esrc = fib_entry_src_find(fib_entry, source, NULL);
555 
558 
560 
561  if (NULL != fib_entry_src_vft[source].fesv_activate)
562  {
563  houston_we_are_go_for_install =
564  fib_entry_src_vft[source].fesv_activate(esrc, fib_entry);
565  }
566  else
567  {
568  /*
569  * the source is not providing an activate function, we'll assume
570  * therefore it has no objection to installing the entry
571  */
572  houston_we_are_go_for_install = !0;
573  }
574 
575  /*
576  * link to the path-list provided by the source, and go check
577  * if that forms any loops in the graph.
578  */
579  fib_entry->fe_parent = esrc->fes_pl;
580  fib_entry->fe_sibling =
583  fib_entry_get_index(fib_entry));
584 
586 
587  FIB_ENTRY_DBG(fib_entry, "activate: %d",
588  fib_entry->fe_parent);
589 
590  if (0 != houston_we_are_go_for_install)
591  {
592  fib_entry_src_action_install(fib_entry, source);
593  }
594  else
595  {
597  }
598 }
599 
600 void
602  fib_source_t source)
603 
604 {
605  fib_node_index_t path_list_index;
607 
608  esrc = fib_entry_src_find(fib_entry, source, NULL);
609 
611 
612  if (NULL != fib_entry_src_vft[source].fesv_deactivate)
613  {
614  fib_entry_src_vft[source].fesv_deactivate(esrc, fib_entry);
615  }
616 
618 
619  FIB_ENTRY_DBG(fib_entry, "deactivate: %d", fib_entry->fe_parent);
620 
621  /*
622  * un-link from an old path-list. Check for any loops this will clear
623  */
624  path_list_index = fib_entry->fe_parent;
625  fib_entry->fe_parent = FIB_NODE_INDEX_INVALID;
626 
627  fib_entry_recursive_loop_detect_i(path_list_index);
628 
629  /*
630  * this will unlock the path-list, so it may be invalid thereafter.
631  */
632  fib_path_list_child_remove(path_list_index, fib_entry->fe_sibling);
633  fib_entry->fe_sibling = FIB_NODE_INDEX_INVALID;
634 }
635 
636 static void
638  fib_source_t source)
639 {
641 
642  vec_foreach(esrc, fib_entry->fe_srcs)
643  {
644  if (NULL != fib_entry_src_vft[esrc->fes_src].fesv_fwd_update)
645  {
646  fib_entry_src_vft[esrc->fes_src].fesv_fwd_update(esrc,
647  fib_entry,
648  source);
649  }
650  }
651 }
652 
653 void
655  fib_source_t source)
656 {
657  fib_node_index_t path_list_index;
659 
660  esrc = fib_entry_src_find(fib_entry, source, NULL);
661 
663 
664  FIB_ENTRY_DBG(fib_entry, "reactivate: %d to %d",
665  fib_entry->fe_parent,
666  esrc->fes_pl);
667 
668  if (fib_entry->fe_parent != esrc->fes_pl)
669  {
670  /*
671  * un-link from an old path-list. Check for any loops this will clear
672  */
673  path_list_index = fib_entry->fe_parent;
674  fib_entry->fe_parent = FIB_NODE_INDEX_INVALID;
675 
676  /*
677  * temporary lock so it doesn't get deleted when this entry is no
678  * longer a child.
679  */
680  fib_path_list_lock(path_list_index);
681 
682  /*
683  * this entry is no longer a child. after unlinking check if any loops
684  * were broken
685  */
686  fib_path_list_child_remove(path_list_index,
687  fib_entry->fe_sibling);
688 
689  fib_entry_recursive_loop_detect_i(path_list_index);
690 
691  /*
692  * link to the path-list provided by the source, and go check
693  * if that forms any loops in the graph.
694  */
695  fib_entry->fe_parent = esrc->fes_pl;
696  fib_entry->fe_sibling =
699  fib_entry_get_index(fib_entry));
700 
702  fib_path_list_unlock(path_list_index);
703  }
704  fib_entry_src_action_install(fib_entry, source);
705  fib_entry_src_action_fwd_update(fib_entry, source);
706 }
707 
708 void
710  fib_source_t source)
711 {
713 
714  esrc = fib_entry_src_find(fib_entry, source, NULL);
715 
716  if (NULL != fib_entry_src_vft[source].fesv_installed)
717  {
718  fib_entry_src_vft[source].fesv_installed(esrc,
719  fib_entry);
720  }
721 
722  fib_entry_src_action_fwd_update(fib_entry, source);
723 }
724 
725 /*
726  * fib_entry_src_action_add
727  *
728  * Adding a source can result in a new fib_entry being created, which
729  * can inturn mean the pool is realloc'd and thus the entry passed as
730  * an argument it also realloc'd
731  * @return the original entry
732  */
733 fib_entry_t *
735  fib_source_t source,
737  const dpo_id_t *dpo)
738 {
739  fib_node_index_t fib_entry_index;
741 
742  esrc = fib_entry_src_find_or_create(fib_entry, source, NULL);
743 
744  esrc->fes_ref_count++;
745 
746  if (1 != esrc->fes_ref_count)
747  {
748  /*
749  * we only want to add the source on the 0->1 transition
750  */
751  return (fib_entry);
752  }
753 
754  esrc->fes_entry_flags = flags;
755 
756  /*
757  * save variable so we can recover from a fib_entry realloc.
758  */
759  fib_entry_index = fib_entry_get_index(fib_entry);
760 
761  if (NULL != fib_entry_src_vft[source].fesv_add)
762  {
763  fib_entry_src_vft[source].fesv_add(esrc,
764  fib_entry,
765  flags,
766  fib_entry_get_proto(fib_entry),
767  dpo);
768  }
769 
770  fib_entry = fib_entry_get(fib_entry_index);
771 
773 
774  fib_path_list_lock(esrc->fes_pl);
775 
776  /*
777  * the source owns a lock on the entry
778  */
780 
781  return (fib_entry);
782 }
783 
784 /*
785  * fib_entry_src_action_update
786  *
787  * Adding a source can result in a new fib_entry being created, which
788  * can inturn mean the pool is realloc'd and thus the entry passed as
789  * an argument it also realloc'd
790  * @return the original entry
791  */
792 fib_entry_t *
794  fib_source_t source,
796  const dpo_id_t *dpo)
797 {
798  fib_node_index_t fib_entry_index, old_path_list_index;
800 
801  esrc = fib_entry_src_find_or_create(fib_entry, source, NULL);
802 
803  if (NULL == esrc)
804  return (fib_entry_src_action_add(fib_entry, source, flags, dpo));
805 
806  old_path_list_index = esrc->fes_pl;
807  esrc->fes_entry_flags = flags;
808 
809  /*
810  * save variable so we can recover from a fib_entry realloc.
811  */
812  fib_entry_index = fib_entry_get_index(fib_entry);
813 
814  if (NULL != fib_entry_src_vft[source].fesv_add)
815  {
816  fib_entry_src_vft[source].fesv_add(esrc,
817  fib_entry,
818  flags,
819  fib_entry_get_proto(fib_entry),
820  dpo);
821  }
822 
823  fib_entry = fib_entry_get(fib_entry_index);
824 
826 
827  fib_path_list_lock(esrc->fes_pl);
828  fib_path_list_unlock(old_path_list_index);
829 
830  return (fib_entry);
831 }
832 
833 
836  fib_source_t source)
837 
838 {
839  fib_node_index_t old_path_list;
840  fib_entry_src_flag_t sflags;
842 
843  esrc = fib_entry_src_find(fib_entry, source, NULL);
844 
845  if (NULL == esrc)
846  return (FIB_ENTRY_SRC_FLAG_ACTIVE);
847 
848  esrc->fes_ref_count--;
849  sflags = esrc->fes_flags;
850 
851  if (0 != esrc->fes_ref_count)
852  {
853  /*
854  * only remove the source on the 1->0 transisition
855  */
856  return (sflags);
857  }
858 
860  {
861  fib_entry_src_action_deactivate(fib_entry, source);
862  }
863 
864  old_path_list = esrc->fes_pl;
865 
866  if (NULL != fib_entry_src_vft[source].fesv_remove)
867  {
868  fib_entry_src_vft[source].fesv_remove(esrc);
869  }
870 
871  fib_path_list_unlock(old_path_list);
873 
874  sflags &= ~FIB_ENTRY_SRC_FLAG_ADDED;
875  fib_entry_src_action_deinit(fib_entry, source);
876 
877  return (sflags);
878 }
879 
880 static inline int
882  const fib_route_path_t *rpath)
883 {
884  /*
885  * not all zeros next hop &&
886  * is recursive path &&
887  * nexthop is same as the route's address
888  */
889  return ((!ip46_address_is_zero(&rpath->frp_addr)) &&
890  (~0 == rpath->frp_sw_if_index) &&
891  (0 == ip46_address_cmp(&rpath->frp_addr, &prefix->fp_addr)));
892 
893 }
894 
895 /*
896  * fib_route_attached_cross_table
897  *
898  * Return true the the route is attached via an interface that
899  * is not in the same table as the route
900  */
901 static inline int
903  const fib_route_path_t *rpath)
904 {
905  /*
906  * - All zeros next-hop
907  * - a valid interface
908  * - entry's fib index not equeal to interface's index
909  */
910  if (ip46_address_is_zero(&rpath->frp_addr) &&
911  (~0 != rpath->frp_sw_if_index) &&
912  (fib_entry->fe_fib_index !=
914  rpath->frp_sw_if_index)))
915  {
916  return (!0);
917  }
918  return (0);
919 }
920 
921 /*
922  * fib_route_attached_cross_table
923  *
924  * Return true the the route is attached via an interface that
925  * is not in the same table as the route
926  */
927 static inline int
929 {
930  /*
931  * - All zeros next-hop
932  * - a valid interface
933  */
934  if (ip46_address_is_zero(&rpath->frp_addr) &&
935  (~0 != rpath->frp_sw_if_index))
936  {
937  return (!0);
938  }
939  return (0);
940 }
941 
944 {
946 
947  if (eflags & FIB_ENTRY_FLAG_DROP)
948  {
950  }
951  if (eflags & FIB_ENTRY_FLAG_LOCAL)
952  {
954  }
955  if (eflags & FIB_ENTRY_FLAG_EXCLUSIVE)
956  {
958  }
959 
960  return (plf);
961 }
962 
963 static void
965  const fib_route_path_t *rpath,
966  fib_path_list_flags_t *pl_flags,
968 {
969  /*
970  * don't allow the addition of a recursive looped path for prefix
971  * via itself.
972  */
973  if (fib_route_recurses_via_self(&fib_entry->fe_prefix, rpath))
974  {
975  /*
976  * force the install of a drop path-list.
977  * we want the entry to have some path-list, mainly so
978  * the dodgy path can be rmeoved when the source stops playing
979  * silly buggers.
980  */
981  *pl_flags |= FIB_PATH_LIST_FLAG_DROP;
982  }
983  else
984  {
985  *pl_flags &= ~FIB_PATH_LIST_FLAG_DROP;
986  }
987 
988  if ((esrc->fes_src == FIB_SOURCE_API) ||
989  (esrc->fes_src == FIB_SOURCE_CLI))
990  {
991  if (fib_path_is_attached(rpath))
992  {
994  }
995  else
996  {
998  }
999  }
1000  if (fib_route_attached_cross_table(fib_entry, rpath))
1001  {
1003  }
1004  else
1005  {
1007  }
1008 }
1009 
1010 /*
1011  * fib_entry_src_path_ext_add
1012  *
1013  * append a path extension to the entry's list
1014  */
1015 static void
1017  const fib_route_path_t *rpath)
1018 {
1019  if (NULL != rpath->frp_label_stack)
1020  {
1021  fib_path_ext_t *path_ext;
1022 
1023  vec_add2(esrc->fes_path_exts, path_ext, 1);
1024 
1025  fib_path_ext_init(path_ext, esrc->fes_pl, rpath);
1026  }
1027 }
1028 
1029 /*
1030  * fib_entry_src_path_ext_insert
1031  *
1032  * insert, sorted, a path extension to the entry's list.
1033  * It's not strictly necessary in sort the path extensions, since each
1034  * extension has the path index to which it resolves. However, by being
1035  * sorted the load-balance produced has a deterministic order, not an order
1036  * based on the sequence of extension additions. this is a considerable benefit.
1037  */
1038 static void
1040  const fib_route_path_t *rpath)
1041 {
1042  if (0 == vec_len(esrc->fes_path_exts))
1043  return (fib_entry_src_path_ext_append(esrc, rpath));
1044 
1045  if (NULL != rpath->frp_label_stack)
1046  {
1047  fib_path_ext_t path_ext;
1048  int i = 0;
1049 
1050  fib_path_ext_init(&path_ext, esrc->fes_pl, rpath);
1051 
1052  while (i < vec_len(esrc->fes_path_exts) &&
1053  (fib_path_ext_cmp(&esrc->fes_path_exts[i], rpath) < 0))
1054  {
1055  i++;
1056  }
1057 
1058  vec_insert_elts(esrc->fes_path_exts, &path_ext, 1, i);
1059  }
1060 }
1061 
1062 /*
1063  * fib_entry_src_action_add
1064  *
1065  * Adding a source can result in a new fib_entry being created, which
1066  * can inturn mean the pool is realloc'd and thus the entry passed as
1067  * an argument it also realloc'd
1068  * @return the entry
1069  */
1070 fib_entry_t*
1072  fib_source_t source,
1074  const fib_route_path_t *rpath)
1075 {
1076  fib_node_index_t old_path_list, fib_entry_index;
1077  fib_path_list_flags_t pl_flags;
1078  fib_path_ext_t *path_ext;
1080 
1081  /*
1082  * save variable so we can recover from a fib_entry realloc.
1083  */
1084  fib_entry_index = fib_entry_get_index(fib_entry);
1085 
1086  esrc = fib_entry_src_find(fib_entry, source, NULL);
1087  if (NULL == esrc)
1088  {
1089  fib_entry =
1090  fib_entry_src_action_add(fib_entry,
1091  source,
1092  flags,
1093  drop_dpo_get(
1095  fib_entry_get_proto(fib_entry))));
1096  esrc = fib_entry_src_find(fib_entry, source, NULL);
1097  }
1098 
1099  /*
1100  * we are no doubt modifying a path-list. If the path-list
1101  * is shared, and hence not modifiable, then the index returned
1102  * will be for a different path-list. This FIB entry to needs
1103  * to maintain its lock appropriately.
1104  */
1105  old_path_list = esrc->fes_pl;
1106 
1107  ASSERT(NULL != fib_entry_src_vft[source].fesv_path_add);
1108 
1110  fib_entry_flags_update(fib_entry, rpath, &pl_flags, esrc);
1111 
1112  fib_entry_src_vft[source].fesv_path_add(esrc, fib_entry, pl_flags, rpath);
1113  fib_entry = fib_entry_get(fib_entry_index);
1114 
1115  /*
1116  * re-resolve all the path-extensions with the new path-list
1117  */
1118  vec_foreach(path_ext, esrc->fes_path_exts)
1119  {
1120  fib_path_ext_resolve(path_ext, esrc->fes_pl);
1121  }
1122  /*
1123  * if the path has a label we need to add a path extension
1124  */
1125  fib_entry_src_path_ext_insert(esrc, rpath);
1126 
1127  fib_path_list_lock(esrc->fes_pl);
1128  fib_path_list_unlock(old_path_list);
1129 
1130  return (fib_entry);
1131 }
1132 
1133 /*
1134  * fib_entry_src_action_swap
1135  *
1136  * The source is providing new paths to replace the old ones.
1137  * Adding a source can result in a new fib_entry being created, which
1138  * can inturn mean the pool is realloc'd and thus the entry passed as
1139  * an argument it also realloc'd
1140  * @return the entry
1141  */
1142 fib_entry_t*
1144  fib_source_t source,
1146  const fib_route_path_t *rpaths)
1147 {
1148  fib_node_index_t old_path_list, fib_entry_index;
1149  fib_path_list_flags_t pl_flags;
1150  const fib_route_path_t *rpath;
1151  fib_path_ext_t *path_ext;
1153 
1154  esrc = fib_entry_src_find(fib_entry, source, NULL);
1155 
1156  /*
1157  * save variable so we can recover from a fib_entry realloc.
1158  */
1159  fib_entry_index = fib_entry_get_index(fib_entry);
1160 
1161  if (NULL == esrc)
1162  {
1163  fib_entry = fib_entry_src_action_add(fib_entry,
1164  source,
1165  flags,
1166  drop_dpo_get(
1168  fib_entry_get_proto(fib_entry))));
1169  esrc = fib_entry_src_find(fib_entry, source, NULL);
1170  }
1171 
1172  /*
1173  * swapping paths may create a new path-list (or may use an existing shared)
1174  * but we are certainly getting a different one. This FIB entry to needs
1175  * to maintain its lock appropriately.
1176  */
1177  old_path_list = esrc->fes_pl;
1178 
1179  ASSERT(NULL != fib_entry_src_vft[source].fesv_path_swap);
1180 
1181  pl_flags = fib_entry_src_flags_2_path_list_flags(flags);
1182 
1183  vec_foreach(rpath, rpaths)
1184  {
1185  fib_entry_flags_update(fib_entry, rpath, &pl_flags, esrc);
1186  }
1187 
1188  fib_entry_src_vft[source].fesv_path_swap(esrc,
1189  fib_entry,
1190  pl_flags,
1191  rpaths);
1192 
1193  vec_foreach(path_ext, esrc->fes_path_exts)
1194  {
1195  vec_free(path_ext->fpe_label_stack);
1196  }
1197  vec_free(esrc->fes_path_exts);
1198 
1199  vec_foreach(rpath, rpaths)
1200  {
1201  fib_entry_src_path_ext_append(esrc, rpath);
1202  }
1203 
1204  fib_entry = fib_entry_get(fib_entry_index);
1205 
1206  fib_path_list_lock(esrc->fes_pl);
1207  fib_path_list_unlock(old_path_list);
1208 
1209  return (fib_entry);
1210 }
1211 
1214  fib_source_t source,
1215  const fib_route_path_t *rpath)
1216 {
1217  fib_path_list_flags_t pl_flags;
1218  fib_node_index_t old_path_list;
1219  fib_path_ext_t *path_ext;
1221 
1222  esrc = fib_entry_src_find(fib_entry, source, NULL);
1223 
1224  ASSERT(NULL != esrc);
1226 
1227  /*
1228  * we no doubt modifying a path-list. If the path-list
1229  * is shared, and hence not modifiable, then the index returned
1230  * will be for a different path-list. This FIB entry to needs
1231  * to maintain its lock appropriately.
1232  */
1233  old_path_list = esrc->fes_pl;
1234 
1235  ASSERT(NULL != fib_entry_src_vft[source].fesv_path_remove);
1236 
1238  fib_entry_flags_update(fib_entry, rpath, &pl_flags, esrc);
1239 
1240  fib_entry_src_vft[source].fesv_path_remove(esrc, pl_flags, rpath);
1241  /*
1242  * find the matching path extension and remove it
1243  */
1244  vec_foreach(path_ext, esrc->fes_path_exts)
1245  {
1246  if (!fib_path_ext_cmp(path_ext, rpath))
1247  {
1248  /*
1249  * delete the element moving the remaining elements down 1 position.
1250  * this preserves the sorted order.
1251  */
1252  vec_free(path_ext->fpe_label_stack);
1253  vec_delete(esrc->fes_path_exts, 1, (path_ext - esrc->fes_path_exts));
1254  break;
1255  }
1256  }
1257  /*
1258  * re-resolve all the path-extensions with the new path-list
1259  */
1260  vec_foreach(path_ext, esrc->fes_path_exts)
1261  {
1262  fib_path_ext_resolve(path_ext, esrc->fes_pl);
1263  }
1264 
1265  /*
1266  * lock the new path-list, unlock the old if it had one
1267  */
1268  fib_path_list_unlock(old_path_list);
1269 
1270  if (FIB_NODE_INDEX_INVALID != esrc->fes_pl) {
1271  fib_path_list_lock(esrc->fes_pl);
1272  return (FIB_ENTRY_SRC_FLAG_ADDED);
1273  }
1274  else
1275  {
1276  /*
1277  * no more paths left from this source
1278  */
1279  fib_entry_src_action_remove(fib_entry, source);
1280  return (FIB_ENTRY_SRC_FLAG_NONE);
1281  }
1282 }
1283 
1284 u8*
1286  fib_source_t source,
1287  u8* s)
1288 {
1290 
1291  esrc = fib_entry_src_find(fib_entry, source, NULL);
1292 
1293  if (NULL != fib_entry_src_vft[source].fesv_format)
1294  {
1295  return (fib_entry_src_vft[source].fesv_format(esrc, s));
1296  }
1297  return (s);
1298 }
1299 
1302  fib_source_t source)
1303 {
1306 
1307  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
1308  return (ADJ_INDEX_INVALID);
1309 
1310  fib_entry = fib_entry_get(fib_entry_index);
1311  esrc = fib_entry_src_find(fib_entry, source, NULL);
1312 
1313  if (NULL != esrc)
1314  {
1315  if (FIB_NODE_INDEX_INVALID != esrc->fes_pl)
1316  {
1317  return (fib_path_list_get_adj(
1318  esrc->fes_pl,
1319  fib_entry_get_default_chain_type(fib_entry)));
1320  }
1321  }
1322  return (ADJ_INDEX_INVALID);
1323 }
1324 
1325 const int
1327  fib_source_t source,
1328  dpo_id_t *dpo)
1329 {
1332 
1333  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
1334  return (0);
1335 
1336  fib_entry = fib_entry_get(fib_entry_index);
1337  esrc = fib_entry_src_find(fib_entry, source, NULL);
1338 
1339  if (NULL != esrc)
1340  {
1341  if (FIB_NODE_INDEX_INVALID != esrc->fes_pl)
1342  {
1344  esrc->fes_pl,
1346  dpo);
1347 
1348  return (dpo_id_is_valid(dpo));
1349  }
1350  }
1351  return (0);
1352 }
1353 
1354 u32
1356  fib_source_t source)
1357 {
1360 
1361  fib_entry = fib_entry_get(entry_index);
1362 
1363  esrc = fib_entry_src_find(fib_entry, source, NULL);
1364 
1365  if (NULL != esrc)
1366  {
1367  if (FIB_NODE_INDEX_INVALID != esrc->fes_pl)
1368  {
1370  }
1371  }
1372  return (~0);
1373 }
1374 
1377  fib_source_t source)
1378 {
1381 
1382  fib_entry = fib_entry_get(entry_index);
1383 
1384  esrc = fib_entry_src_find(fib_entry, source, NULL);
1385 
1386  if (NULL != esrc)
1387  {
1388  return (esrc->fes_entry_flags);
1389  }
1390 
1391  return (FIB_ENTRY_FLAG_NONE);
1392 }
1393 
1396 {
1398 
1399  /*
1400  * the vector of sources is deliberately arranged in priority order
1401  */
1402  if (0 == vec_len(fib_entry->fe_srcs))
1403  {
1404  flags = FIB_ENTRY_FLAG_NONE;
1405  }
1406  else
1407  {
1409 
1410  esrc = vec_elt_at_index(fib_entry->fe_srcs, 0);
1411  flags = esrc->fes_entry_flags;
1412  }
1413 
1414  return (flags);
1415 }
1416 
1417 void
1419  fib_source_t source,
1420  const void *data)
1421 {
1424 
1425  fib_entry = fib_entry_get(fib_entry_index);
1426  esrc = fib_entry_src_find(fib_entry, source, NULL);
1427 
1428  if (NULL != esrc &&
1429  NULL != fib_entry_src_vft[source].fesv_set_data)
1430  {
1431  fib_entry_src_vft[source].fesv_set_data(esrc, fib_entry, data);
1432  }
1433 }
1434 
1435 const void*
1437  fib_source_t source)
1438 {
1441 
1442  fib_entry = fib_entry_get(fib_entry_index);
1443  esrc = fib_entry_src_find(fib_entry, source, NULL);
1444 
1445  if (NULL != esrc &&
1446  NULL != fib_entry_src_vft[source].fesv_get_data)
1447  {
1448  return (fib_entry_src_vft[source].fesv_get_data(esrc, fib_entry));
1449  }
1450  return (NULL);
1451 }
1452 
1453 void
1455 {
1464 }
static int fib_entry_src_cmp_for_sort(void *v1, void *v2)
Definition: fib_entry_src.c:45
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:396
fib_entry_src_cover_res_t fib_entry_src_action_cover_change(fib_entry_t *fib_entry, fib_source_t source)
int fib_path_is_resolved(fib_node_index_t path_index)
Definition: fib_path.c:1877
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:154
fib_entry_src_init_t fesv_init
#define FIB_ENTRY_DBG(_e, _fmt, _args...)
Debug macro.
Definition: fib_entry_src.h:42
ip46_address_t frp_addr
The next-hop address.
Definition: fib_types.h:299
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&#39;s forwarding table
Definition: fib_table.c:261
void fib_entry_unlock(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1407
Contribute an object that is to be used to forward IP6 packets.
Definition: fib_types.h:85
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
An entry in a FIB table.
Definition: fib_entry.h:361
fib_node_index_t path_index
The index of the FIB path.
Definition: load_balance.h:70
static int fib_entry_src_valid_out_label(mpls_label_t label)
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:1724
int is_recursive
fib_entry_src_set_data_t fesv_set_data
struct fib_entry_src_collect_forwarding_ctx_t_ fib_entry_src_collect_forwarding_ctx_t
static int fib_urpf_check_size(index_t ui)
Data-Plane function to check the size of an uRPF list, (i.e.
void fib_path_list_child_remove(fib_node_index_t path_list_index, u32 si)
void fib_path_ext_resolve(fib_path_ext_t *path_ext, fib_node_index_t path_list_index)
Definition: fib_path_ext.c:71
fib_entry_flag_t fib_entry_get_flags_i(const fib_entry_t *fib_entry)
A representation of a path as described by a route producer.
Definition: fib_types.h:285
int fib_path_ext_cmp(fib_path_ext_t *path_ext, const fib_route_path_t *rpath)
Definition: fib_path_ext.c:47
dpo_id_t path_dpo
ID of the Data-path object.
Definition: load_balance.h:65
fib_forward_chain_type_t fct
static void fib_entry_src_action_fwd_update(const fib_entry_t *fib_entry, fib_source_t source)
adj_index_t fib_path_list_get_adj(fib_node_index_t path_list_index, fib_forward_chain_type_t type)
Virtual function table each FIB entry source will register.
u32 fib_path_list_get_resolving_interface(fib_node_index_t path_list_index)
Definition: fib_entry.h:257
static int dpo_id_is_valid(const dpo_id_t *dpoi)
Return true if the DPO object is valid, i.e.
Definition: dpo.h:177
static fib_entry_src_t * fib_entry_src_find_or_create(fib_entry_t *fib_entry, fib_source_t source, u32 *index)
#define NULL
Definition: clib.h:55
Information related to the source of a FIB entry.
Definition: fib_entry.h:270
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:902
Definition: fib_entry.h:222
void load_balance_set_urpf(index_t lbi, index_t urpf)
Definition: load_balance.c:242
int fib_path_is_exclusive(fib_node_index_t path_index)
Definition: fib_path.c:1857
void fib_entry_src_action_deactivate(fib_entry_t *fib_entry, fib_source_t source)
load_balance_path_t * next_hops
enum fib_entry_delegate_type_t_ fib_entry_delegate_type_t
Delegate types.
u32 mpls_label_t
A label value only, i.e.
Definition: packet.h:24
#define MPLS_IETF_IMPLICIT_NULL_LABEL
Definition: mpls_types.h:16
From the CLI.
Definition: fib_entry.h:62
void dpo_copy(dpo_id_t *dst, const dpo_id_t *src)
atomic copy a data-plane object.
Definition: dpo.c:221
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:41
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:482
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:521
Result from a cover update/change.
Definition: fib_entry_src.h:87
void fib_path_list_walk(fib_node_index_t path_list_index, fib_path_list_walk_fn_t func, void *ctx)
Contribute an object that is to be used to forward IP4 packets.
Definition: fib_types.h:81
u32 fe_fib_index
The index of the FIB table this entry is in.
Definition: fib_entry.h:374
uRPF bypass/exemption.
Definition: fib_entry.h:110
Definition: fib_entry.h:218
fib_entry_src_t * fe_srcs
Vector of source infos.
Definition: fib_entry.h:393
static void fib_entry_recursive_loop_detect_i(fib_node_index_t path_list_index)
void fib_entry_src_action_deinit(fib_entry_t *fib_entry, fib_source_t source)
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)
#define ip46_address_cmp(ip46_1, ip46_2)
Definition: ip6_packet.h:80
dpo_id_t fd_dpo
Valid for the forwarding chain delegates.
fib_node_index_t fe_parent
the path-list for which this entry is a child.
Definition: fib_entry.h:398
void fib_entry_src_mpls_register(void)
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
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:918
index_t load_balance_create(u32 n_buckets, dpo_proto_t lb_proto, flow_hash_config_t fhc)
Definition: load_balance.c:192
void fib_path_ext_init(fib_path_ext_t *path_ext, fib_node_index_t path_list_index, const fib_route_path_t *rpath)
Definition: fib_path_ext.c:84
const dpo_id_t * drop_dpo_get(dpo_proto_t proto)
Definition: drop_dpo.c:25
void fib_entry_src_adj_register(void)
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:178
u32 fe_sibling
index of this entry in the parent&#39;s child list.
Definition: fib_entry.h:404
fib_entry_flag_t fib_entry_get_flags_for_source(fib_node_index_t entry_index, fib_source_t source)
const int fib_entry_get_dpo_for_source(fib_node_index_t fib_entry_index, fib_source_t source, dpo_id_t *dpo)
u32 fib_entry_get_resolving_interface_for_source(fib_node_index_t entry_index, fib_source_t source)
void fib_entry_src_lisp_register(void)
u32 frp_sw_if_index
The interface.
Definition: fib_types.h:311
mpls_label_t * frp_label_stack
The outgoing MPLS label Stack.
Definition: fib_types.h:328
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 *rpath)
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 *rpath)
index_t fib_urpf_list_alloc_and_lock(void)
Definition: fib_urpf_list.c:47
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Aggregrate type for a prefix.
Definition: fib_types.h:145
fib_entry_src_path_add_t fesv_path_add
fib_node_index_t fib_entry_get_index(const fib_entry_t *fib_entry)
Definition: fib_entry.c:56
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:471
Contribute an object that is to be used to forward Ethernet packets.
Definition: fib_types.h:103
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
fib_protocol_t dpo_proto_to_fib(dpo_proto_t dpo_proto)
Definition: fib_types.c:236
void fib_entry_src_api_register(void)
void fib_urpf_list_append(index_t ui, u32 sw_if_index)
Append another interface to the list.
Definition: fib_urpf_list.c:92
static void fib_entry_src_path_ext_insert(fib_entry_src_t *esrc, const fib_route_path_t *rpath)
u16 install
Definition: fib_entry_src.h:88
Definition: fib_entry.h:216
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:138
Contribute an object that is to be used to forward end-of-stack MPLS packets.
Definition: fib_types.h:97
Definition: fib_entry.h:221
void fib_entry_src_mk_lb(fib_entry_t *fib_entry, const fib_entry_src_t *esrc, fib_forward_chain_type_t fct, dpo_id_t *dpo_lb)
void fib_entry_src_default_route_register(void)
Definition: fib_entry.h:220
#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_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)
struct fib_path_ext_t_ * fes_path_exts
A vector of path extensions.
Definition: fib_entry.h:274
static int fib_route_attached_cross_table(const fib_entry_t *fib_entry, const fib_route_path_t *rpath)
enum fib_source_t_ fib_source_t
The different sources that can create a route.
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:168
fib_entry_src_fwd_update_t fesv_fwd_update
#define FOR_EACH_DELEGATE_CHAIN(_entry, _fdt, _fed, _body)
fib_entry_src_deinit_t fesv_deinit
dpo_type_t dpoi_type
the type
Definition: dpo.h:142
load-balancing over a choice of [un]equal cost paths
Definition: dpo.h:102
#define MPLS_LABEL_IS_REAL(_lbl)
Definition: mpls_types.h:35
#define vec_del1(v, i)
Delete the element at index I.
Definition: vec.h:765
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&#39;s forwarding table.
Definition: fib_table.c:234
void fib_path_list_lock(fib_node_index_t path_list_index)
static fib_entry_src_t * fib_entry_src_find(const fib_entry_t *fib_entry, fib_source_t source, u32 *index)
Definition: fib_entry_src.c:75
#define FIB_SOURCE_MAX
The maximum number of sources.
Definition: fib_entry.h:130
void fib_entry_src_action_init(fib_entry_t *fib_entry, fib_source_t source)
Definition: fib_entry_src.c:54
enum load_balance_flags_t_ load_balance_flags_t
Flags controlling load-balance creation and modification.
fib_entry_src_flag_t fib_entry_src_action_remove(fib_entry_t *fib_entry, fib_source_t source)
static void fib_entry_flags_update(const fib_entry_t *fib_entry, const fib_route_path_t *rpath, fib_path_list_flags_t *pl_flags, fib_entry_src_t *esrc)
int fib_path_is_recursive(fib_node_index_t path_index)
Definition: fib_path.c:1847
void fib_entry_src_action_installed(const fib_entry_t *fib_entry, fib_source_t source)
Definition: fib_entry.h:255
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:300
void fib_entry_src_action_activate(fib_entry_t *fib_entry, fib_source_t source)
void fib_urpf_list_bake(index_t ui)
Convert the uRPF list from the itf set obtained during the walk to a unique list. ...
void fib_entry_src_rr_register(void)
#define MPLS_IETF_IPV4_EXPLICIT_NULL_LABEL
Definition: mpls_types.h:13
fib_path_list_flags_t fib_entry_src_flags_2_path_list_flags(fib_entry_flag_t eflags)
fib_entry_src_remove_t fesv_remove
Definition: fib_entry.h:219
fib_entry_src_deactivate_t fesv_deactivate
u32 fib_path_list_get_n_paths(fib_node_index_t path_list_index)
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:28
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
fib_forward_chain_type_t fib_entry_delegate_type_to_chain_type(fib_entry_delegate_type_t fdt)
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:154
void fib_path_list_unlock(fib_node_index_t path_list_index)
fib_entry_t * fib_entry_get(fib_node_index_t index)
Definition: fib_entry.c:44
void fib_entry_src_interface_register(void)
void fib_entry_lock(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1397
enum fib_entry_flag_t_ fib_entry_flag_t
int fib_path_list_recursive_loop_detect(fib_node_index_t path_list_index, fib_node_index_t **entry_indicies)
fib_entry_flag_t fes_entry_flags
Flags the source contributes to the entry.
Definition: fib_entry.h:299
static fib_protocol_t fib_entry_get_proto(const fib_entry_t *fib_entry)
Definition: fib_entry_src.c:32
static void fib_entry_src_path_ext_append(fib_entry_src_t *esrc, const fib_route_path_t *rpath)
fib_source_t fes_src
Which source this info block is for.
Definition: fib_entry.h:283
fib_entry_src_cover_res_t fib_entry_src_action_cover_update(fib_entry_t *fib_entry, fib_source_t source)
#define ASSERT(truth)
fib_entry_src_flag_t fes_flags
Flags on the source.
Definition: fib_entry.h:287
void fib_entry_src_special_register(void)
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)
unsigned int u32
Definition: types.h:88
int fib_path_is_deag(fib_node_index_t path_index)
Definition: fib_path.c:1867
#define vec_delete(V, N, M)
Delete N elements starting at element M.
Definition: vec.h:745
#define vec_insert_elts(V, E, N, M)
Insert N vector elements starting at element M, insert given elements (no header, unspecified alignme...
Definition: vec.h:724
void fib_entry_src_module_init(void)
void fib_entry_src_register(fib_source_t source, const fib_entry_src_vft_t *vft)
Definition: fib_entry_src.c:38
enum fib_forward_chain_type_t_ fib_forward_chain_type_t
FIB output chain type.
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.h:256
static int fib_entry_src_collect_forwarding(fib_node_index_t pl_index, fib_node_index_t path_index, void *arg)
void fib_path_list_contribute_forwarding(fib_node_index_t path_list_index, fib_forward_chain_type_t type, dpo_id_t *dpo)
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
Definition: fib_types.c:220
From the control plane API.
Definition: fib_entry.h:58
enum fib_entry_src_flag_t_ fib_entry_src_flag_t
int fib_path_get_weight(fib_node_index_t path_index)
Definition: fib_path.c:1656
u32 flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
Definition: lookup.h:160
fib_entry_src_path_remove_t fesv_path_remove
int fib_entry_is_sourced(fib_node_index_t fib_entry_index, fib_source_t source)
fib_entry_src_path_swap_t fesv_path_swap
dpo_id_t fe_lb
The load-balance used for forwarding.
Definition: fib_entry.h:387
load_balance_path_t * fib_path_ext_stack(fib_path_ext_t *path_ext, const fib_entry_t *entry, fib_forward_chain_type_t child_fct, load_balance_path_t *nhs)
Definition: fib_path_ext.c:105
fib_node_index_t fes_pl
The path-list created by the source.
Definition: fib_entry.h:279
const fib_entry_src_t * esrc
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:154
#define FIB_NODE_INDEX_INVALID
Definition: fib_types.h:29
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
u32 path_weight
weight for the path.
Definition: load_balance.h:75
fib_node_index_t fpe_path_index
The index of the path.
Definition: fib_path_ext.h:46
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:920
fib_entry_src_activate_t fesv_activate
void fib_urpf_list_unlock(index_t ui)
Definition: fib_urpf_list.c:60
#define MPLS_IETF_IPV6_EXPLICIT_NULL_LABEL
Definition: mpls_types.h:15
One path from an [EU]CMP set that the client wants to add to a load-balance object.
Definition: load_balance.h:61
u8 * fib_entry_src_format(fib_entry_t *fib_entry, fib_source_t source, u8 *s)
void fib_entry_set_source_data(fib_node_index_t fib_entry_index, fib_source_t source, const void *data)
fib_entry_src_add_t fesv_add
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.
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.
void fib_entry_src_action_reactivate(fib_entry_t *fib_entry, fib_source_t source)
load_balance_flags_t fib_entry_calc_lb_flags(fib_entry_src_collect_forwarding_ctx_t *ctx)
Determine whether this FIB entry should use a load-balance MAP to support PIC edge fast convergence...
const fib_entry_t * fib_entry
static int fib_route_recurses_via_self(const fib_prefix_t *prefix, const fib_route_path_t *rpath)
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
Definition: dpo.c:191
#define vec_foreach(var, vec)
Vector iterator.
A path extension is a per-entry addition to the forwarding information when packets are sent for that...
Definition: fib_path_ext.h:32
adj_index_t fib_entry_get_adj_for_source(fib_node_index_t fib_entry_index, fib_source_t source)
u8 fes_ref_count
1 bytes ref count.
Definition: fib_entry.h:294
static int fib_path_is_attached(const fib_route_path_t *rpath)
Contribute an object that is to be used to forward non-end-of-stack MPLS packets. ...
Definition: fib_types.h:90
const void * fib_entry_get_source_data(fib_node_index_t fib_entry_index, fib_source_t source)
enum fib_path_list_flags_t_ fib_path_list_flags_t
A Delagate is a means to implmenet the Delagation design pattern; the extension of an objects functio...
u32 flags
Definition: vhost-user.h:75
#define ip46_address_is_zero(ip46)
Definition: ip6_packet.h:81
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:270
fib_forward_chain_type_t fib_entry_get_default_chain_type(const fib_entry_t *fib_entry)
Definition: fib_entry.c:68
void fib_entry_src_action_install(fib_entry_t *fib_entry, fib_source_t source)
fib_entry_src_installed_t fesv_installed
const fib_prefix_t fe_prefix
The prefix of the route.
Definition: fib_entry.h:370
void fib_entry_src_action_uninstall(fib_entry_t *fib_entry)