FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
ip4_mfib.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/mfib/ip4_mfib.h>
17 
18 #include <vnet/mfib/mfib_table.h>
19 #include <vnet/mfib/mfib_entry.h>
20 
21 static const mfib_prefix_t all_zeros =
22 {
24 };
25 static const mfib_prefix_t ip4_specials[] =
26 {
27  /* ALL prefixes are in network order */
28  {
29  /* (*,224.0.0.1)/32 - all hosts */
30  .fp_grp_addr = {
31  .ip4.data_u32 = 0x010000e0,
32  },
33  .fp_len = 32,
34  .fp_proto = FIB_PROTOCOL_IP4,
35  },
36  {
37  /* (*,224.0.0.2)/32 - all routers */
38  .fp_grp_addr = {
39  .ip4.data_u32 = 0x020000e0,
40  },
41  .fp_len = 32,
42  .fp_proto = FIB_PROTOCOL_IP4,
43  },
44 };
45 
46 static u32
49 {
50  mfib_table_t *mfib_table;
51 
53  clib_memset(mfib_table, 0, sizeof(*mfib_table));
54 
55  mfib_table->mft_proto = FIB_PROTOCOL_IP4;
56  mfib_table->mft_index =
57  mfib_table->v4.index =
58  (mfib_table - ip4_main.mfibs);
59 
61  table_id,
62  mfib_table->mft_index);
63 
64  mfib_table->mft_table_id =
65  mfib_table->v4.table_id =
66  table_id;
67 
69 
70  /*
71  * add the default route into the new FIB
72  */
74  &all_zeros,
78 
79  const fib_route_path_t path = {
80  .frp_proto = DPO_PROTO_IP4,
81  .frp_addr = zero_addr,
82  .frp_sw_if_index = ~0,
83  .frp_fib_index = ~0,
84  .frp_weight = 1,
85  .frp_flags = FIB_ROUTE_PATH_LOCAL,
86  .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD,
87  };
88  int ii;
89 
90  for (ii = 0; ii < ARRAY_LEN(ip4_specials); ii++)
91  {
93  &ip4_specials[ii],
95  &path);
96  }
97 
98  return (mfib_table->mft_index);
99 }
100 
101 void
103 {
104  mfib_table_t *mfib_table = (mfib_table_t*)mfib;
105  int ii;
106 
107  /*
108  * remove all the specials we added when the table was created.
109  */
111  &all_zeros,
113 
114  for (ii = 0; ii < ARRAY_LEN(ip4_specials); ii++)
115  {
117  &ip4_specials[ii],
119  }
120 
121  /*
122  * validate no more routes.
123  */
124  ASSERT(0 == mfib_table->mft_total_route_counts);
125  ASSERT(~0 != mfib_table->mft_table_id);
126 
128  pool_put(ip4_main.mfibs, mfib_table);
129 }
130 
131 void
133 {
134  const fib_route_path_t path = {
135  .frp_proto = DPO_PROTO_IP4,
136  .frp_addr = zero_addr,
137  .frp_sw_if_index = sw_if_index,
138  .frp_fib_index = ~0,
139  .frp_weight = 1,
140  .frp_mitf_flags = MFIB_ITF_FLAG_ACCEPT,
141  };
142  u32 mfib_index;
143  int ii;
144 
146 
147  for (ii = 0; ii < ARRAY_LEN(ip4_specials); ii++)
148  {
149  if (is_enable)
150  {
151  mfib_table_entry_path_update(mfib_index,
152  &ip4_specials[ii],
154  &path);
155  }
156  else
157  {
158  mfib_table_entry_path_remove(mfib_index,
159  &ip4_specials[ii],
161  &path);
162  }
163  }
164 }
165 
166 u32
169 {
170  u32 index;
171 
173  if (~0 == index)
176 
177  return (index);
178 }
179 
180 u32
182 {
184  {
185  /*
186  * This is the case for interfaces that are not yet mapped to
187  * a IP table
188  */
189  return (~0);
190  }
192 }
193 
194 #define IPV4_MFIB_GRP_LEN(_len)\
195  (_len > 32 ? 32 : _len)
196 
197 #define IP4_MFIB_MK_KEY(_grp, _src, _len, _key) \
198 { \
199  _key = ((u64)(_grp->data_u32 & \
200  ip4_main.fib_masks[IPV4_MFIB_GRP_LEN(_len)])) << 32; \
201  _key |= _src->data_u32; \
202 }
203 #define IP4_MFIB_MK_GRP_KEY(_grp, _len, _key) \
204 { \
205  _key = ((u64)(_grp->data_u32 & \
206  ip4_main.fib_masks[IPV4_MFIB_GRP_LEN(_len)])) << 32; \
207 }
208 
209 /*
210  * ip4_fib_table_lookup_exact_match
211  *
212  * Exact match prefix lookup
213  */
216  const ip4_address_t *grp,
217  const ip4_address_t *src,
218  u32 len)
219 {
220  uword * hash, * result;
221  u64 key;
222 
223  hash = mfib->fib_entry_by_dst_address[len];
224  IP4_MFIB_MK_KEY(grp, src, len, key);
225 
226  result = hash_get(hash, key);
227 
228  if (NULL != result) {
229  return (result[0]);
230  }
231  return (FIB_NODE_INDEX_INVALID);
232 }
233 
234 /*
235  * ip4_fib_table_lookup
236  *
237  * Longest prefix match
238  */
241  const ip4_address_t *src,
242  const ip4_address_t *grp,
243  u32 len)
244 {
245  uword * hash, * result;
246  i32 mask_len;
247  u64 key;
248 
249  mask_len = len;
250 
251  if (PREDICT_TRUE(64 == mask_len))
252  {
253  hash = mfib->fib_entry_by_dst_address[mask_len];
254  IP4_MFIB_MK_KEY(grp, src, mask_len, key);
255 
256  result = hash_get (hash, key);
257 
258  if (NULL != result) {
259  return (result[0]);
260  }
261  }
262 
263  for (mask_len = (len == 64 ? 32 : len); mask_len >= 0; mask_len--)
264  {
265  hash = mfib->fib_entry_by_dst_address[mask_len];
266  IP4_MFIB_MK_GRP_KEY(grp, mask_len, key);
267 
268  result = hash_get (hash, key);
269 
270  if (NULL != result) {
271  return (result[0]);
272  }
273  }
274  return (FIB_NODE_INDEX_INVALID);
275 }
276 
279  const ip4_address_t *src,
280  const ip4_address_t *grp,
281  u32 len)
282 {
283  u32 mask_len;
284 
285  /*
286  * in the absence of a tree structure for the table that allows for an O(1)
287  * parent get, a cheeky way to find the cover is to LPM for the prefix with
288  * mask-1.
289  * there should always be a cover, though it may be the default route. the
290  * default route's cover is the default route.
291  */
292  if (len == 64)
293  {
294  /* go from (S,G) to (*,G*) */
295  mask_len = 32;
296  }
297  else if (len != 0)
298  {
299  mask_len = len - 1;
300  }
301  else
302  {
303  mask_len = len;
304  }
305 
306  return (ip4_mfib_table_lookup(mfib, src, grp, mask_len));
307 }
308 
309 void
311  const ip4_address_t *grp,
312  const ip4_address_t *src,
313  u32 len,
314  fib_node_index_t fib_entry_index)
315 {
316  uword * hash, * result;
317  u64 key;
318 
319  IP4_MFIB_MK_KEY(grp, src, len, key);
320  hash = mfib->fib_entry_by_dst_address[len];
321  result = hash_get (hash, key);
322 
323  if (NULL == result) {
324  /*
325  * adding a new entry
326  */
327  if (NULL == hash) {
328  hash = hash_create (32 /* elts */, sizeof (uword));
330  }
331  hash = hash_set(hash, key, fib_entry_index);
332  mfib->fib_entry_by_dst_address[len] = hash;
333  }
334  else
335  {
336  ASSERT(0);
337  }
338 }
339 
340 void
342  const ip4_address_t *grp,
343  const ip4_address_t *src,
344  u32 len)
345 {
346  uword * hash, * result;
347  u64 key;
348 
349  IP4_MFIB_MK_KEY(grp, src, len, key);
350  hash = mfib->fib_entry_by_dst_address[len];
351  result = hash_get (hash, key);
352 
353  if (NULL == result)
354  {
355  /*
356  * removing a non-existent entry. i'll allow it.
357  */
358  }
359  else
360  {
361  hash_unset(hash, key);
362  }
363 
364  mfib->fib_entry_by_dst_address[len] = hash;
365 }
366 
367 void
370  void *ctx)
371 {
372  int i;
373 
374  for (i = 0; i < ARRAY_LEN (mfib->fib_entry_by_dst_address); i++)
375  {
376  uword * hash = mfib->fib_entry_by_dst_address[i];
377 
378  if (NULL != hash)
379  {
380  hash_pair_t * p;
381 
382  hash_foreach_pair (p, hash,
383  ({
384  fn(p->value[0], ctx);
385  }));
386  }
387  }
388 }
389 
390 u8 *
391 format_ip4_mfib_table_memory (u8 * s, va_list * args)
392 {
393  mfib_table_t *mfib_table;
394  u64 total_memory;
395 
396  total_memory = 0;
397 
398  pool_foreach (mfib_table, ip4_main.mfibs)
399  {
400  ip4_mfib_t *mfib = &mfib_table->v4;
401  uword mfib_size;
402  int i;
403 
404  mfib_size = 0;
405 
406  for (i = 0; i < ARRAY_LEN (mfib->fib_entry_by_dst_address); i++)
407  {
408  uword * hash = mfib->fib_entry_by_dst_address[i];
409 
410  if (NULL != hash)
411  {
412  mfib_size += hash_bytes(hash);
413  }
414  }
415 
416  total_memory += mfib_size;
417  }
418 
419  s = format(s, "%=30s %=6d %=12ld\n",
420  "IPv4 multicast",
421  pool_elts(ip4_main.mfibs), total_memory);
422 
423  return (s);
424 }
425 
426 static void
428  vlib_main_t * vm)
429 {
430  fib_node_index_t *mfib_entry_indicies;
431  fib_node_index_t *mfib_entry_index;
432  int i;
433 
434  mfib_entry_indicies = NULL;
435 
436  for (i = 0; i < ARRAY_LEN (mfib->fib_entry_by_dst_address); i++)
437  {
438  uword * hash = mfib->fib_entry_by_dst_address[i];
439 
440  if (NULL != hash)
441  {
442  hash_pair_t * p;
443 
444  hash_foreach_pair (p, hash,
445  ({
446  vec_add1(mfib_entry_indicies, p->value[0]);
447  }));
448  }
449  }
450 
451  vec_sort_with_function(mfib_entry_indicies, mfib_entry_cmp_for_sort);
452 
453  vec_foreach(mfib_entry_index, mfib_entry_indicies)
454  {
455  vlib_cli_output(vm, "%U",
457  *mfib_entry_index,
459  }
460 
461  vec_free(mfib_entry_indicies);
462 }
463 
464 static void
466  vlib_main_t * vm,
468  ip4_address_t *grp,
469  u32 mask_len)
470 {
471  vlib_cli_output(vm, "%U",
473  ip4_mfib_table_lookup(mfib, src, grp, mask_len),
475 }
476 
477 static clib_error_t *
479  unformat_input_t * input,
480  vlib_cli_command_t * cmd)
481 {
482  ip4_main_t * im4 = &ip4_main;
483  mfib_table_t *mfib_table;
484  int verbose, matching, memory;
485  ip4_address_t grp, src = {{0}};
486  u32 mask = 32;
487  u64 total_hash_memory;
488  int i, table_id = -1, fib_index = ~0;
489 
490  verbose = 1;
491  memory = matching = 0;
492  total_hash_memory = 0;
493 
495  {
496  if (unformat (input, "brief") || unformat (input, "summary")
497  || unformat (input, "sum"))
498  verbose = 0;
499  else if (unformat (input, "mem") || unformat (input, "memory"))
500  memory = 1;
501  else if (unformat (input, "%U %U",
503  unformat_ip4_address, &grp))
504  {
505  matching = 1;
506  mask = 64;
507  }
508  else if (unformat (input, "%U/%d", unformat_ip4_address, &grp, &mask))
509  {
510  clib_memset(&src, 0, sizeof(src));
511  matching = 1;
512  }
513  else if (unformat (input, "%U", unformat_ip4_address, &grp))
514  {
515  clib_memset(&src, 0, sizeof(src));
516  matching = 1;
517  mask = 32;
518  }
519  else if (unformat (input, "table %d", &table_id))
520  ;
521  else if (unformat (input, "index %d", &fib_index))
522  ;
523  else
524  break;
525  }
526 
527  pool_foreach (mfib_table, im4->mfibs)
528  {
529  ip4_mfib_t *mfib = &mfib_table->v4;
530 
531  if (table_id >= 0 && table_id != (int)mfib->table_id)
532  continue;
533  if (fib_index != ~0 && fib_index != (int)mfib->index)
534  continue;
535 
536  if (memory)
537  {
538  uword hash_size;
539 
540  hash_size = 0;
541 
542  for (i = 0; i < ARRAY_LEN (mfib->fib_entry_by_dst_address); i++)
543  {
544  uword * hash = mfib->fib_entry_by_dst_address[i];
545  if (NULL != hash)
546  {
547  hash_size += hash_bytes(hash);
548  }
549  }
550  if (verbose)
551  vlib_cli_output (vm, "%U hash:%d",
554  hash_size);
555  total_hash_memory += hash_size;
556  continue;
557  }
558 
559  vlib_cli_output (vm, "%U, fib_index:%d flags:%U",
561  mfib->index,
562  format_mfib_table_flags, mfib_table->mft_flags);
563 
564  /* Show summary? */
565  if (! verbose)
566  {
567  vlib_cli_output (vm, "%=20s%=16s", "Prefix length", "Count");
568  for (i = 0; i < ARRAY_LEN (mfib->fib_entry_by_dst_address); i++)
569  {
570  uword * hash = mfib->fib_entry_by_dst_address[i];
571  uword n_elts = hash_elts (hash);
572  if (n_elts > 0)
573  vlib_cli_output (vm, "%20d%16d", i, n_elts);
574  }
575  continue;
576  }
577 
578  if (!matching)
579  {
581  }
582  else
583  {
584  ip4_mfib_table_show_one(mfib, vm, &src, &grp, mask);
585  }
586  }
587  if (memory)
588  vlib_cli_output (vm, "totals: hash:%ld", total_hash_memory);
589 
590  return 0;
591 }
592 
593 /*?
594  * This command displays the IPv4 MulticasrFIB Tables (VRF Tables) and
595  * the route entries for each table.
596  *
597  * @note This command will run for a long time when the FIB tables are
598  * comprised of millions of entries. For those senarios, consider displaying
599  * a single table or summary mode.
600  *
601  * @cliexpar
602  * Example of how to display all the IPv4 Multicast FIB tables:
603  * @cliexstart{show ip fib}
604  * ipv4-VRF:0, fib_index 0
605  * (*, 0.0.0.0/0): flags:D,
606  * Interfaces:
607  * multicast-ip4-chain
608  * [@1]: dpo-drop ip4
609  * (*, 232.1.1.1/32):
610  * Interfaces:
611  * test-eth1: Forward,
612  * test-eth2: Forward,
613  * test-eth0: Accept,
614  * multicast-ip4-chain
615  * [@2]: dpo-replicate: [index:1 buckets:2 to:[0:0]]
616  * [0] [@1]: ipv4-mcast: test-eth1: IP4: d0:d1:d2:d3:d4:01 -> 01:00:05:00:00:00
617  * [1] [@1]: ipv4-mcast: test-eth2: IP4: d0:d1:d2:d3:d4:02 -> 01:00:05:00:00:00
618  *
619  * @cliexend
620  * Example of how to display a summary of all IPv4 FIB tables:
621  * @cliexstart{show ip fib summary}
622  * ipv4-VRF:0, fib_index 0, flow hash: src dst sport dport proto
623  * Prefix length Count
624  * 0 1
625  * 8 2
626  * 32 4
627  * ipv4-VRF:7, fib_index 1, flow hash: src dst sport dport proto
628  * Prefix length Count
629  * 0 1
630  * 8 2
631  * 24 2
632  * 32 4
633  * @cliexend
634  ?*/
635 /* *INDENT-OFF* */
637  .path = "show ip mfib",
638  .short_help = "show ip mfib [summary] [table <table-id>] [index <fib-id>] [<grp-addr>[/<mask>]] [<grp-addr>] [<src-addr> <grp-addr>]",
639  .function = ip4_show_mfib,
640 };
641 /* *INDENT-ON* */
format_ip4_mfib_table_memory
u8 * format_ip4_mfib_table_memory(u8 *s, va_list *args)
format (display) the memory usage for IP4 mfibs
Definition: ip4_mfib.c:391
ip4_mfib_table_show_all
static void ip4_mfib_table_show_all(ip4_mfib_t *mfib, vlib_main_t *vm)
Definition: ip4_mfib.c:427
ip4_mfib_interface_enable_disable
void ip4_mfib_interface_enable_disable(u32 sw_if_index, int is_enable)
Add/remove the interface from the accepting list of the special MFIB entries.
Definition: ip4_mfib.c:132
hash_set
#define hash_set(h, key, value)
Definition: hash.h:255
all_zeros
static const mfib_prefix_t all_zeros
Definition: ip4_mfib.c:21
zero_addr
const ip46_address_t zero_addr
#include <vnet/feature/feature.h>
Definition: lookup.c:182
ip4_main
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1104
HASH_FLAG_NO_AUTO_SHRINK
#define HASH_FLAG_NO_AUTO_SHRINK
Definition: hash.h:64
ip4_mfib_table_entry_insert
void ip4_mfib_table_entry_insert(ip4_mfib_t *mfib, const ip4_address_t *grp, const ip4_address_t *src, u32 len, fib_node_index_t fib_entry_index)
Definition: ip4_mfib.c:310
hash_foreach_pair
#define hash_foreach_pair(p, v, body)
Iterate over hash pairs.
Definition: hash.h:373
MFIB_ITF_FLAG_ACCEPT
@ MFIB_ITF_FLAG_ACCEPT
Definition: mfib_types.h:152
ip4_show_mfib_command
static vlib_cli_command_t ip4_show_mfib_command
(constructor) VLIB_CLI_COMMAND (ip4_show_mfib_command)
Definition: ip4_mfib.c:636
ip4_mfib_table_lookup_exact_match
fib_node_index_t ip4_mfib_table_lookup_exact_match(const ip4_mfib_t *mfib, const ip4_address_t *grp, const ip4_address_t *src, u32 len)
Definition: ip4_mfib.c:215
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
ip4_mfib_table_show_one
static void ip4_mfib_table_show_one(ip4_mfib_t *mfib, vlib_main_t *vm, ip4_address_t *src, ip4_address_t *grp, u32 mask_len)
Definition: ip4_mfib.c:465
hash_bytes
__clib_export uword hash_bytes(void *v)
Definition: hash.c:994
mfib_table_t_::mft_total_route_counts
u32 mft_total_route_counts
Total route counters.
Definition: mfib_table.h:122
mfib_prefix_t_
Aggregate type for a prefix.
Definition: mfib_types.h:24
ip4_mfib_index_from_table_id
static u32 ip4_mfib_index_from_table_id(u32 table_id)
Definition: ip4_mfib.h:91
path
vl_api_fib_path_t path
Definition: mfib_types.api:44
vlib_cli_command_t::path
char * path
Definition: cli.h:96
mfib_entry.h
FIB_NODE_INDEX_INVALID
#define FIB_NODE_INDEX_INVALID
Definition: fib_types.h:30
hash_elts
static uword hash_elts(void *v)
Definition: hash.h:118
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
MFIB_ENTRY_FORMAT_BRIEF
#define MFIB_ENTRY_FORMAT_BRIEF
Definition: mfib_entry.h:110
unformat_input_t
struct _unformat_input_t unformat_input_t
ip4_mfib.h
mfib_table_t_
A protocol Independent IP multicast FIB table.
Definition: mfib_table.h:71
IP4_MFIB_MK_GRP_KEY
#define IP4_MFIB_MK_GRP_KEY(_grp, _len, _key)
Definition: ip4_mfib.c:203
hash_unset
#define hash_unset(h, key)
Definition: hash.h:261
key
typedef key
Definition: ipsec_types.api:91
i32
signed int i32
Definition: types.h:77
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
MFIB_SOURCE_SPECIAL
@ MFIB_SOURCE_SPECIAL
Definition: mfib_types.h:163
mfib_table_lock
void mfib_table_lock(u32 fib_index, fib_protocol_t proto, mfib_source_t source)
Release a reference counting lock on the table.
Definition: mfib_table.c:806
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
ip4_mfib_t::table_id
u32 table_id
Definition: ip4.h:58
mfib_source_t
enum mfib_source_t_ mfib_source_t
Possible [control plane] sources of MFIB entries.
mfib_table_t_::mft_index
fib_node_index_t mft_index
Index into FIB vector.
Definition: mfib_table.h:117
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
len
u8 len
Definition: ip_types.api:103
ip4_mfib_table_destroy
void ip4_mfib_table_destroy(ip4_mfib_t *mfib)
Definition: ip4_mfib.c:102
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
hash_pair_t::value
uword value[0]
Definition: hash.h:165
memory
vhost_user_memory_t memory
Definition: vhost_user.h:131
hash_get
#define hash_get(h, key)
Definition: hash.h:249
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
format_mfib_table_flags
u8 * format_mfib_table_flags(u8 *s, va_list *args)
Definition: mfib_table.c:848
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
ip4_create_mfib_with_table_id
static u32 ip4_create_mfib_with_table_id(u32 table_id, mfib_source_t src)
Definition: ip4_mfib.c:47
mfib_table_walk_fn_t
walk_rc_t(* mfib_table_walk_fn_t)(fib_node_index_t fei, void *ctx)
Call back function when walking entries in a FIB table.
Definition: mfib_table.h:554
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
uword
u64 uword
Definition: types.h:112
MFIB_SOURCE_DEFAULT_ROUTE
@ MFIB_SOURCE_DEFAULT_ROUTE
Definition: mfib_types.h:177
ip4_main_t::mfib_index_by_table_id
uword * mfib_index_by_table_id
Hash table mapping table id to multicast fib index.
Definition: ip4.h:134
ip4_mfib_table_get_index_for_sw_if_index
u32 ip4_mfib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: ip4_mfib.c:181
mask
vl_api_pnat_mask_t mask
Definition: pnat.api:45
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
ip4_specials
static const mfib_prefix_t ip4_specials[]
Definition: ip4_mfib.c:25
src
vl_api_address_t src
Definition: gre.api:54
ip4_mfib_t::index
u32 index
Definition: ip4.h:61
ip4_mfib_t::fib_entry_by_dst_address
uword * fib_entry_by_dst_address[65]
Definition: ip4.h:55
format_mfib_entry
u8 * format_mfib_entry(u8 *s, va_list *args)
Definition: mfib_entry.c:126
ip4_address_t
Definition: ip4_packet.h:50
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
mfib_table.h
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
mfib_prefix_t_::fp_proto
fib_protocol_t fp_proto
protocol type
Definition: mfib_types.h:33
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
mfib_entry_cmp_for_sort
int mfib_entry_cmp_for_sort(void *i1, void *i2)
Definition: mfib_entry.c:1313
index
u32 index
Definition: flow_types.api:221
ip4_main_t::mfib_index_by_sw_if_index
u32 * mfib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip4.h:123
mfib_table_t_::mft_proto
fib_protocol_t mft_proto
Which protocol this table serves.
Definition: mfib_table.h:92
u64
unsigned long u64
Definition: types.h:89
mfib_prefix_t_::fp_grp_addr
ip46_address_t fp_grp_addr
The address type is not deriveable from the fp_addr member.
Definition: mfib_types.h:46
ip4_mfib_table_entry_remove
void ip4_mfib_table_entry_remove(ip4_mfib_t *mfib, const ip4_address_t *grp, const ip4_address_t *src, u32 len)
Definition: ip4_mfib.c:341
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
ip4_mfib_t
Definition: ip4.h:52
mfib_table_t_::mft_table_id
u32 mft_table_id
Table ID (hash key) for this FIB.
Definition: mfib_table.h:107
u32
unsigned int u32
Definition: types.h:88
MFIB_RPF_ID_NONE
#define MFIB_RPF_ID_NONE
Definition: fib_types.h:423
table_id
u32 table_id
Definition: wireguard.api:102
fib_route_path_t_
A representation of a path as described by a route producer.
Definition: fib_types.h:500
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
ip4_mfib_table_lookup
fib_node_index_t ip4_mfib_table_lookup(const ip4_mfib_t *mfib, const ip4_address_t *src, const ip4_address_t *grp, u32 len)
The IPv4 Multicast-FIB.
Definition: ip4_mfib.c:240
pool_elts
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:127
vec_sort_with_function
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:1097
mfib_table_entry_path_remove
void mfib_table_entry_path_remove(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, const fib_route_path_t *rpath)
Remove n paths to an entry (aka route) in the FIB.
Definition: mfib_table.c:407
ip4_main_t::mfibs
struct mfib_table_t_ * mfibs
Vector of MFIBs.
Definition: ip4.h:115
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
ip4_mfib_table_find_or_create_and_lock
u32 ip4_mfib_table_find_or_create_and_lock(u32 table_id, mfib_source_t src)
Get or create an IPv4 fib.
Definition: ip4_mfib.c:167
ip4_mfib_table_get_less_specific
fib_node_index_t ip4_mfib_table_get_less_specific(const ip4_mfib_t *mfib, const ip4_address_t *src, const ip4_address_t *grp, u32 len)
Definition: ip4_mfib.c:278
hash_set_flags
static void hash_set_flags(void *v, uword flags)
Definition: hash.h:153
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
MFIB_ENTRY_FLAG_DROP
@ MFIB_ENTRY_FLAG_DROP
Definition: mfib_types.h:109
mfib_table_entry_update
fib_node_index_t mfib_table_entry_update(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, fib_rpf_id_t rpf_id, mfib_entry_flags_t entry_flags)
Add a new (with no replication) or lock an existing entry.
Definition: mfib_table.c:237
mfib_table_entry_path_update
fib_node_index_t mfib_table_entry_path_update(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, const fib_route_path_t *rpath)
Add n paths to an entry (aka route) in the FIB.
Definition: mfib_table.c:325
ip4_mfib_table_walk
void ip4_mfib_table_walk(ip4_mfib_t *mfib, mfib_table_walk_fn_t fn, void *ctx)
Walk the IP4 mfib table.
Definition: ip4_mfib.c:368
i
int i
Definition: flowhash_template.h:376
DPO_PROTO_IP4
@ DPO_PROTO_IP4
Definition: dpo.h:64
MFIB_ITF_FLAG_FORWARD
@ MFIB_ITF_FLAG_FORWARD
Definition: mfib_types.h:153
ip4_show_mfib
static clib_error_t * ip4_show_mfib(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: ip4_mfib.c:478
unformat_ip4_address
unformat_function_t unformat_ip4_address
Definition: format.h:68
IP4_MFIB_MK_KEY
#define IP4_MFIB_MK_KEY(_grp, _src, _len, _key)
Definition: ip4_mfib.c:197
vlib_cli_command_t
Definition: cli.h:92
format_mfib_table_name
u8 * format_mfib_table_name(u8 *s, va_list *ap)
Format the description/name of the table.
Definition: mfib_table.c:868
PREDICT_TRUE
#define PREDICT_TRUE(x)
Definition: clib.h:125
ip4_main_t
IPv4 main type.
Definition: ip4.h:107
mfib_table_t_::v4
ip4_mfib_t v4
Definition: mfib_table.h:85
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
hash_create
#define hash_create(elts, value_bytes)
Definition: hash.h:695
mfib_table_t_::mft_flags
mfib_table_flags_t mft_flags
table falgs
Definition: mfib_table.h:97
FIB_ROUTE_PATH_LOCAL
@ FIB_ROUTE_PATH_LOCAL
A for-us/local path.
Definition: fib_types.h:344
mfib_table_entry_delete
void mfib_table_entry_delete(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source)
Delete a FIB entry.
Definition: mfib_table.c:493
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
hash_pair_t
Definition: hash.h:159
MFIB_ENTRY_FORMAT_DETAIL
#define MFIB_ENTRY_FORMAT_DETAIL
Definition: mfib_entry.h:111