FD.io VPP  v17.07.01-10-g3be13f0
Vector Packet Processing
ip_api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * ip_api.c - vnet ip 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/ethernet/ethernet.h>
26 #include <vnet/ip/ip.h>
27 #include <vnet/ip/ip6_neighbor.h>
28 #include <vnet/fib/fib_table.h>
29 #include <vnet/fib/fib_api.h>
30 #include <vnet/dpo/drop_dpo.h>
31 #include <vnet/dpo/receive_dpo.h>
32 #include <vnet/dpo/lookup_dpo.h>
33 #include <vnet/dpo/classify_dpo.h>
34 #include <vnet/dpo/ip_null_dpo.h>
36 #include <vnet/mfib/ip6_mfib.h>
37 #include <vnet/mfib/ip4_mfib.h>
38 #include <vnet/mfib/mfib_signal.h>
39 #include <vnet/mfib/mfib_entry.h>
40 
41 #include <vnet/vnet_msg_enum.h>
42 
43 #define vl_typedefs /* define message structures */
44 #include <vnet/vnet_all_api_h.h>
45 #undef vl_typedefs
46 
47 #define vl_endianfun /* define message structures */
48 #include <vnet/vnet_all_api_h.h>
49 #undef vl_endianfun
50 
51 /* instantiate all the print functions we know about */
52 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
53 #define vl_printfun
54 #include <vnet/vnet_all_api_h.h>
55 #undef vl_printfun
56 
58 
59 
60 #define foreach_ip_api_msg \
61 _(IP_FIB_DUMP, ip_fib_dump) \
62 _(IP6_FIB_DUMP, ip6_fib_dump) \
63 _(IP_MFIB_DUMP, ip_mfib_dump) \
64 _(IP6_MFIB_DUMP, ip6_mfib_dump) \
65 _(IP_NEIGHBOR_DUMP, ip_neighbor_dump) \
66 _(IP_MROUTE_ADD_DEL, ip_mroute_add_del) \
67 _(MFIB_SIGNAL_DUMP, mfib_signal_dump) \
68 _(IP_ADDRESS_DUMP, ip_address_dump) \
69 _(IP_DUMP, ip_dump) \
70 _(IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del) \
71 _(IP_ADD_DEL_ROUTE, ip_add_del_route) \
72 _(SET_IP_FLOW_HASH,set_ip_flow_hash) \
73 _(SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config) \
74 _(SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix) \
75 _(IP6ND_PROXY_ADD_DEL, ip6nd_proxy_add_del) \
76 _(IP6ND_PROXY_DUMP, ip6nd_proxy_dump) \
77 _(SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable ) \
78 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, \
79  sw_interface_ip6_set_link_local_address)
80 
81 extern void stats_dslock_with_hint (int hint, int tag);
82 extern void stats_dsunlock (void);
83 
84 static void
86  u8 is_static,
87  u8 * mac_address,
88  u8 * ip_address,
89  unix_shared_memory_queue_t * q, u32 context)
90 {
92 
93  mp = vl_msg_api_alloc (sizeof (*mp));
94  memset (mp, 0, sizeof (*mp));
95  mp->_vl_msg_id = ntohs (VL_API_IP_NEIGHBOR_DETAILS);
96  mp->context = context;
97  mp->is_ipv6 = is_ipv6;
98  mp->is_static = is_static;
99  memcpy (mp->mac_address, mac_address, 6);
100  memcpy (mp->ip_address, ip_address, (is_ipv6) ? 16 : 4);
101 
102  vl_msg_api_send_shmem (q, (u8 *) & mp);
103 }
104 
105 static void
107 {
109 
111  if (q == 0)
112  return;
113 
114  u32 sw_if_index = ntohl (mp->sw_if_index);
115 
116  if (mp->is_ipv6)
117  {
118  ip6_neighbor_t *n, *ns;
119 
120  ns = ip6_neighbors_entries (sw_if_index);
121  /* *INDENT-OFF* */
122  vec_foreach (n, ns)
123  {
125  (mp->is_ipv6, ((n->flags & IP6_NEIGHBOR_FLAG_STATIC) ? 1 : 0),
126  (u8 *) n->link_layer_address,
127  (u8 *) & (n->key.ip6_address.as_u8),
128  q, mp->context);
129  }
130  /* *INDENT-ON* */
131  vec_free (ns);
132  }
133  else
134  {
135  ethernet_arp_ip4_entry_t *n, *ns;
136 
137  ns = ip4_neighbor_entries (sw_if_index);
138  /* *INDENT-OFF* */
139  vec_foreach (n, ns)
140  {
142  ((n->flags & ETHERNET_ARP_IP4_ENTRY_FLAG_STATIC) ? 1 : 0),
143  (u8*) n->ethernet_address,
144  (u8*) & (n->ip4_address.as_u8),
145  q, mp->context);
146  }
147  /* *INDENT-ON* */
148  vec_free (ns);
149  }
150 }
151 
152 
153 void
154 copy_fib_next_hop (fib_route_path_encode_t * api_rpath, void *fp_arg)
155 {
156  int is_ip4;
157  vl_api_fib_path_t *fp = (vl_api_fib_path_t *) fp_arg;
158 
159  if (api_rpath->rpath.frp_proto == FIB_PROTOCOL_IP4)
160  fp->afi = IP46_TYPE_IP4;
161  else if (api_rpath->rpath.frp_proto == FIB_PROTOCOL_IP6)
162  fp->afi = IP46_TYPE_IP6;
163  else
164  {
165  is_ip4 = ip46_address_is_ip4 (&api_rpath->rpath.frp_addr);
166  if (is_ip4)
167  fp->afi = IP46_TYPE_IP4;
168  else
169  fp->afi = IP46_TYPE_IP6;
170  }
171  if (fp->afi == IP46_TYPE_IP4)
172  memcpy (fp->next_hop, &api_rpath->rpath.frp_addr.ip4,
173  sizeof (api_rpath->rpath.frp_addr.ip4));
174  else
175  memcpy (fp->next_hop, &api_rpath->rpath.frp_addr.ip6,
176  sizeof (api_rpath->rpath.frp_addr.ip6));
177 }
178 
179 static void
182  u32 table_id, fib_prefix_t * pfx,
183  fib_route_path_encode_t * api_rpaths, u32 context)
184 {
186  fib_route_path_encode_t *api_rpath;
187  vl_api_fib_path_t *fp;
188  int path_count;
189 
190  path_count = vec_len (api_rpaths);
191  mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
192  if (!mp)
193  return;
194  memset (mp, 0, sizeof (*mp));
195  mp->_vl_msg_id = ntohs (VL_API_IP_FIB_DETAILS);
196  mp->context = context;
197 
198  mp->table_id = htonl (table_id);
199  mp->address_length = pfx->fp_len;
200  memcpy (mp->address, &pfx->fp_addr.ip4, sizeof (pfx->fp_addr.ip4));
201 
202  mp->count = htonl (path_count);
203  fp = mp->path;
204  vec_foreach (api_rpath, api_rpaths)
205  {
206  memset (fp, 0, sizeof (*fp));
207  switch (api_rpath->dpo.dpoi_type)
208  {
209  case DPO_RECEIVE:
210  fp->is_local = true;
211  break;
212  case DPO_DROP:
213  fp->is_drop = true;
214  break;
215  case DPO_IP_NULL:
216  switch (api_rpath->dpo.dpoi_index)
217  {
218  case IP_NULL_ACTION_NONE:
219  fp->is_drop = true;
220  break;
222  fp->is_unreach = true;
223  break;
225  fp->is_prohibit = true;
226  break;
227  default:
228  break;
229  }
230  break;
231  default:
232  break;
233  }
234  fp->weight = htonl (api_rpath->rpath.frp_weight);
235  fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
236  copy_fib_next_hop (api_rpath, fp);
237  fp++;
238  }
239 
240  vl_msg_api_send_shmem (q, (u8 *) & mp);
241 }
242 
244 {
247 
248 static int
250 {
252 
253  vec_add1 (ctx->feis, fei);
254 
255  return (1);
256 }
257 
258 static void
260 {
263  ip4_main_t *im = &ip4_main;
264  fib_table_t *fib_table;
265  fib_node_index_t *lfeip;
266  fib_prefix_t pfx;
267  u32 fib_index;
268  fib_route_path_encode_t *api_rpaths;
270  .feis = NULL,
271  };
272 
274  if (q == 0)
275  return;
276 
277  /* *INDENT-OFF* */
278  pool_foreach (fib_table, im->fibs,
279  ({
280  fib_table_walk(fib_table->ft_index,
281  FIB_PROTOCOL_IP4,
282  vl_api_ip_fib_dump_walk,
283  &ctx);
284  }));
285  /* *INDENT-ON* */
286 
288 
289  vec_foreach (lfeip, ctx.feis)
290  {
291  fib_entry_get_prefix (*lfeip, &pfx);
292  fib_index = fib_entry_get_fib_index (*lfeip);
293  fib_table = fib_table_get (fib_index, pfx.fp_proto);
294  api_rpaths = NULL;
295  fib_entry_encode (*lfeip, &api_rpaths);
296  send_ip_fib_details (am, q,
297  fib_table->ft_table_id, &pfx, api_rpaths,
298  mp->context);
299  vec_free (api_rpaths);
300  }
301 
302  vec_free (ctx.feis);
303 }
304 
305 static void
308  u32 table_id, fib_prefix_t * pfx,
309  fib_route_path_encode_t * api_rpaths, u32 context)
310 {
312  fib_route_path_encode_t *api_rpath;
313  vl_api_fib_path_t *fp;
314  int path_count;
315 
316  path_count = vec_len (api_rpaths);
317  mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
318  if (!mp)
319  return;
320  memset (mp, 0, sizeof (*mp));
321  mp->_vl_msg_id = ntohs (VL_API_IP6_FIB_DETAILS);
322  mp->context = context;
323 
324  mp->table_id = htonl (table_id);
325  mp->address_length = pfx->fp_len;
326  memcpy (mp->address, &pfx->fp_addr.ip6, sizeof (pfx->fp_addr.ip6));
327 
328  mp->count = htonl (path_count);
329  fp = mp->path;
330  vec_foreach (api_rpath, api_rpaths)
331  {
332  memset (fp, 0, sizeof (*fp));
333  switch (api_rpath->dpo.dpoi_type)
334  {
335  case DPO_RECEIVE:
336  fp->is_local = true;
337  break;
338  case DPO_DROP:
339  fp->is_drop = true;
340  break;
341  case DPO_IP_NULL:
342  switch (api_rpath->dpo.dpoi_index)
343  {
345  fp->is_drop = true;
346  break;
348  fp->is_unreach = true;
349  break;
351  fp->is_prohibit = true;
352  break;
353  default:
354  break;
355  }
356  break;
357  default:
358  break;
359  }
360  fp->weight = htonl (api_rpath->rpath.frp_weight);
361  fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
362  copy_fib_next_hop (api_rpath, fp);
363  fp++;
364  }
365 
366  vl_msg_api_send_shmem (q, (u8 *) & mp);
367 }
368 
370 {
374 
375 static void
377 {
378  api_ip6_fib_show_ctx_t *ctx = arg;
379 
380  if ((kvp->key[2] >> 32) == ctx->fib_index)
381  {
382  vec_add1 (ctx->entries, kvp->value);
383  }
384 }
385 
386 static void
389  fib_table_t * fib_table)
390 {
392  ip6_main_t *im6 = &ip6_main;
393  fib_node_index_t *fib_entry_index;
394  api_ip6_fib_show_ctx_t ctx = {
395  .fib_index = fib_table->ft_index,
396  .entries = NULL,
397  };
398  fib_route_path_encode_t *api_rpaths;
399  fib_prefix_t pfx;
400 
402  ((BVT (clib_bihash) *) & im6->ip6_table[IP6_FIB_TABLE_NON_FWDING].
403  ip6_hash, api_ip6_fib_table_put_entries, &ctx);
404 
406 
407  vec_foreach (fib_entry_index, ctx.entries)
408  {
409  fib_entry_get_prefix (*fib_entry_index, &pfx);
410  api_rpaths = NULL;
411  fib_entry_encode (*fib_entry_index, &api_rpaths);
412  send_ip6_fib_details (am, q,
413  fib_table->ft_table_id,
414  &pfx, api_rpaths, mp->context);
415  vec_free (api_rpaths);
416  }
417 
418  vec_free (ctx.entries);
419 }
420 
421 static void
423 {
425  ip6_main_t *im6 = &ip6_main;
426  fib_table_t *fib_table;
427 
429  if (q == 0)
430  return;
431 
432  /* *INDENT-OFF* */
433  pool_foreach (fib_table, im6->fibs,
434  ({
435  api_ip6_fib_table_get_all(q, mp, fib_table);
436  }));
437  /* *INDENT-ON* */
438 }
439 
440 static void
442  u32 context, u32 table_id, fib_node_index_t mfei)
443 {
444  fib_route_path_encode_t *api_rpath, *api_rpaths = NULL;
446  mfib_entry_t *mfib_entry;
447  vl_api_fib_path_t *fp;
448  mfib_prefix_t pfx;
449  int path_count;
450 
451  mfib_entry = mfib_entry_get (mfei);
452  mfib_entry_get_prefix (mfei, &pfx);
453  mfib_entry_encode (mfei, &api_rpaths);
454 
455  path_count = vec_len (api_rpaths);
456  mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
457  if (!mp)
458  return;
459  memset (mp, 0, sizeof (*mp));
460  mp->_vl_msg_id = ntohs (VL_API_IP_FIB_DETAILS);
461  mp->context = context;
462 
463  mp->rpf_id = mfib_entry->mfe_rpf_id;
464  mp->entry_flags = mfib_entry->mfe_flags;
465  mp->table_id = htonl (table_id);
466  mp->address_length = pfx.fp_len;
467  memcpy (mp->grp_address, &pfx.fp_grp_addr.ip4,
468  sizeof (pfx.fp_grp_addr.ip4));
469  memcpy (mp->src_address, &pfx.fp_src_addr.ip4,
470  sizeof (pfx.fp_src_addr.ip4));
471 
472  mp->count = htonl (path_count);
473  fp = mp->path;
474  vec_foreach (api_rpath, api_rpaths)
475  {
476  memset (fp, 0, sizeof (*fp));
477 
478  fp->weight = 0;
479  fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
480  copy_fib_next_hop (api_rpath, fp);
481  fp++;
482  }
483  vec_free (api_rpaths);
484 
485  vl_msg_api_send_shmem (q, (u8 *) & mp);
486 }
487 
489 {
492 
493 static int
495 {
496  vl_api_ip_mfib_dump_ctc_t *ctx = arg;
497 
498  vec_add1 (ctx->entries, fei);
499 
500  return (0);
501 }
502 
503 static void
505 {
507  ip4_main_t *im = &ip4_main;
508  mfib_table_t *mfib_table;
509  fib_node_index_t *mfeip;
511  .entries = NULL,
512  };
513 
515  if (q == 0)
516  return;
517 
518 
519  /* *INDENT-OFF* */
520  pool_foreach (mfib_table, im->mfibs,
521  ({
522  ip4_mfib_table_walk(&mfib_table->v4,
523  vl_api_ip_mfib_table_dump_walk,
524  &ctx);
525 
526  vec_sort_with_function (ctx.entries, mfib_entry_cmp_for_sort);
527 
528  vec_foreach (mfeip, ctx.entries)
529  {
530  send_ip_mfib_details (q, mp->context,
531  mfib_table->mft_table_id,
532  *mfeip);
533  }
535 
536  }));
537  /* *INDENT-ON* */
538 
539  vec_free (ctx.entries);
540 }
541 
542 static void
545  u32 table_id,
546  mfib_prefix_t * pfx,
547  fib_route_path_encode_t * api_rpaths, u32 context)
548 {
550  fib_route_path_encode_t *api_rpath;
551  vl_api_fib_path_t *fp;
552  int path_count;
553 
554  path_count = vec_len (api_rpaths);
555  mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
556  if (!mp)
557  return;
558  memset (mp, 0, sizeof (*mp));
559  mp->_vl_msg_id = ntohs (VL_API_IP6_FIB_DETAILS);
560  mp->context = context;
561 
562  mp->table_id = htonl (table_id);
563  mp->address_length = pfx->fp_len;
564  memcpy (mp->grp_address, &pfx->fp_grp_addr.ip6,
565  sizeof (pfx->fp_grp_addr.ip6));
566  memcpy (mp->src_address, &pfx->fp_src_addr.ip6,
567  sizeof (pfx->fp_src_addr.ip6));
568 
569  mp->count = htonl (path_count);
570  fp = mp->path;
571  vec_foreach (api_rpath, api_rpaths)
572  {
573  memset (fp, 0, sizeof (*fp));
574 
575  fp->weight = 0;
576  fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
577  copy_fib_next_hop (api_rpath, fp);
578  fp++;
579  }
580 
581  vl_msg_api_send_shmem (q, (u8 *) & mp);
582 }
583 
585 {
588 
589 static int
591 {
592  vl_api_ip6_mfib_dump_ctc_t *ctx = arg;
593 
594  vec_add1 (ctx->entries, fei);
595 
596  return (0);
597 }
598 
599 static void
601 {
604  ip6_main_t *im = &ip6_main;
605  mfib_table_t *mfib_table;
606  fib_node_index_t *mfeip;
607  mfib_prefix_t pfx;
608  fib_route_path_encode_t *api_rpaths = NULL;
610  .entries = NULL,
611  };
612 
614  if (q == 0)
615  return;
616 
617 
618  /* *INDENT-OFF* */
619  pool_foreach (mfib_table, im->mfibs,
620  ({
621  ip6_mfib_table_walk(&mfib_table->v6,
622  vl_api_ip6_mfib_table_dump_walk,
623  &ctx);
624 
625  vec_sort_with_function (ctx.entries, mfib_entry_cmp_for_sort);
626 
627  vec_foreach(mfeip, ctx.entries)
628  {
629  mfib_entry_get_prefix (*mfeip, &pfx);
630  mfib_entry_encode (*mfeip, &api_rpaths);
631  send_ip6_mfib_details (am, q,
632  mfib_table->mft_table_id,
633  &pfx, api_rpaths,
634  mp->context);
635  }
636  vec_reset_length (api_rpaths);
638 
639  }));
640  /* *INDENT-ON* */
641 
642  vec_free (ctx.entries);
643  vec_free (api_rpaths);
644 }
645 
646 static void
648  vlib_main_t * vm)
649 {
650  vl_api_ip_neighbor_add_del_reply_t *rmp;
651  vnet_main_t *vnm = vnet_get_main ();
652  int rv = 0;
653 
655 
656  stats_dslock_with_hint (1 /* release hint */ , 7 /* tag */ );
657 
658  /*
659  * there's no validation here of the ND/ARP entry being added.
660  * The expectation is that the FIB will ensure that nothing bad
661  * will come of adding bogus entries.
662  */
663  if (mp->is_ipv6)
664  {
665  if (mp->is_add)
667  (vm, ntohl (mp->sw_if_index),
668  (ip6_address_t *) (mp->dst_address),
669  mp->mac_address, sizeof (mp->mac_address), mp->is_static,
670  mp->is_no_adj_fib);
671  else
673  (vm, ntohl (mp->sw_if_index),
674  (ip6_address_t *) (mp->dst_address),
675  mp->mac_address, sizeof (mp->mac_address));
676  }
677  else
678  {
679  ethernet_arp_ip4_over_ethernet_address_t a;
680 
681  clib_memcpy (&a.ethernet, mp->mac_address, 6);
682  clib_memcpy (&a.ip4, mp->dst_address, 4);
683 
684  if (mp->is_add)
685  rv = vnet_arp_set_ip4_over_ethernet (vnm, ntohl (mp->sw_if_index),
686  &a, mp->is_static,
687  mp->is_no_adj_fib);
688  else
689  rv =
690  vnet_arp_unset_ip4_over_ethernet (vnm, ntohl (mp->sw_if_index), &a);
691  }
692 
694 
695  stats_dsunlock ();
696  REPLY_MACRO (VL_API_IP_NEIGHBOR_ADD_DEL_REPLY);
697 }
698 
699 int
701  u8 is_add,
702  u8 is_drop,
703  u8 is_unreach,
704  u8 is_prohibit,
705  u8 is_local,
706  u8 is_multicast,
707  u8 is_classify,
708  u32 classify_table_index,
709  u8 is_resolve_host,
710  u8 is_resolve_attached,
711  u8 is_interface_rx,
712  u8 is_rpf_id,
713  u32 fib_index,
714  const fib_prefix_t * prefix,
715  u8 next_hop_proto_is_ip4,
716  const ip46_address_t * next_hop,
717  u32 next_hop_sw_if_index,
718  u8 next_hop_fib_index,
719  u32 next_hop_weight,
720  mpls_label_t next_hop_via_label,
721  mpls_label_t * next_hop_out_label_stack)
722 {
725  fib_route_path_t path = {
726  .frp_proto = (next_hop_proto_is_ip4 ?
728  .frp_addr = (NULL == next_hop ? zero_addr : *next_hop),
729  .frp_sw_if_index = next_hop_sw_if_index,
730  .frp_fib_index = next_hop_fib_index,
731  .frp_weight = next_hop_weight,
732  .frp_label_stack = next_hop_out_label_stack,
733  };
734  fib_route_path_t *paths = NULL;
736 
737  /*
738  * the special INVALID label meams we are not recursing via a
739  * label. Exp-null value is never a valid via-label so that
740  * also means it's not a via-label and means clients that set
741  * it to 0 by default get the expected behaviour
742  */
743  if ((MPLS_LABEL_INVALID != next_hop_via_label) && (0 != next_hop_via_label))
744  {
746  path.frp_local_label = next_hop_via_label;
747  path.frp_eos = MPLS_NON_EOS;
748  }
749  if (is_resolve_host)
750  path_flags |= FIB_ROUTE_PATH_RESOLVE_VIA_HOST;
751  if (is_resolve_attached)
753  if (is_interface_rx)
754  path_flags |= FIB_ROUTE_PATH_INTF_RX;
755  if (is_rpf_id)
756  path_flags |= FIB_ROUTE_PATH_RPF_ID;
757  if (is_multicast)
758  entry_flags |= FIB_ENTRY_FLAG_MULTICAST;
759 
760  path.frp_flags = path_flags;
761 
762  if (is_multipath)
763  {
764  stats_dslock_with_hint (1 /* release hint */ , 10 /* tag */ );
765 
766 
767  vec_add1 (paths, path);
768 
769  if (is_add)
770  fib_table_entry_path_add2 (fib_index,
771  prefix,
772  FIB_SOURCE_API, entry_flags, paths);
773  else
774  fib_table_entry_path_remove2 (fib_index,
775  prefix, FIB_SOURCE_API, paths);
776 
777  vec_free (paths);
778  stats_dsunlock ();
779  return 0;
780  }
781 
782  stats_dslock_with_hint (1 /* release hint */ , 2 /* tag */ );
783 
784  if (is_drop || is_local || is_classify || is_unreach || is_prohibit)
785  {
786  /*
787  * special route types that link directly to the adj
788  */
789  if (is_add)
790  {
791  dpo_id_t dpo = DPO_INVALID;
792  dpo_proto_t dproto;
793 
794  dproto = fib_proto_to_dpo (prefix->fp_proto);
795 
796  if (is_drop)
798  else if (is_local)
799  receive_dpo_add_or_lock (dproto, ~0, NULL, &dpo);
800  else if (is_unreach)
801  ip_null_dpo_add_and_lock (dproto,
803  else if (is_prohibit)
804  ip_null_dpo_add_and_lock (dproto,
806  &dpo);
807  else if (is_classify)
808  {
809  if (pool_is_free_index (cm->tables,
810  ntohl (classify_table_index)))
811  {
812  stats_dsunlock ();
813  return VNET_API_ERROR_NO_SUCH_TABLE;
814  }
815 
816  dpo_set (&dpo, DPO_CLASSIFY, dproto,
817  classify_dpo_create (dproto,
818  ntohl (classify_table_index)));
819  }
820  else
821  {
822  stats_dsunlock ();
823  return VNET_API_ERROR_NO_SUCH_TABLE;
824  }
825 
827  prefix,
830  dpo_reset (&dpo);
831  }
832  else
833  {
834  fib_table_entry_special_remove (fib_index, prefix, FIB_SOURCE_API);
835  }
836  }
837  else
838  {
839  if (is_add)
840  {
841  vec_add1 (paths, path);
842  fib_table_entry_update (fib_index,
843  prefix, FIB_SOURCE_API, entry_flags, paths);
844  vec_free (paths);
845  }
846  else
847  {
848  fib_table_entry_delete (fib_index, prefix, FIB_SOURCE_API);
849  }
850  }
851 
852  stats_dsunlock ();
853  return (0);
854 }
855 
856 int
858  u32 table_id,
859  u32 next_hop_sw_if_index,
860  fib_protocol_t next_hop_table_proto,
861  u32 next_hop_table_id,
862  u8 create_missing_tables,
863  u8 is_rpf_id, u32 * fib_index, u32 * next_hop_fib_index)
864 {
865  vnet_main_t *vnm = vnet_get_main ();
866 
867  *fib_index = fib_table_find (table_proto, ntohl (table_id));
868  if (~0 == *fib_index)
869  {
870  if (create_missing_tables)
871  {
872  *fib_index = fib_table_find_or_create_and_lock (table_proto,
873  ntohl (table_id));
874  }
875  else
876  {
877  /* No such VRF, and we weren't asked to create one */
878  return VNET_API_ERROR_NO_SUCH_FIB;
879  }
880  }
881 
882  if (!is_rpf_id && ~0 != ntohl (next_hop_sw_if_index))
883  {
885  ntohl (next_hop_sw_if_index)))
886  {
887  return VNET_API_ERROR_NO_MATCHING_INTERFACE;
888  }
889  }
890  else
891  {
892  if (is_rpf_id)
893  *next_hop_fib_index = mfib_table_find (next_hop_table_proto,
894  ntohl (next_hop_table_id));
895  else
896  *next_hop_fib_index = fib_table_find (next_hop_table_proto,
897  ntohl (next_hop_table_id));
898 
899  if (~0 == *next_hop_fib_index)
900  {
901  if (create_missing_tables)
902  {
903  if (is_rpf_id)
904  *next_hop_fib_index =
905  mfib_table_find_or_create_and_lock (next_hop_table_proto,
906  ntohl
907  (next_hop_table_id));
908  else
909  *next_hop_fib_index =
910  fib_table_find_or_create_and_lock (next_hop_table_proto,
911  ntohl
912  (next_hop_table_id));
913  }
914  else
915  {
916  /* No such VRF, and we weren't asked to create one */
917  return VNET_API_ERROR_NO_SUCH_FIB;
918  }
919  }
920  }
921 
922  return (0);
923 }
924 
925 static int
927 {
928  u32 fib_index, next_hop_fib_index;
929  mpls_label_t *label_stack = NULL;
930  int rv, ii, n_labels;;
931 
933  mp->table_id,
936  mp->next_hop_table_id,
937  mp->create_vrf_if_needed, 0,
938  &fib_index, &next_hop_fib_index);
939 
940  if (0 != rv)
941  return (rv);
942 
943  fib_prefix_t pfx = {
944  .fp_len = mp->dst_address_length,
945  .fp_proto = FIB_PROTOCOL_IP4,
946  };
947  clib_memcpy (&pfx.fp_addr.ip4, mp->dst_address, sizeof (pfx.fp_addr.ip4));
948 
949  ip46_address_t nh;
950  memset (&nh, 0, sizeof (nh));
951  memcpy (&nh.ip4, mp->next_hop_address, sizeof (nh.ip4));
952 
953  n_labels = mp->next_hop_n_out_labels;
954  if (n_labels == 0)
955  ;
956  else if (1 == n_labels)
957  vec_add1 (label_stack, ntohl (mp->next_hop_out_label_stack[0]));
958  else
959  {
960  vec_validate (label_stack, n_labels - 1);
961  for (ii = 0; ii < n_labels; ii++)
962  label_stack[ii] = ntohl (mp->next_hop_out_label_stack[ii]);
963  }
964 
966  mp->is_add,
967  mp->is_drop,
968  mp->is_unreach,
969  mp->is_prohibit,
970  mp->is_local, 0,
971  mp->is_classify,
973  mp->is_resolve_host,
974  mp->is_resolve_attached, 0, 0,
975  fib_index, &pfx, 1,
976  &nh,
977  ntohl (mp->next_hop_sw_if_index),
978  next_hop_fib_index,
979  mp->next_hop_weight,
980  ntohl (mp->next_hop_via_label),
981  label_stack));
982 }
983 
984 static int
986 {
987  u32 fib_index, next_hop_fib_index;
988  mpls_label_t *label_stack = NULL;
989  int rv, ii, n_labels;;
990 
992  mp->table_id,
995  mp->next_hop_table_id,
996  mp->create_vrf_if_needed, 0,
997  &fib_index, &next_hop_fib_index);
998 
999  if (0 != rv)
1000  return (rv);
1001 
1002  fib_prefix_t pfx = {
1003  .fp_len = mp->dst_address_length,
1004  .fp_proto = FIB_PROTOCOL_IP6,
1005  };
1006  clib_memcpy (&pfx.fp_addr.ip6, mp->dst_address, sizeof (pfx.fp_addr.ip6));
1007 
1008  ip46_address_t nh;
1009  memset (&nh, 0, sizeof (nh));
1010  memcpy (&nh.ip6, mp->next_hop_address, sizeof (nh.ip6));
1011 
1012  n_labels = mp->next_hop_n_out_labels;
1013  if (n_labels == 0)
1014  ;
1015  else if (1 == n_labels)
1016  vec_add1 (label_stack, ntohl (mp->next_hop_out_label_stack[0]));
1017  else
1018  {
1019  vec_validate (label_stack, n_labels - 1);
1020  for (ii = 0; ii < n_labels; ii++)
1021  label_stack[ii] = ntohl (mp->next_hop_out_label_stack[ii]);
1022  }
1023 
1025  mp->is_add,
1026  mp->is_drop,
1027  mp->is_unreach,
1028  mp->is_prohibit,
1029  mp->is_local, 0,
1030  mp->is_classify,
1032  mp->is_resolve_host,
1033  mp->is_resolve_attached, 0, 0,
1034  fib_index, &pfx, 0,
1035  &nh, ntohl (mp->next_hop_sw_if_index),
1036  next_hop_fib_index,
1037  mp->next_hop_weight,
1038  ntohl (mp->next_hop_via_label),
1039  label_stack));
1040 }
1041 
1042 void
1044 {
1045  vl_api_ip_add_del_route_reply_t *rmp;
1046  int rv;
1047  vnet_main_t *vnm = vnet_get_main ();
1048 
1049  vnm->api_errno = 0;
1050 
1051  if (mp->is_ipv6)
1052  rv = ip6_add_del_route_t_handler (mp);
1053  else
1054  rv = ip4_add_del_route_t_handler (mp);
1055 
1056  rv = (rv == 0) ? vnm->api_errno : rv;
1057 
1058  REPLY_MACRO (VL_API_IP_ADD_DEL_ROUTE_REPLY);
1059 }
1060 
1061 static int
1063  u32 table_id,
1064  u32 next_hop_sw_if_index,
1065  u8 is_local, u8 create_missing_tables, u32 * fib_index)
1066 {
1067  vnet_main_t *vnm = vnet_get_main ();
1068 
1069  *fib_index = mfib_table_find (table_proto, ntohl (table_id));
1070  if (~0 == *fib_index)
1071  {
1072  if (create_missing_tables)
1073  {
1074  *fib_index = mfib_table_find_or_create_and_lock (table_proto,
1075  ntohl (table_id));
1076  }
1077  else
1078  {
1079  /* No such VRF, and we weren't asked to create one */
1080  return VNET_API_ERROR_NO_SUCH_FIB;
1081  }
1082  }
1083 
1084  if (~0 != ntohl (next_hop_sw_if_index))
1085  {
1087  ntohl (next_hop_sw_if_index)))
1088  {
1089  return VNET_API_ERROR_NO_MATCHING_INTERFACE;
1090  }
1091  }
1092 
1093  return (0);
1094 }
1095 
1096 static int
1098  u8 is_local,
1099  u32 fib_index,
1100  const mfib_prefix_t * prefix,
1101  u32 entry_flags,
1102  fib_rpf_id_t rpf_id,
1103  u32 next_hop_sw_if_index, u32 itf_flags)
1104 {
1105  stats_dslock_with_hint (1 /* release hint */ , 2 /* tag */ );
1106 
1107  fib_route_path_t path = {
1108  .frp_sw_if_index = next_hop_sw_if_index,
1109  .frp_proto = prefix->fp_proto,
1110  };
1111 
1112  if (is_local)
1114 
1115 
1116  if (!is_local && ~0 == next_hop_sw_if_index)
1117  {
1118  mfib_table_entry_update (fib_index, prefix,
1119  MFIB_SOURCE_API, rpf_id, entry_flags);
1120  }
1121  else
1122  {
1123  if (is_add)
1124  {
1125  mfib_table_entry_path_update (fib_index, prefix,
1126  MFIB_SOURCE_API, &path, itf_flags);
1127  }
1128  else
1129  {
1130  mfib_table_entry_path_remove (fib_index, prefix,
1131  MFIB_SOURCE_API, &path);
1132  }
1133  }
1134 
1135  stats_dsunlock ();
1136  return (0);
1137 }
1138 
1139 static int
1141 {
1142  fib_protocol_t fproto;
1143  u32 fib_index;
1144  int rv;
1145 
1146  fproto = (mp->is_ipv6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4);
1147  rv = add_del_mroute_check (fproto,
1148  mp->table_id,
1150  mp->is_local,
1151  mp->create_vrf_if_needed, &fib_index);
1152 
1153  if (0 != rv)
1154  return (rv);
1155 
1156  mfib_prefix_t pfx = {
1157  .fp_len = ntohs (mp->grp_address_length),
1158  .fp_proto = fproto,
1159  };
1160 
1161  if (FIB_PROTOCOL_IP4 == fproto)
1162  {
1163  clib_memcpy (&pfx.fp_grp_addr.ip4, mp->grp_address,
1164  sizeof (pfx.fp_grp_addr.ip4));
1165  clib_memcpy (&pfx.fp_src_addr.ip4, mp->src_address,
1166  sizeof (pfx.fp_src_addr.ip4));
1167  }
1168  else
1169  {
1170  clib_memcpy (&pfx.fp_grp_addr.ip6, mp->grp_address,
1171  sizeof (pfx.fp_grp_addr.ip6));
1172  clib_memcpy (&pfx.fp_src_addr.ip6, mp->src_address,
1173  sizeof (pfx.fp_src_addr.ip6));
1174  }
1175 
1176  return (mroute_add_del_handler (mp->is_add,
1177  mp->is_local,
1178  fib_index, &pfx,
1179  ntohl (mp->entry_flags),
1180  ntohl (mp->rpf_id),
1181  ntohl (mp->next_hop_sw_if_index),
1182  ntohl (mp->itf_flags)));
1183 }
1184 
1185 void
1187 {
1188  vl_api_ip_mroute_add_del_reply_t *rmp;
1189  int rv;
1190  vnet_main_t *vnm = vnet_get_main ();
1191 
1192  vnm->api_errno = 0;
1193 
1194  rv = api_mroute_add_del_t_handler (mp);
1195 
1196  rv = (rv == 0) ? vnm->api_errno : rv;
1197 
1198  REPLY_MACRO (VL_API_IP_MROUTE_ADD_DEL_REPLY);
1199 }
1200 
1201 static void
1203  unix_shared_memory_queue_t * q, u32 sw_if_index,
1204  u8 is_ipv6, u32 context)
1205 {
1206  vl_api_ip_details_t *mp;
1207 
1208  mp = vl_msg_api_alloc (sizeof (*mp));
1209  memset (mp, 0, sizeof (*mp));
1210  mp->_vl_msg_id = ntohs (VL_API_IP_DETAILS);
1211 
1212  mp->sw_if_index = ntohl (sw_if_index);
1213  mp->is_ipv6 = is_ipv6;
1214  mp->context = context;
1215 
1216  vl_msg_api_send_shmem (q, (u8 *) & mp);
1217 }
1218 
1219 static void
1222  u8 * ip, u16 prefix_length,
1223  u32 sw_if_index, u8 is_ipv6, u32 context)
1224 {
1226 
1227  mp = vl_msg_api_alloc (sizeof (*mp));
1228  memset (mp, 0, sizeof (*mp));
1229  mp->_vl_msg_id = ntohs (VL_API_IP_ADDRESS_DETAILS);
1230 
1231  if (is_ipv6)
1232  {
1233  clib_memcpy (&mp->ip, ip, sizeof (mp->ip));
1234  }
1235  else
1236  {
1237  u32 *tp = (u32 *) mp->ip;
1238  *tp = *(u32 *) ip;
1239  }
1240  mp->prefix_length = prefix_length;
1241  mp->context = context;
1242  mp->sw_if_index = htonl (sw_if_index);
1243  mp->is_ipv6 = is_ipv6;
1244 
1245  vl_msg_api_send_shmem (q, (u8 *) & mp);
1246 }
1247 
1248 static void
1250 {
1253  ip6_address_t *r6;
1254  ip4_address_t *r4;
1255  ip6_main_t *im6 = &ip6_main;
1256  ip4_main_t *im4 = &ip4_main;
1257  ip_lookup_main_t *lm6 = &im6->lookup_main;
1258  ip_lookup_main_t *lm4 = &im4->lookup_main;
1259  ip_interface_address_t *ia = 0;
1260  u32 sw_if_index = ~0;
1261  int rv __attribute__ ((unused)) = 0;
1262 
1263  VALIDATE_SW_IF_INDEX (mp);
1264 
1265  sw_if_index = ntohl (mp->sw_if_index);
1266 
1268  if (q == 0)
1269  return;
1270 
1271  if (mp->is_ipv6)
1272  {
1273  /* *INDENT-OFF* */
1274  foreach_ip_interface_address (lm6, ia, sw_if_index,
1275  1 /* honor unnumbered */,
1276  ({
1277  r6 = ip_interface_address_get_address (lm6, ia);
1278  u16 prefix_length = ia->address_length;
1279  send_ip_address_details(am, q, (u8*)r6, prefix_length,
1280  sw_if_index, 1, mp->context);
1281  }));
1282  /* *INDENT-ON* */
1283  }
1284  else
1285  {
1286  /* *INDENT-OFF* */
1287  foreach_ip_interface_address (lm4, ia, sw_if_index,
1288  1 /* honor unnumbered */,
1289  ({
1290  r4 = ip_interface_address_get_address (lm4, ia);
1291  u16 prefix_length = ia->address_length;
1292  send_ip_address_details(am, q, (u8*)r4, prefix_length,
1293  sw_if_index, 0, mp->context);
1294  }));
1295  /* *INDENT-ON* */
1296  }
1298 }
1299 
1300 static void
1302 {
1304  vnet_main_t *vnm = vnet_get_main ();
1305  vlib_main_t *vm = vlib_get_main ();
1308  vnet_sw_interface_t *si, *sorted_sis;
1309  u32 sw_if_index = ~0;
1310 
1312  if (q == 0)
1313  {
1314  return;
1315  }
1316 
1317  /* Gather interfaces. */
1318  sorted_sis = vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
1319  _vec_len (sorted_sis) = 0;
1320  /* *INDENT-OFF* */
1321  pool_foreach (si, im->sw_interfaces,
1322  ({
1323  vec_add1 (sorted_sis, si[0]);
1324  }));
1325  /* *INDENT-ON* */
1326 
1327  vec_foreach (si, sorted_sis)
1328  {
1330  {
1331  if (mp->is_ipv6 && !ip6_interface_enabled (vm, si->sw_if_index))
1332  {
1333  continue;
1334  }
1335  sw_if_index = si->sw_if_index;
1336  send_ip_details (am, q, sw_if_index, mp->is_ipv6, mp->context);
1337  }
1338  }
1339 }
1340 
1341 static void
1343 {
1344  vl_api_set_ip_flow_hash_reply_t *rmp;
1345  int rv;
1346  u32 table_id;
1347  flow_hash_config_t flow_hash_config = 0;
1348 
1349  table_id = ntohl (mp->vrf_id);
1350 
1351 #define _(a,b) if (mp->a) flow_hash_config |= b;
1353 #undef _
1354 
1355  rv = vnet_set_ip6_flow_hash (table_id, flow_hash_config);
1356 
1357  REPLY_MACRO (VL_API_SET_IP_FLOW_HASH_REPLY);
1358 }
1359 
1360 static void
1362 {
1363  vl_api_set_ip_flow_hash_reply_t *rmp;
1364  int rv;
1365  u32 table_id;
1366  flow_hash_config_t flow_hash_config = 0;
1367 
1368  table_id = ntohl (mp->vrf_id);
1369 
1370 #define _(a,b) if (mp->a) flow_hash_config |= b;
1372 #undef _
1373 
1374  rv = vnet_set_ip4_flow_hash (table_id, flow_hash_config);
1375 
1376  REPLY_MACRO (VL_API_SET_IP_FLOW_HASH_REPLY);
1377 }
1378 
1379 
1380 static void
1382 {
1383  if (mp->is_ipv6 == 0)
1384  set_ip4_flow_hash (mp);
1385  else
1386  set_ip6_flow_hash (mp);
1387 }
1388 
1389 static void
1392 {
1393  vl_api_sw_interface_ip6nd_ra_config_reply_t *rmp;
1394  vlib_main_t *vm = vlib_get_main ();
1395  int rv = 0;
1396  u8 is_no, suppress, managed, other, ll_option, send_unicast, cease,
1397  default_router;
1398 
1399  is_no = mp->is_no == 1;
1400  suppress = mp->suppress == 1;
1401  managed = mp->managed == 1;
1402  other = mp->other == 1;
1403  ll_option = mp->ll_option == 1;
1404  send_unicast = mp->send_unicast == 1;
1405  cease = mp->cease == 1;
1406  default_router = mp->default_router == 1;
1407 
1408  VALIDATE_SW_IF_INDEX (mp);
1409 
1410  rv = ip6_neighbor_ra_config (vm, ntohl (mp->sw_if_index),
1411  suppress, managed, other,
1412  ll_option, send_unicast, cease,
1413  default_router, ntohl (mp->lifetime),
1414  ntohl (mp->initial_count),
1415  ntohl (mp->initial_interval),
1416  ntohl (mp->max_interval),
1417  ntohl (mp->min_interval), is_no);
1418 
1420 
1421  REPLY_MACRO (VL_API_SW_INTERFACE_IP6ND_RA_CONFIG_REPLY);
1422 }
1423 
1424 static void
1427 {
1428  vlib_main_t *vm = vlib_get_main ();
1429  vl_api_sw_interface_ip6nd_ra_prefix_reply_t *rmp;
1430  int rv = 0;
1431  u8 is_no, use_default, no_advertise, off_link, no_autoconfig, no_onlink;
1432 
1433  VALIDATE_SW_IF_INDEX (mp);
1434 
1435  is_no = mp->is_no == 1;
1436  use_default = mp->use_default == 1;
1437  no_advertise = mp->no_advertise == 1;
1438  off_link = mp->off_link == 1;
1439  no_autoconfig = mp->no_autoconfig == 1;
1440  no_onlink = mp->no_onlink == 1;
1441 
1442  rv = ip6_neighbor_ra_prefix (vm, ntohl (mp->sw_if_index),
1443  (ip6_address_t *) mp->address,
1444  mp->address_length, use_default,
1445  ntohl (mp->val_lifetime),
1446  ntohl (mp->pref_lifetime), no_advertise,
1447  off_link, no_autoconfig, no_onlink, is_no);
1448 
1450  REPLY_MACRO (VL_API_SW_INTERFACE_IP6ND_RA_PREFIX_REPLY);
1451 }
1452 
1453 static void
1455  u32 context,
1456  const ip46_address_t * addr, u32 sw_if_index)
1457 {
1459 
1460  mp = vl_msg_api_alloc (sizeof (*mp));
1461  memset (mp, 0, sizeof (*mp));
1462  mp->_vl_msg_id = ntohs (VL_API_IP6ND_PROXY_DETAILS);
1463  mp->context = context;
1464  mp->sw_if_index = htonl (sw_if_index);
1465  memcpy (mp->address, addr, 16);
1466 
1467  vl_msg_api_send_shmem (q, (u8 *) & mp);
1468 }
1469 
1471 {
1474 
1475 static int
1477 {
1479 
1481  {
1482  vec_add1 (ctx->indices, fei);
1483  }
1484 
1485  return (1);
1486 }
1487 
1488 static void
1490 {
1491  ip6_main_t *im6 = &ip6_main;
1492  fib_table_t *fib_table;
1494  .indices = NULL,
1495  };
1496  fib_node_index_t *feip;
1497  fib_prefix_t pfx;
1499 
1501  if (q == 0)
1502  {
1503  return;
1504  }
1505 
1506  /* *INDENT-OFF* */
1507  pool_foreach (fib_table, im6->fibs,
1508  ({
1509  fib_table_walk(fib_table->ft_index,
1510  FIB_PROTOCOL_IP6,
1511  api_ip6nd_proxy_fib_table_walk,
1512  &ctx);
1513  }));
1514  /* *INDENT-ON* */
1515 
1517 
1518  vec_foreach (feip, ctx.indices)
1519  {
1520  fib_entry_get_prefix (*feip, &pfx);
1521 
1523  mp->context,
1524  &pfx.fp_addr,
1526  }
1527 
1528  vec_free (ctx.indices);
1529 }
1530 
1531 static void
1533 {
1534  vl_api_ip6nd_proxy_add_del_reply_t *rmp;
1535  int rv = 0;
1536 
1537  VALIDATE_SW_IF_INDEX (mp);
1538 
1539  rv = ip6_neighbor_proxy_add_del (ntohl (mp->sw_if_index),
1540  (ip6_address_t *) mp->address, mp->is_del);
1541 
1543  REPLY_MACRO (VL_API_IP6ND_PROXY_ADD_DEL_REPLY);
1544 }
1545 
1546 static void
1549 {
1550  vlib_main_t *vm = vlib_get_main ();
1551  vl_api_sw_interface_ip6_enable_disable_reply_t *rmp;
1552  vnet_main_t *vnm = vnet_get_main ();
1553  int rv = 0;
1554  clib_error_t *error;
1555 
1556  vnm->api_errno = 0;
1557 
1558  VALIDATE_SW_IF_INDEX (mp);
1559 
1560  error =
1561  (mp->enable == 1) ? enable_ip6_interface (vm,
1562  ntohl (mp->sw_if_index)) :
1563  disable_ip6_interface (vm, ntohl (mp->sw_if_index));
1564 
1565  if (error)
1566  {
1567  clib_error_report (error);
1568  rv = VNET_API_ERROR_UNSPECIFIED;
1569  }
1570  else
1571  {
1572  rv = vnm->api_errno;
1573  }
1574 
1576 
1577  REPLY_MACRO (VL_API_SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY);
1578 }
1579 
1580 static void
1583 {
1584  vlib_main_t *vm = vlib_get_main ();
1585  vl_api_sw_interface_ip6_set_link_local_address_reply_t *rmp;
1586  int rv = 0;
1587  clib_error_t *error;
1588  vnet_main_t *vnm = vnet_get_main ();
1589 
1590  vnm->api_errno = 0;
1591 
1592  VALIDATE_SW_IF_INDEX (mp);
1593 
1594  error = set_ip6_link_local_address (vm,
1595  ntohl (mp->sw_if_index),
1596  (ip6_address_t *) mp->address);
1597  if (error)
1598  {
1599  clib_error_report (error);
1600  rv = VNET_API_ERROR_UNSPECIFIED;
1601  }
1602  else
1603  {
1604  rv = vnm->api_errno;
1605  }
1606 
1608 
1609  REPLY_MACRO (VL_API_SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY);
1610 }
1611 
1612 void
1614  u32 context, const mfib_signal_t * mfs)
1615 {
1617  mfib_prefix_t prefix;
1618  mfib_table_t *mfib;
1619  mfib_itf_t *mfi;
1620 
1621  mp = vl_msg_api_alloc (sizeof (*mp));
1622 
1623  memset (mp, 0, sizeof (*mp));
1624  mp->_vl_msg_id = ntohs (VL_API_MFIB_SIGNAL_DETAILS);
1625  mp->context = context;
1626 
1627  mfi = mfib_itf_get (mfs->mfs_itf);
1628  mfib_entry_get_prefix (mfs->mfs_entry, &prefix);
1630  prefix.fp_proto);
1631  mp->table_id = ntohl (mfib->mft_table_id);
1632  mp->sw_if_index = ntohl (mfi->mfi_sw_if_index);
1633 
1634  if (FIB_PROTOCOL_IP4 == prefix.fp_proto)
1635  {
1636  mp->grp_address_len = ntohs (prefix.fp_len);
1637 
1638  memcpy (mp->grp_address, &prefix.fp_grp_addr.ip4, 4);
1639  if (prefix.fp_len > 32)
1640  {
1641  memcpy (mp->src_address, &prefix.fp_src_addr.ip4, 4);
1642  }
1643  }
1644  else
1645  {
1646  mp->grp_address_len = ntohs (prefix.fp_len);
1647 
1648  ASSERT (0);
1649  }
1650 
1651  if (0 != mfs->mfs_buffer_len)
1652  {
1653  mp->ip_packet_len = ntohs (mfs->mfs_buffer_len);
1654 
1655  memcpy (mp->ip_packet_data, mfs->mfs_buffer, mfs->mfs_buffer_len);
1656  }
1657  else
1658  {
1659  mp->ip_packet_len = 0;
1660  }
1661 
1662  vl_msg_api_send_shmem (q, (u8 *) & mp);
1663 }
1664 
1665 static void
1667 {
1669 
1671  if (q == 0)
1672  {
1673  return;
1674  }
1675 
1676  while (q->cursize < q->maxsize && mfib_signal_send_one (q, mp->context))
1677  ;
1678 }
1679 
1680 #define vl_msg_name_crc_list
1681 #include <vnet/ip/ip.api.h>
1682 #undef vl_msg_name_crc_list
1683 
1684 static void
1686 {
1687 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1688  foreach_vl_msg_name_crc_ip;
1689 #undef _
1690 }
1691 
1692 static clib_error_t *
1694 {
1695  api_main_t *am = &api_main;
1696 
1697 #define _(N,n) \
1698  vl_msg_api_set_handlers(VL_API_##N, #n, \
1699  vl_api_##n##_t_handler, \
1700  vl_noop_handler, \
1701  vl_api_##n##_t_endian, \
1702  vl_api_##n##_t_print, \
1703  sizeof(vl_api_##n##_t), 1);
1705 #undef _
1706 
1707  /*
1708  * Set up the (msg_name, crc, message-id) table
1709  */
1711 
1712  return 0;
1713 }
1714 
1716 
1717 /*
1718  * fd.io coding-style-patch-verification: ON
1719  *
1720  * Local Variables:
1721  * eval: (c-set-style "gnu")
1722  * End:
1723  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:436
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
Definition: lookup.h:179
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:169
#define VNET_SW_INTERFACE_FLAG_UNNUMBERED
Definition: interface.h:567
u32 fib_entry_get_fib_index(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1542
fib_protocol_t frp_proto
The protocol of the address below.
Definition: fib_types.h:341
void ip_null_dpo_add_and_lock(dpo_proto_t proto, ip_null_dpo_action_t action, dpo_id_t *dpo)
Definition: ip_null_dpo.c:78
ip46_address_t frp_addr
The next-hop address.
Definition: fib_types.h:350
ip46_address_t fp_src_addr
Definition: mfib_types.h:47
static void vl_api_ip6nd_proxy_add_del_t_handler(vl_api_ip6nd_proxy_add_del_t *mp)
Definition: ip_api.c:1532
void receive_dpo_add_or_lock(dpo_proto_t proto, u32 sw_if_index, const ip46_address_t *nh_addr, dpo_id_t *dpo)
Definition: receive_dpo.c:56
static int vl_api_ip_fib_dump_walk(fib_node_index_t fei, void *arg)
Definition: ip_api.c:249
A representation of a fib path for fib_path_encode to convey the information to the caller...
Definition: fib_types.h:398
mpls_eos_bit_t frp_eos
EOS bit for the resolving label.
Definition: fib_types.h:361
int vnet_set_ip4_flow_hash(u32 table_id, flow_hash_config_t flow_hash_config)
Definition: ip4_forward.c:3039
u8 next_hop[16]
Definition: ip.api:52
Dump IP neighboors.
Definition: ip.api:104
Dump IP fib table.
Definition: ip.api:25
a
Definition: bitmap.h:516
vl_api_fib_path_t path[count]
Definition: ip.api:438
vl_api_fib_path_t path[count]
Definition: ip.api:69
int ip6_neighbor_ra_prefix(vlib_main_t *vm, u32 sw_if_index, ip6_address_t *prefix_addr, u8 prefix_len, u8 use_default, u32 val_lifetime, u32 pref_lifetime, u8 no_advertise, u8 off_link, u8 no_autoconfig, u8 no_onlink, u8 is_no)
A representation of a path as described by a route producer.
Definition: fib_types.h:336
static void vl_api_ip_neighbor_add_del_t_handler(vl_api_ip_neighbor_add_del_t *mp, vlib_main_t *vm)
Definition: ip_api.c:647
static void send_ip6_mfib_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, u32 table_id, mfib_prefix_t *pfx, fib_route_path_encode_t *api_rpaths, u32 context)
Definition: ip_api.c:543
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
vnet_interface_main_t interface_main
Definition: vnet.h:56
IP FIB table response.
Definition: ip.api:62
The table that stores ALL routes learned by the DP.
Definition: ip6.h:122
static int mroute_add_del_handler(u8 is_add, u8 is_local, u32 fib_index, const mfib_prefix_t *prefix, u32 entry_flags, fib_rpf_id_t rpf_id, u32 next_hop_sw_if_index, u32 itf_flags)
Definition: ip_api.c:1097
u8 as_u8[16]
Definition: ip6_packet.h:48
A pair of indicies, for the entry and interface resp.
Definition: mfib_signal.h:29
void fib_entry_get_prefix(fib_node_index_t fib_entry_index, fib_prefix_t *pfx)
Definition: fib_entry.c:1532
Dump IP multicast fib table.
Definition: ip.api:414
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:705
#define NULL
Definition: clib.h:55
An entry in a FIB table.
Definition: mfib_entry.h:31
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 *rpath)
Add n paths to an entry (aka route) in the FIB.
Definition: fib_table.c:538
ip6_neighbor_t * ip6_neighbors_entries(u32 sw_if_index)
Definition: ip6_neighbor.c:815
u32 mpls_label_t
A label value only, i.e.
Definition: packet.h:24
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
#define IP_NULL_DPO_ACTION_NUM
Definition: ip_null_dpo.h:48
int ip6_neighbor_proxy_add_del(u32 sw_if_index, ip6_address_t *addr, u8 is_del)
ip_lookup_main_t lookup_main
Definition: ip4.h:85
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:165
IPv6 router advertisement config request.
Definition: ip.api:196
static void send_ip6nd_proxy_details(unix_shared_memory_queue_t *q, u32 context, const ip46_address_t *addr, u32 sw_if_index)
Definition: ip_api.c:1454
int add_del_route_t_handler(u8 is_multipath, u8 is_add, u8 is_drop, u8 is_unreach, u8 is_prohibit, u8 is_local, u8 is_multicast, u8 is_classify, u32 classify_table_index, u8 is_resolve_host, u8 is_resolve_attached, u8 is_interface_rx, u8 is_rpf_id, u32 fib_index, const fib_prefix_t *prefix, u8 next_hop_proto_is_ip4, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u8 next_hop_fib_index, u32 next_hop_weight, mpls_label_t next_hop_via_label, mpls_label_t *next_hop_out_label_stack)
Definition: ip_api.c:700
Definition: fib_entry.h:241
struct api_ip6nd_proxy_fib_table_walk_ctx_t_ api_ip6nd_proxy_fib_table_walk_ctx_t
A path that result in received traffic being recieved/recirculated so that it appears to have arrived...
Definition: fib_types.h:301
static void vl_api_ip6nd_proxy_dump_t_handler(vl_api_ip6nd_proxy_dump_t *mp)
Definition: ip_api.c:1489
static void api_ip6_fib_table_put_entries(clib_bihash_kv_24_8_t *kvp, void *arg)
Definition: ip_api.c:376
Dump IP6 fib table.
Definition: ip.api:75
int mfib_signal_send_one(struct _unix_shared_memory_queue *q, u32 context)
Definition: mfib_signal.c:94
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static int add_del_mroute_check(fib_protocol_t table_proto, u32 table_id, u32 next_hop_sw_if_index, u8 is_local, u8 create_missing_tables, u32 *fib_index)
Definition: ip_api.c:1062
static void vl_api_ip_mfib_dump_t_handler(vl_api_ip_mfib_dump_t *mp)
Definition: ip_api.c:504
A local path with a RPF-ID => multicast traffic.
Definition: fib_types.h:305
ip6_neighbor_flags_t flags
Definition: ip6_neighbor.h:42
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:376
u32 frp_sw_if_index
The interface.
Definition: fib_types.h:369
Dump IP6 multicast fib table.
Definition: ip.api:444
void fib_table_entry_special_remove(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Remove a &#39;special&#39; entry from the FIB.
Definition: fib_table.c:390
vl_api_fib_path_t path[count]
Definition: ip.api:466
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
Definition: vec.h:310
static BVT(clib_bihash)
Definition: adj_nbr.c:26
Recursion constraint of via a host prefix.
Definition: fib_types.h:276
static void vl_api_ip6_mfib_dump_t_handler(vl_api_ip6_mfib_dump_t *mp)
Definition: ip_api.c:600
int vnet_set_ip6_ethernet_neighbor(vlib_main_t *vm, u32 sw_if_index, ip6_address_t *a, u8 *link_layer_address, uword n_bytes_link_layer_address, int is_static, int is_no_fib_entry)
Definition: ip6_neighbor.c:583
Aggregrate type for a prefix.
Definition: fib_types.h:160
int ip6_interface_enabled(vlib_main_t *vm, u32 sw_if_index)
static void vl_api_ip_dump_t_handler(vl_api_ip_dump_t *mp)
Definition: ip_api.c:1301
struct vl_api_ip_mfib_dump_ctc_t_ vl_api_ip_mfib_dump_ctc_t
static int ip6_add_del_route_t_handler(vl_api_ip_add_del_route_t *mp)
Definition: ip_api.c:985
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, mfib_itf_flags_t itf_flags)
Add n paths to an entry (aka route) in the FIB.
Definition: mfib_table.c:219
IPv6 interface enable / disable request.
Definition: ip.api:308
enum fib_route_path_flags_t_ fib_route_path_flags_t
Path flags from the control plane.
static void send_ip_address_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, u8 *ip, u16 prefix_length, u32 sw_if_index, u8 is_ipv6, u32 context)
Definition: ip_api.c:1220
struct mfib_table_t_ * mfibs
Vector of MFIBs.
Definition: ip4.h:94
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
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:1025
static void send_ip_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, u32 sw_if_index, u8 is_ipv6, u32 context)
Definition: ip_api.c:1202
u16 fp_len
The mask length.
Definition: fib_types.h:164
static void vl_api_mfib_signal_dump_t_handler(vl_api_mfib_signal_dump_t *mp)
Definition: ip_api.c:1666
int fib_entry_cmp_for_sort(void *i1, void *i2)
Definition: fib_entry.c:1484
int vnet_arp_unset_ip4_over_ethernet(vnet_main_t *vnm, u32 sw_if_index, void *a_arg)
Control Plane hook to remove an ARP entry.
Definition: arp.c:1436
void * vl_msg_api_alloc(int nbytes)
u32 mfib_entry_get_fib_index(fib_node_index_t mfib_entry_index)
Definition: mfib_entry.c:1212
Definition: fib_entry.h:233
vnet_api_error_t api_errno
Definition: vnet.h:76
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:152
static int vl_api_ip6_mfib_table_dump_walk(fib_node_index_t fei, void *arg)
Definition: ip_api.c:590
Definition: fib_entry.h:237
static mfib_itf_t * mfib_itf_get(index_t mi)
Definition: mfib_itf.h:53
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:183
index_t classify_dpo_create(dpo_proto_t proto, u32 classify_table_index)
Definition: classify_dpo.c:43
dpo_type_t dpoi_type
the type
Definition: dpo.h:156
ip4_address_t ip4_address
Definition: arp_packet.h:153
int vnet_unset_ip6_ethernet_neighbor(vlib_main_t *vm, u32 sw_if_index, ip6_address_t *a, u8 *link_layer_address, uword n_bytes_link_layer_address)
Definition: ip6_neighbor.c:731
u8 ethernet_address[6]
Definition: arp_packet.h:155
static void vl_api_sw_interface_ip6nd_ra_prefix_t_handler(vl_api_sw_interface_ip6nd_ra_prefix_t *mp)
Definition: ip_api.c:1426
IP6 Multicast FIB table response.
Definition: ip.api:458
void fib_table_entry_path_remove2(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_route_path_t *rpath)
Remove n paths to an entry (aka route) in the FIB.
Definition: fib_table.c:582
vl_api_fib_path_t path[count]
Definition: ip.api:95
#define REPLY_MACRO(t)
static int api_ip6nd_proxy_fib_table_walk(fib_node_index_t fei, void *arg)
Definition: ip_api.c:1476
Recursion constraint of via an attahced prefix.
Definition: fib_types.h:280
fib_node_index_t * entries
Definition: ip_api.c:372
VLIB_API_INIT_FUNCTION(ip_api_hookup)
static void vl_api_sw_interface_ip6_enable_disable_t_handler(vl_api_sw_interface_ip6_enable_disable_t *mp)
Definition: ip_api.c:1548
static void vl_api_set_ip_flow_hash_t_handler(vl_api_set_ip_flow_hash_t *mp)
Definition: ip_api.c:1381
static mfib_entry_t * mfib_entry_get(fib_node_index_t index)
Definition: mfib_entry.h:148
void stats_dsunlock(void)
u32 fib_entry_get_resolving_interface(fib_node_index_t entry_index)
Definition: fib_entry.c:1338
#define ip46_address_is_ip4(ip46)
Definition: ip6_packet.h:76
void clib_bihash_foreach_key_value_pair(clib_bihash *h, void *callback, void *arg)
Visit active (key,value) pairs in a bi-hash table.
#define BAD_SW_IF_INDEX_LABEL
static void send_ip_mfib_details(unix_shared_memory_queue_t *q, u32 context, u32 table_id, fib_node_index_t mfei)
Definition: ip_api.c:441
struct vl_api_ip6_mfib_dump_ctc_t_ vl_api_ip6_mfib_dump_ctc_t
fib_node_index_t ft_index
Index into FIB vector.
Definition: fib_table.h:49
int fib_entry_is_sourced(fib_node_index_t fib_entry_index, fib_source_t source)
api_main_t api_main
Definition: api_shared.c:35
Set the ip flow hash config for a fib request.
Definition: ip.api:165
fib_node_index_t fib_table_entry_special_dpo_update(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Update a &#39;special&#39; entry to the FIB that links to the DPO passed A special entry is an entry that the...
Definition: fib_table.c:329
u32 ft_table_id
Table ID (hash key) for this FIB.
Definition: fib_table.h:44
#define MPLS_LABEL_INVALID
Definition: mpls_types.h:48
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:340
void copy_fib_next_hop(fib_route_path_encode_t *api_rpath, void *fp_arg)
Definition: ip_api.c:154
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:835
struct vl_api_ip_fib_dump_walk_ctx_t_ vl_api_ip_fib_dump_walk_ctx_t
u32 frp_weight
[un]equal cost path weight
Definition: fib_types.h:383
fib_node_index_t * entries
Definition: ip_api.c:586
#define clib_memcpy(a, b, c)
Definition: string.h:69
static void send_ip_fib_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, u32 table_id, fib_prefix_t *pfx, fib_route_path_encode_t *api_rpaths, u32 context)
Definition: ip_api.c:180
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:28
mfib_entry_flags_t mfe_flags
Route flags.
Definition: mfib_entry.h:74
static void set_ip6_flow_hash(vl_api_set_ip_flow_hash_t *mp)
Definition: ip_api.c:1342
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:238
void dpo_set(dpo_id_t *dpo, dpo_type_t type, dpo_proto_t proto, index_t index)
Set/create a DPO ID The DPO will be locked.
Definition: dpo.c:159
u32 sw_if_index
Definition: ip.api:45
clib_error_t * enable_ip6_interface(vlib_main_t *vm, u32 sw_if_index)
Aggregrate type for a prefix.
Definition: mfib_types.h:24
enum fib_entry_flag_t_ fib_entry_flag_t
u32 fib_rpf_id_t
An RPF-ID is numerical value that is used RPF validate.
Definition: fib_types.h:315
struct _vnet_classify_main vnet_classify_main_t
Definition: vnet_classify.h:72
#define foreach_flow_hash_bit
Definition: lookup.h:71
void vl_api_ip_mroute_add_del_t_handler(vl_api_ip_mroute_add_del_t *mp)
Definition: ip_api.c:1186
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
IP neighbor add / del request.
Definition: ip.api:139
void mfib_entry_get_prefix(fib_node_index_t mfib_entry_index, mfib_prefix_t *pfx)
Definition: mfib_entry.c:1202
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
static int api_mroute_add_del_t_handler(vl_api_ip_mroute_add_del_t *mp)
Definition: ip_api.c:1140
IP Multicast FIB table response.
Definition: ip.api:428
ip6_address_t ip6_address
Definition: ip6_neighbor.h:26
ip6_main_t ip6_main
Definition: ip6_forward.c:2926
ip_lookup_main_t lookup_main
Definition: ip6.h:148
index_t mfs_itf
Definition: mfib_signal.h:32
fib_node_index_t * entries
Definition: ip_api.c:490
static int vl_api_ip_mfib_table_dump_walk(fib_node_index_t fei, void *arg)
Definition: ip_api.c:494
static int ip4_add_del_route_t_handler(vl_api_ip_add_del_route_t *mp)
Definition: ip_api.c:926
FIB path.
Definition: ip.api:43
IPv6 router advertisement prefix config request.
Definition: ip.api:245
IPv6 ND proxy details returned after request.
Definition: ip.api:282
IPv4 main type.
Definition: ip4.h:83
static void set_ip4_flow_hash(vl_api_set_ip_flow_hash_t *mp)
Definition: ip_api.c:1361
An interface associated with a particular MFIB entry.
Definition: mfib_itf.h:25
IPv6 ND proxy dump request.
Definition: ip.api:296
fib_route_path_flags_t frp_flags
flags on the path
Definition: fib_types.h:387
struct mfib_table_t_ * mfibs
Vector of MFIBs.
Definition: ip6.h:157
#define clib_error_report(e)
Definition: error.h:113
u32 fib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:1041
vnet_classify_main_t vnet_classify_main
Definition: vnet_classify.c:22
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
Definition: fib_types.c:211
u32 mft_table_id
Table ID (hash key) for this FIB.
Definition: mfib_table.h:55
From the control plane API.
Definition: fib_entry.h:62
static void send_ip6_fib_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, u32 table_id, fib_prefix_t *pfx, fib_route_path_encode_t *api_rpaths, u32 context)
Definition: ip_api.c:306
void stats_dslock_with_hint(int hint, int tag)
fib_rpf_id_t mfe_rpf_id
RPF-ID used when the packets ingress not from an interface.
Definition: mfib_entry.h:79
ethernet_arp_entry_flags_t flags
Definition: arp_packet.h:157
static clib_error_t * ip_api_hookup(vlib_main_t *vm)
Definition: ip_api.c:1693
u32 flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
Definition: lookup.h:82
static void vl_api_ip_fib_dump_t_handler(vl_api_ip_fib_dump_t *mp)
Definition: ip_api.c:259
int vnet_set_ip6_flow_hash(u32 table_id, flow_hash_config_t flow_hash_config)
Definition: ip6_forward.c:3183
ip6_fib_table_instance_t ip6_table[IP6_FIB_NUM_TABLES]
The two FIB tables; fwding and non-fwding.
Definition: ip6.h:146
IP neighboors dump response.
Definition: ip.api:117
int add_del_route_check(fib_protocol_t table_proto, u32 table_id, u32 next_hop_sw_if_index, fib_protocol_t next_hop_table_proto, u32 next_hop_table_id, u8 create_missing_tables, u8 is_rpf_id, u32 *fib_index, u32 *next_hop_fib_index)
Definition: ip_api.c:857
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
void fib_entry_encode(fib_node_index_t fib_entry_index, fib_route_path_encode_t **api_rpaths)
Definition: fib_entry.c:1519
void mfib_entry_encode(fib_node_index_t mfib_entry_index, fib_route_path_encode_t **api_rpaths)
Definition: mfib_entry.c:1183
mpls_label_t frp_local_label
The MPLS local Label to reursively resolve through.
Definition: fib_types.h:357
Add / del route request.
Definition: ip.api:355
fib_protocol_t fp_proto
protocol type
Definition: mfib_types.h:33
static void setup_message_id_table(api_main_t *am)
Definition: ip_api.c:1685
unsigned short u16
Definition: types.h:57
u32 mfib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: mfib_table.c:426
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:168
mfib_table_t * mfib_table_get(fib_node_index_t index, fib_protocol_t proto)
Get a pointer to a FIB table.
Definition: mfib_table.c:26
ip6_neighbor_key_t key
Definition: ip6_neighbor.h:40
A for-us/local path.
Definition: fib_types.h:284
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
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:409
IPv6 ND proxy config.
Definition: ip.api:269
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:960
int ip6_neighbor_ra_config(vlib_main_t *vm, u32 sw_if_index, u8 suppress, u8 managed, u8 other, u8 ll_option, u8 send_unicast, u8 cease, u8 use_lifetime, u32 lifetime, u32 initial_count, u32 initial_interval, u32 max_interval, u32 min_interval, u8 is_no)
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:644
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
Definition: dpo.h:179
u32 next_hop_out_label_stack[next_hop_n_out_labels]
Definition: ip.api:382
u8 mfs_buffer[MFIB_SIGNAL_BUFFER_SIZE]
A buffer copied from the DP plane that triggered the signal.
Definition: mfib_signal.h:37
fib_table_t * fib_table_get(fib_node_index_t index, fib_protocol_t proto)
Get a pointer to a FIB table.
Definition: fib_table.c:27
clib_error_t * set_ip6_link_local_address(vlib_main_t *vm, u32 sw_if_index, ip6_address_t *address)
static void vl_api_sw_interface_ip6nd_ra_config_t_handler(vl_api_sw_interface_ip6nd_ra_config_t *mp)
Definition: ip_api.c:1391
u32 client_index
Definition: ip.api:496
u32 mfi_sw_if_index
The SW IF index that this MFIB interface represents.
Definition: mfib_itf.h:35
A protocol Independent IP multicast FIB table.
Definition: mfib_table.h:29
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1168
IP6 FIB table response.
Definition: ip.api:88
struct fib_table_t_ * fibs
Vector of FIBs.
Definition: ip4.h:88
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
Definition: dpo.c:205
#define vec_foreach(var, vec)
Vector iterator.
fib_route_path_t rpath
Definition: fib_types.h:399
static void vl_api_sw_interface_ip6_set_link_local_address_t_handler(vl_api_sw_interface_ip6_set_link_local_address_t *mp)
Definition: ip_api.c:1582
static void vl_api_ip_address_dump_t_handler(vl_api_ip_address_dump_t *mp)
Definition: ip_api.c:1249
ethernet_arp_ip4_entry_t * ip4_neighbor_entries(u32 sw_if_index)
Definition: arp.c:1277
vhost_vring_addr_t addr
Definition: vhost-user.h:82
int vnet_arp_set_ip4_over_ethernet(vnet_main_t *vnm, u32 sw_if_index, void *a_arg, int is_static, int is_no_fib_entry)
Definition: arp.c:1797
static void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
Definition: lookup.h:172
static void send_ip_neighbor_details(u8 is_ipv6, u8 is_static, u8 *mac_address, u8 *ip_address, unix_shared_memory_queue_t *q, u32 context)
Definition: ip_api.c:85
static void api_ip6_fib_table_get_all(unix_shared_memory_queue_t *q, vl_api_ip6_fib_dump_t *mp, fib_table_t *fib_table)
Definition: ip_api.c:387
struct apt_ip6_fib_show_ctx_t_ api_ip6_fib_show_ctx_t
u16 fp_len
The mask length.
Definition: mfib_types.h:28
void vl_mfib_signal_send_one(unix_shared_memory_queue_t *q, u32 context, const mfib_signal_t *mfs)
Definition: ip_api.c:1613
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:251
clib_error_t * disable_ip6_interface(vlib_main_t *vm, u32 sw_if_index)
fib_node_index_t mfs_entry
Definition: mfib_signal.h:31
Add / del route request.
Definition: ip.api:393
vpe_api_main_t vpe_api_main
Definition: interface_api.c:49
void vl_api_ip_add_del_route_t_handler(vl_api_ip_add_del_route_t *mp)
Definition: ip_api.c:1043
struct fib_table_t_ * fibs
Definition: ip6.h:151
Definition: dpo.h:98
u8 link_layer_address[8]
Definition: ip6_neighbor.h:41
#define foreach_ip_api_msg
Definition: ip_api.c:60
const ip46_address_t zero_addr
Definition: lookup.c:348
ip46_address_t fp_grp_addr
The address type is not deriveable from the fp_addr member.
Definition: mfib_types.h:46
u8 is_prohibit
Definition: ip.api:50
static void vl_api_ip6_fib_dump_t_handler(vl_api_ip6_fib_dump_t *mp)
Definition: ip_api.c:422
#define VALIDATE_SW_IF_INDEX(mp)
A protocol Independent FIB table.
Definition: fib_table.h:29
Definition: arp_packet.h:150
fib_node_index_t * feis
Definition: ip_api.c:245
IPv6 Proxy ND.
Definition: fib_entry.h:86
struct _unix_shared_memory_queue unix_shared_memory_queue_t
static void vl_api_ip_neighbor_dump_t_handler(vl_api_ip_neighbor_dump_t *mp)
Definition: ip_api.c:106
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:109