FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
ip4_fib.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <vnet/fib/fib_table.h>
17 #include <vnet/fib/fib_entry.h>
18 #include <vnet/fib/ip4_fib.h>
19 
20 /*
21  * A table of prefixes to be added to tables and the sources for them
22  */
28 
30  {
31  /* 0.0.0.0/0*/
32  .ift_prefix = {
33  .fp_addr = {
34  .ip4.data_u32 = 0,
35  },
36  .fp_len = 0,
37  .fp_proto = FIB_PROTOCOL_IP4,
38  },
39  .ift_source = FIB_SOURCE_DEFAULT_ROUTE,
40  .ift_flag = FIB_ENTRY_FLAG_DROP,
41  },
42  {
43  /* 0.0.0.0/32*/
44  .ift_prefix = {
45  .fp_addr = {
46  .ip4.data_u32 = 0,
47  },
48  .fp_len = 32,
49  .fp_proto = FIB_PROTOCOL_IP4,
50  },
51  .ift_source = FIB_SOURCE_DEFAULT_ROUTE,
52  .ift_flag = FIB_ENTRY_FLAG_DROP,
53  },
54  {
55  /*
56  * 240.0.0.0/4
57  * drop class E
58  */
59  .ift_prefix = {
60  .fp_addr = {
61  .ip4.data_u32 = 0xf0000000,
62  },
63  .fp_len = 4,
64  .fp_proto = FIB_PROTOCOL_IP4,
65  },
66  .ift_source = FIB_SOURCE_SPECIAL,
67  .ift_flag = FIB_ENTRY_FLAG_DROP,
68 
69  },
70  {
71  /*
72  * 224.0.0.0/4
73  * drop all mcast
74  */
75  .ift_prefix = {
76  .fp_addr = {
77  .ip4.data_u32 = 0xe0000000,
78  },
79  .fp_len = 4,
80  .fp_proto = FIB_PROTOCOL_IP4,
81  },
82  .ift_source = FIB_SOURCE_SPECIAL,
83  .ift_flag = FIB_ENTRY_FLAG_DROP,
84  },
85  {
86  /*
87  * 255.255.255.255/32
88  * drop, but we'll allow it to be usurped by the likes of DHCP
89  */
90  .ift_prefix = {
91  .fp_addr = {
92  .ip4.data_u32 = 0xffffffff,
93  },
94  .fp_len = 32,
95  .fp_proto = FIB_PROTOCOL_IP4,
96  },
97  .ift_source = FIB_SOURCE_DEFAULT_ROUTE,
98  .ift_flag = FIB_ENTRY_FLAG_DROP,
99  }
100 };
101 
102 void
104 {
105  /*
106  * add the special entries into the new FIB
107  */
108  int ii;
109 
110  for (ii = 0; ii < ARRAY_LEN(ip4_specials); ii++)
111  {
113 
114  prefix.fp_addr.ip4.data_u32 =
115  clib_host_to_net_u32(prefix.fp_addr.ip4.data_u32);
116 
117  fib_table_entry_special_add(fib_index,
118  &prefix,
119  ip4_specials[ii].ift_source,
120  ip4_specials[ii].ift_flag);
121  }
122 }
123 
124 void
126 {
127  int ii;
128 
129  /*
130  * remove all the specials we added when the table was created.
131  * In reverse order so the default route is last.
132  */
133  for (ii = ARRAY_LEN(ip4_specials) - 1; ii >= 0; ii--)
134  {
136 
137  prefix.fp_addr.ip4.data_u32 =
138  clib_host_to_net_u32(prefix.fp_addr.ip4.data_u32);
139 
141  &prefix,
142  ip4_specials[ii].ift_source);
143  }
144 }
145 
146 static u32
149 {
150  fib_table_t *fib_table;
151  ip4_fib_t *v4_fib;
152 
153  pool_get(ip4_main.fibs, fib_table);
154  clib_memset(fib_table, 0, sizeof(*fib_table));
155 
157 
158  fib_table->ft_proto = FIB_PROTOCOL_IP4;
159  fib_table->ft_index = (v4_fib - ip4_fibs);
160 
161  /*
162  * It is required that the index of the fib_table_t in its pool
163  * is the same as the index of the ip4_fib_t in its pool, since the
164  * rest of the code usues the 'fib_index' to mean either of these
165  * objects, depending on the context.
166  */
167  ASSERT(fib_table->ft_index == fib_table - ip4_main.fibs);
168 
170 
171  fib_table->ft_table_id =
172  v4_fib->hash.table_id =
173  table_id;
175 
177 
178  ip4_fib_table_init(v4_fib);
179 
180  /*
181  * add the special entries into the new FIB
182  */
184 
185  return (fib_table->ft_index);
186 }
187 
188 void
190 {
191  fib_table_t *fib_table = pool_elt_at_index(ip4_main.fibs, fib_index);
192  ip4_fib_t *v4_fib = pool_elt_at_index(ip4_fibs, fib_table->ft_index);
193  u32 *n_locks;
194 
195  /*
196  * remove all the specials we added when the table was created.
197  * In reverse order so the default route is last.
198  */
200 
201  /*
202  * validate no more routes.
203  */
204 #if CLIB_DEBUG > 0
205  if (0 != fib_table->ft_total_route_counts)
206  fib_table_assert_empty(fib_table);
207 #endif
208 
209  vec_foreach(n_locks, fib_table->ft_src_route_counts)
210  {
211  ASSERT(0 == *n_locks);
212  }
213 
214  if (~0 != fib_table->ft_table_id)
215  {
217  }
218 
219  vec_free(fib_table->ft_src_route_counts);
220  ip4_fib_table_free(v4_fib);
221 
222  pool_put(ip4_fibs, v4_fib);
223  pool_put(ip4_main.fibs, fib_table);
224 }
225 
226 
227 u32
230 {
231  u32 index;
232 
234  if (~0 == index)
236 
238 
239  return (index);
240 }
241 
242 u32
244 {
245  return (ip4_create_fib_with_table_id(~0, src));
246 }
247 
248 u32
250 {
252  {
253  /*
254  * This is the case for interfaces that are not yet mapped to
255  * a IP table
256  */
257  return (~0);
258  }
260 }
261 
262 
263 /**
264  * Walk show context
265  */
267 {
270 
271 static fib_table_walk_rc_t
273  void *arg)
274 {
276 
277  vec_add1(ctx->ifsw_indicies, fib_entry_index);
278 
279  return (FIB_TABLE_WALK_CONTINUE);
280 }
281 
282 static void
284  vlib_main_t * vm)
285 {
287  .ifsw_indicies = NULL,
288  };
289  fib_node_index_t *fib_entry_index;
290 
292  vec_sort_with_function(ctx.ifsw_indicies,
294 
295  vec_foreach(fib_entry_index, ctx.ifsw_indicies)
296  {
297  vlib_cli_output(vm, "%U",
299  *fib_entry_index,
301  }
302 
303  vec_free(ctx.ifsw_indicies);
304 }
305 
306 static void
308  vlib_main_t * vm,
310  u32 mask_len,
311  int detail)
312 {
313  vlib_cli_output(vm, "%U",
315  ip4_fib_table_lookup(fib, address, mask_len),
316  (detail ?
319 }
320 
321 u8 *
322 format_ip4_fib_table_memory (u8 * s, va_list * args)
323 {
324  s = format(s, "%=30s %=6d\n",
325  "IPv4 unicast",
327  return (s);
328 }
329 
330 static clib_error_t *
332  unformat_input_t * input,
333  vlib_cli_command_t * cmd)
334 {
335  ip4_main_t * im4 = &ip4_main;
336  u64 total_mtrie_memory, total_hash_memory;
337  int verbose, matching, mtrie, memory;
338  ip4_address_t matching_address;
339  u32 fib_index, matching_mask = 32;
340  int i, table_id = -1, user_fib_index = ~0;
341  int detail = 0;
342 
343  verbose = 1;
344  matching = mtrie = memory = 0;
345  total_hash_memory = total_mtrie_memory = 0;
346 
348  {
349  if (unformat (input, "brief") || unformat (input, "summary")
350  || unformat (input, "sum"))
351  verbose = 0;
352 
353  else if (unformat (input, "detail") || unformat (input, "det"))
354  detail = 1;
355 
356  else if (unformat (input, "mtrie"))
357  mtrie = 1;
358 
359  else if (unformat (input, "mem") ||
360  unformat (input, "memory"))
361  memory = 1;
362 
363  else if (unformat (input, "%U/%d",
364  unformat_ip4_address, &matching_address, &matching_mask))
365  matching = 1;
366 
367  else if (unformat (input, "%U", unformat_ip4_address, &matching_address))
368  matching = 1;
369 
370  else if (unformat (input, "table %d", &table_id))
371  ;
372  else if (unformat (input, "index %d", &user_fib_index))
373  ;
374  else
375  break;
376  }
377 
378  pool_foreach_index (fib_index, im4->fibs)
379  {
380  fib_table_t *fib_table = pool_elt_at_index(im4->fibs, fib_index);
381  ip4_fib_t *fib = pool_elt_at_index(ip4_fibs, fib_table->ft_index);
382  fib_source_t source;
383  u8 *s = NULL;
384 
385  if (table_id >= 0 && table_id != (int)fib->hash.table_id)
386  continue;
387  if (user_fib_index != ~0 && user_fib_index != fib_index)
388  continue;
389 
390  if (memory)
391  {
392  uword mtrie_size, hash_size;
393 
394 
395  mtrie_size = ip4_mtrie_memory_usage(&fib->mtrie);
396  hash_size = 0;
397 
398  for (i = 0; i < ARRAY_LEN (fib->hash.fib_entry_by_dst_address); i++)
399  {
400  uword * hash = fib->hash.fib_entry_by_dst_address[i];
401  if (NULL != hash)
402  {
403  hash_size += hash_bytes(hash);
404  }
405  }
406 
407  if (verbose)
408  vlib_cli_output (vm, "%U mtrie:%d hash:%d",
409  format_fib_table_name, fib_index,
411  mtrie_size,
412  hash_size);
413  total_mtrie_memory += mtrie_size;
414  total_hash_memory += hash_size;
415  continue;
416  }
417 
418  s = format(s, "%U, fib_index:%d, flow hash:[%U] epoch:%d flags:%U locks:[",
419  format_fib_table_name, fib_index,
421  fib_index,
423  fib_table->ft_flow_hash_config,
424  fib_table->ft_epoch,
425  format_fib_table_flags, fib_table->ft_flags);
426  vec_foreach_index(source, fib_table->ft_locks)
427  {
428  if (0 != fib_table->ft_locks[source])
429  {
430  s = format(s, "%U:%d, ",
431  format_fib_source, source,
432  fib_table->ft_locks[source]);
433  }
434  }
435  s = format (s, "]");
436  vlib_cli_output (vm, "%v", s);
437  vec_free(s);
438 
439  /* Show summary? */
440  if (mtrie)
441  {
442  vlib_cli_output (vm, "%U", format_ip4_mtrie, &fib->mtrie, verbose);
443  continue;
444  }
445  if (! verbose)
446  {
447  vlib_cli_output (vm, "%=20s%=16s", "Prefix length", "Count");
448  for (i = 0; i < ARRAY_LEN (fib->hash.fib_entry_by_dst_address); i++)
449  {
450  uword * hash = fib->hash.fib_entry_by_dst_address[i];
451  uword n_elts = hash_elts (hash);
452  if (n_elts > 0)
453  vlib_cli_output (vm, "%20d%16d", i, n_elts);
454  }
455  continue;
456  }
457 
458  if (!matching)
459  {
461  }
462  else
463  {
464  ip4_fib_table_show_one(fib, vm, &matching_address,
465  matching_mask, detail);
466  }
467  }
468 
469  if (memory)
470  {
471  vlib_cli_output (vm, "totals: mtrie:%ld hash:%ld all:%ld",
472  total_mtrie_memory,
473  total_hash_memory,
474  total_mtrie_memory + total_hash_memory);
475  }
476  return 0;
477 }
478 
479 /*?
480  * This command displays the IPv4 FIB Tables (VRF Tables) and the route
481  * entries for each table.
482  *
483  * @note This command will run for a long time when the FIB tables are
484  * comprised of millions of entries. For those senarios, consider displaying
485  * a single table or summary mode.
486  *
487  * @cliexpar
488  * Example of how to display all the IPv4 FIB tables:
489  * @cliexstart{show ip fib}
490  * ipv4-VRF:0, fib_index 0, flow hash: src dst sport dport proto
491  * 0.0.0.0/0
492  * unicast-ip4-chain
493  * [@0]: dpo-load-balance: [index:0 buckets:1 uRPF:0 to:[0:0]]
494  * [0] [@0]: dpo-drop ip6
495  * 0.0.0.0/32
496  * unicast-ip4-chain
497  * [@0]: dpo-load-balance: [index:1 buckets:1 uRPF:1 to:[0:0]]
498  * [0] [@0]: dpo-drop ip6
499  * 6.0.1.2/32
500  * unicast-ip4-chain
501  * [@0]: dpo-load-balance: [index:30 buckets:1 uRPF:29 to:[0:0]]
502  * [0] [@3]: arp-ipv4: via 6.0.0.1 af_packet0
503  * 7.0.0.1/32
504  * unicast-ip4-chain
505  * [@0]: dpo-load-balance: [index:31 buckets:4 uRPF:30 to:[0:0]]
506  * [0] [@3]: arp-ipv4: via 6.0.0.2 af_packet0
507  * [1] [@3]: arp-ipv4: via 6.0.0.2 af_packet0
508  * [2] [@3]: arp-ipv4: via 6.0.0.2 af_packet0
509  * [3] [@3]: arp-ipv4: via 6.0.0.1 af_packet0
510  * 224.0.0.0/8
511  * unicast-ip4-chain
512  * [@0]: dpo-load-balance: [index:3 buckets:1 uRPF:3 to:[0:0]]
513  * [0] [@0]: dpo-drop ip6
514  * 240.0.0.0/8
515  * unicast-ip4-chain
516  * [@0]: dpo-load-balance: [index:2 buckets:1 uRPF:2 to:[0:0]]
517  * [0] [@0]: dpo-drop ip6
518  * 255.255.255.255/32
519  * unicast-ip4-chain
520  * [@0]: dpo-load-balance: [index:4 buckets:1 uRPF:4 to:[0:0]]
521  * [0] [@0]: dpo-drop ip6
522  * ipv4-VRF:7, fib_index 1, flow hash: src dst sport dport proto
523  * 0.0.0.0/0
524  * unicast-ip4-chain
525  * [@0]: dpo-load-balance: [index:12 buckets:1 uRPF:11 to:[0:0]]
526  * [0] [@0]: dpo-drop ip6
527  * 0.0.0.0/32
528  * unicast-ip4-chain
529  * [@0]: dpo-load-balance: [index:13 buckets:1 uRPF:12 to:[0:0]]
530  * [0] [@0]: dpo-drop ip6
531  * 172.16.1.0/24
532  * unicast-ip4-chain
533  * [@0]: dpo-load-balance: [index:17 buckets:1 uRPF:16 to:[0:0]]
534  * [0] [@4]: ipv4-glean: af_packet0
535  * 172.16.1.1/32
536  * unicast-ip4-chain
537  * [@0]: dpo-load-balance: [index:18 buckets:1 uRPF:17 to:[1:84]]
538  * [0] [@2]: dpo-receive: 172.16.1.1 on af_packet0
539  * 172.16.1.2/32
540  * unicast-ip4-chain
541  * [@0]: dpo-load-balance: [index:21 buckets:1 uRPF:20 to:[0:0]]
542  * [0] [@5]: ipv4 via 172.16.1.2 af_packet0: IP4: 02:fe:9e:70:7a:2b -> 26:a5:f6:9c:3a:36
543  * 172.16.2.0/24
544  * unicast-ip4-chain
545  * [@0]: dpo-load-balance: [index:19 buckets:1 uRPF:18 to:[0:0]]
546  * [0] [@4]: ipv4-glean: af_packet1
547  * 172.16.2.1/32
548  * unicast-ip4-chain
549  * [@0]: dpo-load-balance: [index:20 buckets:1 uRPF:19 to:[0:0]]
550  * [0] [@2]: dpo-receive: 172.16.2.1 on af_packet1
551  * 224.0.0.0/8
552  * unicast-ip4-chain
553  * [@0]: dpo-load-balance: [index:15 buckets:1 uRPF:14 to:[0:0]]
554  * [0] [@0]: dpo-drop ip6
555  * 240.0.0.0/8
556  * unicast-ip4-chain
557  * [@0]: dpo-load-balance: [index:14 buckets:1 uRPF:13 to:[0:0]]
558  * [0] [@0]: dpo-drop ip6
559  * 255.255.255.255/32
560  * unicast-ip4-chain
561  * [@0]: dpo-load-balance: [index:16 buckets:1 uRPF:15 to:[0:0]]
562  * [0] [@0]: dpo-drop ip6
563  * @cliexend
564  * Example of how to display a single IPv4 FIB table:
565  * @cliexstart{show ip fib table 7}
566  * ipv4-VRF:7, fib_index 1, flow hash: src dst sport dport proto
567  * 0.0.0.0/0
568  * unicast-ip4-chain
569  * [@0]: dpo-load-balance: [index:12 buckets:1 uRPF:11 to:[0:0]]
570  * [0] [@0]: dpo-drop ip6
571  * 0.0.0.0/32
572  * unicast-ip4-chain
573  * [@0]: dpo-load-balance: [index:13 buckets:1 uRPF:12 to:[0:0]]
574  * [0] [@0]: dpo-drop ip6
575  * 172.16.1.0/24
576  * unicast-ip4-chain
577  * [@0]: dpo-load-balance: [index:17 buckets:1 uRPF:16 to:[0:0]]
578  * [0] [@4]: ipv4-glean: af_packet0
579  * 172.16.1.1/32
580  * unicast-ip4-chain
581  * [@0]: dpo-load-balance: [index:18 buckets:1 uRPF:17 to:[1:84]]
582  * [0] [@2]: dpo-receive: 172.16.1.1 on af_packet0
583  * 172.16.1.2/32
584  * unicast-ip4-chain
585  * [@0]: dpo-load-balance: [index:21 buckets:1 uRPF:20 to:[0:0]]
586  * [0] [@5]: ipv4 via 172.16.1.2 af_packet0: IP4: 02:fe:9e:70:7a:2b -> 26:a5:f6:9c:3a:36
587  * 172.16.2.0/24
588  * unicast-ip4-chain
589  * [@0]: dpo-load-balance: [index:19 buckets:1 uRPF:18 to:[0:0]]
590  * [0] [@4]: ipv4-glean: af_packet1
591  * 172.16.2.1/32
592  * unicast-ip4-chain
593  * [@0]: dpo-load-balance: [index:20 buckets:1 uRPF:19 to:[0:0]]
594  * [0] [@2]: dpo-receive: 172.16.2.1 on af_packet1
595  * 224.0.0.0/8
596  * unicast-ip4-chain
597  * [@0]: dpo-load-balance: [index:15 buckets:1 uRPF:14 to:[0:0]]
598  * [0] [@0]: dpo-drop ip6
599  * 240.0.0.0/8
600  * unicast-ip4-chain
601  * [@0]: dpo-load-balance: [index:14 buckets:1 uRPF:13 to:[0:0]]
602  * [0] [@0]: dpo-drop ip6
603  * 255.255.255.255/32
604  * unicast-ip4-chain
605  * [@0]: dpo-load-balance: [index:16 buckets:1 uRPF:15 to:[0:0]]
606  * [0] [@0]: dpo-drop ip6
607  * @cliexend
608  * Example of how to display a summary of all IPv4 FIB tables:
609  * @cliexstart{show ip fib summary}
610  * ipv4-VRF:0, fib_index 0, flow hash: src dst sport dport proto
611  * Prefix length Count
612  * 0 1
613  * 8 2
614  * 32 4
615  * ipv4-VRF:7, fib_index 1, flow hash: src dst sport dport proto
616  * Prefix length Count
617  * 0 1
618  * 8 2
619  * 24 2
620  * 32 4
621  * @cliexend
622  ?*/
623 /* *INDENT-OFF* */
625  .path = "show ip fib",
626  .short_help = "show ip fib [summary] [table <table-id>] [index <fib-id>] [<ip4-addr>[/<mask>]] [mtrie] [detail]",
627  .function = ip4_show_fib,
628 };
629 /* *INDENT-ON* */
format_ip4_mtrie
#define format_ip4_mtrie
Definition: ip4_fib.h:80
fib_entry.h
ip4_fib_table_find_or_create_and_lock
u32 ip4_fib_table_find_or_create_and_lock(u32 table_id, fib_source_t src)
Get or create an IPv4 fib.
Definition: ip4_fib.c:228
hash_set
#define hash_set(h, key, value)
Definition: hash.h:255
ip4_show_fib
static clib_error_t * ip4_show_fib(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: ip4_fib.c:331
ip4_main
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1104
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
fib_entry_cmp_for_sort
int fib_entry_cmp_for_sort(void *i1, void *i2)
Definition: fib_entry.c:1660
FIB_ENTRY_FORMAT_DETAIL
#define FIB_ENTRY_FORMAT_DETAIL
Definition: fib_entry.h:360
ip4_fib_8_t_::hash
ip4_fib_hash_t hash
The hash table DB.
Definition: ip4_fib_8.h:50
fib_table_t_::ft_epoch
u32 ft_epoch
Epoch - number of resyncs performed.
Definition: fib_table.h:117
FIB_ENTRY_FORMAT_DETAIL2
#define FIB_ENTRY_FORMAT_DETAIL2
Definition: fib_entry.h:361
pool_get_aligned
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
Definition: pool.h:249
hash_bytes
__clib_export uword hash_bytes(void *v)
Definition: hash.c:994
ip4_fib_8_t_::mtrie
ip4_mtrie_8_t mtrie
Mtrie for fast lookups.
Definition: ip4_fib_8.h:45
ip4_fib_hash_load_specials
void ip4_fib_hash_load_specials(u32 fib_index)
Definition: ip4_fib.c:103
fib_table_assert_empty
void fib_table_assert_empty(const fib_table_t *fib_table)
Debug function.
Definition: fib_entry.c:1755
format_ip_flow_hash_config
u8 * format_ip_flow_hash_config(u8 *s, va_list *args)
Definition: lookup.c:118
format_fib_table_name
u8 * format_fib_table_name(u8 *s, va_list *ap)
Format the description/name of the table.
Definition: fib_table.c:1385
vlib_cli_command_t::path
char * path
Definition: cli.h:96
fib_table.h
hash_elts
static uword hash_elts(void *v)
Definition: hash.h:118
ip4_fib_8_t_
The IPv4 FIB.
Definition: ip4_fib_8.h:36
ip4_main_t::fib_index_by_table_id
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
Definition: ip4.h:130
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
ip4_fib_table_create_and_lock
u32 ip4_fib_table_create_and_lock(fib_source_t src)
Definition: ip4_fib.c:243
ip4_fib_table_walk
#define ip4_fib_table_walk
Definition: ip4_fib.h:75
unformat_input_t
struct _unformat_input_t unformat_input_t
ip4_show_fib_command
static vlib_cli_command_t ip4_show_fib_command
(constructor) VLIB_CLI_COMMAND (ip4_show_fib_command)
Definition: ip4_fib.c:624
hash_unset
#define hash_unset(h, key)
Definition: hash.h:261
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
ip4_main_t::fib_index_by_sw_if_index
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip4.h:120
ip4_fib_table_show_all
static void ip4_fib_table_show_all(ip4_fib_t *fib, vlib_main_t *vm)
Definition: ip4_fib.c:283
fib_table_t_
A protocol Independent FIB table.
Definition: fib_table.h:71
fib_table_entry_special_remove
void fib_table_entry_special_remove(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Remove a 'special' entry from the FIB.
Definition: fib_table.c:424
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
fib_entry_flag_t
enum fib_entry_flag_t_ fib_entry_flag_t
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
fib_table_t_::ft_index
fib_node_index_t ft_index
Index into FIB vector.
Definition: fib_table.h:97
ip4_fib_table_special_prefix_t
struct ip4_fib_table_special_prefix_t_ ip4_fib_table_special_prefix_t
memory
vhost_user_memory_t memory
Definition: vhost_user.h:131
fib_table_t_::ft_table_id
u32 ft_table_id
Table ID (hash key) for this FIB.
Definition: fib_table.h:92
fib_table_t_::ft_total_route_counts
u32 ft_total_route_counts
Total route counters.
Definition: fib_table.h:112
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
ip4_fib_show_walk_ctx_t_::ifsw_indicies
fib_node_index_t * ifsw_indicies
Definition: ip4_fib.c:268
fib_table_t_::ft_locks
u32 * ft_locks
per-source number of locks on the table
Definition: fib_table.h:86
format_fib_source
u8 * format_fib_source(u8 *s, va_list *args)
Definition: fib_source.c:66
IP_FLOW_HASH_DEFAULT
#define IP_FLOW_HASH_DEFAULT
Default: 5-tuple + flowlabel without the "reverse" bit.
Definition: ip_flow_hash.h:22
ip4_fib_table_free
#define ip4_fib_table_free
Definition: ip4_fib.h:78
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
vec_foreach_index
#define vec_foreach_index(var, v)
Iterate over vector indices.
Definition: vec_bootstrap.h:220
uword
u64 uword
Definition: types.h:112
pool_get
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:255
fib_table_t_::ft_flags
fib_table_flags_t ft_flags
Table flags.
Definition: fib_table.h:81
address
manual_print typedef address
Definition: ip_types.api:96
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
src
vl_api_address_t src
Definition: gre.api:54
ip4_specials
static const ip4_fib_table_special_prefix_t ip4_specials[]
Definition: ip4_fib.c:29
ip4_fib_show_walk_ctx_t_
Walk show context.
Definition: ip4_fib.c:266
ip4_fib_table_special_prefix_t_::ift_source
fib_source_t ift_source
Definition: ip4_fib.c:25
ip4_address_t
Definition: ip4_packet.h:50
ip4_fib_table_init
#define ip4_fib_table_init
Definition: ip4_fib.h:77
ip4_fibs
#define ip4_fibs
Definition: ip4_fib.h:67
FIB_ENTRY_FLAG_DROP
@ FIB_ENTRY_FLAG_DROP
Definition: fib_entry.h:115
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
fib_prefix_t_::fp_addr
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:225
ip4_fib_table_destroy
void ip4_fib_table_destroy(u32 fib_index)
Definition: ip4_fib.c:189
ip4_mtrie_memory_usage
#define ip4_mtrie_memory_usage
Definition: ip4_fib.h:79
ip4_fib_table_special_prefix_t_::ift_flag
fib_entry_flag_t ift_flag
Definition: ip4_fib.c:26
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
index
u32 index
Definition: flow_types.api:221
format_ip4_fib_table_memory
u8 * format_ip4_fib_table_memory(u8 *s, va_list *args)
Definition: ip4_fib.c:322
fib_table_t_::ft_flow_hash_config
u32 ft_flow_hash_config
flow hash configuration
Definition: fib_table.h:102
ip4_fib_hash_t_::table_id
u32 table_id
Definition: ip4_fib_hash.h:31
pool_foreach_index
#define pool_foreach_index(i, v)
Definition: pool.h:572
u64
unsigned long u64
Definition: types.h:89
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
FIB_SOURCE_DEFAULT_ROUTE
@ FIB_SOURCE_DEFAULT_ROUTE
The default route source.
Definition: fib_source.h:134
ip4_fib_hash_flush_specials
void ip4_fib_hash_flush_specials(u32 fib_index)
Definition: ip4_fib.c:125
fib_table_lock
void fib_table_lock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Release a reference counting lock on the table.
Definition: fib_table.c:1361
u32
unsigned int u32
Definition: types.h:88
ip4_fib_table_get_index_for_sw_if_index
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: ip4_fib.c:249
fib_table_walk_rc_t
enum fib_table_walk_rc_t_ fib_table_walk_rc_t
return code controlling how a table walk proceeds
ip4_main_t::fibs
struct fib_table_t_ * fibs
Vector of FIBs.
Definition: ip4.h:112
table_id
u32 table_id
Definition: wireguard.api:102
ip4_fib_table_lookup
#define ip4_fib_table_lookup
Definition: ip4_fib.h:68
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
ip4_fib_hash_t_::fib_entry_by_dst_address
uword * fib_entry_by_dst_address[33]
Definition: ip4_fib_hash.h:28
ip4_fib_show_walk_cb
static fib_table_walk_rc_t ip4_fib_show_walk_cb(fib_node_index_t fib_entry_index, void *arg)
Definition: ip4_fib.c:272
pool_elts
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:127
FIB_ENTRY_FORMAT_BRIEF
#define FIB_ENTRY_FORMAT_BRIEF
Definition: fib_entry.h:359
FIB_SOURCE_SPECIAL
@ FIB_SOURCE_SPECIAL
Special sources.
Definition: fib_source.h:45
ip4_fib.h
vec_sort_with_function
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:1097
ip4_fib_index_from_table_id
static u32 ip4_fib_index_from_table_id(u32 table_id)
Definition: ip4_fib.h:121
FIB_TABLE_WALK_CONTINUE
@ FIB_TABLE_WALK_CONTINUE
Continue on to the next entry.
Definition: fib_table.h:916
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
format_fib_table_flags
u8 * format_fib_table_flags(u8 *s, va_list *args)
Definition: fib_table.c:1399
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
i
int i
Definition: flowhash_template.h:376
fib_source_t
enum fib_source_t_ fib_source_t
The different sources that can create a route.
unformat_ip4_address
unformat_function_t unformat_ip4_address
Definition: format.h:68
ip4_fib_table_special_prefix_t_::ift_prefix
fib_prefix_t ift_prefix
Definition: ip4_fib.c:24
ip4_fib_table_show_one
static void ip4_fib_table_show_one(ip4_fib_t *fib, vlib_main_t *vm, ip4_address_t *address, u32 mask_len, int detail)
Definition: ip4_fib.c:307
fib_table_t_::ft_proto
fib_protocol_t ft_proto
Which protocol this table serves.
Definition: fib_table.h:76
fib_table_entry_special_add
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 'special' entry to the FIB.
Definition: fib_table.c:405
vlib_cli_command_t
Definition: cli.h:92
ip4_main_t
IPv4 main type.
Definition: ip4.h:107
ip4_fib_table_special_prefix_t_
Definition: ip4_fib.c:23
fib_table_t_::ft_src_route_counts
u32 * ft_src_route_counts
Per-source route counters.
Definition: fib_table.h:107
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
fib_prefix_t_
Aggregate type for a prefix.
Definition: fib_types.h:202
ip4_fib_show_walk_ctx_t
struct ip4_fib_show_walk_ctx_t_ ip4_fib_show_walk_ctx_t
Walk show context.
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
prefix
vl_api_prefix_t prefix
Definition: ip.api:175
ip4_create_fib_with_table_id
static u32 ip4_create_fib_with_table_id(u32 table_id, fib_source_t src)
Definition: ip4_fib.c:147
format_fib_entry
u8 * format_fib_entry(u8 *s, va_list *args)
Definition: fib_entry.c:130