FD.io VPP  v17.04-9-g99c0734
Vector Packet Processing
fib_table.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 #include <vnet/dpo/drop_dpo.h>
18 
19 #include <vnet/fib/fib_table.h>
21 #include <vnet/fib/fib_internal.h>
22 #include <vnet/fib/ip4_fib.h>
23 #include <vnet/fib/ip6_fib.h>
24 #include <vnet/fib/mpls_fib.h>
25 
28  fib_protocol_t proto)
29 {
30  switch (proto)
31  {
32  case FIB_PROTOCOL_IP4:
33  return (pool_elt_at_index(ip4_main.fibs, index));
34  case FIB_PROTOCOL_IP6:
35  return (pool_elt_at_index(ip6_main.fibs, index));
36  case FIB_PROTOCOL_MPLS:
37  return (pool_elt_at_index(mpls_main.fibs, index));
38  }
39  ASSERT(0);
40  return (NULL);
41 }
42 
43 static inline fib_node_index_t
45  const fib_prefix_t *prefix)
46 {
47  switch (prefix->fp_proto)
48  {
49  case FIB_PROTOCOL_IP4:
50  return (ip4_fib_table_lookup(&fib_table->v4,
51  &prefix->fp_addr.ip4,
52  prefix->fp_len));
53  case FIB_PROTOCOL_IP6:
54  return (ip6_fib_table_lookup(fib_table->ft_index,
55  &prefix->fp_addr.ip6,
56  prefix->fp_len));
57  case FIB_PROTOCOL_MPLS:
58  return (mpls_fib_table_lookup(&fib_table->mpls,
59  prefix->fp_label,
60  prefix->fp_eos));
61  }
62  return (FIB_NODE_INDEX_INVALID);
63 }
64 
66 fib_table_lookup (u32 fib_index,
67  const fib_prefix_t *prefix)
68 {
69  return (fib_table_lookup_i(fib_table_get(fib_index, prefix->fp_proto), prefix));
70 }
71 
72 static inline fib_node_index_t
74  const fib_prefix_t *prefix)
75 {
76  switch (prefix->fp_proto)
77  {
78  case FIB_PROTOCOL_IP4:
79  return (ip4_fib_table_lookup_exact_match(&fib_table->v4,
80  &prefix->fp_addr.ip4,
81  prefix->fp_len));
82  case FIB_PROTOCOL_IP6:
83  return (ip6_fib_table_lookup_exact_match(fib_table->ft_index,
84  &prefix->fp_addr.ip6,
85  prefix->fp_len));
86  case FIB_PROTOCOL_MPLS:
87  return (mpls_fib_table_lookup(&fib_table->mpls,
88  prefix->fp_label,
89  prefix->fp_eos));
90  }
91  return (FIB_NODE_INDEX_INVALID);
92 }
93 
96  const fib_prefix_t *prefix)
97 {
99  prefix->fp_proto),
100  prefix));
101 }
102 
103 static fib_node_index_t
105  const fib_prefix_t *prefix)
106 {
107  fib_prefix_t pfx;
108 
109  pfx = *prefix;
110 
111  if (FIB_PROTOCOL_MPLS == pfx.fp_proto)
112  {
113  return (FIB_NODE_INDEX_INVALID);
114  }
115 
116  /*
117  * in the absence of a tree structure for the table that allows for an O(1)
118  * parent get, a cheeky way to find the cover is to LPM for the prefix with
119  * mask-1.
120  * there should always be a cover, though it may be the default route. the
121  * default route's cover is the default route.
122  */
123  if (pfx.fp_len != 0) {
124  pfx.fp_len -= 1;
125  }
126 
127  return (fib_table_lookup_i(fib_table, &pfx));
128 }
129 
132  const fib_prefix_t *prefix)
133 {
135  prefix->fp_proto),
136  prefix));
137 }
138 
139 static void
141  const fib_prefix_t *prefix,
142  fib_node_index_t fib_entry_index)
143 {
145 
146  fib_table->ft_total_route_counts--;
147 
148  switch (prefix->fp_proto)
149  {
150  case FIB_PROTOCOL_IP4:
151  ip4_fib_table_entry_remove(&fib_table->v4,
152  &prefix->fp_addr.ip4,
153  prefix->fp_len);
154  break;
155  case FIB_PROTOCOL_IP6:
157  &prefix->fp_addr.ip6,
158  prefix->fp_len);
159  break;
160  case FIB_PROTOCOL_MPLS:
161  mpls_fib_table_entry_remove(&fib_table->mpls,
162  prefix->fp_label,
163  prefix->fp_eos);
164  break;
165  }
166 
167  fib_entry_unlock(fib_entry_index);
168 }
169 
170 static void
172  const fib_prefix_t *prefix,
173  fib_node_index_t fib_entry_index)
174 {
175  fib_node_index_t fib_entry_cover_index;
176 
177  /*
178  * no cover relationships in the MPLS FIB
179  */
180  if (FIB_PROTOCOL_MPLS == prefix->fp_proto)
181  return;
182 
183  /*
184  * find and inform the covering entry that a new more specific
185  * has been inserted beneath it
186  */
187  fib_entry_cover_index = fib_table_get_less_specific_i(fib_table, prefix);
188  /*
189  * the indicies are the same when the default route is first added
190  */
191  if (fib_entry_cover_index != fib_entry_index)
192  {
193  fib_entry_cover_change_notify(fib_entry_cover_index,
194  fib_entry_index);
195  }
196 }
197 
198 static void
200  const fib_prefix_t *prefix,
201  fib_node_index_t fib_entry_index)
202 {
204 
205  fib_entry_lock(fib_entry_index);
206  fib_table->ft_total_route_counts++;
207 
208  switch (prefix->fp_proto)
209  {
210  case FIB_PROTOCOL_IP4:
211  ip4_fib_table_entry_insert(&fib_table->v4,
212  &prefix->fp_addr.ip4,
213  prefix->fp_len,
214  fib_entry_index);
215  break;
216  case FIB_PROTOCOL_IP6:
218  &prefix->fp_addr.ip6,
219  prefix->fp_len,
220  fib_entry_index);
221  break;
222  case FIB_PROTOCOL_MPLS:
223  mpls_fib_table_entry_insert(&fib_table->mpls,
224  prefix->fp_label,
225  prefix->fp_eos,
226  fib_entry_index);
227  break;
228  }
229 
230  fib_table_post_insert_actions(fib_table, prefix, fib_entry_index);
231 }
232 
233 void
235  const fib_prefix_t *prefix,
236  const dpo_id_t *dpo)
237 {
239 
240  switch (prefix->fp_proto)
241  {
242  case FIB_PROTOCOL_IP4:
243  return (ip4_fib_table_fwding_dpo_update(ip4_fib_get(fib_index),
244  &prefix->fp_addr.ip4,
245  prefix->fp_len,
246  dpo));
247  case FIB_PROTOCOL_IP6:
248  return (ip6_fib_table_fwding_dpo_update(fib_index,
249  &prefix->fp_addr.ip6,
250  prefix->fp_len,
251  dpo));
252  case FIB_PROTOCOL_MPLS:
254  prefix->fp_label,
255  prefix->fp_eos,
256  dpo));
257  }
258 }
259 
260 void
262  const fib_prefix_t *prefix,
263  const dpo_id_t *dpo)
264 {
266 
267  switch (prefix->fp_proto)
268  {
269  case FIB_PROTOCOL_IP4:
270  return (ip4_fib_table_fwding_dpo_remove(ip4_fib_get(fib_index),
271  &prefix->fp_addr.ip4,
272  prefix->fp_len,
273  dpo));
274  case FIB_PROTOCOL_IP6:
275  return (ip6_fib_table_fwding_dpo_remove(fib_index,
276  &prefix->fp_addr.ip6,
277  prefix->fp_len,
278  dpo));
279  case FIB_PROTOCOL_MPLS:
281  prefix->fp_label,
282  prefix->fp_eos));
283  }
284 }
285 
286 
289  const fib_prefix_t *prefix,
290  fib_source_t source,
292  const dpo_id_t *dpo)
293 {
294  fib_node_index_t fib_entry_index;
295  fib_table_t *fib_table;
296 
297  fib_table = fib_table_get(fib_index, prefix->fp_proto);
298  fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
299 
300  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
301  {
302  fib_entry_index = fib_entry_create_special(fib_index, prefix,
303  source, flags,
304  dpo);
305 
306  fib_table_entry_insert(fib_table, prefix, fib_entry_index);
307  fib_table->ft_src_route_counts[source]++;
308  }
309  else
310  {
311  int was_sourced;
312 
313  was_sourced = fib_entry_is_sourced(fib_entry_index, source);
314  fib_entry_special_add(fib_entry_index, source, flags, dpo);
315 
316  if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
317  {
318  fib_table->ft_src_route_counts[source]++;
319  }
320  }
321 
322 
323  return (fib_entry_index);
324 }
325 
328  const fib_prefix_t *prefix,
329  fib_source_t source,
331  const dpo_id_t *dpo)
332 {
333  fib_node_index_t fib_entry_index;
334  fib_table_t *fib_table;
335 
336  fib_table = fib_table_get(fib_index, prefix->fp_proto);
337  fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
338 
339  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
340  {
341  fib_entry_index = fib_entry_create_special(fib_index, prefix,
342  source, flags,
343  dpo);
344 
345  fib_table_entry_insert(fib_table, prefix, fib_entry_index);
346  fib_table->ft_src_route_counts[source]++;
347  }
348  else
349  {
350  int was_sourced;
351 
352  was_sourced = fib_entry_is_sourced(fib_entry_index, source);
353 
354  if (was_sourced)
355  fib_entry_special_update(fib_entry_index, source, flags, dpo);
356  else
357  fib_entry_special_add(fib_entry_index, source, flags, dpo);
358 
359  if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
360  {
361  fib_table->ft_src_route_counts[source]++;
362  }
363  }
364 
365  return (fib_entry_index);
366 }
367 
370  const fib_prefix_t *prefix,
371  fib_source_t source,
373 {
374  fib_node_index_t fib_entry_index;
375  dpo_id_t tmp_dpo = DPO_INVALID;
376 
377  dpo_copy(&tmp_dpo, drop_dpo_get(fib_proto_to_dpo(prefix->fp_proto)));
378 
379  fib_entry_index = fib_table_entry_special_dpo_add(fib_index, prefix, source,
380  flags, &tmp_dpo);
381 
382  dpo_unlock(&tmp_dpo);
383 
384  return (fib_entry_index);
385 }
386 
387 void
389  const fib_prefix_t *prefix,
390  fib_source_t source)
391 {
392  /*
393  * 1 is it present
394  * yes => remove source
395  * 2 - is it still sourced?
396  * no => cover walk
397  */
398  fib_node_index_t fib_entry_index;
399  fib_table_t *fib_table;
400 
401  fib_table = fib_table_get(fib_index, prefix->fp_proto);
402  fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
403 
404  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
405  {
406  /*
407  * removing an etry that does not exist. i'll allow it.
408  */
409  }
410  else
411  {
412  fib_entry_src_flag_t src_flag;
413  int was_sourced;
414 
415  /*
416  * don't nobody go nowhere
417  */
418  fib_entry_lock(fib_entry_index);
419  was_sourced = fib_entry_is_sourced(fib_entry_index, source);
420 
421  src_flag = fib_entry_special_remove(fib_entry_index, source);
422 
423  if (!(FIB_ENTRY_SRC_FLAG_ADDED & src_flag))
424  {
425  /*
426  * last source gone. remove from the table
427  */
428  fib_table_entry_remove(fib_table, prefix, fib_entry_index);
429 
430  /*
431  * now the entry is no longer in the table, we can
432  * inform the entries that it covers to re-calculate their cover
433  */
434  fib_entry_cover_change_notify(fib_entry_index,
436  }
437  /*
438  * else
439  * still has sources, leave it be.
440  */
441  if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
442  {
443  fib_table->ft_src_route_counts[source]--;
444  }
445 
446  fib_entry_unlock(fib_entry_index);
447  }
448 }
449 
450 /**
451  * fib_table_route_path_fixup
452  *
453  * Convert attached hosts to attached next-hops.
454  *
455  * This special case is required because an attached path will link to a
456  * glean, and the FIB entry will have the interface or API/CLI source. When
457  * the ARP/ND process is completes then that source (which will provide a
458  * complete adjacency) will be lower priority and so the FIB entry will
459  * remain linked to a glean and traffic will never reach the hosts. For
460  * an ATTAHCED_HOST path we can link the path directly to the [incomplete]
461  * adjacency.
462  */
463 static void
465  fib_route_path_t *path)
466 {
467  if (fib_prefix_is_host(prefix) &&
468  ip46_address_is_zero(&path->frp_addr) &&
469  path->frp_sw_if_index != ~0)
470  {
471  path->frp_addr = prefix->fp_addr;
473  }
474 }
475 
478  const fib_prefix_t *prefix,
479  fib_source_t source,
481  fib_protocol_t next_hop_proto,
482  const ip46_address_t *next_hop,
483  u32 next_hop_sw_if_index,
484  u32 next_hop_fib_index,
485  u32 next_hop_weight,
486  mpls_label_t *next_hop_labels,
487  fib_route_path_flags_t path_flags)
488 {
489  fib_route_path_t path = {
490  .frp_proto = next_hop_proto,
491  .frp_addr = (NULL == next_hop? zero_addr : *next_hop),
492  .frp_sw_if_index = next_hop_sw_if_index,
493  .frp_fib_index = next_hop_fib_index,
494  .frp_weight = next_hop_weight,
495  .frp_flags = path_flags,
496  .frp_label_stack = next_hop_labels,
497  };
498  fib_node_index_t fib_entry_index;
499  fib_route_path_t *paths = NULL;
500 
501  vec_add1(paths, path);
502 
503  fib_entry_index = fib_table_entry_path_add2(fib_index, prefix,
504  source, flags, paths);
505 
506  vec_free(paths);
507  return (fib_entry_index);
508 }
509 
512  const fib_prefix_t *prefix,
513  fib_source_t source,
515  fib_route_path_t *rpath)
516 {
517  fib_node_index_t fib_entry_index;
518  fib_table_t *fib_table;
519  u32 ii;
520 
521  fib_table = fib_table_get(fib_index, prefix->fp_proto);
522  fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
523 
524  for (ii = 0; ii < vec_len(rpath); ii++)
525  {
526  fib_table_route_path_fixup(prefix, &rpath[ii]);
527  }
528 
529  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
530  {
531  fib_entry_index = fib_entry_create(fib_index, prefix,
532  source, flags,
533  rpath);
534 
535  fib_table_entry_insert(fib_table, prefix, fib_entry_index);
536  fib_table->ft_src_route_counts[source]++;
537  }
538  else
539  {
540  int was_sourced;
541 
542  was_sourced = fib_entry_is_sourced(fib_entry_index, source);
543  fib_entry_path_add(fib_entry_index, source, flags, rpath);;
544 
545  if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
546  {
547  fib_table->ft_src_route_counts[source]++;
548  }
549  }
550 
551  return (fib_entry_index);
552 }
553 
554 void
556  const fib_prefix_t *prefix,
557  fib_source_t source,
558  fib_route_path_t *rpath)
559 {
560  /*
561  * 1 is it present
562  * yes => remove source
563  * 2 - is it still sourced?
564  * no => cover walk
565  */
566  fib_node_index_t fib_entry_index;
567  fib_table_t *fib_table;
568  u32 ii;
569 
570  fib_table = fib_table_get(fib_index, prefix->fp_proto);
571  fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
572 
573  for (ii = 0; ii < vec_len(rpath); ii++)
574  {
575  fib_table_route_path_fixup(prefix, &rpath[ii]);
576  }
577 
578  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
579  {
580  /*
581  * removing an etry that does not exist. i'll allow it.
582  */
583  }
584  else
585  {
586  fib_entry_src_flag_t src_flag;
587  int was_sourced;
588 
589  /*
590  * don't nobody go nowhere
591  */
592  fib_entry_lock(fib_entry_index);
593  was_sourced = fib_entry_is_sourced(fib_entry_index, source);
594 
595  src_flag = fib_entry_path_remove(fib_entry_index, source, rpath);
596 
597  if (!(FIB_ENTRY_SRC_FLAG_ADDED & src_flag))
598  {
599  /*
600  * last source gone. remove from the table
601  */
602  fib_table_entry_remove(fib_table, prefix, fib_entry_index);
603 
604  /*
605  * now the entry is no longer in the table, we can
606  * inform the entries that it covers to re-calculate their cover
607  */
608  fib_entry_cover_change_notify(fib_entry_index,
610  }
611  /*
612  * else
613  * still has sources, leave it be.
614  */
615  if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
616  {
617  fib_table->ft_src_route_counts[source]--;
618  }
619 
620  fib_entry_unlock(fib_entry_index);
621  }
622 }
623 
624 void
626  const fib_prefix_t *prefix,
627  fib_source_t source,
628  fib_protocol_t next_hop_proto,
629  const ip46_address_t *next_hop,
630  u32 next_hop_sw_if_index,
631  u32 next_hop_fib_index,
632  u32 next_hop_weight,
633  fib_route_path_flags_t path_flags)
634 {
635  /*
636  * 1 is it present
637  * yes => remove source
638  * 2 - is it still sourced?
639  * no => cover walk
640  */
641  fib_route_path_t path = {
642  .frp_proto = next_hop_proto,
643  .frp_addr = (NULL == next_hop? zero_addr : *next_hop),
644  .frp_sw_if_index = next_hop_sw_if_index,
645  .frp_fib_index = next_hop_fib_index,
646  .frp_weight = next_hop_weight,
647  .frp_flags = path_flags,
648  };
649  fib_route_path_t *paths = NULL;
650 
651  fib_table_route_path_fixup(prefix, &path);
652  vec_add1(paths, path);
653 
654  fib_table_entry_path_remove2(fib_index, prefix, source, paths);
655 
656  vec_free(paths);
657 }
658 
659 static int
661  void * v2)
662 {
663  return (fib_route_path_cmp(v1, v2));
664 }
665 
668  const fib_prefix_t *prefix,
669  fib_source_t source,
671  fib_route_path_t *paths)
672 {
673  fib_node_index_t fib_entry_index;
674  fib_table_t *fib_table;
675  u32 ii;
676 
677  fib_table = fib_table_get(fib_index, prefix->fp_proto);
678  fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
679 
680  for (ii = 0; ii < vec_len(paths); ii++)
681  {
682  fib_table_route_path_fixup(prefix, &paths[ii]);
683  }
684  /*
685  * sort the paths provided by the control plane. this means
686  * the paths and the extension on the entry will be sorted.
687  */
689 
690  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
691  {
692  fib_entry_index = fib_entry_create(fib_index, prefix,
693  source, flags,
694  paths);
695 
696  fib_table_entry_insert(fib_table, prefix, fib_entry_index);
697  fib_table->ft_src_route_counts[source]++;
698  }
699  else
700  {
701  int was_sourced;
702 
703  was_sourced = fib_entry_is_sourced(fib_entry_index, source);
704  fib_entry_update(fib_entry_index, source, flags, paths);
705 
706  if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
707  {
708  fib_table->ft_src_route_counts[source]++;
709  }
710  }
711 
712  return (fib_entry_index);
713 }
714 
717  const fib_prefix_t *prefix,
718  fib_source_t source,
720  fib_protocol_t next_hop_proto,
721  const ip46_address_t *next_hop,
722  u32 next_hop_sw_if_index,
723  u32 next_hop_fib_index,
724  u32 next_hop_weight,
725  mpls_label_t *next_hop_labels,
726  fib_route_path_flags_t path_flags)
727 {
728  fib_node_index_t fib_entry_index;
729  fib_route_path_t path = {
730  .frp_proto = next_hop_proto,
731  .frp_addr = (NULL == next_hop? zero_addr : *next_hop),
732  .frp_sw_if_index = next_hop_sw_if_index,
733  .frp_fib_index = next_hop_fib_index,
734  .frp_weight = next_hop_weight,
735  .frp_flags = path_flags,
736  .frp_label_stack = next_hop_labels,
737  };
738  fib_route_path_t *paths = NULL;
739 
740  fib_table_route_path_fixup(prefix, &path);
741  vec_add1(paths, path);
742 
743  fib_entry_index =
744  fib_table_entry_update(fib_index, prefix, source, flags, paths);
745 
746  vec_free(paths);
747 
748  return (fib_entry_index);
749 }
750 
751 static void
753  fib_node_index_t fib_entry_index,
754  const fib_prefix_t *prefix,
755  fib_source_t source)
756 {
757  fib_entry_src_flag_t src_flag;
758  fib_table_t *fib_table;
759  int was_sourced;
760 
761  fib_table = fib_table_get(fib_index, prefix->fp_proto);
762  was_sourced = fib_entry_is_sourced(fib_entry_index, source);
763 
764  /*
765  * don't nobody go nowhere
766  */
767  fib_entry_lock(fib_entry_index);
768 
769  src_flag = fib_entry_delete(fib_entry_index, source);
770 
771  if (!(FIB_ENTRY_SRC_FLAG_ADDED & src_flag))
772  {
773  /*
774  * last source gone. remove from the table
775  */
776  fib_table_entry_remove(fib_table, prefix, fib_entry_index);
777 
778  /*
779  * now the entry is no longer in the table, we can
780  * inform the entries that it covers to re-calculate their cover
781  */
782  fib_entry_cover_change_notify(fib_entry_index,
784  }
785  /*
786  * else
787  * still has sources, leave it be.
788  */
789  if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
790  {
791  fib_table->ft_src_route_counts[source]--;
792  }
793 
794  fib_entry_unlock(fib_entry_index);
795 }
796 
797 void
799  const fib_prefix_t *prefix,
800  fib_source_t source)
801 {
802  fib_node_index_t fib_entry_index;
803 
804  fib_entry_index = fib_table_lookup_exact_match(fib_index, prefix);
805 
806  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
807  {
808  /*
809  * removing an etry that does not exist.
810  * i'll allow it, but i won't like it.
811  */
812  clib_warning("%U not in FIB", format_fib_prefix, prefix);
813  }
814  else
815  {
816  fib_table_entry_delete_i(fib_index, fib_entry_index, prefix, source);
817  }
818 }
819 
820 void
822  fib_source_t source)
823 {
824  fib_prefix_t prefix;
825 
826  fib_entry_get_prefix(fib_entry_index, &prefix);
827 
829  fib_entry_index, &prefix, source);
830 }
831 
834  const fib_prefix_t *prefix,
835  mpls_label_t label)
836 {
837  fib_node_index_t fib_entry_index;
838 
839  fib_entry_index = fib_table_lookup_exact_match(fib_index, prefix);
840 
841  if (FIB_NODE_INDEX_INVALID == fib_entry_index ||
842  !fib_entry_is_sourced(fib_entry_index, FIB_SOURCE_MPLS))
843  {
844  /*
845  * only source the prefix once. this allows the label change
846  * operation to work
847  */
848  fib_entry_index = fib_table_entry_special_dpo_add(fib_index, prefix,
851  NULL);
852  }
853 
854  fib_entry_set_source_data(fib_entry_index, FIB_SOURCE_MPLS, &label);
855 
856  return (fib_entry_index);
857 }
858 
859 void
861  const fib_prefix_t *prefix,
862  mpls_label_t label)
863 {
864  fib_node_index_t fib_entry_index;
865  const void *data;
866  mpls_label_t pl;
867 
868  fib_entry_index = fib_table_lookup_exact_match(fib_index, prefix);
869 
870  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
871  return;
872 
873  data = fib_entry_get_source_data(fib_entry_index, FIB_SOURCE_MPLS);
874 
875  if (NULL == data)
876  return;
877 
878  pl = *(mpls_label_t*)data;
879 
880  if (pl != label)
881  return;
882 
883  pl = MPLS_LABEL_INVALID;
884 
885  fib_entry_set_source_data(fib_entry_index, FIB_SOURCE_MPLS, &pl);
887  prefix,
889 }
890 
891 u32
893  u32 sw_if_index)
894 {
895  switch (proto)
896  {
897  case FIB_PROTOCOL_IP4:
898  return (ip4_fib_table_get_index_for_sw_if_index(sw_if_index));
899  case FIB_PROTOCOL_IP6:
900  return (ip6_fib_table_get_index_for_sw_if_index(sw_if_index));
901  case FIB_PROTOCOL_MPLS:
902  return (mpls_fib_table_get_index_for_sw_if_index(sw_if_index));
903  }
904  return (~0);
905 }
906 
909  fib_protocol_t proto)
910 {
911  switch (proto)
912  {
913  case FIB_PROTOCOL_IP4:
914  return (ip4_fib_table_get_flow_hash_config(fib_index));
915  case FIB_PROTOCOL_IP6:
916  return (ip6_fib_table_get_flow_hash_config(fib_index));
917  case FIB_PROTOCOL_MPLS:
918  return (mpls_fib_table_get_flow_hash_config(fib_index));
919  }
920  return (0);
921 }
922 
923 
924 u32
926  u32 sw_if_index)
927 {
928  fib_table_t *fib_table;
929 
931  proto, sw_if_index),
932  proto);
933 
934  return ((NULL != fib_table ? fib_table->ft_table_id : ~0));
935 }
936 
937 u32
939  u32 table_id)
940 {
941  switch (proto)
942  {
943  case FIB_PROTOCOL_IP4:
944  return (ip4_fib_index_from_table_id(table_id));
945  case FIB_PROTOCOL_IP6:
946  return (ip6_fib_index_from_table_id(table_id));
947  case FIB_PROTOCOL_MPLS:
948  return (mpls_fib_index_from_table_id(table_id));
949  }
950  return (~0);
951 }
952 
953 u32
955  u32 table_id)
956 {
957  fib_table_t *fib_table;
958  fib_node_index_t fi;
959 
960  switch (proto)
961  {
962  case FIB_PROTOCOL_IP4:
964  break;
965  case FIB_PROTOCOL_IP6:
967  break;
968  case FIB_PROTOCOL_MPLS:
970  break;
971  default:
972  return (~0);
973  }
974 
975  fib_table = fib_table_get(fi, proto);
976 
977  fib_table->ft_desc = format(NULL, "%U-VRF:%d",
978  format_fib_protocol, proto,
979  table_id);
980 
981  return (fi);
982 }
983 
984 u32
986  const char *const fmt,
987  ...)
988 {
989  fib_table_t *fib_table;
990  fib_node_index_t fi;
991  va_list ap;
992 
993  va_start(ap, fmt);
994 
995  switch (proto)
996  {
997  case FIB_PROTOCOL_IP4:
999  break;
1000  case FIB_PROTOCOL_IP6:
1002  break;
1003  case FIB_PROTOCOL_MPLS:
1005  break;
1006  default:
1007  return (~0);
1008  }
1009 
1010  fib_table = fib_table_get(fi, proto);
1011 
1012  fib_table->ft_desc = va_format(fib_table->ft_desc, fmt, &ap);
1013 
1014  va_end(ap);
1015  return (fi);
1016 }
1017 
1018 static void
1020 {
1021  vec_free(fib_table->ft_desc);
1022 
1023  switch (fib_table->ft_proto)
1024  {
1025  case FIB_PROTOCOL_IP4:
1026  ip4_fib_table_destroy(&fib_table->v4);
1027  break;
1028  case FIB_PROTOCOL_IP6:
1029  ip6_fib_table_destroy(fib_table->ft_index);
1030  break;
1031  case FIB_PROTOCOL_MPLS:
1032  mpls_fib_table_destroy(&fib_table->mpls);
1033  break;
1034  }
1035 }
1036 
1037 void
1038 fib_table_walk (u32 fib_index,
1039  fib_protocol_t proto,
1041  void *ctx)
1042 {
1043  switch (proto)
1044  {
1045  case FIB_PROTOCOL_IP4:
1046  ip4_fib_table_walk(ip4_fib_get(fib_index), fn, ctx);
1047  break;
1048  case FIB_PROTOCOL_IP6:
1049  ip6_fib_table_walk(fib_index, fn, ctx);
1050  break;
1051  case FIB_PROTOCOL_MPLS:
1052  mpls_fib_table_walk(mpls_fib_get(fib_index), fn, ctx);
1053  break;
1054  }
1055 }
1056 
1057 void
1059  fib_protocol_t proto)
1060 {
1061  fib_table_t *fib_table;
1062 
1063  fib_table = fib_table_get(fib_index, proto);
1064  fib_table->ft_locks--;
1065 
1066  if (0 == fib_table->ft_locks)
1067  {
1068  fib_table_destroy(fib_table);
1069  }
1070 }
1071 void
1072 fib_table_lock (u32 fib_index,
1073  fib_protocol_t proto)
1074 {
1075  fib_table_t *fib_table;
1076 
1077  fib_table = fib_table_get(fib_index, proto);
1078  fib_table->ft_locks++;
1079 }
1080 
1081 u32
1083  fib_protocol_t proto,
1084  fib_source_t source)
1085 {
1086  fib_table_t *fib_table;
1087 
1088  fib_table = fib_table_get(fib_index, proto);
1089 
1090  return (fib_table->ft_src_route_counts[source]);
1091 }
1092 
1093 u8*
1094 format_fib_table_name (u8* s, va_list ap)
1095 {
1096  fib_node_index_t fib_index = va_arg(ap, fib_node_index_t);
1097  fib_protocol_t proto = va_arg(ap, int); // int promotion
1098  fib_table_t *fib_table;
1099 
1100  fib_table = fib_table_get(fib_index, proto);
1101 
1102  s = format(s, "%v", fib_table->ft_desc);
1103 
1104  return (s);
1105 }
1106 
1107 /**
1108  * @brief Table flush context. Store the indicies of matching FIB entries
1109  * that need to be removed.
1110  */
1112 {
1113  /**
1114  * The list of entries to flush
1115  */
1117 
1118  /**
1119  * The source we are flushing
1120  */
1123 
1124 static int
1126  void *arg)
1127 {
1128  fib_table_flush_ctx_t *ctx = arg;
1129 
1130  if (fib_entry_is_sourced(fib_entry_index, ctx->ftf_source))
1131  {
1132  vec_add1(ctx->ftf_entries, fib_entry_index);
1133  }
1134  return (1);
1135 }
1136 
1137 
1138 void
1140  fib_protocol_t proto,
1141  fib_source_t source)
1142 {
1143  fib_node_index_t *fib_entry_index;
1144  fib_table_flush_ctx_t ctx = {
1145  .ftf_entries = NULL,
1146  .ftf_source = source,
1147  };
1148 
1149  fib_table_walk(fib_index, proto,
1151  &ctx);
1152 
1153  vec_foreach(fib_entry_index, ctx.ftf_entries)
1154  {
1155  fib_table_entry_delete_index(*fib_entry_index, source);
1156  }
1157 
1158  vec_free(ctx.ftf_entries);
1159 }
void dpo_unlock(dpo_id_t *dpo)
Release a reference counting lock on the DPO.
Definition: dpo.c:281
fib_node_index_t fib_table_entry_update_one_path(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, fib_protocol_t next_hop_proto, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_fib_index, u32 next_hop_weight, mpls_label_t *next_hop_labels, fib_route_path_flags_t path_flags)
Update the entry to have just one path.
Definition: fib_table.c:716
u32 fib_table_create_and_lock(fib_protocol_t proto, const char *const fmt,...)
Create a new table with no table ID.
Definition: fib_table.c:985
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:169
u32 fib_entry_get_fib_index(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1466
fib_protocol_t frp_proto
The protocol of the address below.
Definition: fib_types.h:313
void mpls_fib_table_entry_remove(mpls_fib_t *mf, mpls_label_t label, mpls_eos_bit_t eos)
Definition: mpls_fib.c:305
ip46_address_t frp_addr
The next-hop address.
Definition: fib_types.h:322
void fib_entry_unlock(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1427
fib_protocol_t ft_proto
Which protocol this table serves.
Definition: fib_table.h:46
fib_node_index_t fib_table_lookup_exact_match(u32 fib_index, const fib_prefix_t *prefix)
Perfom an exact match in the non-forwarding table.
Definition: fib_table.c:95
A representation of a path as described by a route producer.
Definition: fib_types.h:308
mpls_fib_t mpls
Definition: fib_table.h:40
int fib_route_path_cmp(const fib_route_path_t *rpath1, const fib_route_path_t *rpath2)
Definition: fib_types.c:187
fib_node_index_t mpls_fib_table_lookup(const mpls_fib_t *mf, mpls_label_t label, mpls_eos_bit_t eos)
Definition: mpls_fib.c:281
fib_source_t ftf_source
The source we are flushing.
Definition: fib_table.c:1121
void fib_table_lock(u32 fib_index, fib_protocol_t proto)
Release a reference counting lock on the table.
Definition: fib_table.c:1072
fib_entry_src_flag_t fib_entry_path_remove(fib_node_index_t fib_entry_index, fib_source_t source, const fib_route_path_t *rpath)
Definition: fib_entry.c:868
void fib_entry_path_add(fib_node_index_t fib_entry_index, fib_source_t source, fib_entry_flag_t flags, const fib_route_path_t *rpath)
Definition: fib_entry.c:805
void fib_entry_get_prefix(fib_node_index_t fib_entry_index, fib_prefix_t *pfx)
Definition: fib_entry.c:1456
fib_node_index_t fib_table_entry_update(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, fib_route_path_t *paths)
Update an entry to have a new set of paths.
Definition: fib_table.c:667
#define NULL
Definition: clib.h:55
int(* fib_table_walk_fn_t)(fib_node_index_t fei, void *ctx)
Call back function when walking entries in a FIB table.
Definition: fib_table.h:733
fib_node_index_t fib_table_entry_path_add2(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, fib_route_path_t *rpath)
Add n paths to an entry (aka route) in the FIB.
Definition: fib_table.c:511
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:892
u32 mpls_label_t
A label value only, i.e.
Definition: packet.h:24
void dpo_copy(dpo_id_t *dst, const dpo_id_t *src)
atomic copy a data-plane object.
Definition: dpo.c:224
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
u32 mpls_fib_table_find_or_create_and_lock(u32 table_id)
Definition: mpls_fib.c:225
static fib_node_index_t fib_table_get_less_specific_i(fib_table_t *fib_table, const fib_prefix_t *prefix)
Definition: fib_table.c:104
void fib_table_entry_path_remove(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_protocol_t next_hop_proto, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_fib_index, u32 next_hop_weight, fib_route_path_flags_t path_flags)
remove one path to an entry (aka route) in the FIB.
Definition: fib_table.c:625
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
u8 * va_format(u8 *s, const char *fmt, va_list *va)
Definition: format.c:386
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 mpls_fib_table_destroy(mpls_fib_t *mf)
Definition: mpls_fib.c:244
void fib_table_entry_local_label_remove(u32 fib_index, const fib_prefix_t *prefix, mpls_label_t label)
remove a MPLS local label for the prefix/route.
Definition: fib_table.c:860
int fib_prefix_is_host(const fib_prefix_t *prefix)
Return true is the prefix is a host prefix.
Definition: fib_types.c:135
static void vlib_smp_unsafe_warning(void)
Definition: threads.h:196
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
void mpls_fib_table_entry_insert(mpls_fib_t *mf, mpls_label_t label, mpls_eos_bit_t eos, fib_node_index_t lfei)
Definition: mpls_fib.c:296
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:908
const dpo_id_t * drop_dpo_get(dpo_proto_t proto)
Definition: drop_dpo.c:25
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: ip4_fib.c:211
fib_node_index_t ip6_fib_table_lookup_exact_match(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:239
static void fib_table_post_insert_actions(fib_table_t *fib_table, const fib_prefix_t *prefix, fib_node_index_t fib_entry_index)
Definition: fib_table.c:171
void fib_entry_special_update(fib_node_index_t fib_entry_index, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Definition: fib_entry.c:783
u32 frp_sw_if_index
The interface.
Definition: fib_types.h:334
static fib_node_index_t fib_table_lookup_exact_match_i(const fib_table_t *fib_table, const fib_prefix_t *prefix)
Definition: fib_table.c:73
void fib_table_entry_special_remove(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Remove a &#39;special&#39; entry from the FIB.
Definition: fib_table.c:388
flow_hash_config_t ip6_fib_table_get_flow_hash_config(u32 fib_index)
Definition: ip6_fib.c:386
u8 * format_fib_prefix(u8 *s, va_list *args)
Definition: fib_types.c:150
void fib_table_flush(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Flush all entries from a table for the source.
Definition: fib_table.c:1139
Aggregrate type for a prefix.
Definition: fib_types.h:160
static int fib_table_flush_cb(fib_node_index_t fib_entry_index, void *arg)
Definition: fib_table.c:1125
enum fib_route_path_flags_t_ fib_route_path_flags_t
Path flags from the control plane.
u32 ip4_fib_table_find_or_create_and_lock(u32 table_id)
Get or create an IPv4 fib.
Definition: ip4_fib.c:191
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:938
u16 fp_len
The mask length.
Definition: fib_types.h:164
void ip4_fib_table_destroy(ip4_fib_t *fib)
Definition: ip4_fib.c:153
void ip4_fib_table_entry_remove(ip4_fib_t *fib, const ip4_address_t *addr, u32 len)
Definition: ip4_fib.c:337
fib_node_index_t fib_table_lookup(u32 fib_index, const fib_prefix_t *prefix)
Perfom a longest prefix match in the non-forwarding table.
Definition: fib_table.c:66
u32 ip6_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: ip6_fib.c:392
Definition: fib_entry.h:227
fib_node_index_t fib_table_entry_path_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, fib_protocol_t next_hop_proto, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_fib_index, u32 next_hop_weight, mpls_label_t *next_hop_labels, fib_route_path_flags_t path_flags)
Add one path to an entry (aka route) in the FIB.
Definition: fib_table.c:477
static u32 mpls_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: mpls_fib.h:102
MPLS label.
Definition: fib_entry.h:98
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:146
void fib_table_unlock(u32 fib_index, fib_protocol_t proto)
Take a reference counting lock on the table.
Definition: fib_table.c:1058
static void fib_table_entry_insert(fib_table_t *fib_table, const fib_prefix_t *prefix, fib_node_index_t fib_entry_index)
Definition: fib_table.c:199
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:397
enum fib_source_t_ fib_source_t
The different sources that can create a route.
void ip6_fib_table_fwding_dpo_update(u32 fib_index, const ip6_address_t *addr, u32 len, const dpo_id_t *dpo)
Definition: ip6_fib.c:406
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:183
void mpls_fib_table_walk(mpls_fib_t *mpls_fib, fib_table_walk_fn_t fn, void *ctx)
Walk all entries in a FIB table N.B: This is NOT safe to deletes.
Definition: mpls_fib.c:347
static u32 ip6_fib_index_from_table_id(u32 table_id)
Definition: ip6_fib.h:122
flow_hash_config_t ip4_fib_table_get_flow_hash_config(u32 fib_index)
Definition: ip4_fib.c:225
void ip6_fib_table_fwding_dpo_remove(u32 fib_index, const ip6_address_t *addr, u32 len, const dpo_id_t *dpo)
Definition: ip6_fib.c:436
void fib_table_entry_path_remove2(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_route_path_t *rpath)
Remove n paths to an entry (aka route) in the FIB.
Definition: fib_table.c:555
u32 ft_total_route_counts
Total route counters.
Definition: fib_table.h:76
u32 fib_table_get_num_entries(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Return the number of entries in the FIB added by a given source.
Definition: fib_table.c:1082
u16 ft_locks
number of locks on the table
Definition: fib_table.h:51
fib_entry_src_flag_t fib_entry_delete(fib_node_index_t fib_entry_index, fib_source_t source)
fib_entry_delete
Definition: fib_entry.c:1053
fib_node_index_t fib_entry_create_special(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Definition: fib_entry.c:673
void ip4_fib_table_fwding_dpo_update(ip4_fib_t *fib, const ip4_address_t *addr, u32 len, const dpo_id_t *dpo)
Definition: ip4_fib.c:363
void ip6_fib_table_walk(u32 fib_index, fib_table_walk_fn_t fn, void *arg)
Walk all entries in a FIB table N.B: This is NOT safe to deletes.
Definition: ip6_fib.c:494
struct fib_table_t_ * fibs
A pool of all the MPLS FIBs.
Definition: mpls.h:68
void ip6_fib_table_entry_remove(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:278
fib_node_index_t ip4_fib_table_lookup(const ip4_fib_t *fib, const ip4_address_t *addr, u32 len)
The IPv4 FIB.
Definition: ip4_fib.c:284
static void fib_table_entry_delete_i(u32 fib_index, fib_node_index_t fib_entry_index, const fib_prefix_t *prefix, fib_source_t source)
Definition: fib_table.c:752
fib_node_index_t fib_table_entry_special_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags)
Add a &#39;special&#39; entry to the FIB.
Definition: fib_table.c:369
void ip4_fib_table_entry_insert(ip4_fib_t *fib, const ip4_address_t *addr, u32 len, fib_node_index_t fib_entry_index)
Definition: ip4_fib.c:307
u32 mpls_fib_table_create_and_lock(void)
Definition: mpls_fib.c:238
fib_node_index_t ft_index
Index into FIB vector.
Definition: fib_table.h:61
static fib_node_index_t fib_table_lookup_i(fib_table_t *fib_table, const fib_prefix_t *prefix)
Definition: fib_table.c:44
int fib_entry_is_sourced(fib_node_index_t fib_entry_index, fib_source_t source)
u32 ip6_fib_table_create_and_lock(void)
Definition: ip6_fib.c:95
fib_node_index_t fib_table_entry_special_dpo_update(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Update a &#39;special&#39; entry to the FIB that links to the DPO passed A special entry is an entry that the...
Definition: fib_table.c:327
void ip6_fib_table_destroy(u32 fib_index)
Definition: ip6_fib.c:101
fib_node_index_t fib_table_entry_local_label_add(u32 fib_index, const fib_prefix_t *prefix, mpls_label_t label)
Add a MPLS local label for the prefix/route.
Definition: fib_table.c:833
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
mpls_main_t mpls_main
Definition: mpls.c:25
u32 ft_table_id
Table ID (hash key) for this FIB.
Definition: fib_table.h:56
void fib_table_entry_delete_index(fib_node_index_t fib_entry_index, fib_source_t source)
Delete a FIB entry.
Definition: fib_table.c:821
static void fib_table_destroy(fib_table_t *fib_table)
Definition: fib_table.c:1019
#define MPLS_LABEL_INVALID
Definition: mpls_types.h:33
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:340
void fib_table_entry_delete(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Delete a FIB entry.
Definition: fib_table.c:798
static ip4_fib_t * ip4_fib_get(u32 index)
Get the FIB at the given index.
Definition: ip4_fib.h:80
static void fib_table_route_path_fixup(const fib_prefix_t *prefix, fib_route_path_t *path)
fib_table_route_path_fixup
Definition: fib_table.c:464
u8 * ft_desc
Table description.
Definition: fib_table.h:81
static void fib_table_entry_remove(fib_table_t *fib_table, const fib_prefix_t *prefix, fib_node_index_t fib_entry_index)
Definition: fib_table.c:140
#define clib_warning(format, args...)
Definition: error.h:59
void fib_entry_cover_change_notify(fib_node_index_t cover_index, fib_node_index_t covered)
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:28
static int fib_route_path_cmp_for_sort(void *v1, void *v2)
Definition: fib_table.c:660
static u32 ip4_fib_index_from_table_id(u32 table_id)
Definition: ip4_fib.h:110
u32 mpls_fib_index_from_table_id(u32 table_id)
Definition: mpls_fib.c:78
void ip4_fib_table_walk(ip4_fib_t *fib, fib_table_walk_fn_t fn, void *ctx)
Walk all entries in a FIB table N.B: This is NOT safe to deletes.
Definition: ip4_fib.c:381
enum fib_entry_flag_t_ fib_entry_flag_t
mpls_label_t fp_label
Definition: fib_types.h:186
void fib_entry_lock(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1417
fib_node_index_t fib_table_entry_special_dpo_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Add a &#39;special&#39; entry to the FIB that links to the DPO passed A special entry is an entry that the FI...
Definition: fib_table.c:288
u32 fib_table_get_table_id_for_sw_if_index(fib_protocol_t proto, u32 sw_if_index)
Get the Table-ID of the FIB bound to the interface.
Definition: fib_table.c:925
#define ASSERT(truth)
const void * fib_entry_get_source_data(fib_node_index_t fib_entry_index, fib_source_t source)
void mpls_fib_forwarding_table_reset(mpls_fib_t *mf, mpls_label_t label, mpls_eos_bit_t eos)
Definition: mpls_fib.c:328
unsigned int u32
Definition: types.h:88
static mpls_fib_t * mpls_fib_get(fib_node_index_t index)
Definition: mpls_fib.h:29
ip6_main_t ip6_main
Definition: ip6_forward.c:2846
void fib_table_walk(u32 fib_index, fib_protocol_t proto, fib_table_walk_fn_t fn, void *ctx)
Walk all entries in a FIB table N.B: This is NOT safe to deletes.
Definition: fib_table.c:1038
fib_route_path_flags_t frp_flags
flags on the path
Definition: fib_types.h:347
Definition: fib_entry.h:268
u32 fib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:954
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
Definition: fib_types.c:220
u32 ft_src_route_counts[FIB_SOURCE_MAX]
Per-source route counters.
Definition: fib_table.h:71
void mpls_fib_forwarding_table_update(mpls_fib_t *mf, mpls_label_t label, mpls_eos_bit_t eos, const dpo_id_t *dpo)
Definition: mpls_fib.c:313
enum fib_entry_src_flag_t_ fib_entry_src_flag_t
u32 flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
Definition: lookup.h:165
u8 * format_fib_protocol(u8 *s, va_list ap)
Definition: fib_types.c:30
u8 * format_fib_table_name(u8 *s, va_list ap)
Format the description/name of the table.
Definition: fib_table.c:1094
fib_node_index_t fib_entry_create(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, const fib_route_path_t *paths)
Definition: fib_entry.c:636
#define FIB_NODE_INDEX_INVALID
Definition: fib_types.h:29
u32 ip6_fib_table_find_or_create_and_lock(u32 table_id)
Get or create an IPv6 fib.
Definition: ip6_fib.c:81
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
fib_node_index_t * ftf_entries
The list of entries to flush.
Definition: fib_table.c:1116
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:960
void ip6_fib_table_entry_insert(u32 fib_index, const ip6_address_t *addr, u32 len, fib_node_index_t fib_entry_index)
Definition: ip6_fib.c:309
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
Definition: dpo.h:173
fib_table_t * fib_table_get(fib_node_index_t index, fib_protocol_t proto)
Get a pointer to a FIB table.
Definition: fib_table.c:27
ip4_fib_t v4
Definition: fib_table.h:38
void fib_entry_update(fib_node_index_t fib_entry_index, fib_source_t source, fib_entry_flag_t flags, const fib_route_path_t *paths)
fib_entry_update
Definition: fib_entry.c:1065
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1117
struct fib_table_t_ * fibs
Vector of FIBs.
Definition: ip4.h:112
#define vec_foreach(var, vec)
Vector iterator.
fib_node_index_t ip6_fib_table_lookup(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:193
struct fib_table_flush_ctx_t_ fib_table_flush_ctx_t
Table flush context.
void ip4_fib_table_fwding_dpo_remove(ip4_fib_t *fib, const ip4_address_t *addr, u32 len, const dpo_id_t *dpo)
Definition: ip4_fib.c:372
Attached path.
Definition: fib_types.h:288
Table flush context.
Definition: fib_table.c:1111
u32 flags
Definition: vhost-user.h:78
u32 ip4_fib_table_create_and_lock(void)
Definition: ip4_fib.c:205
fib_node_index_t ip4_fib_table_lookup_exact_match(const ip4_fib_t *fib, const ip4_address_t *addr, u32 len)
Definition: ip4_fib.c:236
#define ip46_address_is_zero(ip46)
Definition: ip6_packet.h:81
struct fib_table_t_ * fibs
Definition: ip6.h:154
void fib_entry_set_source_data(fib_node_index_t fib_entry_index, fib_source_t source, const void *data)
void fib_entry_special_add(fib_node_index_t fib_entry_index, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Definition: fib_entry.c:762
const ip46_address_t zero_addr
Definition: lookup.c:354
fib_entry_src_flag_t fib_entry_special_remove(fib_node_index_t fib_entry_index, fib_source_t source)
Definition: fib_entry.c:965
flow_hash_config_t mpls_fib_table_get_flow_hash_config(u32 fib_index)
Definition: mpls_fib.c:340
A protocol Independent FIB table.
Definition: fib_table.h:29
fib_node_index_t fib_table_get_less_specific(u32 fib_index, const fib_prefix_t *prefix)
Get the less specific (covering) prefix.
Definition: fib_table.c:131
mpls_eos_bit_t fp_eos
Definition: fib_types.h:187