FD.io VPP  v21.10.1-2-g0a485f517
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/format_fns.h>
34 #include <vnet/mpls/mpls.api_enum.h>
35 #include <vnet/mpls/mpls.api_types.h>
36 
37 #define REPLY_MSG_ID_BASE mpls_main.msg_id_base
39 
40 void
42 {
43  u32 fib_index;
44 
45  /*
46  * The MPLS defult table must also be explicitly created via the API.
47  * So in contrast to IP, it gets no special treatment here.
48  *
49  * The API holds only one lock on the table.
50  * i.e. it can be added many times via the API but needs to be
51  * deleted only once.
52  */
54 
55  if (~0 != fib_index)
56  {
57  fib_table_unlock (fib_index,
59  (is_api ? FIB_SOURCE_API : FIB_SOURCE_CLI));
60  }
61 }
62 
63 void
65 {
66  vl_api_mpls_table_add_del_reply_t *rmp;
67  vnet_main_t *vnm;
68  int rv = 0;
69 
70  vnm = vnet_get_main ();
71  vnm->api_errno = 0;
72 
73  if (mp->mt_is_add)
74  mpls_table_create (ntohl (mp->mt_table.mt_table_id),
75  1, mp->mt_table.mt_name);
76  else
77  mpls_table_delete (ntohl (mp->mt_table.mt_table_id), 1);
78 
79  // NB: Nothing sets rv; none of the above returns an error
80 
81  REPLY_MACRO (VL_API_MPLS_TABLE_ADD_DEL_REPLY);
82 }
83 
84 static int
87 {
88  u32 mpls_fib_index, ip_fib_index;
89  fib_prefix_t pfx;
90 
91  mpls_fib_index =
93 
94  if (~0 == mpls_fib_index)
95  {
96  return VNET_API_ERROR_NO_SUCH_FIB;
97  }
98 
99  ip_prefix_decode (&mp->mb_prefix, &pfx);
100 
101  ip_fib_index = fib_table_find (pfx.fp_proto, ntohl (mp->mb_ip_table_id));
102  if (~0 == ip_fib_index)
103  return VNET_API_ERROR_NO_SUCH_FIB;
104 
105  if (mp->mb_is_bind)
106  fib_table_entry_local_label_add (ip_fib_index, &pfx,
107  ntohl (mp->mb_label));
108  else
109  fib_table_entry_local_label_remove (ip_fib_index, &pfx,
110  ntohl (mp->mb_label));
111 
112  return (0);
113 }
114 
115 void
117 {
118  vl_api_mpls_ip_bind_unbind_reply_t *rmp;
119  vnet_main_t *vnm;
120  int rv;
121 
122  vnm = vnet_get_main ();
123  vnm->api_errno = 0;
124 
125  rv = mpls_ip_bind_unbind_handler (vnm, mp);
126  rv = (rv == 0) ? vnm->api_errno : rv;
127 
128  REPLY_MACRO (VL_API_MPLS_IP_BIND_UNBIND_REPLY);
129 }
130 
131 static int
134  u32 * stats_index)
135 {
136  fib_route_path_t *rpaths = NULL, *rpath;
137  vl_api_fib_path_t *apath;
138  u32 fib_index;
139  int rv, ii;
140 
141  fib_prefix_t pfx = {
142  .fp_len = 21,
143  .fp_proto = FIB_PROTOCOL_MPLS,
144  .fp_eos = mp->mr_route.mr_eos,
145  .fp_label = ntohl (mp->mr_route.mr_label),
146  };
147  if (pfx.fp_eos)
148  {
149  pfx.fp_payload_proto = mp->mr_route.mr_eos_proto;
150  }
151  else
152  {
154  }
155 
157  ntohl (mp->mr_route.mr_table_id), &fib_index);
158  if (0 != rv)
159  goto out;
160 
161  vec_validate (rpaths, mp->mr_route.mr_n_paths - 1);
162 
163  for (ii = 0; ii < mp->mr_route.mr_n_paths; ii++)
164  {
165  apath = &mp->mr_route.mr_paths[ii];
166  rpath = &rpaths[ii];
167 
168  rv = fib_api_path_decode (apath, rpath);
169 
170  if (0 != rv)
171  goto out;
172  }
173 
175  mp->mr_is_add, mp->mr_is_multipath, fib_index, &pfx, FIB_SOURCE_API,
176  (mp->mr_route.mr_is_multicast ? FIB_ENTRY_FLAG_MULTICAST :
178  rpaths);
179 
180  if (mp->mr_is_add && 0 == rv)
181  *stats_index = fib_table_entry_get_stats_index (fib_index, &pfx);
182 
183 out:
184  vec_free (rpaths);
185 
186  return (rv);
187 }
188 
189 void
191 {
193  vnet_main_t *vnm;
195  int rv;
196 
197  vnm = vnet_get_main ();
198  stats_index = ~0;
199 
201 
202  /* *INDENT-OFF* */
203  REPLY_MACRO2 (VL_API_MPLS_ROUTE_ADD_DEL_REPLY,
204  ({
205  rmp->stats_index = htonl (stats_index);
206  }));
207  /* *INDENT-ON* */
208 }
209 
210 void
212 {
213  u32 fib_index;
214 
215  /*
216  * The MPLS defult table must also be explicitly created via the API.
217  * So in contrast to IP, it gets no special treatment here.
218  */
219 
220  /*
221  * The API holds only one lock on the table.
222  * i.e. it can be added many times via the API but needs to be
223  * deleted only once.
224  */
226 
227  if (~0 == fib_index)
228  {
230  table_id,
231  (is_api ?
233  FIB_SOURCE_CLI), name);
234  }
235 }
236 
237 static void
239 {
240  u32 tunnel_sw_if_index = ~0, tunnel_index = ~0;
242  fib_route_path_t *rpath, *rpaths = NULL;
243  int ii, rv = 0;
244 
245  vec_validate (rpaths, mp->mt_tunnel.mt_n_paths - 1);
246 
247  for (ii = 0; ii < mp->mt_tunnel.mt_n_paths; ii++)
248  {
249  rpath = &rpaths[ii];
250 
251  rv = fib_api_path_decode (&mp->mt_tunnel.mt_paths[ii], rpath);
252 
253  if (0 != rv)
254  goto out;
255  }
256  tunnel_sw_if_index = ntohl (mp->mt_tunnel.mt_sw_if_index);
257 
258  if (mp->mt_is_add)
259  {
260  if (~0 == tunnel_sw_if_index)
261  tunnel_sw_if_index =
262  vnet_mpls_tunnel_create (mp->mt_tunnel.mt_l2_only,
263  mp->mt_tunnel.mt_is_multicast,
264  mp->mt_tunnel.mt_tag);
265  vnet_mpls_tunnel_path_add (tunnel_sw_if_index, rpaths);
266 
267  tunnel_index = vnet_mpls_tunnel_get_index (tunnel_sw_if_index);
268  }
269  else
270  {
271  tunnel_index = vnet_mpls_tunnel_get_index (tunnel_sw_if_index);
272  tunnel_sw_if_index = ntohl (mp->mt_tunnel.mt_sw_if_index);
273  if (!vnet_mpls_tunnel_path_remove (tunnel_sw_if_index, rpaths))
274  vnet_mpls_tunnel_del (tunnel_sw_if_index);
275  }
276 
277  vec_free (rpaths);
278 
279 out:
280  /* *INDENT-OFF* */
281  REPLY_MACRO2(VL_API_MPLS_TUNNEL_ADD_DEL_REPLY,
282  ({
283  rmp->sw_if_index = ntohl(tunnel_sw_if_index);
284  rmp->tunnel_index = ntohl(tunnel_index);
285  }));
286  /* *INDENT-ON* */
287 }
288 
289 static void
292 {
293  vl_api_sw_interface_set_mpls_enable_reply_t *rmp;
294  int rv = 0;
295 
297 
299  ntohl (mp->sw_if_index),
300  mp->enable, 1);
301 
303  REPLY_MACRO (VL_API_SW_INTERFACE_SET_MPLS_ENABLE_REPLY);
304 }
305 
307 {
312 
313 static void
314 send_mpls_tunnel_entry (u32 mti, void *arg)
315 {
318  fib_path_encode_ctx_t path_ctx = {
319  .rpaths = NULL,
320  };
321  const mpls_tunnel_t *mt;
322  fib_route_path_t *rpath;
323  vl_api_fib_path_t *fp;
324  u32 n;
325 
326  ctx = arg;
327 
328  mt = mpls_tunnel_get (mti);
329 
330  if (~0 != ctx->sw_if_index && mt->mt_sw_if_index != ctx->sw_if_index)
331  return;
332 
334 
335  mp = vl_msg_api_alloc (sizeof (*mp) + n * sizeof (vl_api_fib_path_t));
336  clib_memset (mp, 0, sizeof (*mp) + n * sizeof (vl_api_fib_path_t));
337 
338  mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_MPLS_TUNNEL_DETAILS);
339  mp->context = ctx->context;
340 
341  mp->mt_tunnel.mt_n_paths = n;
342  mp->mt_tunnel.mt_sw_if_index = ntohl (mt->mt_sw_if_index);
343  mp->mt_tunnel.mt_tunnel_index = ntohl (mti);
344  mp->mt_tunnel.mt_l2_only = ! !(MPLS_TUNNEL_FLAG_L2 & mt->mt_flags);
345  mp->mt_tunnel.mt_is_multicast = ! !(MPLS_TUNNEL_FLAG_MCAST & mt->mt_flags);
346  memcpy (mp->mt_tunnel.mt_tag, mt->mt_tag, sizeof (mp->mt_tunnel.mt_tag));
347 
349  &mt->mt_path_exts, fib_path_encode, &path_ctx);
350 
351  fp = mp->mt_tunnel.mt_paths;
352  vec_foreach (rpath, path_ctx.rpaths)
353  {
354  fib_api_path_encode (rpath, fp);
355  fp++;
356  }
357 
358  vl_api_send_msg (ctx->reg, (u8 *) mp);
359 
360  vec_free (path_ctx.rpaths);
361 }
362 
363 static void
365 {
367 
369  if (!reg)
370  return;
371 
373  .reg = reg,
374  .sw_if_index = ntohl (mp->sw_if_index),
375  .context = mp->context,
376  };
378 }
379 
380 static void
382  vl_api_registration_t * reg,
383  u32 context, const fib_table_t * table)
384 {
386 
387  mp = vl_msg_api_alloc (sizeof (*mp));
388  memset (mp, 0, sizeof (*mp));
389  mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_MPLS_TABLE_DETAILS);
390  mp->context = context;
391 
392  mp->mt_table.mt_table_id = htonl (table->ft_table_id);
393  memcpy (mp->mt_table.mt_name,
394  table->ft_desc,
395  clib_min (vec_len (table->ft_desc), sizeof (mp->mt_table.mt_name)));
396 
397  vl_api_send_msg (reg, (u8 *) mp);
398 }
399 
400 static void
402 {
405  mpls_main_t *mm = &mpls_main;
406  fib_table_t *fib_table;
407 
409  if (!reg)
410  return;
411 
412  /* *INDENT-OFF* */
413  pool_foreach (fib_table, mm->fibs)
414  {
415  send_mpls_table_details(am, reg, mp->context, fib_table);
416  }
417  /* *INDENT-ON* */
418 }
419 
420 static void
422  vl_api_registration_t * reg,
423  u32 context, fib_node_index_t fib_entry_index)
424 {
425  fib_route_path_t *rpaths, *rpath;
427  const fib_prefix_t *pfx;
428  vl_api_fib_path_t *fp;
429  int path_count;
430 
431  rpaths = fib_entry_encode (fib_entry_index);
432  pfx = fib_entry_get_prefix (fib_entry_index);
433 
434  path_count = vec_len (rpaths);
435  mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
436  if (!mp)
437  return;
438  clib_memset (mp, 0, sizeof (*mp));
439  mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_MPLS_ROUTE_DETAILS);
440  mp->context = context;
441 
442  mp->mr_route.mr_table_id =
444  (fib_entry_get_fib_index (fib_entry_index), pfx->fp_proto));
445  mp->mr_route.mr_eos = pfx->fp_eos;
446  mp->mr_route.mr_eos_proto = pfx->fp_payload_proto;
447  mp->mr_route.mr_label = htonl (pfx->fp_label);
448 
449  mp->mr_route.mr_n_paths = path_count;
450  fp = mp->mr_route.mr_paths;
451  vec_foreach (rpath, rpaths)
452  {
453  fib_api_path_encode (rpath, fp);
454  fp++;
455  }
456 
457  vec_free (rpaths);
458  vl_api_send_msg (reg, (u8 *) mp);
459 }
460 
462 {
465 
466 static fib_table_walk_rc_t
468 {
470 
471  vec_add1 (ctx->lfeis, fei);
472 
473  return (FIB_TABLE_WALK_CONTINUE);
474 }
475 
476 static void
478 {
481  fib_node_index_t *lfeip = NULL;
483  .lfeis = NULL,
484  };
485  u32 fib_index;
486 
488  if (!reg)
489  return;
490 
491  fib_index = fib_table_find (FIB_PROTOCOL_MPLS,
492  ntohl (mp->table.mt_table_id));
493 
494  if (INDEX_INVALID != fib_index)
495  {
496  fib_table_walk (fib_index,
500 
501  vec_foreach (lfeip, ctx.lfeis)
502  {
503  send_mpls_route_details (am, reg, mp->context, *lfeip);
504  }
505 
506  vec_free (ctx.lfeis);
507  }
508 }
509 
510 #include <vnet/mpls/mpls.api.c>
511 static clib_error_t *
513 {
515 
516  /*
517  * Trace space for 8 MPLS encap labels
518  */
519  am->api_trace_cfg[VL_API_MPLS_TUNNEL_ADD_DEL].size += 8 * sizeof (u32);
520 
521  /*
522  * Set up the (msg_name, crc, message-id) table
523  */
525 
526  return 0;
527 }
528 
530 
531 /*
532  * fd.io coding-style-patch-verification: ON
533  *
534  * Local Variables:
535  * eval: (c-set-style "gnu")
536  * End:
537  */
stats_index
u32 stats_index
Definition: ip.api:174
vl_api_mpls_route_add_del_t
MPLS Route Add / del route.
Definition: mpls.api:162
mpls_table_delete
void mpls_table_delete(u32 table_id, u8 is_api)
Definition: mpls_api.c:41
vl_api_mpls_tunnel_dump_t_handler
static void vl_api_mpls_tunnel_dump_t_handler(vl_api_mpls_tunnel_dump_t *mp)
Definition: mpls_api.c:364
VLIB_API_INIT_FUNCTION
VLIB_API_INIT_FUNCTION(mpls_api_hookup)
VALIDATE_SW_IF_INDEX
#define VALIDATE_SW_IF_INDEX(mp)
Definition: api_helper_macros.h:281
vl_api_client_index_to_registration
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
vl_api_mpls_route_dump_t_handler
static void vl_api_mpls_route_dump_t_handler(vl_api_mpls_route_dump_t *mp)
Definition: mpls_api.c:477
api.h
vl_api_mpls_table_details_t
Definition: mpls.api:126
mpls_tunnel_send_walk_ctx_t_::context
u32 context
Definition: mpls_api.c:310
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
mpls_tunnel_t_::mt_path_list
fib_node_index_t mt_path_list
The path-list over which the tunnel's destination is reachable.
Definition: mpls_tunnel.h:91
fib_entry_get_prefix
const fib_prefix_t * fib_entry_get_prefix(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1728
REPLY_MACRO2
#define REPLY_MACRO2(t, body)
Definition: api_helper_macros.h:65
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
mpls_tunnel.h
fib_path_encode_ctx_t_
Path encode context to use when walking a path-list to encode paths.
Definition: fib_path.h:219
vl_api_mpls_tunnel_dump_t::sw_if_index
vl_api_interface_index_t sw_if_index[default=0xffffffff]
Definition: mpls.api:84
vl_api_send_msg
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
vl_api_mpls_route_dump_t
Dump MPLS fib table.
Definition: mpls.api:181
fib_table_find_or_create_and_lock_w_name
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:1179
fib_entry_cmp_for_sort
int fib_entry_cmp_for_sort(void *i1, void *i2)
Definition: fib_entry.c:1660
name
string name[64]
Definition: fib.api:25
vl_api_mpls_route_dump_table_walk_ctx_t_
Definition: mpls_api.c:461
vl_api_mpls_table_add_del_t
Definition: mpls.api:109
vpe_api_main_t
Definition: api_helper_macros.h:414
vl_api_mpls_route_details_t::mr_route
vl_api_mpls_route_t mr_route
Definition: mpls.api:198
mpls_main
mpls_main_t mpls_main
Definition: mpls.c:25
vl_api_mpls_route_add_del_reply_t::stats_index
u32 stats_index
Definition: mpls.api:175
fib_table.h
vl_api_mpls_table_add_del_t::mt_table
vl_api_mpls_table_t mt_table
Definition: mpls.api:114
am
app_main_t * am
Definition: application.c:489
fib_prefix_t_::fp_len
u16 fp_len
The mask length.
Definition: fib_types.h:206
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vl_api_mpls_route_add_del_reply_t
Definition: mpls.api:171
fib_prefix_t_::fp_eos
mpls_eos_bit_t fp_eos
Definition: fib_types.h:229
fib_table_walk
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:1244
mpls_tunnel_send_walk_ctx_t_
Definition: mpls_api.c:306
mpls.h
mpls_table_create
void mpls_table_create(u32 table_id, u8 is_api, const u8 *name)
Definition: mpls_api.c:211
vl_api_mpls_tunnel_add_del_t
Definition: mpls.api:54
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
vl_api_mpls_tunnel_dump_t::client_index
u32 client_index
Definition: mpls.api:82
vl_api_mpls_table_dump_t::client_index
u32 client_index
Definition: mpls.api:122
fib_path_list_get_n_paths
u32 fib_path_list_get_n_paths(fib_node_index_t path_list_index)
Definition: fib_path_list.c:595
vl_api_mpls_table_add_del_t::mt_is_add
bool mt_is_add[default=true]
Definition: mpls.api:113
fib_path_encode_ctx_t_::rpaths
fib_route_path_t * rpaths
Definition: fib_path.h:221
vl_api_mpls_ip_bind_unbind_t::mb_is_bind
bool mb_is_bind
Definition: mpls.api:39
vnet_mpls_tunnel_path_remove
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:759
vl_api_mpls_ip_bind_unbind_t
Bind/Unbind an MPLS local label to an IP prefix.
Definition: mpls.api:32
mpls_fib.h
vl_api_sw_interface_set_mpls_enable_t
Enable or Disable MPLS on and interface.
Definition: mpls.api:207
vnet_mpls_tunnel_path_add
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:703
fib_table_t_
A protocol Independent FIB table.
Definition: fib_table.h:71
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
mpls_tunnel_walk
void mpls_tunnel_walk(mpls_tunnel_walk_cb_t cb, void *ctx)
Walk all the MPLS tunnels.
Definition: mpls_tunnel.c:615
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
FIB_ENTRY_FLAG_MULTICAST
@ FIB_ENTRY_FLAG_MULTICAST
Definition: fib_entry.h:121
mpls_tunnel_get
const mpls_tunnel_t * mpls_tunnel_get(u32 mti)
Definition: mpls_tunnel.c:606
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
vl_api_mpls_table_dump_t
Dump MPLS fib table.
Definition: mpls.api:120
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
mpls_tunnel_send_walk_ctx_t_::reg
vl_api_registration_t * reg
Definition: mpls_api.c:308
vl_api_mpls_route_dump_table_walk_ctx_t_::lfeis
fib_node_index_t * lfeis
Definition: mpls_api.c:463
fib_table_t_::ft_table_id
u32 ft_table_id
Table ID (hash key) for this FIB.
Definition: fib_table.h:92
vl_api_registration_
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
vl_api_mpls_route_details_t::context
u32 context
Definition: mpls.api:197
REPLY_MACRO
#define REPLY_MACRO(t)
Definition: api_helper_macros.h:30
fib_table_t_::ft_desc
u8 * ft_desc
Table description.
Definition: fib_table.h:122
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: sr_mpls_api.c:174
vl_api_mpls_ip_bind_unbind_t::mb_ip_table_id
u32 mb_ip_table_id
Definition: mpls.api:38
FIB_ENTRY_FLAG_NONE
@ FIB_ENTRY_FLAG_NONE
Definition: fib_entry.h:112
ip_prefix_decode
void ip_prefix_decode(const vl_api_prefix_t *in, fib_prefix_t *out)
Definition: ip_types_api.c:245
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
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
vl_api_mpls_tunnel_add_del_reply_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: mpls.api:71
vl_api_mpls_tunnel_details_t
mpls tunnel details
Definition: mpls.api:89
vlibapi_get_main
static api_main_t * vlibapi_get_main(void)
Definition: api_common.h:390
interface.h
vl_api_mpls_table_dump_t::context
u32 context
Definition: mpls.api:123
fib_prefix_t_::fp_label
mpls_label_t fp_label
Definition: fib_types.h:228
send_mpls_route_details
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:421
vl_api_mpls_route_dump_table_walk_ctx_t
struct vl_api_mpls_route_dump_table_walk_ctx_t_ vl_api_mpls_route_dump_table_walk_ctx_t
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_prefix_t_::fp_payload_proto
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:235
vl_api_mpls_tunnel_details_t::context
u32 context
Definition: mpls.api:91
vnet_mpls_tunnel_create
u32 vnet_mpls_tunnel_create(u8 l2_only, u8 is_multicast, u8 *tag)
Create a new MPLS tunnel.
Definition: mpls_tunnel.c:648
vl_api_mpls_table_details_t::context
u32 context
Definition: mpls.api:128
vl_api_mpls_tunnel_add_del_reply_t::tunnel_index
u32 tunnel_index
Definition: mpls.api:72
clib_min
#define clib_min(x, y)
Definition: clib.h:342
vl_api_mpls_ip_bind_unbind_t::mb_mpls_table_id
u32 mb_mpls_table_id
Definition: mpls.api:36
fib_api.h
mpls_tunnel_t_::mt_path_exts
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
mpls_tunnel_send_walk_ctx_t
struct mpls_tunnel_send_walk_ctx_t_ mpls_tunnel_send_walk_ctx_t
vl_api_mpls_route_dump_t::context
u32 context
Definition: mpls.api:184
vnet_mpls_tunnel_del
void vnet_mpls_tunnel_del(u32 sw_if_index)
Delete an MPLS tunnel.
Definition: mpls_tunnel.c:627
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
vl_api_mpls_tunnel_add_del_t_handler
static void vl_api_mpls_tunnel_add_del_t_handler(vl_api_mpls_tunnel_add_del_t *mp)
Definition: mpls_api.c:238
fib_table_entry_local_label_remove
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:971
BAD_SW_IF_INDEX_LABEL
#define BAD_SW_IF_INDEX_LABEL
Definition: api_helper_macros.h:289
vl_api_mpls_tunnel_details_t::mt_tunnel
vl_api_mpls_tunnel_t mt_tunnel
Definition: mpls.api:92
vnet_main_t::api_errno
vnet_api_error_t api_errno
Definition: vnet.h:109
fib_path_list_walk_w_ext
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)
Definition: fib_path_list.c:1401
api_main_t
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:228
mpls_ip_bind_unbind_handler
static int mpls_ip_bind_unbind_handler(vnet_main_t *vnm, vl_api_mpls_ip_bind_unbind_t *mp)
Definition: mpls_api.c:85
vl_api_mpls_route_add_del_t::mr_is_add
bool mr_is_add
Definition: mpls.api:166
MPLS_TUNNEL_FLAG_L2
@ MPLS_TUNNEL_FLAG_L2
Definition: mpls_tunnel.h:47
vl_api_sw_interface_set_mpls_enable_t::enable
bool enable[default=true]
Definition: mpls.api:212
mpls_tunnel_t_
A uni-directional MPLS tunnel.
Definition: mpls_tunnel.h:55
vnet_main_t
Definition: vnet.h:76
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
vl_api_mpls_ip_bind_unbind_t::mb_prefix
vl_api_prefix_t mb_prefix
Definition: mpls.api:40
mpls_api_hookup
static clib_error_t * mpls_api_hookup(vlib_main_t *vm)
Definition: mpls_api.c:512
vl_api_mpls_tunnel_add_del_reply_t
Reply for MPLS tunnel add / del request.
Definition: mpls.api:67
fib_path_list.h
vl_api_mpls_tunnel_dump_t
Dump mpls eth tunnel table.
Definition: mpls.api:80
format_fns.h
FIB_PROTOCOL_MPLS
@ FIB_PROTOCOL_MPLS
Definition: fib_types.h:38
DPO_PROTO_MPLS
@ DPO_PROTO_MPLS
Definition: dpo.h:66
u32
unsigned int u32
Definition: types.h:88
fib_table_walk_rc_t
enum fib_table_walk_rc_t_ fib_table_walk_rc_t
return code controlling how a table walk proceeds
mpls_sw_interface_enable_disable
int mpls_sw_interface_enable_disable(mpls_main_t *mm, u32 sw_if_index, u8 is_enable, u8 is_api)
Definition: interface.c:38
table_id
u32 table_id
Definition: wireguard.api:102
send_mpls_tunnel_entry
static void send_mpls_tunnel_entry(u32 mti, void *arg)
Definition: mpls_api.c:314
fib_route_path_t_
A representation of a path as described by a route producer.
Definition: fib_types.h:500
vl_api_mpls_ip_bind_unbind_t_handler
void vl_api_mpls_ip_bind_unbind_t_handler(vl_api_mpls_ip_bind_unbind_t *mp)
Definition: mpls_api.c:116
vl_api_mpls_route_add_del_t::mr_route
vl_api_mpls_route_t mr_route
Definition: mpls.api:168
fib_path_encode
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:2710
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
api_helper_macros.h
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
vl_api_mpls_tunnel_dump_t::context
u32 context
Definition: mpls.api:83
FIB_SOURCE_CLI
@ FIB_SOURCE_CLI
From the CLI.
Definition: fib_source.h:79
mpls_route_add_del_t_handler
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:132
MPLS_TUNNEL_FLAG_MCAST
@ MPLS_TUNNEL_FLAG_MCAST
Definition: mpls_tunnel.h:48
FIB_SOURCE_API
@ FIB_SOURCE_API
From the control plane API.
Definition: fib_source.h:75
fib_prefix_t_::fp_proto
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:211
fib_entry_get_fib_index
u32 fib_entry_get_fib_index(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1738
vl_api_mpls_route_details_t
mpls FIB table response
Definition: mpls.api:195
vec_sort_with_function
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:1097
vl_api_mpls_route_dump_table_walk
static fib_table_walk_rc_t vl_api_mpls_route_dump_table_walk(fib_node_index_t fei, void *arg)
Definition: mpls_api.c:467
fib_entry_encode
fib_route_path_t * fib_entry_encode(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1698
FIB_TABLE_WALK_CONTINUE
@ FIB_TABLE_WALK_CONTINUE
Continue on to the next entry.
Definition: fib_table.h:916
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
mpls_tunnel_send_walk_ctx_t_::sw_if_index
u32 sw_if_index
Definition: mpls_api.c:309
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
mpls_tunnel_t_::mt_flags
mpls_tunnel_flags_t mt_flags
Tunnel flags.
Definition: mpls_tunnel.h:65
vl_api_mpls_route_dump_t::client_index
u32 client_index
Definition: mpls.api:183
fib_table_unlock
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:1342
vl_api_mpls_route_dump_t::table
vl_api_mpls_table_t table
Definition: mpls.api:185
mpls_main_t
Definition: mpls.h:41
mpls_tunnel_t_::mt_tag
u8 mt_tag[64]
User defined name tag for this MPLS Tunnel.
Definition: mpls_tunnel.h:70
vl_api_mpls_tunnel_add_del_t::mt_tunnel
vl_api_mpls_tunnel_t mt_tunnel
Definition: mpls.api:59
context
u32 context
Definition: ip.api:852
mpls_main_t::fibs
struct fib_table_t_ * fibs
A pool of all the MPLS FIBs.
Definition: mpls.h:47
vl_api_mpls_route_add_del_t_handler
void vl_api_mpls_route_add_del_t_handler(vl_api_mpls_route_add_del_t *mp)
Definition: mpls_api.c:190
rv
int __clib_unused rv
Definition: application.c:491
fib_table_entry_local_label_add
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:944
vnet.h
api_errno.h
vl_api_sw_interface_set_mpls_enable_t_handler
static void vl_api_sw_interface_set_mpls_enable_t_handler(vl_api_sw_interface_set_mpls_enable_t *mp)
Definition: mpls_api.c:291
fib_table_entry_get_stats_index
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:936
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
vl_api_mpls_table_dump_t_handler
static void vl_api_mpls_table_dump_t_handler(vl_api_mpls_table_dump_t *mp)
Definition: mpls_api.c:401
vl_api_mpls_route_add_del_t::mr_is_multipath
bool mr_is_multipath
Definition: mpls.api:167
ip_types_api.h
mpls_tunnel_t_::mt_sw_if_index
u32 mt_sw_if_index
The SW interface index of the tunnel interfaces.
Definition: mpls_tunnel.h:86
vl_api_sw_interface_set_mpls_enable_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: mpls.api:211
fib_prefix_t_
Aggregate type for a prefix.
Definition: fib_types.h:202
vl_api_mpls_ip_bind_unbind_t::mb_label
u32 mb_label
Definition: mpls.api:37
send_mpls_table_details
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:381
vnet_mpls_tunnel_get_index
int vnet_mpls_tunnel_get_index(u32 sw_if_index)
return the tunnel index from the sw_if_index
Definition: mpls_tunnel.c:829
vl_api_mpls_tunnel_add_del_t::mt_is_add
bool mt_is_add[default=true]
Definition: mpls.api:58
vl_api_mpls_table_add_del_t_handler
void vl_api_mpls_table_add_del_t_handler(vl_api_mpls_table_add_del_t *mp)
Definition: mpls_api.c:64
vpe_api_main
vpe_api_main_t vpe_api_main
Definition: interface_api.c:47
vl_msg_api_alloc
void * vl_msg_api_alloc(int nbytes)
Definition: memory_shared.c:199
vl_api_mpls_table_details_t::mt_table
vl_api_mpls_table_t mt_table
Definition: mpls.api:129
REPLY_MSG_ID_BASE
#define REPLY_MSG_ID_BASE
Definition: mpls_api.c:37