FD.io VPP  v17.07-30-g839fa73
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(ip4_fib_get(fib_table->ft_index),
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(mpls_fib_get(fib_table->ft_index),
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:
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(mpls_fib_get(fib_table->ft_index),
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:
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:
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:
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:
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  fib_table_get_less_specific(fib_index,
275  prefix)));
276  case FIB_PROTOCOL_IP6:
277  return (ip6_fib_table_fwding_dpo_remove(fib_index,
278  &prefix->fp_addr.ip6,
279  prefix->fp_len,
280  dpo));
281  case FIB_PROTOCOL_MPLS:
283  prefix->fp_label,
284  prefix->fp_eos));
285  }
286 }
287 
288 
291  const fib_prefix_t *prefix,
292  fib_source_t source,
294  const dpo_id_t *dpo)
295 {
296  fib_node_index_t fib_entry_index;
297  fib_table_t *fib_table;
298 
299  fib_table = fib_table_get(fib_index, prefix->fp_proto);
300  fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
301 
302  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
303  {
304  fib_entry_index = fib_entry_create_special(fib_index, prefix,
305  source, flags,
306  dpo);
307 
308  fib_table_entry_insert(fib_table, prefix, fib_entry_index);
309  fib_table->ft_src_route_counts[source]++;
310  }
311  else
312  {
313  int was_sourced;
314 
315  was_sourced = fib_entry_is_sourced(fib_entry_index, source);
316  fib_entry_special_add(fib_entry_index, source, flags, dpo);
317 
318  if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
319  {
320  fib_table->ft_src_route_counts[source]++;
321  }
322  }
323 
324 
325  return (fib_entry_index);
326 }
327 
330  const fib_prefix_t *prefix,
331  fib_source_t source,
333  const dpo_id_t *dpo)
334 {
335  fib_node_index_t fib_entry_index;
336  fib_table_t *fib_table;
337 
338  fib_table = fib_table_get(fib_index, prefix->fp_proto);
339  fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
340 
341  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
342  {
343  fib_entry_index = fib_entry_create_special(fib_index, prefix,
344  source, flags,
345  dpo);
346 
347  fib_table_entry_insert(fib_table, prefix, fib_entry_index);
348  fib_table->ft_src_route_counts[source]++;
349  }
350  else
351  {
352  int was_sourced;
353 
354  was_sourced = fib_entry_is_sourced(fib_entry_index, source);
355 
356  if (was_sourced)
357  fib_entry_special_update(fib_entry_index, source, flags, dpo);
358  else
359  fib_entry_special_add(fib_entry_index, source, flags, dpo);
360 
361  if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
362  {
363  fib_table->ft_src_route_counts[source]++;
364  }
365  }
366 
367  return (fib_entry_index);
368 }
369 
372  const fib_prefix_t *prefix,
373  fib_source_t source,
375 {
376  fib_node_index_t fib_entry_index;
377  dpo_id_t tmp_dpo = DPO_INVALID;
378 
379  dpo_copy(&tmp_dpo, drop_dpo_get(fib_proto_to_dpo(prefix->fp_proto)));
380 
381  fib_entry_index = fib_table_entry_special_dpo_add(fib_index, prefix, source,
382  flags, &tmp_dpo);
383 
384  dpo_unlock(&tmp_dpo);
385 
386  return (fib_entry_index);
387 }
388 
389 void
391  const fib_prefix_t *prefix,
392  fib_source_t source)
393 {
394  /*
395  * 1 is it present
396  * yes => remove source
397  * 2 - is it still sourced?
398  * no => cover walk
399  */
400  fib_node_index_t fib_entry_index;
401  fib_table_t *fib_table;
402 
403  fib_table = fib_table_get(fib_index, prefix->fp_proto);
404  fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
405 
406  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
407  {
408  /*
409  * removing an etry that does not exist. i'll allow it.
410  */
411  }
412  else
413  {
414  fib_entry_src_flag_t src_flag;
415  int was_sourced;
416 
417  /*
418  * don't nobody go nowhere
419  */
420  fib_entry_lock(fib_entry_index);
421  was_sourced = fib_entry_is_sourced(fib_entry_index, source);
422 
423  src_flag = fib_entry_special_remove(fib_entry_index, source);
424 
425  if (!(FIB_ENTRY_SRC_FLAG_ADDED & src_flag))
426  {
427  /*
428  * last source gone. remove from the table
429  */
430  fib_table_entry_remove(fib_table, prefix, fib_entry_index);
431 
432  /*
433  * now the entry is no longer in the table, we can
434  * inform the entries that it covers to re-calculate their cover
435  */
436  fib_entry_cover_change_notify(fib_entry_index,
438  }
439  /*
440  * else
441  * still has sources, leave it be.
442  */
443  if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
444  {
445  fib_table->ft_src_route_counts[source]--;
446  }
447 
448  fib_entry_unlock(fib_entry_index);
449  }
450 }
451 
452 /**
453  * fib_table_route_path_fixup
454  *
455  * Convert attached hosts to attached next-hops.
456  *
457  * This special case is required because an attached path will link to a
458  * glean, and the FIB entry will have the interface or API/CLI source. When
459  * the ARP/ND process is completes then that source (which will provide a
460  * complete adjacency) will be lower priority and so the FIB entry will
461  * remain linked to a glean and traffic will never reach the hosts. For
462  * an ATTAHCED_HOST path we can link the path directly to the [incomplete]
463  * adjacency.
464  */
465 static void
467  fib_entry_flag_t eflags,
468  fib_route_path_t *path)
469 {
470  /*
471  * not all zeros next hop &&
472  * is recursive path &&
473  * nexthop is same as the route's address
474  */
475  if ((!ip46_address_is_zero(&path->frp_addr)) &&
476  (~0 == path->frp_sw_if_index) &&
477  (0 == ip46_address_cmp(&path->frp_addr, &prefix->fp_addr)))
478  {
479  /* Prefix recurses via itse;f */
481  }
482  if (fib_prefix_is_host(prefix) &&
483  ip46_address_is_zero(&path->frp_addr) &&
484  path->frp_sw_if_index != ~0)
485  {
486  path->frp_addr = prefix->fp_addr;
488  }
489  if (eflags & FIB_ENTRY_FLAG_DROP)
490  {
492  }
493  if (eflags & FIB_ENTRY_FLAG_LOCAL)
494  {
496  }
497  if (eflags & FIB_ENTRY_FLAG_EXCLUSIVE)
498  {
500  }
501 }
502 
505  const fib_prefix_t *prefix,
506  fib_source_t source,
508  fib_protocol_t next_hop_proto,
509  const ip46_address_t *next_hop,
510  u32 next_hop_sw_if_index,
511  u32 next_hop_fib_index,
512  u32 next_hop_weight,
513  mpls_label_t *next_hop_labels,
514  fib_route_path_flags_t path_flags)
515 {
516  fib_route_path_t path = {
517  .frp_proto = next_hop_proto,
518  .frp_addr = (NULL == next_hop? zero_addr : *next_hop),
519  .frp_sw_if_index = next_hop_sw_if_index,
520  .frp_fib_index = next_hop_fib_index,
521  .frp_weight = next_hop_weight,
522  .frp_flags = path_flags,
523  .frp_label_stack = next_hop_labels,
524  };
525  fib_node_index_t fib_entry_index;
526  fib_route_path_t *paths = NULL;
527 
528  vec_add1(paths, path);
529 
530  fib_entry_index = fib_table_entry_path_add2(fib_index, prefix,
531  source, flags, paths);
532 
533  vec_free(paths);
534  return (fib_entry_index);
535 }
536 
539  const fib_prefix_t *prefix,
540  fib_source_t source,
542  fib_route_path_t *rpath)
543 {
544  fib_node_index_t fib_entry_index;
545  fib_table_t *fib_table;
546  u32 ii;
547 
548  fib_table = fib_table_get(fib_index, prefix->fp_proto);
549  fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
550 
551  for (ii = 0; ii < vec_len(rpath); ii++)
552  {
553  fib_table_route_path_fixup(prefix, flags, &rpath[ii]);
554  }
555 
556  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
557  {
558  fib_entry_index = fib_entry_create(fib_index, prefix,
559  source, flags,
560  rpath);
561 
562  fib_table_entry_insert(fib_table, prefix, fib_entry_index);
563  fib_table->ft_src_route_counts[source]++;
564  }
565  else
566  {
567  int was_sourced;
568 
569  was_sourced = fib_entry_is_sourced(fib_entry_index, source);
570  fib_entry_path_add(fib_entry_index, source, flags, rpath);;
571 
572  if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
573  {
574  fib_table->ft_src_route_counts[source]++;
575  }
576  }
577 
578  return (fib_entry_index);
579 }
580 
581 void
583  const fib_prefix_t *prefix,
584  fib_source_t source,
585  fib_route_path_t *rpath)
586 {
587  /*
588  * 1 is it present
589  * yes => remove source
590  * 2 - is it still sourced?
591  * no => cover walk
592  */
593  fib_node_index_t fib_entry_index;
594  fib_table_t *fib_table;
595  u32 ii;
596 
597  fib_table = fib_table_get(fib_index, prefix->fp_proto);
598  fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
599 
600  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
601  {
602  /*
603  * removing an etry that does not exist. i'll allow it.
604  */
605  }
606  else
607  {
608  fib_entry_src_flag_t src_flag;
609  int was_sourced;
610 
611  /*
612  * if it's not sourced, then there's nowt to remove
613  */
614  was_sourced = fib_entry_is_sourced(fib_entry_index, source);
615  if (!was_sourced)
616  {
617  return;
618  }
619 
620  /*
621  * don't nobody go nowhere
622  */
623  fib_entry_lock(fib_entry_index);
624 
625  for (ii = 0; ii < vec_len(rpath); ii++)
626  {
628  prefix,
629  fib_entry_get_flags_for_source(fib_entry_index,
630  source),
631  &rpath[ii]);
632  }
633 
634  src_flag = fib_entry_path_remove(fib_entry_index, source, rpath);
635 
636  if (!(FIB_ENTRY_SRC_FLAG_ADDED & src_flag))
637  {
638  /*
639  * last source gone. remove from the table
640  */
641  fib_table_entry_remove(fib_table, prefix, fib_entry_index);
642 
643  /*
644  * now the entry is no longer in the table, we can
645  * inform the entries that it covers to re-calculate their cover
646  */
647  fib_entry_cover_change_notify(fib_entry_index,
649  }
650  /*
651  * else
652  * still has sources, leave it be.
653  */
654  if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
655  {
656  fib_table->ft_src_route_counts[source]--;
657  }
658 
659  fib_entry_unlock(fib_entry_index);
660  }
661 }
662 
663 void
665  const fib_prefix_t *prefix,
666  fib_source_t source,
667  fib_protocol_t next_hop_proto,
668  const ip46_address_t *next_hop,
669  u32 next_hop_sw_if_index,
670  u32 next_hop_fib_index,
671  u32 next_hop_weight,
672  fib_route_path_flags_t path_flags)
673 {
674  /*
675  * 1 is it present
676  * yes => remove source
677  * 2 - is it still sourced?
678  * no => cover walk
679  */
680  fib_route_path_t path = {
681  .frp_proto = next_hop_proto,
682  .frp_addr = (NULL == next_hop? zero_addr : *next_hop),
683  .frp_sw_if_index = next_hop_sw_if_index,
684  .frp_fib_index = next_hop_fib_index,
685  .frp_weight = next_hop_weight,
686  .frp_flags = path_flags,
687  };
688  fib_route_path_t *paths = NULL;
689 
690  vec_add1(paths, path);
691 
692  fib_table_entry_path_remove2(fib_index, prefix, source, paths);
693 
694  vec_free(paths);
695 }
696 
697 static int
699  void * v2)
700 {
701  return (fib_route_path_cmp(v1, v2));
702 }
703 
706  const fib_prefix_t *prefix,
707  fib_source_t source,
709  fib_route_path_t *paths)
710 {
711  fib_node_index_t fib_entry_index;
712  fib_table_t *fib_table;
713  u32 ii;
714 
715  fib_table = fib_table_get(fib_index, prefix->fp_proto);
716  fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
717 
718  for (ii = 0; ii < vec_len(paths); ii++)
719  {
720  fib_table_route_path_fixup(prefix, flags, &paths[ii]);
721  }
722  /*
723  * sort the paths provided by the control plane. this means
724  * the paths and the extension on the entry will be sorted.
725  */
727 
728  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
729  {
730  fib_entry_index = fib_entry_create(fib_index, prefix,
731  source, flags,
732  paths);
733 
734  fib_table_entry_insert(fib_table, prefix, fib_entry_index);
735  fib_table->ft_src_route_counts[source]++;
736  }
737  else
738  {
739  int was_sourced;
740 
741  was_sourced = fib_entry_is_sourced(fib_entry_index, source);
742  fib_entry_update(fib_entry_index, source, flags, paths);
743 
744  if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
745  {
746  fib_table->ft_src_route_counts[source]++;
747  }
748  }
749 
750  return (fib_entry_index);
751 }
752 
755  const fib_prefix_t *prefix,
756  fib_source_t source,
758  fib_protocol_t next_hop_proto,
759  const ip46_address_t *next_hop,
760  u32 next_hop_sw_if_index,
761  u32 next_hop_fib_index,
762  u32 next_hop_weight,
763  mpls_label_t *next_hop_labels,
764  fib_route_path_flags_t path_flags)
765 {
766  fib_node_index_t fib_entry_index;
767  fib_route_path_t path = {
768  .frp_proto = next_hop_proto,
769  .frp_addr = (NULL == next_hop? zero_addr : *next_hop),
770  .frp_sw_if_index = next_hop_sw_if_index,
771  .frp_fib_index = next_hop_fib_index,
772  .frp_weight = next_hop_weight,
773  .frp_flags = path_flags,
774  .frp_label_stack = next_hop_labels,
775  };
776  fib_route_path_t *paths = NULL;
777 
778  vec_add1(paths, path);
779 
780  fib_entry_index =
781  fib_table_entry_update(fib_index, prefix, source, flags, paths);
782 
783  vec_free(paths);
784 
785  return (fib_entry_index);
786 }
787 
788 static void
790  fib_node_index_t fib_entry_index,
791  const fib_prefix_t *prefix,
792  fib_source_t source)
793 {
794  fib_entry_src_flag_t src_flag;
795  fib_table_t *fib_table;
796  int was_sourced;
797 
798  fib_table = fib_table_get(fib_index, prefix->fp_proto);
799  was_sourced = fib_entry_is_sourced(fib_entry_index, source);
800 
801  /*
802  * don't nobody go nowhere
803  */
804  fib_entry_lock(fib_entry_index);
805 
806  src_flag = fib_entry_delete(fib_entry_index, source);
807 
808  if (!(FIB_ENTRY_SRC_FLAG_ADDED & src_flag))
809  {
810  /*
811  * last source gone. remove from the table
812  */
813  fib_table_entry_remove(fib_table, prefix, fib_entry_index);
814 
815  /*
816  * now the entry is no longer in the table, we can
817  * inform the entries that it covers to re-calculate their cover
818  */
819  fib_entry_cover_change_notify(fib_entry_index,
821  }
822  /*
823  * else
824  * still has sources, leave it be.
825  */
826  if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
827  {
828  fib_table->ft_src_route_counts[source]--;
829  }
830 
831  fib_entry_unlock(fib_entry_index);
832 }
833 
834 void
836  const fib_prefix_t *prefix,
837  fib_source_t source)
838 {
839  fib_node_index_t fib_entry_index;
840 
841  fib_entry_index = fib_table_lookup_exact_match(fib_index, prefix);
842 
843  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
844  {
845  /*
846  * removing an etry that does not exist.
847  * i'll allow it, but i won't like it.
848  */
849  clib_warning("%U not in FIB", format_fib_prefix, prefix);
850  }
851  else
852  {
853  fib_table_entry_delete_i(fib_index, fib_entry_index, prefix, source);
854  }
855 }
856 
857 void
859  fib_source_t source)
860 {
861  fib_prefix_t prefix;
862 
863  fib_entry_get_prefix(fib_entry_index, &prefix);
864 
866  fib_entry_index, &prefix, source);
867 }
868 
871  const fib_prefix_t *prefix,
872  mpls_label_t label)
873 {
874  fib_node_index_t fib_entry_index;
875 
876  fib_entry_index = fib_table_lookup_exact_match(fib_index, prefix);
877 
878  if (FIB_NODE_INDEX_INVALID == fib_entry_index ||
879  !fib_entry_is_sourced(fib_entry_index, FIB_SOURCE_MPLS))
880  {
881  /*
882  * only source the prefix once. this allows the label change
883  * operation to work
884  */
885  fib_entry_index = fib_table_entry_special_dpo_add(fib_index, prefix,
888  NULL);
889  }
890 
891  fib_entry_set_source_data(fib_entry_index, FIB_SOURCE_MPLS, &label);
892 
893  return (fib_entry_index);
894 }
895 
896 void
898  const fib_prefix_t *prefix,
899  mpls_label_t label)
900 {
901  fib_node_index_t fib_entry_index;
902  const void *data;
903  mpls_label_t pl;
904 
905  fib_entry_index = fib_table_lookup_exact_match(fib_index, prefix);
906 
907  if (FIB_NODE_INDEX_INVALID == fib_entry_index)
908  return;
909 
910  data = fib_entry_get_source_data(fib_entry_index, FIB_SOURCE_MPLS);
911 
912  if (NULL == data)
913  return;
914 
915  pl = *(mpls_label_t*)data;
916 
917  if (pl != label)
918  return;
919 
920  pl = MPLS_LABEL_INVALID;
921 
922  fib_entry_set_source_data(fib_entry_index, FIB_SOURCE_MPLS, &pl);
924  prefix,
926 }
927 
928 u32
930  u32 sw_if_index)
931 {
932  switch (proto)
933  {
934  case FIB_PROTOCOL_IP4:
935  return (ip4_fib_table_get_index_for_sw_if_index(sw_if_index));
936  case FIB_PROTOCOL_IP6:
937  return (ip6_fib_table_get_index_for_sw_if_index(sw_if_index));
938  case FIB_PROTOCOL_MPLS:
939  return (mpls_fib_table_get_index_for_sw_if_index(sw_if_index));
940  }
941  return (~0);
942 }
943 
946  fib_protocol_t proto)
947 {
948  fib_table_t *fib;
949 
950  fib = fib_table_get(fib_index, proto);
951 
952  return (fib->ft_flow_hash_config);
953 }
956 {
957  switch (proto)
958  {
959  case FIB_PROTOCOL_IP4:
960  case FIB_PROTOCOL_IP6:
961  return (IP_FLOW_HASH_DEFAULT);
962 
963  case FIB_PROTOCOL_MPLS:
964  return (MPLS_FLOW_HASH_DEFAULT);
965  }
966 
967  ASSERT(0);
968  return (IP_FLOW_HASH_DEFAULT);
969 }
970 
971 /**
972  * @brief Table set flow hash config context.
973  */
975 {
976  /**
977  * the flow hash config to set
978  */
981 
982 static int
984  void *arg)
985 {
987 
988  fib_entry_set_flow_hash_config(fib_entry_index, ctx->hash_config);
989 
990  return (1);
991 }
992 
993 void
995  fib_protocol_t proto,
997 {
1000  };
1001  fib_table_t *fib;
1002 
1003  fib = fib_table_get(fib_index, proto);
1005 
1006  fib_table_walk(fib_index, proto,
1008  &ctx);
1009 }
1010 
1011 u32
1013  u32 sw_if_index)
1014 {
1015  fib_table_t *fib_table;
1016 
1018  proto, sw_if_index),
1019  proto);
1020 
1021  return ((NULL != fib_table ? fib_table->ft_table_id : ~0));
1022 }
1023 
1024 u32
1026  u32 table_id)
1027 {
1028  switch (proto)
1029  {
1030  case FIB_PROTOCOL_IP4:
1031  return (ip4_fib_index_from_table_id(table_id));
1032  case FIB_PROTOCOL_IP6:
1033  return (ip6_fib_index_from_table_id(table_id));
1034  case FIB_PROTOCOL_MPLS:
1035  return (mpls_fib_index_from_table_id(table_id));
1036  }
1037  return (~0);
1038 }
1039 
1040 u32
1042  u32 table_id)
1043 {
1044  fib_table_t *fib_table;
1045  fib_node_index_t fi;
1046 
1047  switch (proto)
1048  {
1049  case FIB_PROTOCOL_IP4:
1051  break;
1052  case FIB_PROTOCOL_IP6:
1054  break;
1055  case FIB_PROTOCOL_MPLS:
1057  break;
1058  default:
1059  return (~0);
1060  }
1061 
1062  fib_table = fib_table_get(fi, proto);
1063 
1064  fib_table->ft_desc = format(NULL, "%U-VRF:%d",
1065  format_fib_protocol, proto,
1066  table_id);
1067 
1068  return (fi);
1069 }
1070 
1071 u32
1073  const char *const fmt,
1074  ...)
1075 {
1076  fib_table_t *fib_table;
1077  fib_node_index_t fi;
1078  va_list ap;
1079 
1080  va_start(ap, fmt);
1081 
1082  switch (proto)
1083  {
1084  case FIB_PROTOCOL_IP4:
1086  break;
1087  case FIB_PROTOCOL_IP6:
1089  break;
1090  case FIB_PROTOCOL_MPLS:
1092  break;
1093  default:
1094  return (~0);
1095  }
1096 
1097  fib_table = fib_table_get(fi, proto);
1098 
1099  fib_table->ft_desc = va_format(fib_table->ft_desc, fmt, &ap);
1100 
1101  va_end(ap);
1102  return (fi);
1103 }
1104 
1105 static void
1107 {
1108  vec_free(fib_table->ft_desc);
1109 
1110  switch (fib_table->ft_proto)
1111  {
1112  case FIB_PROTOCOL_IP4:
1113  ip4_fib_table_destroy(fib_table->ft_index);
1114  break;
1115  case FIB_PROTOCOL_IP6:
1116  ip6_fib_table_destroy(fib_table->ft_index);
1117  break;
1118  case FIB_PROTOCOL_MPLS:
1119  mpls_fib_table_destroy(fib_table->ft_index);
1120  break;
1121  }
1122 }
1123 
1124 void
1125 fib_table_walk (u32 fib_index,
1126  fib_protocol_t proto,
1128  void *ctx)
1129 {
1130  switch (proto)
1131  {
1132  case FIB_PROTOCOL_IP4:
1133  ip4_fib_table_walk(ip4_fib_get(fib_index), fn, ctx);
1134  break;
1135  case FIB_PROTOCOL_IP6:
1136  ip6_fib_table_walk(fib_index, fn, ctx);
1137  break;
1138  case FIB_PROTOCOL_MPLS:
1139  mpls_fib_table_walk(mpls_fib_get(fib_index), fn, ctx);
1140  break;
1141  }
1142 }
1143 
1144 void
1146  fib_protocol_t proto)
1147 {
1148  fib_table_t *fib_table;
1149 
1150  fib_table = fib_table_get(fib_index, proto);
1151  fib_table->ft_locks--;
1152 
1153  if (0 == fib_table->ft_locks)
1154  {
1155  fib_table_destroy(fib_table);
1156  }
1157 }
1158 void
1159 fib_table_lock (u32 fib_index,
1160  fib_protocol_t proto)
1161 {
1162  fib_table_t *fib_table;
1163 
1164  fib_table = fib_table_get(fib_index, proto);
1165  fib_table->ft_locks++;
1166 }
1167 
1168 u32
1170  fib_protocol_t proto,
1171  fib_source_t source)
1172 {
1173  fib_table_t *fib_table;
1174 
1175  fib_table = fib_table_get(fib_index, proto);
1176 
1177  return (fib_table->ft_src_route_counts[source]);
1178 }
1179 
1180 u8*
1181 format_fib_table_name (u8* s, va_list ap)
1182 {
1183  fib_node_index_t fib_index = va_arg(ap, fib_node_index_t);
1184  fib_protocol_t proto = va_arg(ap, int); // int promotion
1185  fib_table_t *fib_table;
1186 
1187  fib_table = fib_table_get(fib_index, proto);
1188 
1189  s = format(s, "%v", fib_table->ft_desc);
1190 
1191  return (s);
1192 }
1193 
1194 /**
1195  * @brief Table flush context. Store the indicies of matching FIB entries
1196  * that need to be removed.
1197  */
1199 {
1200  /**
1201  * The list of entries to flush
1202  */
1204 
1205  /**
1206  * The source we are flushing
1207  */
1210 
1211 static int
1213  void *arg)
1214 {
1215  fib_table_flush_ctx_t *ctx = arg;
1216 
1217  if (fib_entry_is_sourced(fib_entry_index, ctx->ftf_source))
1218  {
1219  vec_add1(ctx->ftf_entries, fib_entry_index);
1220  }
1221  return (1);
1222 }
1223 
1224 
1225 void
1227  fib_protocol_t proto,
1228  fib_source_t source)
1229 {
1230  fib_node_index_t *fib_entry_index;
1231  fib_table_flush_ctx_t ctx = {
1232  .ftf_entries = NULL,
1233  .ftf_source = source,
1234  };
1235 
1236  fib_table_walk(fib_index, proto,
1238  &ctx);
1239 
1240  vec_foreach(fib_entry_index, ctx.ftf_entries)
1241  {
1242  fib_table_entry_delete_index(*fib_entry_index, source);
1243  }
1244 
1245  vec_free(ctx.ftf_entries);
1246 }
void dpo_unlock(dpo_id_t *dpo)
Release a reference counting lock on the DPO.
Definition: dpo.c:292
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:754
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:1072
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:1542
fib_protocol_t frp_proto
The protocol of the address below.
Definition: fib_types.h:341
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:350
void fib_entry_unlock(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1503
fib_protocol_t ft_proto
Which protocol this table serves.
Definition: fib_table.h:34
void ip4_fib_table_fwding_dpo_remove(ip4_fib_t *fib, const ip4_address_t *addr, u32 len, const dpo_id_t *dpo, u32 cover_index)
Definition: ip4_fib.c:376
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:336
int fib_route_path_cmp(const fib_route_path_t *rpath1, const fib_route_path_t *rpath2)
Definition: fib_types.c:188
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:1208
void fib_table_lock(u32 fib_index, fib_protocol_t proto)
Release a reference counting lock on the table.
Definition: fib_table.c:1159
A Drop path - resolve the path on the drop DPO.
Definition: fib_types.h:292
void mpls_fib_table_destroy(u32 fib_index)
Definition: mpls_fib.c:242
void fib_entry_set_flow_hash_config(fib_node_index_t fib_entry_index, flow_hash_config_t hash_config)
Definition: fib_entry.c:1390
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:885
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:822
void fib_entry_get_prefix(fib_node_index_t fib_entry_index, fib_prefix_t *pfx)
Definition: fib_entry.c:1532
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:705
#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:751
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:538
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:929
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:235
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
void ip4_fib_table_destroy(u32 fib_index)
Definition: ip4_fib.c:157
u32 mpls_fib_table_find_or_create_and_lock(u32 table_id)
Definition: mpls_fib.c:223
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:664
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
u8 * va_format(u8 *s, const char *fmt, va_list *va)
Definition: format.c:387
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
#define ip46_address_cmp(ip46_1, ip46_2)
Definition: ip6_packet.h:80
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:897
int fib_prefix_is_host(const fib_prefix_t *prefix)
Return true is the prefix is a host prefix.
Definition: fib_types.c:136
static void vlib_smp_unsafe_warning(void)
Definition: threads.h:191
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:945
static void fib_table_route_path_fixup(const fib_prefix_t *prefix, fib_entry_flag_t eflags, fib_route_path_t *path)
fib_table_route_path_fixup
Definition: fib_table.c:466
const dpo_id_t * drop_dpo_get(dpo_proto_t proto)
Definition: drop_dpo.c:25
flow_hash_config_t fib_table_get_default_flow_hash_config(fib_protocol_t proto)
Get the flow hash configured used by the protocol.
Definition: fib_table.c:955
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: ip4_fib.c:221
fib_node_index_t ip6_fib_table_lookup_exact_match(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:245
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:800
u32 frp_sw_if_index
The interface.
Definition: fib_types.h:369
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:390
u8 * format_fib_prefix(u8 *s, va_list *args)
Definition: fib_types.c:151
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:1226
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:1212
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:201
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:1025
u16 fp_len
The mask length.
Definition: fib_types.h:164
void ip4_fib_table_entry_remove(ip4_fib_t *fib, const ip4_address_t *addr, u32 len)
Definition: ip4_fib.c:341
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:353
Definition: fib_entry.h:233
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:504
static u32 mpls_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: mpls_fib.h:129
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:152
Definition: fib_entry.h:238
void fib_table_unlock(u32 fib_index, fib_protocol_t proto)
Take a reference counting lock on the table.
Definition: fib_table.c:1145
Definition: fib_entry.h:237
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:367
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:158
#define MPLS_FLOW_HASH_DEFAULT
There are no options for controlling the MPLS flow hash.
Definition: mpls_fib.h:39
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:397
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:582
u32 ft_total_route_counts
Total route counters.
Definition: fib_table.h:64
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:1169
u16 ft_locks
number of locks on the table
Definition: fib_table.h:39
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:1070
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:690
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:367
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:455
struct fib_table_t_ * fibs
A pool of all the MPLS FIBs.
Definition: mpls.h:45
void ip6_fib_table_entry_remove(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:284
struct fib_table_set_flow_hash_config_ctx_t_ fib_table_set_flow_hash_config_ctx_t
Table set flow hash config context.
fib_node_index_t ip4_fib_table_lookup(const ip4_fib_t *fib, const ip4_address_t *addr, u32 len)
Definition: ip4_fib.c:288
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:789
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:371
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:311
u32 mpls_fib_table_create_and_lock(void)
Definition: mpls_fib.c:236
fib_node_index_t ft_index
Index into FIB vector.
Definition: fib_table.h:49
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:100
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:329
void ip6_fib_table_destroy(u32 fib_index)
Definition: ip6_fib.c:106
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:870
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:44
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:858
u32 ft_flow_hash_config
flow hash configuration
Definition: fib_table.h:54
static void fib_table_destroy(fib_table_t *fib_table)
Definition: fib_table.c:1106
#define MPLS_LABEL_INVALID
Definition: mpls_types.h:48
#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:835
static ip4_fib_t * ip4_fib_get(u32 index)
Get the FIB at the given index.
Definition: ip4_fib.h:105
void fib_table_set_flow_hash_config(u32 fib_index, fib_protocol_t proto, flow_hash_config_t hash_config)
Set the flow hash configured used by the table.
Definition: fib_table.c:994
u8 * ft_desc
Table description.
Definition: fib_table.h:69
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
Definition: fib_entry.h:236
void fib_entry_cover_change_notify(fib_node_index_t cover_index, fib_node_index_t covered)
flow_hash_config_t hash_config
the flow hash config to set
Definition: fib_table.c:979
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:698
Don&#39;t resolve the path, use the DPO the client provides.
Definition: fib_types.h:296
static u32 ip4_fib_index_from_table_id(u32 table_id)
Definition: ip4_fib.h:135
u32 mpls_fib_index_from_table_id(u32 table_id)
Definition: mpls_fib.c:73
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:402
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:1493
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:290
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:1012
#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:335
unsigned int u32
Definition: types.h:88
static mpls_fib_t * mpls_fib_get(fib_node_index_t index)
Definition: mpls_fib.h:57
ip6_main_t ip6_main
Definition: ip6_forward.c:2926
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:1125
fib_route_path_flags_t frp_flags
flags on the path
Definition: fib_types.h:387
Definition: fib_entry.h:275
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:1041
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
Definition: fib_types.c:211
u32 ft_src_route_counts[FIB_SOURCE_MAX]
Per-source route counters.
Definition: fib_table.h:59
#define IP_FLOW_HASH_DEFAULT
Default: 5-tuple without the "reverse" bit.
Definition: lookup.h:69
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:82
u8 * format_fib_protocol(u8 *s, va_list ap)
Definition: fib_types.c:30
fib_entry_flag_t fib_entry_get_flags_for_source(fib_node_index_t fib_entry_index, fib_source_t source)
u8 * format_fib_table_name(u8 *s, va_list ap)
Format the description/name of the table.
Definition: fib_table.c:1181
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:653
static int fib_table_set_flow_hash_config_cb(fib_node_index_t fib_entry_index, void *arg)
Definition: fib_table.c:983
#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:86
A for-us/local path.
Definition: fib_types.h:284
#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:1203
#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:315
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
Definition: dpo.h:179
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
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:1082
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1168
Table set flow hash config context.
Definition: fib_table.c:974
struct fib_table_t_ * fibs
Vector of FIBs.
Definition: ip4.h:88
#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:199
struct fib_table_flush_ctx_t_ fib_table_flush_ctx_t
Table flush context.
Attached path.
Definition: fib_types.h:288
Table flush context.
Definition: fib_table.c:1198
u32 flags
Definition: vhost-user.h:76
u32 ip4_fib_table_create_and_lock(void)
Definition: ip4_fib.c:215
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:240
#define ip46_address_is_zero(ip46)
Definition: ip6_packet.h:81
struct fib_table_t_ * fibs
Definition: ip6.h:151
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:779
const ip46_address_t zero_addr
Definition: lookup.c:348
fib_entry_src_flag_t fib_entry_special_remove(fib_node_index_t fib_entry_index, fib_source_t source)
Definition: fib_entry.c:982
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