FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
fib_api.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/vnet.h>
17 #include <vlibmemory/api.h>
18 #include <vnet/fib/fib_api.h>
19 #include <vnet/ip/ip_types_api.h>
20 #include <vnet/fib/fib_table.h>
21 #include <vnet/mfib/mfib_table.h>
23 #include <vpp/api/types.h>
25 #include <vnet/ip/ip_format_fns.h>
26 
27 #include <vnet/fib/fib.api_enum.h>
28 #include <vnet/fib/fib.api_types.h>
29 
31 #define REPLY_MSG_ID_BASE fib_base_msg_id
33 
34 int
36  u32 table_id,
37  u32 *fib_index)
38 {
39  *fib_index = fib_table_find(fproto, table_id);
40 
41  if (INDEX_INVALID == *fib_index)
42  {
43  return VNET_API_ERROR_NO_SUCH_FIB;
44  }
45 
46  return (0);
47 }
48 
49 int
51  u32 table_id,
52  u32 *fib_index)
53 {
54  *fib_index = mfib_table_find(fproto, table_id);
55 
56  if (~0 == *fib_index)
57  {
58  return VNET_API_ERROR_NO_SUCH_FIB;
59  }
60 
61  return (0);
62 }
63 
64 static void
65 fib_api_next_hop_decode (const vl_api_fib_path_t *in,
66  ip46_address_t *out)
67 {
68  if (in->proto == FIB_API_PATH_NH_PROTO_IP4)
69  clib_memcpy (&out->ip4, &in->nh.address.ip4, sizeof (out->ip4));
70  else if (in->proto == FIB_API_PATH_NH_PROTO_IP6)
71  clib_memcpy (&out->ip6, &in->nh.address.ip6, sizeof (out->ip6));
72 }
73 
74 static vl_api_fib_path_nh_proto_t
76 {
77  switch (dproto)
78  {
79  case DPO_PROTO_IP4:
81  case DPO_PROTO_IP6:
83  case DPO_PROTO_MPLS:
85  case DPO_PROTO_BIER:
87  case DPO_PROTO_ETHERNET:
89  case DPO_PROTO_NSH:
90  ASSERT(0);
91  break;
92  }
94 }
95 
96 
97 static void
99  vl_api_fib_path_t *fp)
100 {
101  fp->proto = fib_api_path_dpo_proto_to_nh(rpath->frp_proto);
102 
103  if (rpath->frp_proto == DPO_PROTO_IP4)
104  clib_memcpy (&fp->nh.address.ip4,
105  &rpath->frp_addr.ip4,
106  sizeof (rpath->frp_addr.ip4));
107  else if (rpath->frp_proto == DPO_PROTO_IP6)
108  clib_memcpy (&fp->nh.address.ip6,
109  &rpath->frp_addr.ip6,
110  sizeof (rpath->frp_addr.ip6));
111 }
112 
113 static int
114 fib_api_path_nh_proto_to_dpo (vl_api_fib_path_nh_proto_t pp,
115  dpo_proto_t *dproto)
116 {
117  switch (pp)
118  {
120  *dproto = DPO_PROTO_IP4;
121  break;
123  *dproto = DPO_PROTO_IP6;
124  break;
126  *dproto = DPO_PROTO_MPLS;
127  break;
129  *dproto = DPO_PROTO_BIER;
130  break;
132  *dproto = DPO_PROTO_ETHERNET;
133  break;
134  default:
135  return (-1);
136  }
137  return (0);
138 }
139 
140 int
141 fib_api_path_decode (vl_api_fib_path_t *in,
142  fib_route_path_t *out)
143 {
145  int rv = 0, n_labels;
146  vnet_main_t *vnm;
147  u8 ii;
148 
149  vnm = vnet_get_main ();
150  clib_memset(&out->frp_dpo, 0, sizeof(out->frp_dpo));
151 
152  /* enums are u32 */
153  in->flags = ntohl (in->flags);
154  in->type = ntohl (in->type);
155  in->proto = ntohl (in->proto);
156 
157  /*
158  * attributes that apply to all path types
159  */
160  out->frp_flags = 0;
161  out->frp_weight = in->weight;
162  if (0 == out->frp_weight)
163  {
164  out->frp_weight = 1;
165  }
166  out->frp_preference = in->preference;
167 
168  rv = fib_api_path_nh_proto_to_dpo(in->proto, &out->frp_proto);
169 
170  if (0 != rv)
171  return (rv);
172 
173  /*
174  * convert the flags and the AFI to determine the path type
175  */
176  if (in->flags & FIB_API_PATH_FLAG_RESOLVE_VIA_HOST)
180  if (in->flags & FIB_API_PATH_FLAG_POP_PW_CW)
182 
183  switch (in->type)
184  {
186  out->frp_sw_if_index = ntohl(in->sw_if_index);
188  break;
190  out->frp_sw_if_index = ntohl(in->sw_if_index);
192  break;
195  break;
198  out->frp_sw_if_index = ntohl(in->sw_if_index);
199  break;
202  break;
205  break;
208 
209  if (pool_is_free_index (cm->tables, ntohl (in->nh.classify_table_index)))
210  {
211  return VNET_API_ERROR_NO_SUCH_TABLE;
212  }
213  out->frp_classify_table_id = ntohl (in->nh.classify_table_index);
214  break;
217  out->frp_udp_encap_id = ntohl(in->nh.obj_id);
218  break;
221  out->frp_bier_imp = ntohl (in->nh.obj_id);
222  break;
223 
226  /* fall through */
228  switch (out->frp_proto)
229  {
230  case DPO_PROTO_IP4:
231  case DPO_PROTO_IP6:
233  out->frp_sw_if_index = ntohl(in->sw_if_index);
234  out->frp_rpf_id = ntohl(in->rpf_id);
235 
236  if (0 == out->frp_rpf_id)
237  {
238  /* allow 0 to be an unset value on the API */
239  out->frp_rpf_id = ~0;
240  }
241 
242  if (~0 != out->frp_rpf_id)
243  {
245  }
246 
247  if (~0 == out->frp_sw_if_index)
248  {
249  /* recursive or deag, validate the next-hop FIB */
250  if (~0 != out->frp_rpf_id)
251  {
254  ntohl(in->table_id),
255  &out->frp_fib_index);
256  }
257  else
258  {
261  ntohl(in->table_id),
262  &out->frp_fib_index);
263  }
264  if (0 != rv)
265  {
266  return (rv);
267  }
268  }
269  else
270  {
272  out->frp_sw_if_index))
273  {
274  return VNET_API_ERROR_NO_MATCHING_INTERFACE;
275  }
276  }
277 
278  if (ip46_address_is_zero(&out->frp_addr))
279  {
280  if (~0 == out->frp_sw_if_index &&
281  ~0 != out->frp_fib_index)
282  {
284  }
285  }
286 
287  break;
288  case DPO_PROTO_MPLS:
289  out->frp_local_label = ntohl (in->nh.via_label);
290  out->frp_eos = MPLS_NON_EOS;
291  out->frp_sw_if_index = ~0;
292  break;
293  case DPO_PROTO_BIER:
294  out->frp_sw_if_index = ntohl(in->sw_if_index);
295  out->frp_rpf_id = ntohl(in->rpf_id);
296 
297  if (!(out->frp_flags & FIB_ROUTE_PATH_BIER_IMP))
298  {
300 
301  if (ip46_address_is_zero(&out->frp_addr))
302  {
303  index_t bdti;
304 
305  bdti = bier_disp_table_find(ntohl(in->table_id));
306 
307  if (INDEX_INVALID != bdti)
308  {
309  out->frp_fib_index = bdti;
310  }
311  else
312  {
313  return (VNET_API_ERROR_NO_SUCH_FIB);
314  }
315  }
316  }
317  break;
318  case DPO_PROTO_ETHERNET:
319  out->frp_sw_if_index = ntohl(in->sw_if_index);
320  break;
321  case DPO_PROTO_NSH:
322  break;
323  }
324  }
325 
326  n_labels = in->n_labels;
327  if (n_labels != 0)
328  {
330  for (ii = 0; ii < n_labels; ii++)
331  {
332  out->frp_label_stack[ii].fml_value =
333  ntohl(in->label_stack[ii].label);
334  out->frp_label_stack[ii].fml_ttl =
335  in->label_stack[ii].ttl;
336  out->frp_label_stack[ii].fml_exp =
337  in->label_stack[ii].exp;
338  out->frp_label_stack[ii].fml_mode =
339  (in->label_stack[ii].is_uniform ?
342  }
343  }
344 
345  return (0);
346 }
347 
348 void
350  vl_api_fib_path_t *out)
351 {
352  memset (out, 0, sizeof (*out));
353 
354  out->weight = rpath->frp_weight;
355  out->preference = rpath->frp_preference;
356  out->sw_if_index = htonl (rpath->frp_sw_if_index);
357  out->proto = fib_api_path_dpo_proto_to_nh(rpath->frp_proto);
358  out->rpf_id = rpath->frp_rpf_id;
359  fib_api_next_hop_encode (rpath, out);
360 
361  if (0 != rpath->frp_fib_index)
362  {
363  if ((DPO_PROTO_IP6 == rpath->frp_proto) ||
364  (DPO_PROTO_IP4 == rpath->frp_proto))
365  {
366  if (rpath->frp_flags & FIB_ROUTE_PATH_RPF_ID)
367  {
368  out->table_id = htonl (mfib_table_get_table_id(
369  rpath->frp_fib_index,
370  dpo_proto_to_fib(rpath->frp_proto)));
371  }
372  else
373  {
374  out->table_id = htonl (fib_table_get_table_id(
375  rpath->frp_fib_index,
376  dpo_proto_to_fib(rpath->frp_proto)));
377  }
378  }
379  }
380 
381  if (rpath->frp_flags & FIB_ROUTE_PATH_DVR)
382  {
383  out->type = FIB_API_PATH_TYPE_DVR;
384  }
385  else if (rpath->frp_flags & FIB_ROUTE_PATH_ICMP_UNREACH)
386  {
387  out->type = FIB_API_PATH_TYPE_ICMP_UNREACH;
388  }
389  else if (rpath->frp_flags & FIB_ROUTE_PATH_ICMP_PROHIBIT)
390  {
392  }
393  else if (rpath->frp_flags & FIB_ROUTE_PATH_LOCAL)
394  {
395  out->type = FIB_API_PATH_TYPE_LOCAL;
396  }
397  else if (rpath->frp_flags & FIB_ROUTE_PATH_DROP)
398  {
399  out->type = FIB_API_PATH_TYPE_DROP;
400  }
401  else if (rpath->frp_flags & FIB_ROUTE_PATH_UDP_ENCAP)
402  {
403  out->type = FIB_API_PATH_TYPE_UDP_ENCAP;
404  out->nh.obj_id = rpath->frp_udp_encap_id;
405  }
406  else if (rpath->frp_flags & FIB_ROUTE_PATH_BIER_IMP)
407  {
408  out->type = FIB_API_PATH_TYPE_BIER_IMP;
409  out->nh.obj_id = rpath->frp_bier_imp;
410  }
411  else if (rpath->frp_flags & FIB_ROUTE_PATH_INTF_RX)
412  {
413  out->type = FIB_API_PATH_TYPE_INTERFACE_RX;
414  }
415  else
416  {
417  out->type = FIB_API_PATH_TYPE_NORMAL;
418  }
420  {
422  }
424  {
426  }
427 
428  out->flags = htonl (out->flags);
429  out->type = htonl (out->type);
430  out->proto = htonl (out->proto);
431 
432  if (rpath->frp_label_stack)
433  {
434  int ii;
435 
436  for (ii = 0; ii < vec_len(rpath->frp_label_stack); ii++)
437  {
438  out->label_stack[ii].label =
439  htonl(rpath->frp_label_stack[ii].fml_value);
440  out->label_stack[ii].ttl =
441  rpath->frp_label_stack[ii].fml_ttl;
442  out->label_stack[ii].exp =
443  rpath->frp_label_stack[ii].fml_exp;
444  }
445  out->n_labels = ii;
446  }
447 }
448 
449 int
451  u8 is_multipath,
452  u32 fib_index,
453  const fib_prefix_t * prefix,
456  fib_route_path_t *rpaths)
457 {
458  if (is_multipath)
459  {
460  if (vec_len(rpaths) == 0)
461  return (VNET_API_ERROR_NO_PATHS_IN_ROUTE);
462 
463  /* Iterative path add/remove */
464  if (is_add)
465  fib_table_entry_path_add2 (fib_index,
466  prefix,
467  src,
468  entry_flags,
469  rpaths);
470  else
471  fib_table_entry_path_remove2 (fib_index,
472  prefix,
473  src,
474  rpaths);
475  }
476  else
477  {
478  if (is_add)
479  {
480  if (vec_len(rpaths) == 0)
481  return (VNET_API_ERROR_NO_PATHS_IN_ROUTE);
482 
483  /* path replacement */
484  fib_table_entry_update (fib_index,
485  prefix,
486  src,
487  entry_flags,
488  rpaths);
489  }
490  else
491  /* entry delete */
492  fib_table_entry_delete (fib_index,
493  prefix,
494  src);
495  }
496 
497  return (0);
498 }
499 
500 u8*
501 format_vl_api_fib_path (u8 * s, va_list * args)
502 {
503  const vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t*);
504 
505  s = format (s, "sw_if_index %d", ntohl (path->sw_if_index));
506  switch (clib_net_to_host_u32(path->proto))
507  {
509  s = format (s, " %U", format_vl_api_address_union,
510  &path->nh.address, ADDRESS_IP4);
511  break;
513  s = format (s, " %U", format_vl_api_address_union,
514  &path->nh.address, ADDRESS_IP6);
515  break;
516  default:
517  break;
518  }
519  s = format (s, " weight %d", path->weight);
520  s = format (s, " preference %d", path->preference);
521  s = format (s, " type %d", ntohl(path->type));
522  s = format (s, " proto %d", ntohl(path->proto));
523  s = format (s, " flags %d", ntohl(path->flags));
524  s = format (s, " n_labels %d", ntohl(path->n_labels));
525  s = format (s, " table-id %d", ntohl(path->table_id));
526  s = format (s, " rpf-id %d", ntohl(path->rpf_id));
527 
528  return (s);
529 }
530 
531 int
532 fib_proto_from_api_address_family (vl_api_address_family_t af, fib_protocol_t * out)
533 {
534  switch (af)
535  {
536  case ADDRESS_IP4:
537  *out = (FIB_PROTOCOL_IP4);
538  return (0);
539  case ADDRESS_IP6:
540  *out = (FIB_PROTOCOL_IP6);
541  return (0);
542  }
543 
544  return (VNET_API_ERROR_INVALID_ADDRESS_FAMILY);
545 }
546 
547 vl_api_address_family_t
549 {
550  switch (fproto)
551  {
552  case FIB_PROTOCOL_IP4:
553  return (ADDRESS_IP4);
554  case FIB_PROTOCOL_IP6:
555  return (ADDRESS_IP6);
556  default:
557  break;
558  }
559 
560  ASSERT(0);
561  return (ADDRESS_IP4);
562 }
563 
564 void
566 {
569  int rv = 0;
570  u8 *name;
571 
572  name = format (0, "%s", mp->src.name);
573  vec_add1 (name, 0);
574 
575  src = fib_source_allocate((const char *)name,
576  mp->src.priority,
578 
579  vec_free(name);
580 
581  REPLY_MACRO2 (VL_API_FIB_SOURCE_ADD_REPLY,
582  ({
583  rmp->id = src;
584  }));
585 }
586 
588 {
592 
593 static walk_rc_t
595  const char *name,
598  void *data)
599 {
602 
603  ctx = data;
604  mp = vl_msg_api_alloc_zero (sizeof (*mp));
605  if (!mp)
606  return WALK_STOP;
607 
608  mp->_vl_msg_id = ntohs (VL_API_FIB_SOURCE_DETAILS + REPLY_MSG_ID_BASE);
609  mp->context = ctx->context;
610 
611  mp->src.priority = prio;
612  mp->src.id = id;
613  clib_memcpy(mp->src.name, name,
614  clib_min(strlen(name), ARRAY_LEN(mp->src.name)));
615 
616  vl_api_send_msg (ctx->reg, (u8 *) mp);
617 
618  return (WALK_CONTINUE);
619 }
620 
621 void
623 {
625 
627  if (!reg)
628  return;
629 
631  .reg = reg,
632  .context = mp->context,
633  };
634 
636 }
637 
638 
639 #include <vnet/fib/fib.api.c>
640 
641 static clib_error_t *
643 {
644  /*
645  * Set up the (msg_name, crc, message-id) table
646  */
648 
649  return (NULL);
650 }
651 
fib_route_path_t_::frp_fib_index
u32 frp_fib_index
The FIB index to lookup the nexthop Only valid for recursive paths.
Definition: fib_types.h:556
FIB_API_PATH_TYPE_DROP
@ FIB_API_PATH_TYPE_DROP
Definition: fib_types.api:78
vl_api_client_index_to_registration
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
api.h
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
REPLY_MSG_ID_BASE
#define REPLY_MSG_ID_BASE
Definition: fib_api.c:31
WALK_CONTINUE
@ WALK_CONTINUE
Definition: interface_funcs.h:174
REPLY_MACRO2
#define REPLY_MACRO2(t, body)
Definition: api_helper_macros.h:65
fib_route_path_t_::frp_bier_imp
index_t frp_bier_imp
A path via a BIER imposition object.
Definition: fib_types.h:533
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
fib_table_get_table_id
u32 fib_table_get_table_id(u32 fib_index, fib_protocol_t proto)
Get the Table-ID of the FIB from protocol and index.
Definition: fib_table.c:1100
fib_table_entry_delete
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:900
fib_route_path_t_::frp_weight
u8 frp_weight
[un]equal cost path weight
Definition: fib_types.h:599
dpo_proto_t
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
vl_api_send_msg
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
FIB_ROUTE_PATH_ICMP_PROHIBIT
@ FIB_ROUTE_PATH_ICMP_PROHIBIT
Definition: fib_types.h:396
entry_flags
vl_api_mfib_entry_flags_t entry_flags
Definition: ip.api:443
name
string name[64]
Definition: fib.api:25
fib_mpls_label_t_::fml_exp
u8 fml_exp
EXP bits; valid only at imposition.
Definition: fib_types.h:475
fib_source_dump_ctx_t_
Definition: fib_api.c:587
fib_source_dump_ctx_t_::context
u32 context
Definition: fib_api.c:590
fib_api_next_hop_decode
static void fib_api_next_hop_decode(const vl_api_fib_path_t *in, ip46_address_t *out)
Definition: fib_api.c:65
path
vl_api_fib_path_t path
Definition: mfib_types.api:44
vnet_classify_main
vnet_classify_main_t vnet_classify_main
Definition: vnet_classify.c:32
fib_route_path_t_::frp_dpo
dpo_id_t frp_dpo
The DPO for use with exclusive paths.
Definition: fib_types.h:594
fib_api_next_hop_encode
static void fib_api_next_hop_encode(const fib_route_path_t *rpath, vl_api_fib_path_t *fp)
Definition: fib_api.c:98
FIB_API_PATH_TYPE_CLASSIFY
@ FIB_API_PATH_TYPE_CLASSIFY
Definition: fib_types.api:95
fib_table.h
fib_route_path_t_::frp_addr
ip46_address_t frp_addr
The next-hop address.
Definition: fib_types.h:516
fib_route_path_t_::frp_rpf_id
fib_rpf_id_t frp_rpf_id
The RPF-ID.
Definition: fib_types.h:550
u16
unsigned short u16
Definition: types.h:57
FIB_API_PATH_TYPE_ICMP_UNREACH
@ FIB_API_PATH_TYPE_ICMP_UNREACH
Definition: fib_types.api:84
vl_api_fib_source_details_t::src
vl_api_fib_source_t src
Definition: fib.api:51
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
fib_route_path_t_::frp_eos
mpls_eos_bit_t frp_eos
EOS bit for the resolving label.
Definition: fib_types.h:527
fib_route_path_t_::frp_sw_if_index
u32 frp_sw_if_index
The interface.
Definition: fib_types.h:545
DPO_PROTO_BIER
@ DPO_PROTO_BIER
Definition: dpo.h:68
fib_api_path_nh_proto_to_dpo
static int fib_api_path_nh_proto_to_dpo(vl_api_fib_path_nh_proto_t pp, dpo_proto_t *dproto)
Definition: fib_api.c:114
FIB_API_PATH_NH_PROTO_BIER
@ FIB_API_PATH_NH_PROTO_BIER
Definition: fib_types.api:38
vl_api_fib_source_add_t_handler
void vl_api_fib_source_add_t_handler(vl_api_fib_source_add_t *mp)
Definition: fib_api.c:565
vl_msg_api_alloc_zero
void * vl_msg_api_alloc_zero(int nbytes)
Definition: memory_shared.c:214
vl_api_fib_source_dump_t_handler
void vl_api_fib_source_dump_t_handler(vl_api_fib_source_dump_t *mp)
Definition: fib_api.c:622
fib_route_path_t_::frp_proto
dpo_proto_t frp_proto
The protocol of the address below.
Definition: fib_types.h:505
n_labels
u8 n_labels
Definition: fib_types.api:127
ADDRESS_IP6
@ ADDRESS_IP6
Definition: ip_types.api:23
fib_api_hookup
static clib_error_t * fib_api_hookup(vlib_main_t *vm)
Definition: fib_api.c:642
format_vl_api_fib_path
u8 * format_vl_api_fib_path(u8 *s, va_list *args)
Definition: fib_api.c:501
fib_api_path_encode
void fib_api_path_encode(const fib_route_path_t *rpath, vl_api_fib_path_t *out)
Encode and decode functions from the API types to internal types.
Definition: fib_api.c:349
FIB_ROUTE_PATH_DVR
@ FIB_ROUTE_PATH_DVR
A path that resolves via a DVR DPO.
Definition: fib_types.h:393
vl_api_fib_source_add_t::src
vl_api_fib_source_t src
Definition: fib.api:32
ip_format_fns.h
fib_route_path_t_::frp_label_stack
fib_mpls_label_t * frp_label_stack
The outgoing MPLS label Stack.
Definition: fib_types.h:560
pool_is_free_index
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:302
FIB_API_PATH_NH_PROTO_IP4
@ FIB_API_PATH_NH_PROTO_IP4
Definition: fib_types.api:34
fib_proto_to_api_address_family
vl_api_address_family_t fib_proto_to_api_address_family(fib_protocol_t fproto)
Definition: fib_api.c:548
fib_entry_flag_t
enum fib_entry_flag_t_ fib_entry_flag_t
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
FIB_ROUTE_PATH_INTF_RX
@ FIB_ROUTE_PATH_INTF_RX
A path that result in received traffic being recieved/recirculated so that it appears to have arrived...
Definition: fib_types.h:361
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
fib_source_dump_ctx_t_::reg
vl_api_registration_t * reg
Definition: fib_api.c:589
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
fib_proto_from_api_address_family
int fib_proto_from_api_address_family(vl_api_address_family_t af, fib_protocol_t *out)
Definition: fib_api.c:532
vl_api_registration_
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: sr_mpls_api.c:174
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
index_t
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:43
FIB_ROUTE_PATH_SOURCE_LOOKUP
@ FIB_ROUTE_PATH_SOURCE_LOOKUP
A deag path using the packet's source not destination address.
Definition: fib_types.h:369
FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED
@ FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED
Definition: fib_types.api:47
fib_api_route_add_del
int fib_api_route_add_del(u8 is_add, u8 is_multipath, u32 fib_index, const fib_prefix_t *prefix, fib_source_t src, fib_entry_flag_t entry_flags, fib_route_path_t *rpaths)
Adding routes from the API.
Definition: fib_api.c:450
FIB_ROUTE_PATH_RESOLVE_VIA_HOST
@ FIB_ROUTE_PATH_RESOLVE_VIA_HOST
Recursion constraint of via a host prefix.
Definition: fib_types.h:336
vl_api_fib_source_add_t
Definition: fib.api:28
fib_route_path_t_::frp_classify_table_id
u32 frp_classify_table_id
Classify table ID.
Definition: fib_types.h:584
FIB_ROUTE_PATH_DEAG
@ FIB_ROUTE_PATH_DEAG
A path that resolves via another table.
Definition: fib_types.h:389
format_vl_api_address_union
u8 * format_vl_api_address_union(u8 *s, va_list *args)
Definition: types.c:52
FIB_ROUTE_PATH_UDP_ENCAP
@ FIB_ROUTE_PATH_UDP_ENCAP
A path via a UDP encap object.
Definition: fib_types.h:373
cm
vnet_feature_config_main_t * cm
Definition: nat44_ei_hairpinning.c:594
bier_disp_table.h
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
FIB_ROUTE_PATH_RPF_ID
@ FIB_ROUTE_PATH_RPF_ID
A local path with a RPF-ID => multicast traffic.
Definition: fib_types.h:365
src
vl_api_address_t src
Definition: gre.api:54
fib_protocol_t
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
fib_source_behaviour_t
enum fib_source_behaviour_t_ fib_source_behaviour_t
Each source has a defined behaviour that controls how entries behave that have that source.
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
clib_min
#define clib_min(x, y)
Definition: clib.h:342
mfib_table.h
fib_api_path_dpo_proto_to_nh
static vl_api_fib_path_nh_proto_t fib_api_path_dpo_proto_to_nh(dpo_proto_t dproto)
Definition: fib_api.c:75
VLIB_API_INIT_FUNCTION
VLIB_API_INIT_FUNCTION(fib_api_hookup)
fib_api.h
fib_source_allocate
fib_source_t fib_source_allocate(const char *name, fib_source_priority_t prio, fib_source_behaviour_t bh)
Definition: fib_source.c:118
vnet_interface_main_t::sw_interfaces
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:1015
fib_api_table_id_decode
int fib_api_table_id_decode(fib_protocol_t fproto, u32 table_id, u32 *fib_index)
Definition: fib_api.c:35
ip46_address_is_zero
static u8 ip46_address_is_zero(const ip46_address_t *ip46)
Definition: ip46_address.h:87
FIB_SOURCE_BH_API
@ FIB_SOURCE_BH_API
add paths with [mpls] path extensions
Definition: fib_source.h:208
data
u8 data[128]
Definition: ipsec_types.api:95
fib_source_walk
void fib_source_walk(fib_source_walk_t fn, void *ctx)
Definition: fib_source.c:169
fib_mpls_label_t_::fml_value
mpls_label_t fml_value
The label value.
Definition: fib_types.h:460
fib_source_priority_t
u8 fib_source_priority_t
Each source is assigned a priority.
Definition: fib_source.h:182
FIB_API_PATH_NH_PROTO_ETHERNET
@ FIB_API_PATH_NH_PROTO_ETHERNET
Definition: fib_types.api:37
id
u8 id[64]
Definition: dhcp.api:160
vl_api_fib_source_dump_t
Definition: fib.api:42
vnet_main_t
Definition: vnet.h:76
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
FIB_ROUTE_PATH_RESOLVE_VIA_ATTACHED
@ FIB_ROUTE_PATH_RESOLVE_VIA_ATTACHED
Recursion constraint of via an attahced prefix.
Definition: fib_types.h:340
vl_api_fib_source_details_t::context
u32 context
Definition: fib.api:50
fib_route_path_t_::frp_flags
fib_route_path_flags_t frp_flags
flags on the path
Definition: fib_types.h:609
bier_disp_table_find
index_t bier_disp_table_find(u32 table_id)
Definition: bier_disp_table.c:42
types.h
dpo_proto_to_fib
fib_protocol_t dpo_proto_to_fib(dpo_proto_t dpo_proto)
Definition: fib_types.c:359
fib_table_entry_path_add2
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 *rpaths)
Add n paths to an entry (aka route) in the FIB.
Definition: fib_table.c:605
FIB_API_PATH_TYPE_DVR
@ FIB_API_PATH_TYPE_DVR
Definition: fib_types.api:91
mfib_table_find
u32 mfib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: mfib_table.c:555
FIB_ROUTE_PATH_POP_PW_CW
@ FIB_ROUTE_PATH_POP_PW_CW
Pop a Psuedo Wire Control Word.
Definition: fib_types.h:402
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
vl_api_fib_source_details_t
Definition: fib.api:48
mfib_table_get_table_id
u32 mfib_table_get_table_id(u32 fib_index, fib_protocol_t proto)
Get the Table-ID of the FIB from protocol and index.
Definition: mfib_table.c:544
MPLS_NON_EOS
@ MPLS_NON_EOS
Definition: packet.h:38
DPO_PROTO_IP6
@ DPO_PROTO_IP6
Definition: dpo.h:65
DPO_PROTO_MPLS
@ DPO_PROTO_MPLS
Definition: dpo.h:66
FIB_MPLS_LSP_MODE_UNIFORM
@ FIB_MPLS_LSP_MODE_UNIFORM
Uniform mode.
Definition: fib_types.h:439
u32
unsigned int u32
Definition: types.h:88
FIB_API_PATH_FLAG_RESOLVE_VIA_HOST
@ FIB_API_PATH_FLAG_RESOLVE_VIA_HOST
Definition: fib_types.api:49
af
vl_api_address_family_t af
Definition: ip.api:619
FIB_API_PATH_TYPE_INTERFACE_RX
@ FIB_API_PATH_TYPE_INTERFACE_RX
Definition: fib_types.api:93
table_id
u32 table_id
Definition: wireguard.api:102
fib_mpls_label_t_::fml_ttl
u8 fml_ttl
TTL.
Definition: fib_types.h:470
FIB_API_PATH_NH_PROTO_IP6
@ FIB_API_PATH_NH_PROTO_IP6
Definition: fib_types.api:35
FIB_PROTOCOL_IP6
@ FIB_PROTOCOL_IP6
Definition: fib_types.h:37
fib_table_entry_path_remove2
void fib_table_entry_path_remove2(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_route_path_t *rpaths)
Remove n paths to an entry (aka route) in the FIB.
Definition: fib_table.c:654
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
fib_source_dump_ctx_t
struct fib_source_dump_ctx_t_ fib_source_dump_ctx_t
api_helper_macros.h
FIB_API_PATH_TYPE_UDP_ENCAP
@ FIB_API_PATH_TYPE_UDP_ENCAP
Definition: fib_types.api:80
FIB_API_PATH_TYPE_BIER_IMP
@ FIB_API_PATH_TYPE_BIER_IMP
Definition: fib_types.api:82
fib_mpls_label_t_::fml_mode
fib_mpls_lsp_mode_t fml_mode
The LSP mode.
Definition: fib_types.h:465
FIB_ROUTE_PATH_ICMP_UNREACH
@ FIB_ROUTE_PATH_ICMP_UNREACH
Definition: fib_types.h:395
vnet_classify_main_t
struct _vnet_classify_main vnet_classify_main_t
Definition: vnet_classify.h:61
fib_base_msg_id
static u16 fib_base_msg_id
Definition: fib_api.c:30
FIB_API_PATH_FLAG_POP_PW_CW
@ FIB_API_PATH_FLAG_POP_PW_CW
Definition: fib_types.api:51
vnet_classify.h
vl_api_fib_source_dump_t::context
u32 context
Definition: fib.api:45
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
send_fib_source
static walk_rc_t send_fib_source(fib_source_t id, const char *name, fib_source_priority_t prio, fib_source_behaviour_t bh, void *data)
Definition: fib_api.c:594
FIB_API_PATH_TYPE_NORMAL
@ FIB_API_PATH_TYPE_NORMAL
Definition: fib_types.api:74
vl_api_fib_source_add_reply_t::id
u8 id
Definition: fib.api:39
FIB_API_PATH_TYPE_ICMP_PROHIBIT
@ FIB_API_PATH_TYPE_ICMP_PROHIBIT
Definition: fib_types.api:86
FIB_API_PATH_TYPE_LOCAL
@ FIB_API_PATH_TYPE_LOCAL
Definition: fib_types.api:76
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
DPO_PROTO_IP4
@ DPO_PROTO_IP4
Definition: dpo.h:64
fib_api_mtable_id_decode
int fib_api_mtable_id_decode(fib_protocol_t fproto, u32 table_id, u32 *fib_index)
Definition: fib_api.c:50
FIB_ROUTE_PATH_DROP
@ FIB_ROUTE_PATH_DROP
A Drop path - resolve the path on the drop DPO.
Definition: fib_types.h:352
fib_source_t
enum fib_source_t_ fib_source_t
The different sources that can create a route.
fib_route_path_t_::frp_preference
u8 frp_preference
A path preference.
Definition: fib_types.h:605
rv
int __clib_unused rv
Definition: application.c:491
vl_api_fib_source_add_reply_t
Definition: fib.api:35
DPO_PROTO_NSH
@ DPO_PROTO_NSH
Definition: dpo.h:69
fib_route_path_t_::frp_udp_encap_id
u32 frp_udp_encap_id
UDP encap ID.
Definition: fib_types.h:579
FIB_ROUTE_PATH_BIER_IMP
@ FIB_ROUTE_PATH_BIER_IMP
A path that resolves via a BIER impostion object.
Definition: fib_types.h:385
DPO_PROTO_ETHERNET
@ DPO_PROTO_ETHERNET
Definition: dpo.h:67
vnet.h
FIB_MPLS_LSP_MODE_PIPE
@ FIB_MPLS_LSP_MODE_PIPE
Pipe Mode - the default.
Definition: fib_types.h:434
FIB_API_PATH_NH_PROTO_MPLS
@ FIB_API_PATH_NH_PROTO_MPLS
Definition: fib_types.api:36
vl_api_fib_source_dump_t::client_index
u32 client_index
Definition: fib.api:44
ADDRESS_IP4
@ ADDRESS_IP4
Definition: ip_types.api:22
INDEX_INVALID
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:49
fib_api_path_decode
int fib_api_path_decode(vl_api_fib_path_t *in, fib_route_path_t *out)
Definition: fib_api.c:141
fib_table_find
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:1111
fib_route_path_t_::frp_local_label
mpls_label_t frp_local_label
The MPLS local Label to reursively resolve through.
Definition: fib_types.h:523
ip_types_api.h
walk_rc_t
enum walk_rc_t_ walk_rc_t
Walk return code.
FIB_ROUTE_PATH_CLASSIFY
@ FIB_ROUTE_PATH_CLASSIFY
Definition: fib_types.h:397
WALK_STOP
@ WALK_STOP
Definition: interface_funcs.h:173
fib_prefix_t_
Aggregate type for a prefix.
Definition: fib_types.h:202
FIB_API_PATH_TYPE_SOURCE_LOOKUP
@ FIB_API_PATH_TYPE_SOURCE_LOOKUP
Definition: fib_types.api:88
FIB_ROUTE_PATH_LOCAL
@ FIB_ROUTE_PATH_LOCAL
A for-us/local path.
Definition: fib_types.h:344
vnet_main_t::interface_main
vnet_interface_main_t interface_main
Definition: vnet.h:81
fib_table_entry_update
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:770
prefix
vl_api_prefix_t prefix
Definition: ip.api:175