FD.io VPP  v17.10-9-gd594711
Vector Packet Processing
mfib_entry.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 <vlib/vlib.h>
17 
18 #include <vnet/mfib/mfib_entry.h>
19 #include <vnet/fib/fib_path_list.h>
20 
21 #include <vnet/dpo/drop_dpo.h>
22 #include <vnet/dpo/replicate_dpo.h>
23 
24 /**
25  * Debug macro
26  */
27 #ifdef MFIB_DEBUG
28 #DEFIne MFIB_ENTRY_DBG(_e, _fmt, _args...) \
29 { \
30  u8*__tmp = NULL; \
31  __tmp = format(__tmp, "e:[%d:%U", \
32  mfib_entry_get_index(_e), \
33  format_ip46_address, \
34  &_e->mfe_prefix.fp_grp_addr, \
35  IP46_TYPE_ANY); \
36  __tmp = format(__tmp, "/%d,", \
37  _e->mfe_prefix.fp_len); \
38  __tmp = format(__tmp, "%U]", \
39  mfib_entry_get_index(_e), \
40  format_ip46_address, \
41  &_e->mfe_prefix.fp_src_addr, \
42  IP46_TYPE_ANY); \
43  __tmp = format(__tmp, _fmt, ##_args); \
44  clib_warning("%s", __tmp); \
45  vec_free(__tmp); \
46 }
47 #else
48 #define MFIB_ENTRY_DBG(_e, _fmt, _args...)
49 #endif
50 
51 /**
52  * MFIB extensions to each path
53  */
54 typedef struct mfib_path_ext_t_
55 {
59 
60 /**
61  * The source of an MFIB entry
62  */
63 typedef struct mfib_entry_src_t_
64 {
65  /**
66  * Which source this is
67  */
69 
70  /**
71  * Route flags
72  */
74 
75  /**
76  * The path-list of forwarding interfaces
77  */
79 
80  /**
81  * RPF-ID
82  */
84 
85  /**
86  * Hash table of path extensions
87  */
89 
90  /**
91  * The hash table of all interfaces.
92  * This is forwarding time information derived from the paths
93  * and their extensions.
94  */
97 
98 /**
99  * Pool of path extensions
100  */
102 
103 /**
104  * String names for each source
105  */
106 static const char *mfib_source_names[] = MFIB_SOURCE_NAMES;
107 
108 /*
109  * Pool for all fib_entries
110  */
112 
113 static fib_node_t *
115 {
116  return ((fib_node_t*)mfib_entry_get(index));
117 }
118 
119 static fib_protocol_t
120 mfib_entry_get_proto (const mfib_entry_t * mfib_entry)
121 {
122  return (mfib_entry->mfe_prefix.fp_proto);
123 }
124 
127 {
128  switch (mfib_entry->mfe_prefix.fp_proto)
129  {
130  case FIB_PROTOCOL_IP4:
132  case FIB_PROTOCOL_IP6:
134  case FIB_PROTOCOL_MPLS:
135  ASSERT(0);
136  break;
137  }
139 }
140 
141 static u8 *
142 format_mfib_entry_dpo (u8 * s, va_list * args)
143 {
144  index_t fei = va_arg(*args, index_t);
145  CLIB_UNUSED(u32 indent) = va_arg(*args, u32);
146 
147  return (format(s, "%U",
148  format_mfib_entry, fei,
150 }
151 
152 static inline mfib_path_ext_t *
154 {
155  return (pool_elt_at_index(mfib_path_ext_pool, mi));
156 }
157 
158 static u8 *
159 format_mfib_entry_path_ext (u8 * s, va_list * args)
160 {
161  mfib_path_ext_t *path_ext;
162  index_t mpi = va_arg(*args, index_t);
163 
164  path_ext = mfib_entry_path_ext_get(mpi);
165  return (format(s, "path:%d flags:%U",
166  path_ext->mfpe_path,
167  format_mfib_itf_flags, path_ext->mfpe_flags));
168 }
169 
170 u8 *
171 format_mfib_entry (u8 * s, va_list * args)
172 {
173  fib_node_index_t fei, mfi;
174  mfib_entry_t *mfib_entry;
175  mfib_entry_src_t *msrc;
176  u32 sw_if_index;
177  int level;
178 
179  fei = va_arg (*args, fib_node_index_t);
180  level = va_arg (*args, int);
181  mfib_entry = mfib_entry_get(fei);
182 
183  s = format (s, "%U", format_mfib_prefix, &mfib_entry->mfe_prefix);
184  s = format (s, ": %U", format_mfib_entry_flags, mfib_entry->mfe_flags);
185 
186  if (level >= MFIB_ENTRY_FORMAT_DETAIL)
187  {
188  fib_node_index_t path_index, mpi;
189 
190  s = format (s, "\n");
191  s = format (s, " fib:%d", mfib_entry->mfe_fib_index);
192  s = format (s, " index:%d", mfib_entry_get_index(mfib_entry));
193  s = format (s, " locks:%d\n", mfib_entry->mfe_node.fn_locks);
194  vec_foreach(msrc, mfib_entry->mfe_srcs)
195  {
196  s = format (s, " src:%s", mfib_source_names[msrc->mfes_src]);
197  s = format (s, ": %U\n", format_mfib_entry_flags, msrc->mfes_flags);
198  if (FIB_NODE_INDEX_INVALID != msrc->mfes_pl)
199  {
200  s = fib_path_list_format(msrc->mfes_pl, s);
201  }
202  s = format (s, " Extensions:\n");
203  hash_foreach(path_index, mpi, msrc->mfes_exts,
204  ({
205  s = format(s, " %U\n", format_mfib_entry_path_ext, mpi);
206  }));
207  s = format (s, " Interface-Forwarding:\n");
208  hash_foreach(sw_if_index, mfi, msrc->mfes_itfs,
209  ({
210  s = format(s, " %U\n", format_mfib_itf, mfi);
211  }));
212  }
213  }
214 
215  s = format(s, "\n Interfaces:");
216  hash_foreach(sw_if_index, mfi, mfib_entry->mfe_itfs,
217  ({
218  s = format(s, "\n %U", format_mfib_itf, mfi);
219  }));
220  s = format(s, "\n RPF-ID:%d", mfib_entry->mfe_rpf_id);
221  s = format(s, "\n %U-chain\n %U",
225  &mfib_entry->mfe_rep,
226  2);
227  s = format(s, "\n");
228 
229  if (level >= MFIB_ENTRY_FORMAT_DETAIL2)
230  {
231  s = format(s, "\nchildren:");
232  s = fib_node_children_format(mfib_entry->mfe_node.fn_children, s);
233  }
234 
235  return (s);
236 }
237 
238 static mfib_entry_t*
240 {
241 #if CLIB_DEBUG > 0
243 #endif
244  return ((mfib_entry_t*)node);
245 }
246 
247 static int
249  void * v2)
250 {
251  mfib_entry_src_t *esrc1 = v1, *esrc2 = v2;
252 
253  return (esrc1->mfes_src - esrc2->mfes_src);
254 }
255 
256 static void
258  mfib_source_t source)
259 
260 {
261  mfib_entry_src_t esrc = {
263  .mfes_flags = MFIB_ENTRY_FLAG_NONE,
264  .mfes_src = source,
265  };
266 
267  vec_add1(mfib_entry->mfe_srcs, esrc);
268  vec_sort_with_function(mfib_entry->mfe_srcs,
270 }
271 
272 static mfib_entry_src_t *
274  mfib_source_t source,
275  u32 *index)
276 
277 {
278  mfib_entry_src_t *esrc;
279  int ii;
280 
281  ii = 0;
282  vec_foreach(esrc, mfib_entry->mfe_srcs)
283  {
284  if (esrc->mfes_src == source)
285  {
286  if (NULL != index)
287  {
288  *index = ii;
289  }
290  return (esrc);
291  }
292  else
293  {
294  ii++;
295  }
296  }
297 
298  return (NULL);
299 }
300 
301 static mfib_entry_src_t *
303  mfib_source_t source)
304 {
305  mfib_entry_src_t *esrc;
306 
307  esrc = mfib_entry_src_find(mfib_entry, source, NULL);
308 
309  if (NULL == esrc)
310  {
311  mfib_entry_src_init(mfib_entry, source);
312  }
313 
314  return (mfib_entry_src_find(mfib_entry, source, NULL));
315 }
316 
317 static mfib_entry_src_t*
319 {
320  mfib_entry_src_t *bsrc;
321 
322  /*
323  * the enum of sources is deliberately arranged in priority order
324  */
325  if (0 == vec_len(mfib_entry->mfe_srcs))
326  {
327  bsrc = NULL;
328  }
329  else
330  {
331  bsrc = vec_elt_at_index(mfib_entry->mfe_srcs, 0);
332  }
333 
334  return (bsrc);
335 }
336 
337 int
339  mfib_source_t source)
340 {
341  mfib_entry_t *mfib_entry;
342 
343  mfib_entry = mfib_entry_get(mfib_entry_index);
344 
345  return (NULL != mfib_entry_src_find(mfib_entry, source, NULL));
346 }
347 
348 static void
350 {
351  u32 sw_if_index;
352  index_t mfii;
353 
354  hash_foreach(sw_if_index, mfii, msrc->mfes_itfs,
355  ({
356  mfib_itf_delete(mfib_itf_get(mfii));
357  }));
358  hash_free(msrc->mfes_itfs);
359  msrc->mfes_itfs = NULL;
361 }
362 
363 static void
365  mfib_source_t source)
366 
367 {
368  mfib_entry_src_t *msrc;
369  u32 index = ~0;
370 
371  msrc = mfib_entry_src_find(mfib_entry, source, &index);
372 
373  if (NULL != msrc)
374  {
375  mfib_entry_src_flush(msrc);
376  vec_del1(mfib_entry->mfe_srcs, index);
377  }
378 }
379 
380 u32
382  fib_node_type_t child_type,
383  fib_node_index_t child_index)
384 {
386  mfib_entry_index,
387  child_type,
388  child_index));
389 };
390 
391 void
393  u32 sibling_index)
394 {
396  mfib_entry_index,
397  sibling_index);
398 }
399 
400 static mfib_entry_t *
402  const mfib_prefix_t *prefix,
403  fib_node_index_t *mfib_entry_index)
404 {
405  mfib_entry_t *mfib_entry;
406 
407  pool_get_aligned(mfib_entry_pool, mfib_entry, CLIB_CACHE_LINE_BYTES);
408 
409  fib_node_init(&mfib_entry->mfe_node,
411 
412  /*
413  * Some of the members require non-default initialisation
414  * so we also init those that don't and thus save on the call to memset.
415  */
416  mfib_entry->mfe_flags = 0;
417  mfib_entry->mfe_fib_index = fib_index;
418  mfib_entry->mfe_prefix = *prefix;
419  mfib_entry->mfe_srcs = NULL;
420  mfib_entry->mfe_itfs = NULL;
421  mfib_entry->mfe_rpf_id = MFIB_RPF_ID_NONE;
422  mfib_entry->mfe_pl = FIB_NODE_INDEX_INVALID;
423 
424  dpo_reset(&mfib_entry->mfe_rep);
425 
426  *mfib_entry_index = mfib_entry_get_index(mfib_entry);
427 
428  MFIB_ENTRY_DBG(mfib_entry, "alloc");
429 
430  return (mfib_entry);
431 }
432 
433 static inline mfib_path_ext_t *
435  fib_node_index_t path_index)
436 {
437  uword *p;
438 
439  p = hash_get(exts, path_index);
440 
441  if (NULL != p)
442  {
443  return (mfib_entry_path_ext_get(p[0]));
444  }
445 
446  return (NULL);
447 }
448 
449 static mfib_path_ext_t*
451  fib_node_index_t path_index,
452  mfib_itf_flags_t mfi_flags)
453 {
454  mfib_path_ext_t *path_ext;
455 
456  pool_get(mfib_path_ext_pool, path_ext);
457 
458  path_ext->mfpe_flags = mfi_flags;
459  path_ext->mfpe_path = path_index;
460 
461  hash_set(msrc->mfes_exts, path_index,
462  path_ext - mfib_path_ext_pool);
463 
464  return (path_ext);
465 }
466 
467 static void
469  fib_node_index_t path_index)
470 {
471  mfib_path_ext_t *path_ext;
472 
473  path_ext = mfib_entry_path_ext_find(msrc->mfes_exts, path_index);
474 
475  hash_unset(msrc->mfes_exts, path_index);
476  pool_put(mfib_path_ext_pool, path_ext);
477 }
478 
480 {
485 
488  fib_node_index_t path_index,
489  void *arg)
490 {
493 
494  ctx = arg;
495 
496  /*
497  * if the path is not resolved, don't include it.
498  */
499  if (!fib_path_is_resolved(path_index))
500  {
502  }
503 
504  /*
505  * If the path is not forwarding to use it
506  */
507  mfib_path_ext_t *path_ext;
508 
509  path_ext = mfib_entry_path_ext_find(ctx->msrc->mfes_exts,
510  path_index);
511 
512  if (NULL != path_ext &&
513  !(path_ext->mfpe_flags & MFIB_ITF_FLAG_FORWARD))
514  {
516  }
517 
518  switch (ctx->fct)
519  {
522  /*
523  * EOS traffic with no label to stack, we need the IP Adj
524  */
525  vec_add2(ctx->next_hops, nh, 1);
526 
527  nh->path_index = path_index;
528  nh->path_weight = fib_path_get_weight(path_index);
529  fib_path_contribute_forwarding(path_index, ctx->fct, &nh->path_dpo);
530  break;
531 
538  ASSERT(0);
539  break;
540  }
541 
543 }
544 
545 static void
547  mfib_entry_src_t *msrc)
548 {
549  dpo_proto_t dp;
550 
551  dp = fib_proto_to_dpo(mfib_entry_get_proto(mfib_entry));
552 
553  /*
554  * unlink the enty from the previous path list.
555  */
556  if (FIB_NODE_INDEX_INVALID != mfib_entry->mfe_pl)
557  {
559  mfib_entry->mfe_sibling);
560  }
561 
562  if (NULL != msrc &&
564  {
566  .next_hops = NULL,
567  .fct = mfib_entry_get_default_chain_type(mfib_entry),
568  .msrc = msrc,
569  };
570 
573  &ctx);
574 
575  if (!(MFIB_ENTRY_FLAG_EXCLUSIVE & mfib_entry->mfe_flags))
576  {
577  if (NULL == ctx.next_hops)
578  {
579  /*
580  * no next-hops, stack directly on the drop
581  */
583  &mfib_entry->mfe_rep,
584  drop_dpo_get(dp));
585  }
586  else
587  {
588  /*
589  * each path contirbutes a next-hop. form a replicate
590  * from those choices.
591  */
592  if (!dpo_id_is_valid(&mfib_entry->mfe_rep) ||
593  dpo_is_drop(&mfib_entry->mfe_rep))
594  {
595  dpo_id_t tmp_dpo = DPO_INVALID;
596 
597  dpo_set(&tmp_dpo,
598  DPO_REPLICATE, dp,
599  replicate_create(0, dp));
600 
602  &mfib_entry->mfe_rep,
603  &tmp_dpo);
604 
605  dpo_reset(&tmp_dpo);
606  }
607  replicate_multipath_update(&mfib_entry->mfe_rep,
608  ctx.next_hops);
609  }
610  }
611  else
612  {
613  /*
614  * for exclusive routes the source provided a replicate DPO
615  * we we stashed inthe special path list with one path
616  * so we can stack directly on that.
617  */
618  ASSERT(1 == vec_len(ctx.next_hops));
619 
621  &mfib_entry->mfe_rep,
622  &ctx.next_hops[0].path_dpo);
623  dpo_reset(&ctx.next_hops[0].path_dpo);
624  vec_free(ctx.next_hops);
625  }
626 
627  /*
628  * link the entry to the path-list.
629  * The entry needs to be a child so that we receive the back-walk
630  * updates to recalculate forwarding.
631  */
632  mfib_entry->mfe_pl = msrc->mfes_pl;
633  mfib_entry->mfe_sibling =
634  fib_path_list_child_add(mfib_entry->mfe_pl,
636  mfib_entry_get_index(mfib_entry));
637  }
638  else
639  {
641  &mfib_entry->mfe_rep,
642  drop_dpo_get(dp));
643  }
644 }
645 
646 static fib_node_index_t
648  const fib_route_path_t *rpath)
649 {
650  fib_node_index_t path_index;
651  fib_route_path_t *rpaths;
652 
654 
655  /*
656  * path-lists require a vector of paths
657  */
658  rpaths = NULL;
659  vec_add1(rpaths, rpath[0]);
660 
661  if (FIB_NODE_INDEX_INVALID == msrc->mfes_pl)
662  {
663  /* A non-shared path-list */
665  NULL);
667  }
668 
669  path_index = fib_path_list_path_add(msrc->mfes_pl, rpaths);
670 
671  vec_free(rpaths);
672 
673  return (path_index);
674 }
675 
676 static fib_node_index_t
678  const fib_route_path_t *rpath)
679 {
680  fib_node_index_t path_index;
681  fib_route_path_t *rpaths;
682 
684 
685  /*
686  * path-lists require a vector of paths
687  */
688  rpaths = NULL;
689  vec_add1(rpaths, rpath[0]);
690 
691  path_index = fib_path_list_path_remove(msrc->mfes_pl, rpaths);
692 
693  vec_free(rpaths);
694 
695  return (path_index);
696 }
697 
698 static void
700 {
701  mfib_entry_src_t *bsrc;
702 
703  /*
704  * copy the forwarding data from the bast source
705  */
706  bsrc = mfib_entry_get_best_src(mfib_entry);
707 
708  if (NULL != bsrc)
709  {
710  mfib_entry->mfe_flags = bsrc->mfes_flags;
711  mfib_entry->mfe_itfs = bsrc->mfes_itfs;
712  mfib_entry->mfe_rpf_id = bsrc->mfes_rpf_id;
713  }
714 
715  mfib_entry_stack(mfib_entry, bsrc);
716 }
717 
718 
721  mfib_source_t source,
722  const mfib_prefix_t *prefix,
723  fib_rpf_id_t rpf_id,
724  mfib_entry_flags_t entry_flags)
725 {
726  fib_node_index_t mfib_entry_index;
727  mfib_entry_t *mfib_entry;
728  mfib_entry_src_t *msrc;
729 
730  mfib_entry = mfib_entry_alloc(fib_index, prefix,
731  &mfib_entry_index);
732  msrc = mfib_entry_src_find_or_create(mfib_entry, source);
733  msrc->mfes_flags = entry_flags;
734  msrc->mfes_rpf_id = rpf_id;
735 
737 
738  return (mfib_entry_index);
739 }
740 
741 static int
743 {
744  return (0 == vec_len(mfib_entry->mfe_srcs));
745 }
746 
747 static int
749 {
750  return ((MFIB_ENTRY_FLAG_NONE == msrc->mfes_flags &&
751  0 == fib_path_list_get_n_paths(msrc->mfes_pl)));
752 }
753 
754 int
756  mfib_source_t source,
757  mfib_entry_flags_t entry_flags,
758  fib_rpf_id_t rpf_id,
759  index_t repi)
760 {
761  mfib_entry_t *mfib_entry;
762  mfib_entry_src_t *msrc;
763 
764  mfib_entry = mfib_entry_get(mfib_entry_index);
765  msrc = mfib_entry_src_find_or_create(mfib_entry, source);
766  msrc->mfes_flags = entry_flags;
767  msrc->mfes_rpf_id = rpf_id;
768 
769  if (INDEX_INVALID != repi)
770  {
771  /*
772  * The source is providing its own replicate DPO.
773  * Create a sepcial path-list to manage it, that way
774  * this entry and the source are equivalent to a normal
775  * entry
776  */
777  fib_node_index_t old_pl_index;
778  dpo_proto_t dp;
779  dpo_id_t dpo = DPO_INVALID;
780 
781  dp = fib_proto_to_dpo(mfib_entry_get_proto(mfib_entry));
782  old_pl_index = msrc->mfes_pl;
783 
784  dpo_set(&dpo, DPO_REPLICATE, dp, repi);
785 
786  msrc->mfes_pl =
789  &dpo);
790 
791  dpo_reset(&dpo);
793  fib_path_list_unlock(old_pl_index);
794  }
795 
797  {
798  /*
799  * this source has no interfaces and no flags.
800  * it has nothing left to give - remove it
801  */
802  mfib_entry_src_remove(mfib_entry, source);
803  }
804 
806 
807  return (mfib_entry_ok_for_delete(mfib_entry));
808 }
809 
810 static void
812  u32 sw_if_index,
813  index_t mi)
814 {
815  hash_set(msrc->mfes_itfs, sw_if_index, mi);
816 }
817 
818 static void
820  u32 sw_if_index)
821 {
822  mfib_itf_t *mfi;
823 
824  mfi = mfib_entry_itf_find(msrc->mfes_itfs, sw_if_index);
825 
826  mfib_itf_delete(mfi);
827 
828  hash_unset(msrc->mfes_itfs, sw_if_index);
829 }
830 
831 void
833  mfib_source_t source,
834  const fib_route_path_t *rpath,
835  mfib_itf_flags_t itf_flags)
836 {
837  fib_node_index_t path_index;
838  mfib_path_ext_t *path_ext;
839  mfib_itf_flags_t old, new;
840  mfib_entry_t *mfib_entry;
841  mfib_entry_src_t *msrc;
842 
843  mfib_entry = mfib_entry_get(mfib_entry_index);
844  ASSERT(NULL != mfib_entry);
845  msrc = mfib_entry_src_find_or_create(mfib_entry, source);
846 
847  /*
848  * add the path to the path-list. If it's a duplicate we'll get
849  * back the original path.
850  */
851  path_index = mfib_entry_src_path_add(msrc, rpath);
852 
853  /*
854  * find the path extension for that path
855  */
856  path_ext = mfib_entry_path_ext_find(msrc->mfes_exts, path_index);
857 
858  if (NULL == path_ext)
859  {
860  old = MFIB_ITF_FLAG_NONE;
861  path_ext = mfib_path_ext_add(msrc, path_index, itf_flags);
862  }
863  else
864  {
865  old = path_ext->mfpe_flags;
866  path_ext->mfpe_flags = itf_flags;
867  }
868 
869  /*
870  * Has the path changed its contribution to the input interface set.
871  * Which only paths with interfaces can do...
872  */
873  if (~0 != rpath[0].frp_sw_if_index)
874  {
875  mfib_itf_t *mfib_itf;
876 
877  new = itf_flags;
878 
879  if (old != new)
880  {
881  if (MFIB_ITF_FLAG_NONE == new)
882  {
883  /*
884  * no more interface flags on this path, remove
885  * from the data-plane set
886  */
887  mfib_entry_itf_remove(msrc, rpath[0].frp_sw_if_index);
888  }
889  else if (MFIB_ITF_FLAG_NONE == old)
890  {
891  /*
892  * This interface is now contributing
893  */
894  mfib_entry_itf_add(msrc,
895  rpath[0].frp_sw_if_index,
896  mfib_itf_create(rpath[0].frp_sw_if_index,
897  itf_flags));
898  }
899  else
900  {
901  /*
902  * change of flag contributions
903  */
904  mfib_itf = mfib_entry_itf_find(msrc->mfes_itfs,
905  rpath[0].frp_sw_if_index);
906  /* Seen by packets inflight */
907  mfib_itf->mfi_flags = new;
908  }
909  }
910  }
911 
913 }
914 
915 /*
916  * mfib_entry_path_remove
917  *
918  * remove a path from the entry.
919  * return the mfib_entry's index if it is still present, INVALID otherwise.
920  */
921 int
923  mfib_source_t source,
924  const fib_route_path_t *rpath)
925 {
926  fib_node_index_t path_index;
927  mfib_entry_t *mfib_entry;
928  mfib_entry_src_t *msrc;
929 
930  mfib_entry = mfib_entry_get(mfib_entry_index);
931  ASSERT(NULL != mfib_entry);
932  msrc = mfib_entry_src_find(mfib_entry, source, NULL);
933 
934  if (NULL == msrc)
935  {
936  /*
937  * there are no paths left for this source
938  */
939  return (mfib_entry_ok_for_delete(mfib_entry));
940  }
941 
942  /*
943  * remove the path from the path-list. If it's not there we'll get
944  * back invalid
945  */
946  path_index = mfib_entry_src_path_remove(msrc, rpath);
947 
948  if (FIB_NODE_INDEX_INVALID != path_index)
949  {
950  /*
951  * don't need the extension, nor the interface anymore
952  */
953  mfib_path_ext_remove(msrc, path_index);
954  if (~0 != rpath[0].frp_sw_if_index)
955  {
956  mfib_entry_itf_remove(msrc, rpath[0].frp_sw_if_index);
957  }
958  }
959 
961  {
962  /*
963  * this source has no interfaces and no flags.
964  * it has nothing left to give - remove it
965  */
966  mfib_entry_src_remove(mfib_entry, source);
967  }
968 
970 
971  return (mfib_entry_ok_for_delete(mfib_entry));
972 }
973 
974 /**
975  * mfib_entry_delete
976  *
977  * The source is withdrawing all the paths it provided
978  */
979 int
981  mfib_source_t source)
982 {
983  mfib_entry_t *mfib_entry;
984 
985  mfib_entry = mfib_entry_get(mfib_entry_index);
986  mfib_entry_src_remove(mfib_entry, source);
987 
989 
990  return (mfib_entry_ok_for_delete(mfib_entry));
991 }
992 
993 static int
995  ip4_address_t * a2)
996 {
997  /*
998  * IP addresses are unsiged ints. the return value here needs to be signed
999  * a simple subtraction won't cut it.
1000  * If the addresses are the same, the sort order is undefiend, so phoey.
1001  */
1002  return ((clib_net_to_host_u32(a1->data_u32) >
1003  clib_net_to_host_u32(a2->data_u32) ) ?
1004  1 : -1);
1005 }
1006 
1007 static int
1009  ip6_address_t * a2)
1010 {
1011  int i;
1012  for (i = 0; i < ARRAY_LEN (a1->as_u16); i++)
1013  {
1014  int cmp = (clib_net_to_host_u16 (a1->as_u16[i]) -
1015  clib_net_to_host_u16 (a2->as_u16[i]));
1016  if (cmp != 0)
1017  return cmp;
1018  }
1019  return 0;
1020 }
1021 
1022 static int
1024  fib_node_index_t mfib_entry_index2)
1025 {
1026  mfib_entry_t *mfib_entry1, *mfib_entry2;
1027  int cmp = 0;
1028 
1029  mfib_entry1 = mfib_entry_get(mfib_entry_index1);
1030  mfib_entry2 = mfib_entry_get(mfib_entry_index2);
1031 
1032  switch (mfib_entry1->mfe_prefix.fp_proto)
1033  {
1034  case FIB_PROTOCOL_IP4:
1035  cmp = fib_ip4_address_compare(&mfib_entry1->mfe_prefix.fp_grp_addr.ip4,
1036  &mfib_entry2->mfe_prefix.fp_grp_addr.ip4);
1037 
1038  if (0 == cmp)
1039  {
1040  cmp = fib_ip4_address_compare(&mfib_entry1->mfe_prefix.fp_src_addr.ip4,
1041  &mfib_entry2->mfe_prefix.fp_src_addr.ip4);
1042  }
1043  break;
1044  case FIB_PROTOCOL_IP6:
1045  cmp = fib_ip6_address_compare(&mfib_entry1->mfe_prefix.fp_grp_addr.ip6,
1046  &mfib_entry2->mfe_prefix.fp_grp_addr.ip6);
1047 
1048  if (0 == cmp)
1049  {
1050  cmp = fib_ip6_address_compare(&mfib_entry1->mfe_prefix.fp_src_addr.ip6,
1051  &mfib_entry2->mfe_prefix.fp_src_addr.ip6);
1052  }
1053  break;
1054  case FIB_PROTOCOL_MPLS:
1055  ASSERT(0);
1056  cmp = 0;
1057  break;
1058  }
1059 
1060  if (0 == cmp) {
1061  cmp = (mfib_entry1->mfe_prefix.fp_len - mfib_entry2->mfe_prefix.fp_len);
1062  }
1063  return (cmp);
1064 }
1065 
1066 int
1067 mfib_entry_cmp_for_sort (void *i1, void *i2)
1068 {
1069  fib_node_index_t *mfib_entry_index1 = i1, *mfib_entry_index2 = i2;
1070 
1071  return (mfib_entry_cmp(*mfib_entry_index1,
1072  *mfib_entry_index2));
1073 }
1074 
1075 static void
1077 {
1078  mfib_entry_t *mfib_entry;
1079  mfib_entry_src_t *msrc;
1080 
1081  mfib_entry = mfib_entry_from_fib_node(node);
1082 
1083  dpo_reset(&mfib_entry->mfe_rep);
1084 
1085  MFIB_ENTRY_DBG(mfib_entry, "last-lock");
1086 
1087  vec_foreach(msrc, mfib_entry->mfe_srcs)
1088  {
1089  mfib_entry_src_flush(msrc);
1090  }
1091 
1092  vec_free(mfib_entry->mfe_srcs);
1093 
1094  fib_node_deinit(&mfib_entry->mfe_node);
1095  pool_put(mfib_entry_pool, mfib_entry);
1096 }
1097 
1098 /*
1099  * mfib_entry_back_walk_notify
1100  *
1101  * A back walk has reach this entry.
1102  */
1106 {
1108 
1109  return (FIB_NODE_BACK_WALK_CONTINUE);
1110 }
1111 
1112 static void
1114 {
1115  fib_show_memory_usage("multicast-Entry",
1116  pool_elts(mfib_entry_pool),
1117  pool_len(mfib_entry_pool),
1118  sizeof(mfib_entry_t));
1119 }
1120 
1121 /*
1122  * The MFIB entry's graph node virtual function table
1123  */
1124 static const fib_node_vft_t mfib_entry_vft = {
1126  .fnv_last_lock = mfib_entry_last_lock_gone,
1127  .fnv_back_walk = mfib_entry_back_walk_notify,
1128  .fnv_mem_show = mfib_entry_show_memory,
1129 };
1130 
1131 void
1133 {
1134  mfib_entry_t *mfib_entry;
1135 
1136  mfib_entry = mfib_entry_get(mfib_entry_index);
1137 
1138  fib_node_lock(&mfib_entry->mfe_node);
1139 }
1140 
1141 void
1143 {
1144  mfib_entry_t *mfib_entry;
1145 
1146  mfib_entry = mfib_entry_get(mfib_entry_index);
1147 
1148  fib_node_unlock(&mfib_entry->mfe_node);
1149 }
1150 
1151 static void
1153 {
1154 }
1155 static void
1157 {
1158 }
1159 
1160 const static dpo_vft_t mfib_entry_dpo_vft = {
1162  .dv_unlock = mfib_entry_dpo_unlock,
1163  .dv_format = format_mfib_entry_dpo,
1164  .dv_mem_show = mfib_entry_show_memory,
1165 };
1166 
1167 const static char* const mfib_entry_ip4_nodes[] =
1168 {
1169  "ip4-mfib-forward-rpf",
1170  NULL,
1171 };
1172 const static char* const mfib_entry_ip6_nodes[] =
1173 {
1174  "ip6-mfib-forward-rpf",
1175  NULL,
1176 };
1177 
1178 const static char* const * const mfib_entry_nodes[DPO_PROTO_NUM] =
1179 {
1182 };
1183 
1184 void
1186 {
1188  dpo_register(DPO_MFIB_ENTRY, &mfib_entry_dpo_vft, mfib_entry_nodes);
1189 }
1190 
1191 void
1193  fib_route_path_encode_t **api_rpaths)
1194 {
1195  mfib_entry_t *mfib_entry;
1196  mfib_entry_src_t *bsrc;
1197 
1198  mfib_entry = mfib_entry_get(mfib_entry_index);
1199  bsrc = mfib_entry_get_best_src(mfib_entry);
1200 
1201  if (FIB_NODE_INDEX_INVALID != bsrc->mfes_pl)
1202  {
1205  api_rpaths);
1206  }
1207 }
1208 
1209 
1210 void
1212  mfib_prefix_t *pfx)
1213 {
1214  mfib_entry_t *mfib_entry;
1215 
1216  mfib_entry = mfib_entry_get(mfib_entry_index);
1217  *pfx = mfib_entry->mfe_prefix;
1218 }
1219 
1220 u32
1222 {
1223  mfib_entry_t *mfib_entry;
1224 
1225  mfib_entry = mfib_entry_get(mfib_entry_index);
1226 
1227  return (mfib_entry->mfe_fib_index);
1228 }
1229 
1230 void
1233  dpo_id_t *dpo)
1234 {
1235  /*
1236  * An IP mFIB entry can only provide a forwarding chain that
1237  * is the same IP proto as the prefix.
1238  * No use-cases (i know of) for other combinations.
1239  */
1240  mfib_entry_t *mfib_entry;
1241  dpo_proto_t dp;
1242 
1243  mfib_entry = mfib_entry_get(mfib_entry_index);
1244 
1245  dp = fib_proto_to_dpo(mfib_entry->mfe_prefix.fp_proto);
1246 
1247  if (type == fib_forw_chain_type_from_dpo_proto(dp))
1248  {
1249  dpo_copy(dpo, &mfib_entry->mfe_rep);
1250  }
1251  else
1252  {
1253  dpo_copy(dpo, drop_dpo_get(dp));
1254  }
1255 }
1256 
1257 u32
1259 {
1260  return (pool_elts(mfib_entry_pool));
1261 }
1262 
1263 static clib_error_t *
1265  unformat_input_t * input,
1266  vlib_cli_command_t * cmd)
1267 {
1268  fib_node_index_t fei;
1269 
1270  if (unformat (input, "%d", &fei))
1271  {
1272  /*
1273  * show one in detail
1274  */
1275  if (!pool_is_free_index(mfib_entry_pool, fei))
1276  {
1277  vlib_cli_output (vm, "%d@%U",
1278  fei,
1279  format_mfib_entry, fei,
1281  }
1282  else
1283  {
1284  vlib_cli_output (vm, "entry %d invalid", fei);
1285  }
1286  }
1287  else
1288  {
1289  /*
1290  * show all
1291  */
1292  vlib_cli_output (vm, "FIB Entries:");
1293  pool_foreach_index(fei, mfib_entry_pool,
1294  ({
1295  vlib_cli_output (vm, "%d@%U",
1296  fei,
1297  format_mfib_entry, fei,
1299  }));
1300  }
1301 
1302  return (NULL);
1303 }
1304 
1305 /*?
1306  * This commnad displays an entry, or all entries, in the mfib tables indexed by their unique
1307  * numerical indentifier.
1308  ?*/
1309 VLIB_CLI_COMMAND (show_mfib_entry, static) = {
1310  .path = "show mfib entry",
1311  .function = show_mfib_entry_command,
1312  .short_help = "show mfib entry",
1313 };
int fib_path_is_resolved(fib_node_index_t path_index)
Definition: fib_path.c:2113
dpo_lock_fn_t dv_lock
A reference counting lock function.
Definition: dpo.h:350
#define MFIB_ENTRY_FORMAT_DETAIL
Definition: mfib_entry.h:88
static void mfib_entry_recalculate_forwarding(mfib_entry_t *mfib_entry)
Definition: mfib_entry.c:699
static const char *const mfib_entry_ip4_nodes[]
Definition: mfib_entry.c:1167
Contribute an object that is to be used to forward IP6 packets.
Definition: fib_types.h:105
ip46_address_t fp_src_addr
Definition: mfib_types.h:47
Contribute an object that is to be used to forward IP6 packets.
Definition: fib_types.h:85
#define hash_set(h, key, value)
Definition: hash.h:254
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:337
static mfib_entry_src_t * mfib_entry_src_find_or_create(mfib_entry_t *mfib_entry, mfib_source_t source)
Definition: mfib_entry.c:302
fib_node_index_t path_index
The index of the FIB path.
Definition: load_balance.h:71
#define CLIB_UNUSED(x)
Definition: clib.h:79
A virtual function table regisitered for a DPO type.
Definition: dpo.h:345
A representation of a fib path for fib_path_encode to convey the information to the caller...
Definition: fib_types.h:404
fib_forward_chain_type_t fct
Definition: mfib_entry.c:482
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:1899
static const char *const *const mfib_entry_nodes[DPO_PROTO_NUM]
Definition: mfib_entry.c:1178
u32 mfib_entry_pool_size(void)
Definition: mfib_entry.c:1258
void fib_path_list_child_remove(fib_node_index_t path_list_index, u32 si)
enum fib_node_type_t_ fib_node_type_t
The types of nodes in a FIB graph.
int mfib_entry_delete(fib_node_index_t mfib_entry_index, mfib_source_t source)
mfib_entry_delete
Definition: mfib_entry.c:980
enum mfib_entry_flags_t_ mfib_entry_flags_t
#define hash_unset(h, key)
Definition: hash.h:260
fib_node_index_t mfib_entry_create(u32 fib_index, mfib_source_t source, const mfib_prefix_t *prefix, fib_rpf_id_t rpf_id, mfib_entry_flags_t entry_flags)
Definition: mfib_entry.c:720
A representation of a path as described by a route producer.
Definition: fib_types.h:336
dpo_id_t path_dpo
ID of the Data-path object.
Definition: load_balance.h:66
void fib_node_init(fib_node_t *node, fib_node_type_t type)
Definition: fib_node.c:183
static int dpo_id_is_valid(const dpo_id_t *dpoi)
Return true if the DPO object is valid, i.e.
Definition: dpo.h:189
void mfib_entry_unlock(fib_node_index_t mfib_entry_index)
Definition: mfib_entry.c:1142
struct mfib_entry_src_t_ * mfe_srcs
A vector of sources contributing forwarding.
Definition: mfib_entry.h:49
#define NULL
Definition: clib.h:55
An entry in a FIB table.
Definition: mfib_entry.h:31
u32 mfe_sibling
The sibling index on the path-list.
Definition: mfib_entry.h:59
enum fib_node_back_walk_rc_t_ fib_node_back_walk_rc_t
Return code from a back walk function.
fib_node_index_t fib_path_list_create_special(dpo_proto_t nh_proto, fib_path_list_flags_t flags, const dpo_id_t *dpo)
#define MFIB_SOURCE_NAMES
Definition: mfib_types.h:175
void dpo_copy(dpo_id_t *dst, const dpo_id_t *src)
atomic copy a data-plane object.
Definition: dpo.c:255
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
static void mfib_entry_dpo_unlock(dpo_id_t *dpo)
Definition: mfib_entry.c:1156
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:518
static fib_node_t * mfib_entry_get_node(fib_node_index_t index)
Definition: mfib_entry.c:114
static void mfib_entry_itf_remove(mfib_entry_src_t *msrc, u32 sw_if_index)
Definition: mfib_entry.c:819
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:557
static fib_node_index_t mfib_entry_get_index(const mfib_entry_t *mfe)
Definition: mfib_entry.h:155
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
void fib_node_deinit(fib_node_t *node)
Definition: fib_node.c:198
u32 mfib_entry_child_add(fib_node_index_t mfib_entry_index, fib_node_type_t child_type, fib_node_index_t child_index)
Definition: mfib_entry.c:381
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
static mfib_path_ext_t * mfib_entry_path_ext_find(mfib_path_ext_t *exts, fib_node_index_t path_index)
Definition: mfib_entry.c:434
static const char *const mfib_entry_ip6_nodes[]
Definition: mfib_entry.c:1172
#define MFIB_ENTRY_FORMAT_BRIEF
Definition: mfib_entry.h:87
mfib_itf_t * mfes_itfs
The hash table of all interfaces.
Definition: mfib_entry.c:95
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:225
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 pool_len(p)
Number of elements in pool vector.
Definition: pool.h:140
fib_forward_chain_type_t mfib_entry_get_default_chain_type(const mfib_entry_t *mfib_entry)
Definition: mfib_entry.c:126
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
static mfib_entry_t * mfib_entry_from_fib_node(fib_node_t *node)
Definition: mfib_entry.c:239
u32 fib_node_child_add(fib_node_type_t parent_type, fib_node_index_t parent_index, fib_node_type_t type, fib_node_index_t index)
Definition: fib_node.c:96
void fib_node_register_type(fib_node_type_t type, const fib_node_vft_t *vft)
fib_node_register_type
Definition: fib_node.c:58
const dpo_id_t * drop_dpo_get(dpo_proto_t proto)
Definition: drop_dpo.c:25
u8 * format_mfib_entry_flags(u8 *s, va_list *args)
Definition: mfib_types.c:85
enum mfib_source_t_ mfib_source_t
Possible [control plane] sources of MFIB entries.
static mfib_entry_t * mfib_entry_alloc(u32 fib_index, const mfib_prefix_t *prefix, fib_node_index_t *mfib_entry_index)
Definition: mfib_entry.c:401
void dpo_register(dpo_type_t type, const dpo_vft_t *vft, const char *const *const *nodes)
For a given DPO type Register:
Definition: dpo.c:303
u32 frp_sw_if_index
The interface.
Definition: fib_types.h:369
#define MFIB_RPF_ID_NONE
Definition: fib_types.h:317
The source of an MFIB entry.
Definition: mfib_entry.c:63
mfib_source_t mfes_src
Which source this is.
Definition: mfib_entry.c:68
#define hash_foreach(key_var, value_var, h, body)
Definition: hash.h:418
load_balance_path_t * next_hops
Definition: mfib_entry.c:481
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static fib_protocol_t mfib_entry_get_proto(const mfib_entry_t *mfib_entry)
Definition: mfib_entry.c:120
mfib_prefix_t mfe_prefix
The prefix of the route.
Definition: mfib_entry.h:40
void fib_show_memory_usage(const char *name, u32 in_use_elts, u32 allocd_elts, size_t size_elt)
Show the memory usage for a type.
Definition: fib_node.c:221
void mfib_entry_module_init(void)
Definition: mfib_entry.c:1185
struct mfib_entry_collect_forwarding_ctx_t_ mfib_entry_collect_forwarding_ctx_t
Contribute an object that is to be used to forward Ethernet packets.
Definition: fib_types.h:109
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
u16 fib_path_get_weight(fib_node_index_t path_index)
Definition: fib_path.c:1772
index_t mfib_itf_create(u32 sw_if_index, mfib_itf_flags_t mfi_flags)
Definition: mfib_itf.c:24
u32 mfib_entry_get_fib_index(fib_node_index_t mfib_entry_index)
Definition: mfib_entry.c:1221
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:150
Contribute an object that is to be used to forward end-of-stack MPLS packets.
Definition: fib_types.h:97
int mfib_entry_update(fib_node_index_t mfib_entry_index, mfib_source_t source, mfib_entry_flags_t entry_flags, fib_rpf_id_t rpf_id, index_t repi)
Definition: mfib_entry.c:755
#define hash_get(h, key)
Definition: hash.h:248
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:458
fib_node_index_t fib_path_list_create(fib_path_list_flags_t flags, const fib_route_path_t *rpaths)
dpo_id_t mfe_rep
The DPO used for forwarding; replicate, drop, etc.
Definition: mfib_entry.h:69
static fib_path_list_walk_rc_t mfib_entry_src_collect_forwarding(fib_node_index_t pl_index, fib_node_index_t path_index, void *arg)
Definition: mfib_entry.c:487
static void mfib_entry_src_flush(mfib_entry_src_t *msrc)
Definition: mfib_entry.c:349
void fib_node_lock(fib_node_t *node)
Definition: fib_node.c:204
static int fib_ip6_address_compare(ip6_address_t *a1, ip6_address_t *a2)
Definition: mfib_entry.c:1008
struct _unformat_input_t unformat_input_t
static fib_node_index_t mfib_entry_src_path_add(mfib_entry_src_t *msrc, const fib_route_path_t *rpath)
Definition: mfib_entry.c:647
int mfib_entry_is_sourced(fib_node_index_t mfib_entry_index, mfib_source_t source)
Definition: mfib_entry.c:338
#define hash_free(h)
Definition: hash.h:286
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:270
fib_node_t mfe_node
Base class.
Definition: mfib_entry.h:36
int mfib_entry_cmp_for_sort(void *i1, void *i2)
Definition: mfib_entry.c:1067
void mfib_entry_path_update(fib_node_index_t mfib_entry_index, mfib_source_t source, const fib_route_path_t *rpath, mfib_itf_flags_t itf_flags)
Definition: mfib_entry.c:832
mfib_entry_t * mfib_entry_pool
Definition: mfib_entry.c:111
#define vec_del1(v, i)
Delete the element at index I.
Definition: vec.h:801
void fib_path_list_lock(fib_node_index_t path_list_index)
static mfib_path_ext_t * mfib_entry_path_ext_get(index_t mi)
Definition: mfib_entry.c:153
fib_rpf_id_t mfes_rpf_id
RPF-ID.
Definition: mfib_entry.c:83
fib_node_type_t fn_type
The node&#39;s type.
Definition: fib_node.h:284
static void mfib_entry_dpo_lock(dpo_id_t *dpo)
Definition: mfib_entry.c:1152
An node in the FIB graph.
Definition: fib_node.h:279
void fib_node_unlock(fib_node_t *node)
Definition: fib_node.c:210
void mfib_entry_lock(fib_node_index_t mfib_entry_index)
Definition: mfib_entry.c:1132
u32 mfe_fib_index
The index of the FIB table this entry is in.
Definition: mfib_entry.h:44
static mfib_entry_t * mfib_entry_get(fib_node_index_t index)
Definition: mfib_entry.h:150
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
Definition: pool.h:188
static mfib_path_ext_t * mfib_path_ext_add(mfib_entry_src_t *msrc, fib_node_index_t path_index, mfib_itf_flags_t mfi_flags)
Definition: mfib_entry.c:450
void replicate_multipath_update(const dpo_id_t *dpo, load_balance_path_t *next_hops)
fib_node_list_t fn_children
Vector of nodes that depend upon/use/share this node.
Definition: fib_node.h:296
static u8 * format_mfib_entry_dpo(u8 *s, va_list *args)
Definition: mfib_entry.c:142
vlib_main_t * vm
Definition: buffer.c:283
static mfib_entry_src_t * mfib_entry_src_find(const mfib_entry_t *mfib_entry, mfib_source_t source, u32 *index)
Definition: mfib_entry.c:273
Contribute an object that is to be used to forward NSH packets.
Definition: fib_types.h:115
u8 * format_mfib_entry(u8 *s, va_list *args)
Definition: mfib_entry.c:171
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:336
static mfib_itf_t * mfib_entry_itf_find(mfib_itf_t *itfs, u32 sw_if_index)
Definition: mfib_entry.h:162
mfib_itf_flags_t mfi_flags
Falags on the entry.
Definition: mfib_itf.h:30
fib_node_get_t fnv_get
Definition: fib_node.h:267
u32 fib_path_list_get_n_paths(fib_node_index_t path_list_index)
fib_node_index_t mfes_pl
The path-list of forwarding interfaces.
Definition: mfib_entry.c:78
mfib_itf_t * mfe_itfs
A hash table of interfaces.
Definition: mfib_entry.h:84
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:28
mfib_entry_flags_t mfe_flags
Route flags.
Definition: mfib_entry.h:74
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:267
#define ARRAY_LEN(x)
Definition: clib.h:59
mfib_path_ext_t * mfes_exts
Hash table of path extensions.
Definition: mfib_entry.c:88
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:179
void fib_path_list_unlock(fib_node_index_t path_list_index)
index_t replicate_create(u32 n_buckets, dpo_proto_t rep_proto)
static void mfib_entry_itf_add(mfib_entry_src_t *msrc, u32 sw_if_index, index_t mi)
Definition: mfib_entry.c:811
void mfib_entry_contribute_forwarding(fib_node_index_t mfib_entry_index, fib_forward_chain_type_t type, dpo_id_t *dpo)
Definition: mfib_entry.c:1231
Aggregrate type for a prefix.
Definition: mfib_types.h:24
Context passed between object during a back walk.
Definition: fib_node.h:192
u32 fib_rpf_id_t
An RPF-ID is numerical value that is used RPF validate.
Definition: fib_types.h:315
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
fib_node_index_t mfe_pl
The path-list of which this entry is a child.
Definition: mfib_entry.h:54
static void mfib_path_ext_remove(mfib_entry_src_t *msrc, fib_node_index_t path_index)
Definition: mfib_entry.c:468
MFIB extensions to each path.
Definition: mfib_entry.c:54
static void mfib_entry_last_lock_gone(fib_node_t *node)
Definition: mfib_entry.c:1076
void mfib_entry_get_prefix(fib_node_index_t mfib_entry_index, mfib_prefix_t *pfx)
Definition: mfib_entry.c:1211
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
static void mfib_entry_stack(mfib_entry_t *mfib_entry, mfib_entry_src_t *msrc)
Definition: mfib_entry.c:546
long ctx[MAX_CONNS]
Definition: main.c:95
fib_path_list_walk_rc_t fib_path_encode(fib_node_index_t path_list_index, fib_node_index_t path_index, void *ctx)
Definition: fib_path.c:2136
mfib_itf_flags_t mfpe_flags
Definition: mfib_entry.c:56
struct mfib_entry_src_t_ mfib_entry_src_t
The source of an MFIB entry.
An interface associated with a particular MFIB entry.
Definition: mfib_itf.h:25
static int mfib_entry_ok_for_delete(mfib_entry_t *mfib_entry)
Definition: mfib_entry.c:742
static u8 * format_mfib_entry_path_ext(u8 *s, va_list *args)
Definition: mfib_entry.c:159
enum fib_forward_chain_type_t_ fib_forward_chain_type_t
FIB output chain type.
u8 * format_fib_forw_chain_type(u8 *s, va_list *args)
Definition: fib_types.c:46
static int mfib_entry_cmp(fib_node_index_t mfib_entry_index1, fib_node_index_t mfib_entry_index2)
Definition: mfib_entry.c:1023
void fib_node_child_remove(fib_node_type_t parent_type, fib_node_index_t parent_index, fib_node_index_t sibling_index)
Definition: fib_node.c:121
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
Definition: fib_types.c:211
fib_rpf_id_t mfe_rpf_id
RPF-ID used when the packets ingress not from an interface.
Definition: mfib_entry.h:79
u8 * format_dpo_id(u8 *s, va_list *args)
Format a DPO_id_t oject
Definition: dpo.c:143
u64 uword
Definition: types.h:112
static clib_error_t * show_mfib_entry_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: mfib_entry.c:1264
void mfib_entry_encode(fib_node_index_t mfib_entry_index, fib_route_path_encode_t **api_rpaths)
Definition: mfib_entry.c:1192
#define MFIB_ENTRY_DBG(_e, _fmt, _args...)
Debug macro.
Definition: mfib_entry.c:48
fib_protocol_t fp_proto
protocol type
Definition: mfib_types.h:33
#define DPO_PROTO_NUM
Definition: dpo.h:69
enum fib_path_list_walk_rc_t_ fib_path_list_walk_rc_t
return code to control pat-hlist walk
#define FIB_NODE_INDEX_INVALID
Definition: fib_types.h:29
fib_node_index_t mfpe_path
Definition: mfib_entry.c:57
#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:76
u32 fn_locks
Number of dependents on this node.
Definition: fib_node.h:302
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:47
static mfib_path_ext_t * mfib_path_ext_pool
Pool of path extensions.
Definition: mfib_entry.c:101
u8 * fib_path_list_format(fib_node_index_t path_list_index, u8 *s)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:956
static int fib_ip4_address_compare(ip4_address_t *a1, ip4_address_t *a2)
Definition: mfib_entry.c:994
u8 * format_mfib_itf_flags(u8 *s, va_list *args)
Definition: mfib_types.c:105
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
Definition: dpo.h:177
One path from an [EU]CMP set that the client wants to add to a load-balance object.
Definition: load_balance.h:62
static mfib_entry_src_t * mfib_entry_get_best_src(const mfib_entry_t *mfib_entry)
Definition: mfib_entry.c:318
enum mfib_itf_flags_t_ mfib_itf_flags_t
Definition: mfib_entry.c:479
fib_node_index_t fib_path_list_path_add(fib_node_index_t path_list_index, const fib_route_path_t *rpaths)
static int mfib_entry_src_ok_for_delete(const mfib_entry_src_t *msrc)
Definition: mfib_entry.c:748
A FIB graph nodes virtual function table.
Definition: fib_node.h:266
static fib_node_index_t mfib_entry_src_path_remove(mfib_entry_src_t *msrc, const fib_route_path_t *rpath)
Definition: mfib_entry.c:677
static const char * mfib_source_names[]
String names for each source.
Definition: mfib_entry.c:106
static void mfib_entry_src_init(mfib_entry_t *mfib_entry, mfib_source_t source)
Definition: mfib_entry.c:257
mfib_entry_flags_t mfes_flags
Route flags.
Definition: mfib_entry.c:73
struct mfib_path_ext_t_ mfib_path_ext_t
MFIB extensions to each path.
static fib_node_back_walk_rc_t mfib_entry_back_walk_notify(fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
Definition: mfib_entry.c:1104
int dpo_is_drop(const dpo_id_t *dpo)
The Drop DPO will drop all packets, no questions asked.
Definition: drop_dpo.c:33
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
Definition: dpo.c:225
#define vec_foreach(var, vec)
Vector iterator.
void mfib_itf_delete(mfib_itf_t *mfi)
Definition: mfib_itf.c:40
static void mfib_entry_show_memory(void)
Definition: mfib_entry.c:1113
u16 as_u16[8]
Definition: ip6_packet.h:49
Contribute an object that is to be used to forward non-end-of-stack MPLS packets. ...
Definition: fib_types.h:90
static void mfib_entry_src_remove(mfib_entry_t *mfib_entry, mfib_source_t source)
Definition: mfib_entry.c:364
#define pool_foreach_index(i, v, body)
Iterate pool by index.
Definition: pool.h:479
#define MFIB_ENTRY_FORMAT_DETAIL2
Definition: mfib_entry.h:89
u16 fp_len
The mask length.
Definition: mfib_types.h:28
u8 * fib_node_children_format(fib_node_list_t list, u8 *s)
Definition: fib_node.c:174
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
void mfib_entry_child_remove(fib_node_index_t mfib_entry_index, u32 sibling_index)
Definition: mfib_entry.c:392
mfib_entry_src_t * msrc
Definition: mfib_entry.c:483
static int mfib_entry_src_cmp_for_sort(void *v1, void *v2)
Definition: mfib_entry.c:248
Contribute an object that is to be used to forward IP4 packets.
Definition: fib_types.h:101
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:680
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:261
u8 * format_mfib_prefix(u8 *s, va_list *args)
Definition: mfib_types.c:30
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
ip46_address_t fp_grp_addr
The address type is not deriveable from the fp_addr member.
Definition: mfib_types.h:46
fib_node_index_t fib_path_list_path_remove(fib_node_index_t path_list_index, const fib_route_path_t *rpaths)
int mfib_entry_path_remove(fib_node_index_t mfib_entry_index, mfib_source_t source, const fib_route_path_t *rpath)
Definition: mfib_entry.c:922
void dpo_stack(dpo_type_t child_type, dpo_proto_t child_proto, dpo_id_t *dpo, const dpo_id_t *parent)
Stack one DPO object on another, and thus establish a child-parent relationship.
Definition: dpo.c:456
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128