FD.io VPP  v20.05.1-6-gf53edbc3b
Vector Packet Processing
mpls_api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * mpls_api.c - mpls api
4  *
5  * Copyright (c) 2016 Cisco and/or its affiliates.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *------------------------------------------------------------------
18  */
19 
20 #include <vnet/vnet.h>
21 #include <vlibmemory/api.h>
22 
23 #include <vnet/interface.h>
24 #include <vnet/api_errno.h>
25 #include <vnet/mpls/mpls.h>
26 #include <vnet/mpls/mpls_tunnel.h>
27 #include <vnet/fib/fib_table.h>
28 #include <vnet/fib/fib_api.h>
29 #include <vnet/fib/mpls_fib.h>
30 #include <vnet/fib/fib_path_list.h>
31 #include <vnet/ip/ip_types_api.h>
32 
33 #include <vnet/vnet_msg_enum.h>
34 
35 #define vl_typedefs /* define message structures */
36 #include <vnet/vnet_all_api_h.h>
37 #undef vl_typedefs
38 
39 #define vl_endianfun /* define message structures */
40 #include <vnet/vnet_all_api_h.h>
41 #undef vl_endianfun
42 
43 /* instantiate all the print functions we know about */
44 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
45 #define vl_printfun
46 #include <vnet/vnet_all_api_h.h>
47 #undef vl_printfun
48 
50 
51 #define foreach_vpe_api_msg \
52 _(MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind) \
53 _(MPLS_ROUTE_ADD_DEL, mpls_route_add_del) \
54 _(MPLS_TABLE_ADD_DEL, mpls_table_add_del) \
55 _(MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del) \
56 _(MPLS_TUNNEL_DUMP, mpls_tunnel_dump) \
57 _(SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable) \
58 _(MPLS_TABLE_DUMP, mpls_table_dump) \
59 _(MPLS_ROUTE_DUMP, mpls_route_dump)
60 
61 void
63 {
64  u32 fib_index;
65 
66  /*
67  * The MPLS defult table must also be explicitly created via the API.
68  * So in contrast to IP, it gets no special treatment here.
69  *
70  * The API holds only one lock on the table.
71  * i.e. it can be added many times via the API but needs to be
72  * deleted only once.
73  */
74  fib_index = fib_table_find (FIB_PROTOCOL_MPLS, table_id);
75 
76  if (~0 != fib_index)
77  {
78  fib_table_unlock (fib_index,
80  (is_api ? FIB_SOURCE_API : FIB_SOURCE_CLI));
81  }
82 }
83 
84 void
86 {
87  vl_api_mpls_table_add_del_reply_t *rmp;
88  vnet_main_t *vnm;
89  int rv = 0;
90 
91  vnm = vnet_get_main ();
92  vnm->api_errno = 0;
93 
94  if (mp->mt_is_add)
95  mpls_table_create (ntohl (mp->mt_table.mt_table_id),
96  1, mp->mt_table.mt_name);
97  else
98  mpls_table_delete (ntohl (mp->mt_table.mt_table_id), 1);
99 
100  // NB: Nothing sets rv; none of the above returns an error
101 
102  REPLY_MACRO (VL_API_MPLS_TABLE_ADD_DEL_REPLY);
103 }
104 
105 static int
108 {
109  u32 mpls_fib_index, ip_fib_index;
110  fib_prefix_t pfx;
111 
112  mpls_fib_index =
114 
115  if (~0 == mpls_fib_index)
116  {
117  return VNET_API_ERROR_NO_SUCH_FIB;
118  }
119 
120  ip_prefix_decode (&mp->mb_prefix, &pfx);
121 
122  ip_fib_index = fib_table_find (pfx.fp_proto, ntohl (mp->mb_ip_table_id));
123  if (~0 == ip_fib_index)
124  return VNET_API_ERROR_NO_SUCH_FIB;
125 
126  if (mp->mb_is_bind)
127  fib_table_entry_local_label_add (ip_fib_index, &pfx,
128  ntohl (mp->mb_label));
129  else
130  fib_table_entry_local_label_remove (ip_fib_index, &pfx,
131  ntohl (mp->mb_label));
132 
133  return (0);
134 }
135 
136 void
138 {
139  vl_api_mpls_ip_bind_unbind_reply_t *rmp;
140  vnet_main_t *vnm;
141  int rv;
142 
143  vnm = vnet_get_main ();
144  vnm->api_errno = 0;
145 
146  rv = mpls_ip_bind_unbind_handler (vnm, mp);
147  rv = (rv == 0) ? vnm->api_errno : rv;
148 
149  REPLY_MACRO (VL_API_MPLS_IP_BIND_UNBIND_REPLY);
150 }
151 
152 static int
155  u32 * stats_index)
156 {
157  fib_route_path_t *rpaths = NULL, *rpath;
158  vl_api_fib_path_t *apath;
159  u32 fib_index;
160  int rv, ii;
161 
162  fib_prefix_t pfx = {
163  .fp_len = 21,
164  .fp_proto = FIB_PROTOCOL_MPLS,
165  .fp_eos = mp->mr_route.mr_eos,
166  .fp_label = ntohl (mp->mr_route.mr_label),
167  };
168  if (pfx.fp_eos)
169  {
170  pfx.fp_payload_proto = mp->mr_route.mr_eos_proto;
171  }
172  else
173  {
175  }
176 
178  ntohl (mp->mr_route.mr_table_id), &fib_index);
179  if (0 != rv)
180  goto out;
181 
182  vec_validate (rpaths, mp->mr_route.mr_n_paths - 1);
183 
184  for (ii = 0; ii < mp->mr_route.mr_n_paths; ii++)
185  {
186  apath = &mp->mr_route.mr_paths[ii];
187  rpath = &rpaths[ii];
188 
189  rv = fib_api_path_decode (apath, rpath);
190 
191  if (0 != rv)
192  goto out;
193  }
194 
196  mp->mr_is_multipath,
197  fib_index,
198  &pfx,
199  (mp->mr_route.mr_is_multicast ?
201  FIB_ENTRY_FLAG_NONE), rpaths);
202 
203  if (mp->mr_is_add && 0 == rv)
204  *stats_index = fib_table_entry_get_stats_index (fib_index, &pfx);
205 
206 out:
207  vec_free (rpaths);
208 
209  return (rv);
210 }
211 
212 void
214 {
216  vnet_main_t *vnm;
218  int rv;
219 
220  vnm = vnet_get_main ();
221  stats_index = ~0;
222 
223  rv = mpls_route_add_del_t_handler (vnm, mp, &stats_index);
224 
225  /* *INDENT-OFF* */
226  REPLY_MACRO2 (VL_API_MPLS_ROUTE_ADD_DEL_REPLY,
227  ({
228  rmp->stats_index = htonl (stats_index);
229  }));
230  /* *INDENT-ON* */
231 }
232 
233 void
235 {
236  u32 fib_index;
237 
238  /*
239  * The MPLS defult table must also be explicitly created via the API.
240  * So in contrast to IP, it gets no special treatment here.
241  */
242 
243  /*
244  * The API holds only one lock on the table.
245  * i.e. it can be added many times via the API but needs to be
246  * deleted only once.
247  */
248  fib_index = fib_table_find (FIB_PROTOCOL_MPLS, table_id);
249 
250  if (~0 == fib_index)
251  {
253  table_id,
254  (is_api ?
256  FIB_SOURCE_CLI), name);
257  }
258 }
259 
260 static void
262 {
263  u32 tunnel_sw_if_index = ~0, tunnel_index = ~0;
265  fib_route_path_t *rpath, *rpaths = NULL;
266  int ii, rv = 0;
267 
268  vec_validate (rpaths, mp->mt_tunnel.mt_n_paths - 1);
269 
270  for (ii = 0; ii < mp->mt_tunnel.mt_n_paths; ii++)
271  {
272  rpath = &rpaths[ii];
273 
274  rv = fib_api_path_decode (&mp->mt_tunnel.mt_paths[ii], rpath);
275 
276  if (0 != rv)
277  goto out;
278  }
279  tunnel_sw_if_index = ntohl (mp->mt_tunnel.mt_sw_if_index);
280 
281  if (mp->mt_is_add)
282  {
283  if (~0 == tunnel_sw_if_index)
284  tunnel_sw_if_index =
285  vnet_mpls_tunnel_create (mp->mt_tunnel.mt_l2_only,
286  mp->mt_tunnel.mt_is_multicast,
287  mp->mt_tunnel.mt_tag);
288  vnet_mpls_tunnel_path_add (tunnel_sw_if_index, rpaths);
289 
290  tunnel_index = vnet_mpls_tunnel_get_index (tunnel_sw_if_index);
291  }
292  else
293  {
294  tunnel_index = vnet_mpls_tunnel_get_index (tunnel_sw_if_index);
295  tunnel_sw_if_index = ntohl (mp->mt_tunnel.mt_sw_if_index);
296  if (!vnet_mpls_tunnel_path_remove (tunnel_sw_if_index, rpaths))
297  vnet_mpls_tunnel_del (tunnel_sw_if_index);
298  }
299 
300  vec_free (rpaths);
301 
302 out:
303  /* *INDENT-OFF* */
304  REPLY_MACRO2(VL_API_MPLS_TUNNEL_ADD_DEL_REPLY,
305  ({
306  rmp->sw_if_index = ntohl(tunnel_sw_if_index);
307  rmp->tunnel_index = ntohl(tunnel_index);
308  }));
309  /* *INDENT-ON* */
310 }
311 
312 static void
315 {
316  vl_api_sw_interface_set_mpls_enable_reply_t *rmp;
317  int rv = 0;
318 
320 
322  ntohl (mp->sw_if_index),
323  mp->enable, 1);
324 
326  REPLY_MACRO (VL_API_SW_INTERFACE_SET_MPLS_ENABLE_REPLY);
327 }
328 
330 {
335 
336 static void
337 send_mpls_tunnel_entry (u32 mti, void *arg)
338 {
341  fib_path_encode_ctx_t path_ctx = {
342  .rpaths = NULL,
343  };
344  const mpls_tunnel_t *mt;
345  fib_route_path_t *rpath;
346  vl_api_fib_path_t *fp;
347  u32 n;
348 
349  ctx = arg;
350 
351  mt = mpls_tunnel_get (mti);
352 
353  if (~0 != ctx->sw_if_index && mt->mt_sw_if_index != ctx->sw_if_index)
354  return;
355 
357 
358  mp = vl_msg_api_alloc (sizeof (*mp) + n * sizeof (vl_api_fib_path_t));
359  clib_memset (mp, 0, sizeof (*mp) + n * sizeof (vl_api_fib_path_t));
360 
361  mp->_vl_msg_id = ntohs (VL_API_MPLS_TUNNEL_DETAILS);
362  mp->context = ctx->context;
363 
364  mp->mt_tunnel.mt_n_paths = n;
365  mp->mt_tunnel.mt_sw_if_index = ntohl (mt->mt_sw_if_index);
366  mp->mt_tunnel.mt_tunnel_index = ntohl (mti);
367  mp->mt_tunnel.mt_l2_only = ! !(MPLS_TUNNEL_FLAG_L2 & mt->mt_flags);
368  mp->mt_tunnel.mt_is_multicast = ! !(MPLS_TUNNEL_FLAG_MCAST & mt->mt_flags);
369  memcpy (mp->mt_tunnel.mt_tag, mt->mt_tag, sizeof (mp->mt_tunnel.mt_tag));
370 
372  &mt->mt_path_exts, fib_path_encode, &path_ctx);
373 
374  fp = mp->mt_tunnel.mt_paths;
375  vec_foreach (rpath, path_ctx.rpaths)
376  {
377  fib_api_path_encode (rpath, fp);
378  fp++;
379  }
380 
381  vl_api_send_msg (ctx->reg, (u8 *) mp);
382 
383  vec_free (path_ctx.rpaths);
384 }
385 
386 static void
388 {
390 
392  if (!reg)
393  return;
394 
396  .reg = reg,
397  .sw_if_index = ntohl (mp->sw_if_index),
398  .context = mp->context,
399  };
401 }
402 
403 static void
406  u32 context, const fib_table_t * table)
407 {
409 
410  mp = vl_msg_api_alloc (sizeof (*mp));
411  memset (mp, 0, sizeof (*mp));
412  mp->_vl_msg_id = ntohs (VL_API_MPLS_TABLE_DETAILS);
413  mp->context = context;
414 
415  mp->mt_table.mt_table_id = htonl (table->ft_table_id);
416  memcpy (mp->mt_table.mt_name,
417  table->ft_desc,
418  clib_min (vec_len (table->ft_desc), sizeof (mp->mt_table.mt_name)));
419 
420  vl_api_send_msg (reg, (u8 *) mp);
421 }
422 
423 static void
425 {
428  mpls_main_t *mm = &mpls_main;
429  fib_table_t *fib_table;
430 
432  if (!reg)
433  return;
434 
435  /* *INDENT-OFF* */
436  pool_foreach (fib_table, mm->fibs,
437  ({
438  send_mpls_table_details(am, reg, mp->context, fib_table);
439  }));
440  /* *INDENT-ON* */
441 }
442 
443 static void
446  u32 context, fib_node_index_t fib_entry_index)
447 {
448  fib_route_path_t *rpaths, *rpath;
450  const fib_prefix_t *pfx;
451  vl_api_fib_path_t *fp;
452  int path_count;
453 
454  rpaths = fib_entry_encode (fib_entry_index);
455  pfx = fib_entry_get_prefix (fib_entry_index);
456 
457  path_count = vec_len (rpaths);
458  mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
459  if (!mp)
460  return;
461  clib_memset (mp, 0, sizeof (*mp));
462  mp->_vl_msg_id = ntohs (VL_API_MPLS_ROUTE_DETAILS);
463  mp->context = context;
464 
465  mp->mr_route.mr_table_id =
467  (fib_entry_get_fib_index (fib_entry_index), pfx->fp_proto));
468  mp->mr_route.mr_eos = pfx->fp_eos;
469  mp->mr_route.mr_eos_proto = pfx->fp_payload_proto;
470  mp->mr_route.mr_label = htonl (pfx->fp_label);
471 
472  mp->mr_route.mr_n_paths = path_count;
473  fp = mp->mr_route.mr_paths;
474  vec_foreach (rpath, rpaths)
475  {
476  fib_api_path_encode (rpath, fp);
477  fp++;
478  }
479 
480  vec_free (rpaths);
481  vl_api_send_msg (reg, (u8 *) mp);
482 }
483 
485 {
488 
489 static fib_table_walk_rc_t
491 {
493 
494  vec_add1 (ctx->lfeis, fei);
495 
496  return (FIB_TABLE_WALK_CONTINUE);
497 }
498 
499 static void
501 {
504  fib_node_index_t *lfeip = NULL;
506  .lfeis = NULL,
507  };
508  u32 fib_index;
509 
511  if (!reg)
512  return;
513 
514  fib_index = fib_table_find (FIB_PROTOCOL_MPLS,
515  ntohl (mp->table.mt_table_id));
516 
517  if (INDEX_INVALID != fib_index)
518  {
519  fib_table_walk (fib_index,
523 
524  vec_foreach (lfeip, ctx.lfeis)
525  {
526  send_mpls_route_details (am, reg, mp->context, *lfeip);
527  }
528 
529  vec_free (ctx.lfeis);
530  }
531 }
532 
533 /*
534  * mpls_api_hookup
535  * Add vpe's API message handlers to the table.
536  * vlib has already mapped shared memory and
537  * added the client registration handlers.
538  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
539  */
540 #define vl_msg_name_crc_list
541 #include <vnet/vnet_all_api_h.h>
542 #undef vl_msg_name_crc_list
543 
544 static void
546 {
547 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
548  foreach_vl_msg_name_crc_mpls;
549 #undef _
550 }
551 
552 static clib_error_t *
554 {
555  api_main_t *am = vlibapi_get_main ();
556 
557 #define _(N,n) \
558  vl_msg_api_set_handlers(VL_API_##N, #n, \
559  vl_api_##n##_t_handler, \
560  vl_noop_handler, \
561  vl_api_##n##_t_endian, \
562  vl_api_##n##_t_print, \
563  sizeof(vl_api_##n##_t), 1);
565 #undef _
566 
567  /*
568  * Trace space for 8 MPLS encap labels
569  */
570  am->api_trace_cfg[VL_API_MPLS_TUNNEL_ADD_DEL].size += 8 * sizeof (u32);
571 
572  /*
573  * Set up the (msg_name, crc, message-id) table
574  */
576 
577  return 0;
578 }
579 
581 
582 /*
583  * fd.io coding-style-patch-verification: ON
584  *
585  * Local Variables:
586  * eval: (c-set-style "gnu")
587  * End:
588  */
Bind/Unbind an MPLS local label to an IP prefix.
Definition: mpls.api:32
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:507
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:212
u32 fib_entry_get_fib_index(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1701
Continue on to the next entry.
Definition: fib_table.h:916
void mpls_table_delete(u32 table_id, u8 is_api)
Definition: mpls_api.c:62
#define clib_min(x, y)
Definition: clib.h:319
Dump MPLS fib table.
Definition: mpls.api:181
vl_api_mpls_tunnel_t mt_tunnel
Definition: mpls.api:92
void mpls_table_create(u32 table_id, u8 is_api, const u8 *name)
Definition: mpls_api.c:234
void ip_prefix_decode(const vl_api_prefix_t *in, fib_prefix_t *out)
Definition: ip_types_api.c:233
A representation of a path as described by a route producer.
Definition: fib_types.h:490
int fib_api_route_add_del(u8 is_add, u8 is_multipath, u32 fib_index, const fib_prefix_t *prefix, fib_entry_flag_t entry_flags, fib_route_path_t *rpaths)
Adding routes from the API.
Definition: fib_api.c:460
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
fib_node_index_t mt_path_list
The path-list over which the tunnel&#39;s destination is reachable.
Definition: mpls_tunnel.h:91
bool mt_is_add[default=true]
Definition: mpls.api:58
int size
for sanity checking
Definition: api_common.h:83
u32 fib_table_find_or_create_and_lock_w_name(fib_protocol_t proto, u32 table_id, fib_source_t src, const u8 *name)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:1165
struct vl_api_mpls_route_dump_table_walk_ctx_t_ vl_api_mpls_route_dump_table_walk_ctx_t
void fib_api_path_encode(const fib_route_path_t *rpath, vl_api_fib_path_t *out)
Definition: fib_api.c:359
#define REPLY_MACRO2(t, body)
mpls_tunnel_flags_t mt_flags
Tunnel flags.
Definition: mpls_tunnel.h:65
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static void send_mpls_tunnel_entry(u32 mti, void *arg)
Definition: mpls_api.c:337
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
struct mpls_tunnel_send_walk_ctx_t_ mpls_tunnel_send_walk_ctx_t
A uni-directional MPLS tunnel.
Definition: mpls_tunnel.h:55
vl_api_mpls_route_t mr_route
Definition: mpls.api:198
static fib_table_walk_rc_t vl_api_mpls_route_dump_table_walk(fib_node_index_t fei, void *arg)
Definition: mpls_api.c:490
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:590
const fib_prefix_t * fib_entry_get_prefix(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1691
Definition: fib_entry.h:121
static int mpls_route_add_del_t_handler(vnet_main_t *vnm, vl_api_mpls_route_add_del_t *mp, u32 *stats_index)
Definition: mpls_api.c:153
const mpls_tunnel_t * mpls_tunnel_get(u32 mti)
Definition: mpls_tunnel.c:566
void * vl_msg_api_alloc(int nbytes)
#define foreach_vpe_api_msg
Definition: mpls_api.c:51
void fib_table_entry_local_label_remove(u32 fib_index, const fib_prefix_t *prefix, mpls_label_t label)
remove a MPLS local label for the prefix/route.
Definition: fib_table.c:957
unsigned char u8
Definition: types.h:56
trace_cfg_t * api_trace_cfg
Current trace configuration.
Definition: api_common.h:273
static void vl_api_mpls_tunnel_add_del_t_handler(vl_api_mpls_tunnel_add_del_t *mp)
Definition: mpls_api.c:261
void vl_api_mpls_route_add_del_t_handler(vl_api_mpls_route_add_del_t *mp)
Definition: mpls_api.c:213
vl_api_interface_index_t sw_if_index
Definition: mpls.api:71
dpo_proto_t fp_payload_proto
This protocol determines the payload protocol of packets that will be forwarded by this entry once th...
Definition: fib_types.h:236
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:513
static clib_error_t * mpls_api_hookup(vlib_main_t *vm)
Definition: mpls_api.c:553
Aggregate type for a prefix.
Definition: fib_types.h:203
fib_path_ext_list_t mt_path_exts
A vector of path extensions o hold the label stack for each path.
Definition: mpls_tunnel.h:101
unsigned int u32
Definition: types.h:88
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:1097
u16 fp_len
The mask length.
Definition: fib_types.h:207
u8 mt_tag[64]
User defined name tag for this MPLS Tunnel.
Definition: mpls_tunnel.h:70
Dump mpls eth tunnel table.
Definition: mpls.api:80
int fib_entry_cmp_for_sort(void *i1, void *i2)
Definition: fib_entry.c:1623
Definition: fib_entry.h:112
vnet_api_error_t api_errno
Definition: vnet.h:78
void vnet_mpls_tunnel_del(u32 sw_if_index)
Delete an MPLS tunnel.
Definition: mpls_tunnel.c:587
int vnet_mpls_tunnel_get_index(u32 sw_if_index)
return the tunnel index from the sw_if_index
Definition: mpls_tunnel.c:785
long ctx[MAX_CONNS]
Definition: main.c:144
static int mpls_ip_bind_unbind_handler(vnet_main_t *vnm, vl_api_mpls_ip_bind_unbind_t *mp)
Definition: mpls_api.c:106
MPLS Route Add / del route.
Definition: mpls.api:162
vl_api_prefix_t mb_prefix
Definition: mpls.api:40
#define REPLY_MACRO(t)
Enable or Disable MPLS on and interface.
Definition: mpls.api:207
void fib_table_unlock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Take a reference counting lock on the table.
Definition: fib_table.c:1291
vlib_main_t * vm
Definition: in2out_ed.c:1599
vl_api_mpls_route_t mr_route
Definition: mpls.api:168
struct fib_table_t_ * fibs
A pool of all the MPLS FIBs.
Definition: mpls.h:47
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:226
static void vl_api_mpls_table_dump_t_handler(vl_api_mpls_table_dump_t *mp)
Definition: mpls_api.c:424
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
#define BAD_SW_IF_INDEX_LABEL
Reply for MPLS tunnel add / del request.
Definition: mpls.api:67
From the CLI.
Definition: fib_source.h:76
fib_node_index_t fib_table_entry_local_label_add(u32 fib_index, const fib_prefix_t *prefix, mpls_label_t label)
Add a MPLS local label for the prefix/route.
Definition: fib_table.c:930
mpls_main_t mpls_main
Definition: mpls.c:25
u32 ft_table_id
Table ID (hash key) for this FIB.
Definition: fib_table.h:92
vl_api_registration_t * reg
Definition: mpls_api.c:331
enum fib_table_walk_rc_t_ fib_table_walk_rc_t
return code controlling how a table walk proceeds
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:380
u8 * ft_desc
Table description.
Definition: fib_table.h:122
int mpls_sw_interface_enable_disable(mpls_main_t *mm, u32 sw_if_index, u8 is_enable, u8 is_api)
Definition: interface.c:39
u32 fib_path_list_get_n_paths(fib_node_index_t path_list_index)
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:30
void mpls_tunnel_walk(mpls_tunnel_walk_cb_t cb, void *ctx)
Walk all the MPLS tunnels.
Definition: mpls_tunnel.c:575
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:57
string name[64]
Definition: ip.api:44
static void send_mpls_route_details(vpe_api_main_t *am, vl_api_registration_t *reg, u32 context, fib_node_index_t fib_entry_index)
Definition: mpls_api.c:444
mpls_label_t fp_label
Definition: fib_types.h:229
vl_api_mpls_table_t table
Definition: mpls.api:185
vl_api_interface_index_t sw_if_index
Definition: mpls.api:211
vl_api_mpls_table_t mt_table
Definition: mpls.api:114
u32 stats_index
Definition: ip.api:143
int vnet_mpls_tunnel_path_remove(u32 sw_if_index, fib_route_path_t *rpaths)
remove a path from a tunnel.
Definition: mpls_tunnel.c:715
void fib_table_walk(u32 fib_index, fib_protocol_t proto, fib_table_walk_fn_t fn, void *ctx)
Walk all entries in a FIB table N.B: This is NOT safe to deletes.
Definition: fib_table.c:1230
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:1086
int fib_api_path_decode(vl_api_fib_path_t *in, fib_route_path_t *out)
Definition: fib_api.c:151
static void send_mpls_table_details(vpe_api_main_t *am, vl_api_registration_t *reg, u32 context, const fib_table_t *table)
Definition: mpls_api.c:404
Path encode context to use when walking a path-list to encode paths.
Definition: fib_path.h:213
From the control plane API.
Definition: fib_source.h:72
vl_api_mpls_table_t mt_table
Definition: mpls.api:129
u32 fib_table_entry_get_stats_index(u32 fib_index, const fib_prefix_t *prefix)
Return the stats index for a FIB entry.
Definition: fib_table.c:922
fib_route_path_t * rpaths
Definition: fib_path.h:215
u32 vnet_mpls_tunnel_create(u8 l2_only, u8 is_multicast, u8 *tag)
Create a new MPLS tunnel.
Definition: mpls_tunnel.c:608
vl_api_interface_index_t sw_if_index[default=0xffffffff]
Definition: mpls.api:84
void vnet_mpls_tunnel_path_add(u32 sw_if_index, fib_route_path_t *rpaths)
Add a path to an MPLS tunnel.
Definition: mpls_tunnel.c:659
int fib_api_table_id_decode(fib_protocol_t fproto, u32 table_id, u32 *fib_index)
Definition: fib_api.c:45
fib_route_path_t * fib_entry_encode(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1661
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void vl_api_mpls_tunnel_dump_t_handler(vl_api_mpls_tunnel_dump_t *mp)
Definition: mpls_api.c:387
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:47
VLIB_API_INIT_FUNCTION(mpls_api_hookup)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:1053
static void vl_api_sw_interface_set_mpls_enable_t_handler(vl_api_sw_interface_set_mpls_enable_t *mp)
Definition: mpls_api.c:314
static void vl_api_mpls_route_dump_t_handler(vl_api_mpls_route_dump_t *mp)
Definition: mpls_api.c:500
bool mt_is_add[default=true]
Definition: mpls.api:113
static api_main_t * vlibapi_get_main(void)
Definition: api_common.h:379
#define vec_foreach(var, vec)
Vector iterator.
u32 mt_sw_if_index
The SW interface index of the tunnel interfaces.
Definition: mpls_tunnel.h:86
void fib_path_list_walk_w_ext(fib_node_index_t path_list_index, const fib_path_ext_list_t *ext_list, fib_path_list_walk_w_ext_fn_t func, void *ctx)
mpls tunnel details
Definition: mpls.api:89
vl_api_mpls_tunnel_t mt_tunnel
Definition: mpls.api:59
u32 table_id
Definition: fib_types.api:118
Dump MPLS fib table.
Definition: mpls.api:120
vpe_api_main_t vpe_api_main
Definition: interface_api.c:54
mpls FIB table response
Definition: mpls.api:195
void vl_api_mpls_table_add_del_t_handler(vl_api_mpls_table_add_del_t *mp)
Definition: mpls_api.c:85
static void setup_message_id_table(api_main_t *am)
Definition: mpls_api.c:545
void vl_api_mpls_ip_bind_unbind_t_handler(vl_api_mpls_ip_bind_unbind_t *mp)
Definition: mpls_api.c:137
#define VALIDATE_SW_IF_INDEX(mp)
A protocol Independent FIB table.
Definition: fib_table.h:71
fib_path_list_walk_rc_t fib_path_encode(fib_node_index_t path_list_index, fib_node_index_t path_index, const fib_path_ext_t *path_ext, void *args)
Definition: fib_path.c:2706
mpls_eos_bit_t fp_eos
Definition: fib_types.h:230