FD.io VPP  v17.01.1-3-gc6833f8
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 pefixes to be added to tables and the sources for them
22  */
28 
29 static const ip4_fib_table_special_prefix_t ip4_specials[] = {
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 
103 static u32
105 {
106  fib_table_t *fib_table;
107 
109  memset(fib_table, 0, sizeof(*fib_table));
110 
111  fib_table->ft_proto = FIB_PROTOCOL_IP4;
112  fib_table->ft_index =
113  fib_table->v4.index =
114  (fib_table - ip4_main.fibs);
115 
116  hash_set (ip4_main.fib_index_by_table_id, table_id, fib_table->ft_index);
117 
118  fib_table->ft_table_id =
119  fib_table->v4.table_id =
120  table_id;
121  fib_table->ft_flow_hash_config =
122  fib_table->v4.flow_hash_config =
124  fib_table->v4.fwd_classify_table_index = ~0;
125  fib_table->v4.rev_classify_table_index = ~0;
126 
128 
129  ip4_mtrie_init(&fib_table->v4.mtrie);
130 
131  /*
132  * add the special entries into the new FIB
133  */
134  int ii;
135 
136  for (ii = 0; ii < ARRAY_LEN(ip4_specials); ii++)
137  {
138  fib_prefix_t prefix = ip4_specials[ii].ift_prefix;
139 
140  prefix.fp_addr.ip4.data_u32 =
141  clib_host_to_net_u32(prefix.fp_addr.ip4.data_u32);
142 
144  &prefix,
145  ip4_specials[ii].ift_source,
146  ip4_specials[ii].ift_flag,
148  }
149 
150  return (fib_table->ft_index);
151 }
152 
153 void
155 {
156  fib_table_t *fib_table = (fib_table_t*)fib;
157  int ii;
158 
159  /*
160  * remove all the specials we added when the table was created.
161  */
162  for (ii = 0; ii < ARRAY_LEN(ip4_specials); ii++)
163  {
164  fib_prefix_t prefix = ip4_specials[ii].ift_prefix;
165 
166  prefix.fp_addr.ip4.data_u32 =
167  clib_host_to_net_u32(prefix.fp_addr.ip4.data_u32);
168 
170  &prefix,
171  ip4_specials[ii].ift_source);
172  }
173 
174  /*
175  * validate no more routes.
176  */
177  ASSERT(0 == fib_table->ft_total_route_counts);
179  {
180  ASSERT(0 == fib_table->ft_src_route_counts[ii]);
181  }
182 
183  if (~0 != fib_table->ft_table_id)
184  {
186  }
187  pool_put(ip4_main.fibs, fib_table);
188 }
189 
190 
191 u32
193 {
194  u32 index;
195 
196  index = ip4_fib_index_from_table_id(table_id);
197  if (~0 == index)
198  return ip4_create_fib_with_table_id(table_id);
199 
201 
202  return (index);
203 }
204 
205 u32
207 {
208  return (ip4_create_fib_with_table_id(~0));
209 }
210 
211 u32
213 {
214  if (sw_if_index >= vec_len(ip4_main.fib_index_by_sw_if_index))
215  {
216  /*
217  * This is the case for interfaces that are not yet mapped to
218  * a IP table
219  */
220  return (~0);
221  }
222  return (ip4_main.fib_index_by_sw_if_index[sw_if_index]);
223 }
224 
227 {
228  return (ip4_fib_get(fib_index)->flow_hash_config);
229 }
230 
231 /*
232  * ip4_fib_table_lookup_exact_match
233  *
234  * Exact match prefix lookup
235  */
238  const ip4_address_t *addr,
239  u32 len)
240 {
241  uword * hash, * result;
242  u32 key;
243 
244  hash = fib->fib_entry_by_dst_address[len];
245  key = (addr->data_u32 & ip4_main.fib_masks[len]);
246 
247  result = hash_get(hash, key);
248 
249  if (NULL != result) {
250  return (result[0]);
251  }
252  return (FIB_NODE_INDEX_INVALID);
253 }
254 
255 /*
256  * ip4_fib_table_lookup_adj
257  *
258  * Longest prefix match
259  */
260 index_t
262  const ip4_address_t *addr)
263 {
264  fib_node_index_t fei;
265 
266  fei = ip4_fib_table_lookup(fib, addr, 32);
267 
268  if (FIB_NODE_INDEX_INVALID != fei)
269  {
270  const dpo_id_t *dpo;
271 
273 
274  return (dpo->dpoi_index);
275  }
276  return (INDEX_INVALID);
277 }
278 
279 /*
280  * ip4_fib_table_lookup
281  *
282  * Longest prefix match
283  */
286  const ip4_address_t *addr,
287  u32 len)
288 {
289  uword * hash, * result;
290  i32 mask_len;
291  u32 key;
292 
293  for (mask_len = len; mask_len >= 0; mask_len--)
294  {
295  hash = fib->fib_entry_by_dst_address[mask_len];
296  key = (addr->data_u32 & ip4_main.fib_masks[mask_len]);
297 
298  result = hash_get (hash, key);
299 
300  if (NULL != result) {
301  return (result[0]);
302  }
303  }
304  return (FIB_NODE_INDEX_INVALID);
305 }
306 
307 void
309  const ip4_address_t *addr,
310  u32 len,
311  fib_node_index_t fib_entry_index)
312 {
313  uword * hash, * result;
314  u32 key;
315 
316  key = (addr->data_u32 & ip4_main.fib_masks[len]);
317  hash = fib->fib_entry_by_dst_address[len];
318  result = hash_get (hash, key);
319 
320  if (NULL == result) {
321  /*
322  * adding a new entry
323  */
324  if (NULL == hash) {
325  hash = hash_create (32 /* elts */, sizeof (uword));
327  }
328  hash = hash_set(hash, key, fib_entry_index);
329  fib->fib_entry_by_dst_address[len] = hash;
330  }
331  else
332  {
333  ASSERT(0);
334  }
335 }
336 
337 void
339  const ip4_address_t *addr,
340  u32 len)
341 {
342  uword * hash, * result;
343  u32 key;
344 
345  key = (addr->data_u32 & ip4_main.fib_masks[len]);
346  hash = fib->fib_entry_by_dst_address[len];
347  result = hash_get (hash, key);
348 
349  if (NULL == result)
350  {
351  /*
352  * removing a non-existant entry. i'll allow it.
353  */
354  }
355  else
356  {
357  hash_unset(hash, key);
358  }
359 
360  fib->fib_entry_by_dst_address[len] = hash;
361 }
362 
363 void
365  const ip4_address_t *addr,
366  u32 len,
367  const dpo_id_t *dpo)
368 {
369  ip4_fib_mtrie_add_del_route(fib, *addr, len, dpo->dpoi_index, 0); // ADD
370 }
371 
372 void
374  const ip4_address_t *addr,
375  u32 len,
376  const dpo_id_t *dpo)
377 {
378  ip4_fib_mtrie_add_del_route(fib, *addr, len, dpo->dpoi_index, 1); // DELETE
379 }
380 
381 static void
383  vlib_main_t * vm)
384 {
385  fib_node_index_t *fib_entry_indicies;
386  fib_node_index_t *fib_entry_index;
387  int i;
388 
389  fib_entry_indicies = NULL;
390 
391  for (i = 0; i < ARRAY_LEN (fib->fib_entry_by_dst_address); i++)
392  {
393  uword * hash = fib->fib_entry_by_dst_address[i];
394 
395  if (NULL != hash)
396  {
397  hash_pair_t * p;
398 
399  hash_foreach_pair (p, hash,
400  ({
401  vec_add1(fib_entry_indicies, p->value[0]);
402  }));
403  }
404  }
405 
406  vec_sort_with_function(fib_entry_indicies, fib_entry_cmp_for_sort);
407 
408  vec_foreach(fib_entry_index, fib_entry_indicies)
409  {
410  vlib_cli_output(vm, "%U",
412  *fib_entry_index,
414  }
415 
416  vec_free(fib_entry_indicies);
417 }
418 
419 static void
421  vlib_main_t * vm,
422  ip4_address_t *address,
423  u32 mask_len)
424 {
425  vlib_cli_output(vm, "%U",
427  ip4_fib_table_lookup(fib, address, mask_len),
429 }
430 
431 static clib_error_t *
433  unformat_input_t * input,
434  vlib_cli_command_t * cmd)
435 {
436  ip4_main_t * im4 = &ip4_main;
437  fib_table_t * fib_table;
438  int verbose, matching, mtrie;
439  ip4_address_t matching_address;
440  u32 matching_mask = 32;
441  int i, table_id = -1, fib_index = ~0;
442 
443  verbose = 1;
444  matching = 0;
445  mtrie = 0;
447  {
448  if (unformat (input, "brief") || unformat (input, "summary")
449  || unformat (input, "sum"))
450  verbose = 0;
451 
452  else if (unformat (input, "mtrie"))
453  mtrie = 1;
454 
455  else if (unformat (input, "%U/%d",
456  unformat_ip4_address, &matching_address, &matching_mask))
457  matching = 1;
458 
459  else if (unformat (input, "%U", unformat_ip4_address, &matching_address))
460  matching = 1;
461 
462  else if (unformat (input, "table %d", &table_id))
463  ;
464  else if (unformat (input, "index %d", &fib_index))
465  ;
466  else
467  break;
468  }
469 
470  pool_foreach (fib_table, im4->fibs,
471  ({
472  ip4_fib_t *fib = &fib_table->v4;
473 
474  if (table_id >= 0 && table_id != (int)fib->table_id)
475  continue;
476  if (fib_index != ~0 && fib_index != (int)fib->index)
477  continue;
478 
479  vlib_cli_output (vm, "%U, fib_index %d, flow hash: %U",
480  format_fib_table_name, fib->index, FIB_PROTOCOL_IP4,
481  fib->index,
482  format_ip_flow_hash_config, fib->flow_hash_config);
483 
484  /* Show summary? */
485  if (! verbose)
486  {
487  vlib_cli_output (vm, "%=20s%=16s", "Prefix length", "Count");
488  for (i = 0; i < ARRAY_LEN (fib->fib_entry_by_dst_address); i++)
489  {
490  uword * hash = fib->fib_entry_by_dst_address[i];
491  uword n_elts = hash_elts (hash);
492  if (n_elts > 0)
493  vlib_cli_output (vm, "%20d%16d", i, n_elts);
494  }
495  continue;
496  }
497 
498  if (!matching)
499  {
500  ip4_fib_table_show_all(fib, vm);
501  }
502  else
503  {
504  ip4_fib_table_show_one(fib, vm, &matching_address, matching_mask);
505  }
506 
507  if (mtrie)
508  vlib_cli_output (vm, "%U", format_ip4_fib_mtrie, &fib->mtrie);
509  }));
510 
511  return 0;
512 }
513 
514 /*?
515  * This command displays the IPv4 FIB Tables (VRF Tables) and the route
516  * entries for each table.
517  *
518  * @note This command will run for a long time when the FIB tables are
519  * comprised of millions of entries. For those senarios, consider displaying
520  * a single table or summary mode.
521  *
522  * @cliexpar
523  * Example of how to display all the IPv4 FIB tables:
524  * @cliexstart{show ip fib}
525  * ipv4-VRF:0, fib_index 0, flow hash: src dst sport dport proto
526  * 0.0.0.0/0
527  * unicast-ip4-chain
528  * [@0]: dpo-load-balance: [index:0 buckets:1 uRPF:0 to:[0:0]]
529  * [0] [@0]: dpo-drop ip6
530  * 0.0.0.0/32
531  * unicast-ip4-chain
532  * [@0]: dpo-load-balance: [index:1 buckets:1 uRPF:1 to:[0:0]]
533  * [0] [@0]: dpo-drop ip6
534  * 6.0.1.2/32
535  * unicast-ip4-chain
536  * [@0]: dpo-load-balance: [index:30 buckets:1 uRPF:29 to:[0:0]]
537  * [0] [@3]: arp-ipv4: via 6.0.0.1 af_packet0
538  * 7.0.0.1/32
539  * unicast-ip4-chain
540  * [@0]: dpo-load-balance: [index:31 buckets:4 uRPF:30 to:[0:0]]
541  * [0] [@3]: arp-ipv4: via 6.0.0.2 af_packet0
542  * [1] [@3]: arp-ipv4: via 6.0.0.2 af_packet0
543  * [2] [@3]: arp-ipv4: via 6.0.0.2 af_packet0
544  * [3] [@3]: arp-ipv4: via 6.0.0.1 af_packet0
545  * 224.0.0.0/8
546  * unicast-ip4-chain
547  * [@0]: dpo-load-balance: [index:3 buckets:1 uRPF:3 to:[0:0]]
548  * [0] [@0]: dpo-drop ip6
549  * 240.0.0.0/8
550  * unicast-ip4-chain
551  * [@0]: dpo-load-balance: [index:2 buckets:1 uRPF:2 to:[0:0]]
552  * [0] [@0]: dpo-drop ip6
553  * 255.255.255.255/32
554  * unicast-ip4-chain
555  * [@0]: dpo-load-balance: [index:4 buckets:1 uRPF:4 to:[0:0]]
556  * [0] [@0]: dpo-drop ip6
557  * ipv4-VRF:7, fib_index 1, flow hash: src dst sport dport proto
558  * 0.0.0.0/0
559  * unicast-ip4-chain
560  * [@0]: dpo-load-balance: [index:12 buckets:1 uRPF:11 to:[0:0]]
561  * [0] [@0]: dpo-drop ip6
562  * 0.0.0.0/32
563  * unicast-ip4-chain
564  * [@0]: dpo-load-balance: [index:13 buckets:1 uRPF:12 to:[0:0]]
565  * [0] [@0]: dpo-drop ip6
566  * 172.16.1.0/24
567  * unicast-ip4-chain
568  * [@0]: dpo-load-balance: [index:17 buckets:1 uRPF:16 to:[0:0]]
569  * [0] [@4]: ipv4-glean: af_packet0
570  * 172.16.1.1/32
571  * unicast-ip4-chain
572  * [@0]: dpo-load-balance: [index:18 buckets:1 uRPF:17 to:[1:84]]
573  * [0] [@2]: dpo-receive: 172.16.1.1 on af_packet0
574  * 172.16.1.2/32
575  * unicast-ip4-chain
576  * [@0]: dpo-load-balance: [index:21 buckets:1 uRPF:20 to:[0:0]]
577  * [0] [@5]: ipv4 via 172.16.1.2 af_packet0: IP4: 02:fe:9e:70:7a:2b -> 26:a5:f6:9c:3a:36
578  * 172.16.2.0/24
579  * unicast-ip4-chain
580  * [@0]: dpo-load-balance: [index:19 buckets:1 uRPF:18 to:[0:0]]
581  * [0] [@4]: ipv4-glean: af_packet1
582  * 172.16.2.1/32
583  * unicast-ip4-chain
584  * [@0]: dpo-load-balance: [index:20 buckets:1 uRPF:19 to:[0:0]]
585  * [0] [@2]: dpo-receive: 172.16.2.1 on af_packet1
586  * 224.0.0.0/8
587  * unicast-ip4-chain
588  * [@0]: dpo-load-balance: [index:15 buckets:1 uRPF:14 to:[0:0]]
589  * [0] [@0]: dpo-drop ip6
590  * 240.0.0.0/8
591  * unicast-ip4-chain
592  * [@0]: dpo-load-balance: [index:14 buckets:1 uRPF:13 to:[0:0]]
593  * [0] [@0]: dpo-drop ip6
594  * 255.255.255.255/32
595  * unicast-ip4-chain
596  * [@0]: dpo-load-balance: [index:16 buckets:1 uRPF:15 to:[0:0]]
597  * [0] [@0]: dpo-drop ip6
598  * @cliexend
599  * Example of how to display a single IPv4 FIB table:
600  * @cliexstart{show ip fib table 7}
601  * ipv4-VRF:7, fib_index 1, flow hash: src dst sport dport proto
602  * 0.0.0.0/0
603  * unicast-ip4-chain
604  * [@0]: dpo-load-balance: [index:12 buckets:1 uRPF:11 to:[0:0]]
605  * [0] [@0]: dpo-drop ip6
606  * 0.0.0.0/32
607  * unicast-ip4-chain
608  * [@0]: dpo-load-balance: [index:13 buckets:1 uRPF:12 to:[0:0]]
609  * [0] [@0]: dpo-drop ip6
610  * 172.16.1.0/24
611  * unicast-ip4-chain
612  * [@0]: dpo-load-balance: [index:17 buckets:1 uRPF:16 to:[0:0]]
613  * [0] [@4]: ipv4-glean: af_packet0
614  * 172.16.1.1/32
615  * unicast-ip4-chain
616  * [@0]: dpo-load-balance: [index:18 buckets:1 uRPF:17 to:[1:84]]
617  * [0] [@2]: dpo-receive: 172.16.1.1 on af_packet0
618  * 172.16.1.2/32
619  * unicast-ip4-chain
620  * [@0]: dpo-load-balance: [index:21 buckets:1 uRPF:20 to:[0:0]]
621  * [0] [@5]: ipv4 via 172.16.1.2 af_packet0: IP4: 02:fe:9e:70:7a:2b -> 26:a5:f6:9c:3a:36
622  * 172.16.2.0/24
623  * unicast-ip4-chain
624  * [@0]: dpo-load-balance: [index:19 buckets:1 uRPF:18 to:[0:0]]
625  * [0] [@4]: ipv4-glean: af_packet1
626  * 172.16.2.1/32
627  * unicast-ip4-chain
628  * [@0]: dpo-load-balance: [index:20 buckets:1 uRPF:19 to:[0:0]]
629  * [0] [@2]: dpo-receive: 172.16.2.1 on af_packet1
630  * 224.0.0.0/8
631  * unicast-ip4-chain
632  * [@0]: dpo-load-balance: [index:15 buckets:1 uRPF:14 to:[0:0]]
633  * [0] [@0]: dpo-drop ip6
634  * 240.0.0.0/8
635  * unicast-ip4-chain
636  * [@0]: dpo-load-balance: [index:14 buckets:1 uRPF:13 to:[0:0]]
637  * [0] [@0]: dpo-drop ip6
638  * 255.255.255.255/32
639  * unicast-ip4-chain
640  * [@0]: dpo-load-balance: [index:16 buckets:1 uRPF:15 to:[0:0]]
641  * [0] [@0]: dpo-drop ip6
642  * @cliexend
643  * Example of how to display a summary of all IPv4 FIB tables:
644  * @cliexstart{show ip fib summary}
645  * ipv4-VRF:0, fib_index 0, flow hash: src dst sport dport proto
646  * Prefix length Count
647  * 0 1
648  * 8 2
649  * 32 4
650  * ipv4-VRF:7, fib_index 1, flow hash: src dst sport dport proto
651  * Prefix length Count
652  * 0 1
653  * 8 2
654  * 24 2
655  * 32 4
656  * @cliexend
657  ?*/
658 /* *INDENT-OFF* */
659 VLIB_CLI_COMMAND (ip4_show_fib_command, static) = {
660  .path = "show ip fib",
661  .short_help = "show ip fib [summary] [table <table-id>] [index <fib-id>] [<ip4-addr>[/<mask>]] [mtrie]",
662  .function = ip4_show_fib,
663 };
664 /* *INDENT-ON* */
u8 * format_fib_entry(u8 *s, va_list *args)
Definition: fib_entry.c:93
#define hash_set(h, key, value)
Definition: hash.h:254
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
fib_protocol_t ft_proto
Which protocol this table serves.
Definition: fib_table.h:46
uword unformat(unformat_input_t *i, char *fmt,...)
Definition: unformat.c:966
#define hash_unset(h, key)
Definition: hash.h:260
void fib_table_lock(u32 fib_index, fib_protocol_t proto)
Release a reference counting lock on the table.
Definition: fib_table.c:1062
u32 table_id
Definition: ip4.h:57
#define FIB_ENTRY_FORMAT_DETAIL
Definition: fib_entry.h:416
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
#define NULL
Definition: clib.h:55
const dpo_id_t * fib_entry_contribute_ip_forwarding(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:432
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:41
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:482
static clib_error_t * ip4_show_fib(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: ip4_fib.c:432
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip4.h:105
static void ip4_fib_table_show_all(ip4_fib_t *fib, vlib_main_t *vm)
Definition: ip4_fib.c:382
static u32 ip4_create_fib_with_table_id(u32 table_id)
Definition: ip4_fib.c:104
u32 index
Definition: ip4.h:60
uword value[0]
Definition: hash.h:164
u32 fwd_classify_table_index
Definition: ip4.h:66
fib_entry_flag_t ift_flag
Definition: ip4_fib.c:26
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: ip4_fib.c:212
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:348
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:399
int i32
Definition: types.h:81
void ip4_fib_mtrie_add_del_route(ip4_fib_t *fib, ip4_address_t dst_address, u32 dst_address_length, u32 adj_index, u32 is_del)
Definition: ip4_mtrie.c:387
Aggregrate type for a prefix.
Definition: fib_types.h:145
static void hash_set_flags(void *v, uword flags)
Definition: hash.h:152
u32 ip4_fib_table_find_or_create_and_lock(u32 table_id)
Get or create an IPv4 fib.
Definition: ip4_fib.c:192
u32 rev_classify_table_index
Definition: ip4.h:67
void ip4_fib_table_destroy(ip4_fib_t *fib)
Definition: ip4_fib.c:154
void ip4_fib_table_entry_remove(ip4_fib_t *fib, const ip4_address_t *addr, u32 len)
Definition: ip4_fib.c:338
int fib_entry_cmp_for_sort(void *i1, void *i2)
Definition: fib_entry.c:1388
unformat_function_t unformat_ip4_address
Definition: format.h:76
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:138
#define hash_get(h, key)
Definition: hash.h:248
#define ADJ_INDEX_INVALID
Invalid ADJ index - used when no adj is known likewise blazoned capitals INVALID speak volumes where ...
Definition: adj_types.h:36
uword * fib_entry_by_dst_address[33]
Definition: ip4.h:51
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, adj_index_t adj_index)
Add a &#39;special&#39; entry to the FIB that links to the adj passed A special entry is an entry that the FI...
Definition: fib_table.c:369
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
Definition: ip4.h:112
enum fib_source_t_ fib_source_t
The different sources that can create a route.
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:168
flow_hash_config_t ip4_fib_table_get_flow_hash_config(u32 fib_index)
Definition: ip4_fib.c:226
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:214
u32 ft_total_route_counts
Total route counters.
Definition: fib_table.h:76
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:364
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:576
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
Definition: pool.h:169
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:285
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:308
fib_node_index_t ft_index
Index into FIB vector.
Definition: fib_table.h:61
void ip4_mtrie_init(ip4_fib_mtrie_t *m)
Definition: ip4_mtrie.c:376
u32 ft_table_id
Table ID (hash key) for this FIB.
Definition: fib_table.h:56
u32 ft_flow_hash_config
flow hash configuration
Definition: fib_table.h:66
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:300
#define FOR_EACH_FIB_SOURCE(_item)
Definition: fib_entry.h:151
static ip4_fib_t * ip4_fib_get(u32 index)
Get the FIB at the given index.
Definition: ip4_fib.h:71
Definition: ip4.h:48
Definition: fib_entry.h:219
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:28
static u32 ip4_fib_index_from_table_id(u32 table_id)
Definition: ip4_fib.h:101
#define ARRAY_LEN(x)
Definition: clib.h:59
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
enum fib_entry_flag_t_ fib_entry_flag_t
#define hash_create(elts, value_bytes)
Definition: hash.h:658
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
The default route source.
Definition: fib_entry.h:117
IPv4 main type.
Definition: ip4.h:95
u32 ft_src_route_counts[FIB_SOURCE_MAX]
Per-source route counters.
Definition: fib_table.h:71
#define IP_FLOW_HASH_DEFAULT
Default: 5-tuple without the "reverse" bit.
Definition: lookup.h:147
u32 flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
Definition: lookup.h:160
u64 uword
Definition: types.h:112
#define FIB_ENTRY_FORMAT_BRIEF
Definition: fib_entry.h:415
format_function_t format_ip4_fib_mtrie
Definition: ip4_mtrie.h:160
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:154
#define FIB_NODE_INDEX_INVALID
Definition: fib_types.h:29
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define hash_foreach_pair(p, v, body)
Iterate over hash pairs.
Definition: hash.h:349
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:47
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:920
ip4_fib_mtrie_t mtrie
Definition: ip4.h:54
Special sources.
Definition: fib_entry.h:40
flow_hash_config_t flow_hash_config
Definition: ip4.h:63
ip4_fib_t v4
Definition: fib_table.h:38
static void ip4_fib_table_show_one(ip4_fib_t *fib, vlib_main_t *vm, ip4_address_t *address, u32 mask_len)
Definition: ip4_fib.c:420
struct ip4_fib_table_special_prefix_t_ ip4_fib_table_special_prefix_t
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1099
struct fib_table_t_ * fibs
Vector of FIBs.
Definition: ip4.h:100
#define vec_foreach(var, vec)
Vector iterator.
index_t ip4_fib_table_lookup_lb(ip4_fib_t *fib, const ip4_address_t *addr)
Definition: ip4_fib.c:261
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:373
vhost_vring_addr_t addr
Definition: vhost-user.h:81
struct _unformat_input_t unformat_input_t
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
u32 ip4_fib_table_create_and_lock(void)
Definition: ip4_fib.c:206
#define HASH_FLAG_NO_AUTO_SHRINK
Definition: hash.h:64
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:237
A protocol Independent FIB table.
Definition: fib_table.h:29
u32 fib_masks[33]
Definition: ip4.h:102