FD.io VPP  v17.01.1-3-gc6833f8
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 
37 #include <vnet/vnet_msg_enum.h>
38 
39 #define vl_typedefs /* define message structures */
40 #include <vnet/vnet_all_api_h.h>
41 #undef vl_typedefs
42 
43 #define vl_endianfun /* define message structures */
44 #include <vnet/vnet_all_api_h.h>
45 #undef vl_endianfun
46 
47 /* instantiate all the print functions we know about */
48 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
49 #define vl_printfun
50 #include <vnet/vnet_all_api_h.h>
51 #undef vl_printfun
52 
54 
55 #define foreach_ip_api_msg \
56 _(IP_FIB_DUMP, ip_fib_dump) \
57 _(IP_FIB_DETAILS, ip_fib_details) \
58 _(IP6_FIB_DUMP, ip6_fib_dump) \
59 _(IP6_FIB_DETAILS, ip6_fib_details) \
60 _(IP_NEIGHBOR_DUMP, ip_neighbor_dump) \
61 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
62 _(IP_ADDRESS_DUMP, ip_address_dump) \
63 _(IP_DUMP, ip_dump) \
64 _(IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del) \
65 _(IP_ADD_DEL_ROUTE, ip_add_del_route) \
66 _(SET_IP_FLOW_HASH,set_ip_flow_hash) \
67 _(SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config) \
68 _(SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix) \
69 _(SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable ) \
70 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, \
71  sw_interface_ip6_set_link_local_address)
72 
73 extern void stats_dslock_with_hint (int hint, int tag);
74 extern void stats_dsunlock (void);
75 
76 static void
78  u8 is_static,
79  u8 * mac_address,
80  u8 * ip_address,
81  unix_shared_memory_queue_t * q, u32 context)
82 {
84 
85  mp = vl_msg_api_alloc (sizeof (*mp));
86  memset (mp, 0, sizeof (*mp));
87  mp->_vl_msg_id = ntohs (VL_API_IP_NEIGHBOR_DETAILS);
88  mp->context = context;
89  mp->is_ipv6 = is_ipv6;
90  mp->is_static = is_static;
91  memcpy (mp->mac_address, mac_address, 6);
92  memcpy (mp->ip_address, ip_address, (is_ipv6) ? 16 : 4);
93 
94  vl_msg_api_send_shmem (q, (u8 *) & mp);
95 }
96 
97 static void
99 {
100  clib_warning ("BUG");
101 }
102 
103 static void
105 {
107 
109  if (q == 0)
110  return;
111 
112  u32 sw_if_index = ntohl (mp->sw_if_index);
113 
114  if (mp->is_ipv6)
115  {
116  ip6_neighbor_t *n, *ns;
117 
118  ns = ip6_neighbors_entries (sw_if_index);
119  /* *INDENT-OFF* */
120  vec_foreach (n, ns)
121  {
123  (mp->is_ipv6, ((n->flags & IP6_NEIGHBOR_FLAG_STATIC) ? 1 : 0),
124  (u8 *) n->link_layer_address,
125  (u8 *) & (n->key.ip6_address.as_u8),
126  q, mp->context);
127  }
128  /* *INDENT-ON* */
129  vec_free (ns);
130  }
131  else
132  {
133  ethernet_arp_ip4_entry_t *n, *ns;
134 
135  ns = ip4_neighbor_entries (sw_if_index);
136  /* *INDENT-OFF* */
137  vec_foreach (n, ns)
138  {
140  ((n->flags & ETHERNET_ARP_IP4_ENTRY_FLAG_STATIC) ? 1 : 0),
141  (u8*) n->ethernet_address,
142  (u8*) & (n->ip4_address.as_u8),
143  q, mp->context);
144  }
145  /* *INDENT-ON* */
146  vec_free (ns);
147  }
148 }
149 
150 
151 void
152 copy_fib_next_hop (fib_route_path_encode_t * api_rpath, void *fp_arg)
153 {
154  int is_ip4;
155  vl_api_fib_path_t *fp = (vl_api_fib_path_t *) fp_arg;
156 
157  if (api_rpath->rpath.frp_proto == FIB_PROTOCOL_IP4)
158  fp->afi = IP46_TYPE_IP4;
159  else if (api_rpath->rpath.frp_proto == FIB_PROTOCOL_IP6)
160  fp->afi = IP46_TYPE_IP6;
161  else
162  {
163  is_ip4 = ip46_address_is_ip4 (&api_rpath->rpath.frp_addr);
164  if (is_ip4)
165  fp->afi = IP46_TYPE_IP4;
166  else
167  fp->afi = IP46_TYPE_IP6;
168  }
169  if (fp->afi == IP46_TYPE_IP4)
170  memcpy (fp->next_hop, &api_rpath->rpath.frp_addr.ip4,
171  sizeof (api_rpath->rpath.frp_addr.ip4));
172  else
173  memcpy (fp->next_hop, &api_rpath->rpath.frp_addr.ip6,
174  sizeof (api_rpath->rpath.frp_addr.ip6));
175 }
176 
177 static void
179 {
180  clib_warning ("BUG");
181 }
182 
183 static void
185 {
186  clib_warning ("BUG");
187 }
188 
189 static void
191 {
192  clib_warning ("BUG");
193 }
194 
195 static void
198  u32 table_id, fib_prefix_t * pfx,
199  fib_route_path_encode_t * api_rpaths, u32 context)
200 {
202  fib_route_path_encode_t *api_rpath;
203  vl_api_fib_path_t *fp;
204  int path_count;
205 
206  path_count = vec_len (api_rpaths);
207  mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
208  if (!mp)
209  return;
210  memset (mp, 0, sizeof (*mp));
211  mp->_vl_msg_id = ntohs (VL_API_IP_FIB_DETAILS);
212  mp->context = context;
213 
214  mp->table_id = htonl (table_id);
215  mp->address_length = pfx->fp_len;
216  memcpy (mp->address, &pfx->fp_addr.ip4, sizeof (pfx->fp_addr.ip4));
217 
218  mp->count = htonl (path_count);
219  fp = mp->path;
220  vec_foreach (api_rpath, api_rpaths)
221  {
222  memset (fp, 0, sizeof (*fp));
223  switch (api_rpath->dpo.dpoi_type)
224  {
225  case DPO_RECEIVE:
226  fp->is_local = true;
227  break;
228  case DPO_DROP:
229  fp->is_drop = true;
230  break;
231  case DPO_IP_NULL:
232  switch (api_rpath->dpo.dpoi_index)
233  {
234  case IP_NULL_ACTION_NONE:
235  fp->is_drop = true;
236  break;
238  fp->is_unreach = true;
239  break;
241  fp->is_prohibit = true;
242  break;
243  default:
244  break;
245  }
246  break;
247  default:
248  break;
249  }
250  fp->weight = htonl (api_rpath->rpath.frp_weight);
251  fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
252  copy_fib_next_hop (api_rpath, fp);
253  fp++;
254  }
255 
256  vl_msg_api_send_shmem (q, (u8 *) & mp);
257 }
258 
259 static void
261 {
264  ip4_main_t *im = &ip4_main;
265  fib_table_t *fib_table;
266  fib_node_index_t lfei, *lfeip, *lfeis = NULL;
267  mpls_label_t key;
268  fib_prefix_t pfx;
269  u32 fib_index;
270  fib_route_path_encode_t *api_rpaths;
271  int i;
272 
274  if (q == 0)
275  return;
276 
277  /* *INDENT-OFF* */
278  pool_foreach (fib_table, im->fibs,
279  ({
280  for (i = 0; i < ARRAY_LEN (fib_table->v4.fib_entry_by_dst_address); i++)
281  {
282  hash_foreach(key, lfei, fib_table->v4.fib_entry_by_dst_address[i],
283  ({
284  vec_add1(lfeis, lfei);
285  }));
286  }
287  }));
288  /* *INDENT-ON* */
289 
291 
292  vec_foreach (lfeip, lfeis)
293  {
294  fib_entry_get_prefix (*lfeip, &pfx);
295  fib_index = fib_entry_get_fib_index (*lfeip);
296  fib_table = fib_table_get (fib_index, pfx.fp_proto);
297  api_rpaths = NULL;
298  fib_entry_encode (*lfeip, &api_rpaths);
299  send_ip_fib_details (am, q,
300  fib_table->ft_table_id, &pfx, api_rpaths,
301  mp->context);
302  vec_free (api_rpaths);
303  }
304 
305  vec_free (lfeis);
306 }
307 
308 static void
310 {
311  clib_warning ("BUG");
312 }
313 
314 static void
316 {
317  clib_warning ("BUG");
318 }
319 
320 static void
322 {
323  clib_warning ("BUG");
324 }
325 
326 static void
329  u32 table_id, fib_prefix_t * pfx,
330  fib_route_path_encode_t * api_rpaths, u32 context)
331 {
333  fib_route_path_encode_t *api_rpath;
334  vl_api_fib_path_t *fp;
335  int path_count;
336 
337  path_count = vec_len (api_rpaths);
338  mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
339  if (!mp)
340  return;
341  memset (mp, 0, sizeof (*mp));
342  mp->_vl_msg_id = ntohs (VL_API_IP6_FIB_DETAILS);
343  mp->context = context;
344 
345  mp->table_id = htonl (table_id);
346  mp->address_length = pfx->fp_len;
347  memcpy (mp->address, &pfx->fp_addr.ip6, sizeof (pfx->fp_addr.ip6));
348 
349  mp->count = htonl (path_count);
350  fp = mp->path;
351  vec_foreach (api_rpath, api_rpaths)
352  {
353  memset (fp, 0, sizeof (*fp));
354  switch (api_rpath->dpo.dpoi_type)
355  {
356  case DPO_RECEIVE:
357  fp->is_local = true;
358  break;
359  case DPO_DROP:
360  fp->is_drop = true;
361  break;
362  case DPO_IP_NULL:
363  switch (api_rpath->dpo.dpoi_index)
364  {
366  fp->is_drop = true;
367  break;
369  fp->is_unreach = true;
370  break;
372  fp->is_prohibit = true;
373  break;
374  default:
375  break;
376  }
377  break;
378  default:
379  break;
380  }
381  fp->weight = htonl (api_rpath->rpath.frp_weight);
382  fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
383  copy_fib_next_hop (api_rpath, fp);
384  fp++;
385  }
386 
387  vl_msg_api_send_shmem (q, (u8 *) & mp);
388 }
389 
391 {
395 
396 static void
398 {
399  api_ip6_fib_show_ctx_t *ctx = arg;
400 
401  if ((kvp->key[2] >> 32) == ctx->fib_index)
402  {
403  vec_add1 (ctx->entries, kvp->value);
404  }
405 }
406 
407 static void
410  fib_table_t * fib_table)
411 {
413  ip6_main_t *im6 = &ip6_main;
414  ip6_fib_t *fib = &fib_table->v6;
415  fib_node_index_t *fib_entry_index;
416  api_ip6_fib_show_ctx_t ctx = {
417  .fib_index = fib->index,.entries = NULL,
418  };
419  fib_route_path_encode_t *api_rpaths;
420  fib_prefix_t pfx;
421 
423  ((BVT (clib_bihash) *) & im6->ip6_table[IP6_FIB_TABLE_NON_FWDING].
424  ip6_hash, api_ip6_fib_table_put_entries, &ctx);
425 
427 
428  vec_foreach (fib_entry_index, ctx.entries)
429  {
430  fib_entry_get_prefix (*fib_entry_index, &pfx);
431  api_rpaths = NULL;
432  fib_entry_encode (*fib_entry_index, &api_rpaths);
433  send_ip6_fib_details (am, q,
434  fib_table->ft_table_id,
435  &pfx, api_rpaths, mp->context);
436  vec_free (api_rpaths);
437  }
438 
439  vec_free (ctx.entries);
440 }
441 
442 static void
444 {
446  ip6_main_t *im6 = &ip6_main;
447  fib_table_t *fib_table;
448 
450  if (q == 0)
451  return;
452 
453  /* *INDENT-OFF* */
454  pool_foreach (fib_table, im6->fibs,
455  ({
456  api_ip6_fib_table_get_all(q, mp, fib_table);
457  }));
458  /* *INDENT-ON* */
459 }
460 
461 static void
463  vlib_main_t * vm)
464 {
466  vnet_main_t *vnm = vnet_get_main ();
467  int rv = 0;
468 
470 
471  stats_dslock_with_hint (1 /* release hint */ , 7 /* tag */ );
472 
473  /*
474  * there's no validation here of the ND/ARP entry being added.
475  * The expectation is that the FIB will ensure that nothing bad
476  * will come of adding bogus entries.
477  */
478  if (mp->is_ipv6)
479  {
480  if (mp->is_add)
482  (vm, ntohl (mp->sw_if_index),
483  (ip6_address_t *) (mp->dst_address),
484  mp->mac_address, sizeof (mp->mac_address), mp->is_static);
485  else
487  (vm, ntohl (mp->sw_if_index),
488  (ip6_address_t *) (mp->dst_address),
489  mp->mac_address, sizeof (mp->mac_address));
490  }
491  else
492  {
493  ethernet_arp_ip4_over_ethernet_address_t a;
494 
495  clib_memcpy (&a.ethernet, mp->mac_address, 6);
496  clib_memcpy (&a.ip4, mp->dst_address, 4);
497 
498  if (mp->is_add)
499  rv = vnet_arp_set_ip4_over_ethernet (vnm, ntohl (mp->sw_if_index),
500  &a, mp->is_static);
501  else
502  rv =
503  vnet_arp_unset_ip4_over_ethernet (vnm, ntohl (mp->sw_if_index), &a);
504  }
505 
507 
508  stats_dsunlock ();
509  REPLY_MACRO (VL_API_IP_NEIGHBOR_ADD_DEL_REPLY);
510 }
511 
512 int
514  u8 is_add,
515  u8 is_drop,
516  u8 is_unreach,
517  u8 is_prohibit,
518  u8 is_local,
519  u8 is_classify,
520  u32 classify_table_index,
521  u8 is_resolve_host,
522  u8 is_resolve_attached,
523  u32 fib_index,
524  const fib_prefix_t * prefix,
525  u8 next_hop_proto_is_ip4,
526  const ip46_address_t * next_hop,
527  u32 next_hop_sw_if_index,
528  u8 next_hop_fib_index,
529  u32 next_hop_weight,
530  mpls_label_t next_hop_via_label,
531  mpls_label_t * next_hop_out_label_stack)
532 {
535  fib_route_path_t path = {
536  .frp_proto = (next_hop_proto_is_ip4 ?
538  .frp_addr = (NULL == next_hop ? zero_addr : *next_hop),
539  .frp_sw_if_index = next_hop_sw_if_index,
540  .frp_fib_index = next_hop_fib_index,
541  .frp_weight = next_hop_weight,
542  .frp_label_stack = next_hop_out_label_stack,
543  };
544  fib_route_path_t *paths = NULL;
545 
546  if (MPLS_LABEL_INVALID != next_hop_via_label)
547  {
549  path.frp_local_label = next_hop_via_label;
550  }
551  if (is_resolve_host)
552  path_flags |= FIB_ROUTE_PATH_RESOLVE_VIA_HOST;
553  if (is_resolve_attached)
555 
556  path.frp_flags = path_flags;
557 
558  if (is_multipath)
559  {
560  stats_dslock_with_hint (1 /* release hint */ , 10 /* tag */ );
561 
562 
563  vec_add1 (paths, path);
564 
565  if (is_add)
566  fib_table_entry_path_add2 (fib_index,
567  prefix,
569  FIB_ENTRY_FLAG_NONE, paths);
570  else
571  fib_table_entry_path_remove2 (fib_index,
572  prefix, FIB_SOURCE_API, paths);
573 
574  vec_free (paths);
575  stats_dsunlock ();
576  return 0;
577  }
578 
579  stats_dslock_with_hint (1 /* release hint */ , 2 /* tag */ );
580 
581  if (is_drop || is_local || is_classify || is_unreach || is_prohibit)
582  {
583  /*
584  * special route types that link directly to the adj
585  */
586  if (is_add)
587  {
588  dpo_id_t dpo = DPO_INVALID;
589  dpo_proto_t dproto;
590 
591  dproto = fib_proto_to_dpo (prefix->fp_proto);
592 
593  if (is_drop)
595  else if (is_local)
596  receive_dpo_add_or_lock (dproto, ~0, NULL, &dpo);
597  else if (is_unreach)
598  ip_null_dpo_add_and_lock (dproto,
600  else if (is_prohibit)
601  ip_null_dpo_add_and_lock (dproto,
603  &dpo);
604  else if (is_classify)
605  {
606  if (pool_is_free_index (cm->tables,
607  ntohl (classify_table_index)))
608  {
609  stats_dsunlock ();
610  return VNET_API_ERROR_NO_SUCH_TABLE;
611  }
612 
613  dpo_set (&dpo, DPO_CLASSIFY, dproto,
614  classify_dpo_create (dproto,
615  ntohl (classify_table_index)));
616  }
617  else
618  {
619  stats_dsunlock ();
620  return VNET_API_ERROR_NO_SUCH_TABLE;
621  }
622 
624  prefix,
627  dpo_reset (&dpo);
628  }
629  else
630  {
631  fib_table_entry_special_remove (fib_index, prefix, FIB_SOURCE_API);
632  }
633  }
634  else
635  {
636  if (is_add)
637  {
638  vec_add1 (paths, path);
639  fib_table_entry_update (fib_index,
640  prefix,
642  vec_free (paths);
643  }
644  else
645  {
646  fib_table_entry_delete (fib_index, prefix, FIB_SOURCE_API);
647  }
648  }
649 
650  stats_dsunlock ();
651  return (0);
652 }
653 
654 int
656  u32 table_id,
657  u32 next_hop_sw_if_index,
658  fib_protocol_t next_hop_table_proto,
659  u32 next_hop_table_id,
660  u8 create_missing_tables,
661  u32 * fib_index, u32 * next_hop_fib_index)
662 {
663  vnet_main_t *vnm = vnet_get_main ();
664 
665  *fib_index = fib_table_find (table_proto, ntohl (table_id));
666  if (~0 == *fib_index)
667  {
668  if (create_missing_tables)
669  {
670  *fib_index = fib_table_find_or_create_and_lock (table_proto,
671  ntohl (table_id));
672  }
673  else
674  {
675  /* No such VRF, and we weren't asked to create one */
676  return VNET_API_ERROR_NO_SUCH_FIB;
677  }
678  }
679 
680  if (~0 != ntohl (next_hop_sw_if_index))
681  {
683  ntohl (next_hop_sw_if_index)))
684  {
685  return VNET_API_ERROR_NO_MATCHING_INTERFACE;
686  }
687  }
688  else
689  {
690  *next_hop_fib_index = fib_table_find (next_hop_table_proto,
691  ntohl (next_hop_table_id));
692 
693  if (~0 == *next_hop_fib_index)
694  {
695  if (create_missing_tables)
696  {
697  *next_hop_fib_index =
698  fib_table_find_or_create_and_lock (next_hop_table_proto,
699  ntohl (next_hop_table_id));
700  }
701  else
702  {
703  /* No such VRF, and we weren't asked to create one */
704  return VNET_API_ERROR_NO_SUCH_FIB;
705  }
706  }
707  }
708 
709  return (0);
710 }
711 
712 static int
714 {
715  u32 fib_index, next_hop_fib_index;
716  mpls_label_t *label_stack = NULL;
717  int rv, ii, n_labels;;
718 
720  mp->table_id,
723  mp->next_hop_table_id,
725  &fib_index, &next_hop_fib_index);
726 
727  if (0 != rv)
728  return (rv);
729 
730  fib_prefix_t pfx = {
731  .fp_len = mp->dst_address_length,
732  .fp_proto = FIB_PROTOCOL_IP4,
733  };
734  clib_memcpy (&pfx.fp_addr.ip4, mp->dst_address, sizeof (pfx.fp_addr.ip4));
735 
736  ip46_address_t nh;
737  memset (&nh, 0, sizeof (nh));
738  memcpy (&nh.ip4, mp->next_hop_address, sizeof (nh.ip4));
739 
740  n_labels = mp->next_hop_n_out_labels;
741  if (n_labels == 0)
742  ;
743  else if (1 == n_labels)
744  vec_add1 (label_stack, ntohl (mp->next_hop_out_label_stack[0]));
745  else
746  {
747  vec_validate (label_stack, n_labels - 1);
748  for (ii = 0; ii < n_labels; ii++)
749  label_stack[ii] = ntohl (mp->next_hop_out_label_stack[ii]);
750  }
751 
753  mp->is_add,
754  mp->is_drop,
755  mp->is_unreach,
756  mp->is_prohibit,
757  mp->is_local,
758  mp->is_classify,
760  mp->is_resolve_host,
762  fib_index, &pfx, 1,
763  &nh,
764  ntohl (mp->next_hop_sw_if_index),
765  next_hop_fib_index,
766  mp->next_hop_weight,
767  ntohl (mp->next_hop_via_label),
768  label_stack));
769 }
770 
771 static int
773 {
774  u32 fib_index, next_hop_fib_index;
775  mpls_label_t *label_stack = NULL;
776  int rv, ii, n_labels;;
777 
779  mp->table_id,
782  mp->next_hop_table_id,
784  &fib_index, &next_hop_fib_index);
785 
786  if (0 != rv)
787  return (rv);
788 
789  fib_prefix_t pfx = {
790  .fp_len = mp->dst_address_length,
791  .fp_proto = FIB_PROTOCOL_IP6,
792  };
793  clib_memcpy (&pfx.fp_addr.ip6, mp->dst_address, sizeof (pfx.fp_addr.ip6));
794 
795  ip46_address_t nh;
796  memset (&nh, 0, sizeof (nh));
797  memcpy (&nh.ip6, mp->next_hop_address, sizeof (nh.ip6));
798 
799  n_labels = mp->next_hop_n_out_labels;
800  if (n_labels == 0)
801  ;
802  else if (1 == n_labels)
803  vec_add1 (label_stack, ntohl (mp->next_hop_out_label_stack[0]));
804  else
805  {
806  vec_validate (label_stack, n_labels - 1);
807  for (ii = 0; ii < n_labels; ii++)
808  label_stack[ii] = ntohl (mp->next_hop_out_label_stack[ii]);
809  }
810 
812  mp->is_add,
813  mp->is_drop,
814  mp->is_unreach,
815  mp->is_prohibit,
816  mp->is_local,
817  mp->is_classify,
819  mp->is_resolve_host,
821  fib_index, &pfx, 0,
822  &nh, ntohl (mp->next_hop_sw_if_index),
823  next_hop_fib_index,
824  mp->next_hop_weight,
825  ntohl (mp->next_hop_via_label),
826  label_stack));
827 }
828 
829 void
831 {
833  int rv;
834  vnet_main_t *vnm = vnet_get_main ();
835 
836  vnm->api_errno = 0;
837 
838  if (mp->is_ipv6)
839  rv = ip6_add_del_route_t_handler (mp);
840  else
841  rv = ip4_add_del_route_t_handler (mp);
842 
843  rv = (rv == 0) ? vnm->api_errno : rv;
844 
845  REPLY_MACRO (VL_API_IP_ADD_DEL_ROUTE_REPLY);
846 }
847 
848 static void
850  unix_shared_memory_queue_t * q, u32 sw_if_index, u32 context)
851 {
853 
854  mp = vl_msg_api_alloc (sizeof (*mp));
855  memset (mp, 0, sizeof (*mp));
856  mp->_vl_msg_id = ntohs (VL_API_IP_DETAILS);
857 
858  mp->sw_if_index = ntohl (sw_if_index);
859  mp->context = context;
860 
861  vl_msg_api_send_shmem (q, (u8 *) & mp);
862 }
863 
864 static void
867  u8 * ip, u16 prefix_length, u8 is_ipv6, u32 context)
868 {
870 
871  mp = vl_msg_api_alloc (sizeof (*mp));
872  memset (mp, 0, sizeof (*mp));
873  mp->_vl_msg_id = ntohs (VL_API_IP_ADDRESS_DETAILS);
874 
875  if (is_ipv6)
876  {
877  clib_memcpy (&mp->ip, ip, sizeof (mp->ip));
878  }
879  else
880  {
881  u32 *tp = (u32 *) mp->ip;
882  *tp = *(u32 *) ip;
883  }
884  mp->prefix_length = prefix_length;
885  mp->context = context;
886 
887  vl_msg_api_send_shmem (q, (u8 *) & mp);
888 }
889 
890 static void
892 {
895  ip6_address_t *r6;
896  ip4_address_t *r4;
897  ip6_main_t *im6 = &ip6_main;
898  ip4_main_t *im4 = &ip4_main;
899  ip_lookup_main_t *lm6 = &im6->lookup_main;
900  ip_lookup_main_t *lm4 = &im4->lookup_main;
901  ip_interface_address_t *ia = 0;
902  u32 sw_if_index = ~0;
903  int rv __attribute__ ((unused)) = 0;
904 
906 
907  sw_if_index = ntohl (mp->sw_if_index);
908 
910  if (q == 0)
911  return;
912 
913  if (mp->is_ipv6)
914  {
915  /* *INDENT-OFF* */
916  foreach_ip_interface_address (lm6, ia, sw_if_index,
917  1 /* honor unnumbered */,
918  ({
919  r6 = ip_interface_address_get_address (lm6, ia);
920  u16 prefix_length = ia->address_length;
921  send_ip_address_details(am, q, (u8*)r6, prefix_length, 1, mp->context);
922  }));
923  /* *INDENT-ON* */
924  }
925  else
926  {
927  /* *INDENT-OFF* */
928  foreach_ip_interface_address (lm4, ia, sw_if_index,
929  1 /* honor unnumbered */,
930  ({
931  r4 = ip_interface_address_get_address (lm4, ia);
932  u16 prefix_length = ia->address_length;
933  send_ip_address_details(am, q, (u8*)r4, prefix_length, 0, mp->context);
934  }));
935  /* *INDENT-ON* */
936  }
938 }
939 
940 static void
942 {
944  vnet_main_t *vnm = vnet_get_main ();
945  vlib_main_t *vm = vlib_get_main ();
948  vnet_sw_interface_t *si, *sorted_sis;
949  u32 sw_if_index = ~0;
950 
952  if (q == 0)
953  {
954  return;
955  }
956 
957  /* Gather interfaces. */
958  sorted_sis = vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
959  _vec_len (sorted_sis) = 0;
960  /* *INDENT-OFF* */
961  pool_foreach (si, im->sw_interfaces,
962  ({
963  vec_add1 (sorted_sis, si[0]);
964  }));
965  /* *INDENT-ON* */
966 
967  vec_foreach (si, sorted_sis)
968  {
970  {
971  if (mp->is_ipv6 && !ip6_interface_enabled (vm, si->sw_if_index))
972  {
973  continue;
974  }
975  sw_if_index = si->sw_if_index;
976  send_ip_details (am, q, sw_if_index, mp->context);
977  }
978  }
979 }
980 
981 static void
983 {
985  int rv = VNET_API_ERROR_UNIMPLEMENTED;
986 
987  clib_warning ("unimplemented...");
988 
989  REPLY_MACRO (VL_API_SET_IP_FLOW_HASH_REPLY);
990 }
991 
992 static void
994 {
996  int rv;
997  u32 table_id;
998  flow_hash_config_t flow_hash_config = 0;
999 
1000  table_id = ntohl (mp->vrf_id);
1001 
1002 #define _(a,b) if (mp->a) flow_hash_config |= b;
1004 #undef _
1005 
1006  rv = vnet_set_ip4_flow_hash (table_id, flow_hash_config);
1007 
1008  REPLY_MACRO (VL_API_SET_IP_FLOW_HASH_REPLY);
1009 }
1010 
1011 
1012 static void
1014 {
1015  if (mp->is_ipv6 == 0)
1016  set_ip4_flow_hash (mp);
1017  else
1018  set_ip6_flow_hash (mp);
1019 }
1020 
1021 static void
1024 {
1026  vlib_main_t *vm = vlib_get_main ();
1027  int rv = 0;
1028  u8 is_no, suppress, managed, other, ll_option, send_unicast, cease,
1029  default_router;
1030 
1031  is_no = mp->is_no == 1;
1032  suppress = mp->suppress == 1;
1033  managed = mp->managed == 1;
1034  other = mp->other == 1;
1035  ll_option = mp->ll_option == 1;
1036  send_unicast = mp->send_unicast == 1;
1037  cease = mp->cease == 1;
1038  default_router = mp->default_router == 1;
1039 
1040  VALIDATE_SW_IF_INDEX (mp);
1041 
1042  rv = ip6_neighbor_ra_config (vm, ntohl (mp->sw_if_index),
1043  suppress, managed, other,
1044  ll_option, send_unicast, cease,
1045  default_router, ntohl (mp->lifetime),
1046  ntohl (mp->initial_count),
1047  ntohl (mp->initial_interval),
1048  ntohl (mp->max_interval),
1049  ntohl (mp->min_interval), is_no);
1050 
1052 
1053  REPLY_MACRO (VL_API_SW_INTERFACE_IP6ND_RA_CONFIG_REPLY);
1054 }
1055 
1056 static void
1059 {
1060  vlib_main_t *vm = vlib_get_main ();
1062  int rv = 0;
1063  u8 is_no, use_default, no_advertise, off_link, no_autoconfig, no_onlink;
1064 
1065  VALIDATE_SW_IF_INDEX (mp);
1066 
1067  is_no = mp->is_no == 1;
1068  use_default = mp->use_default == 1;
1069  no_advertise = mp->no_advertise == 1;
1070  off_link = mp->off_link == 1;
1071  no_autoconfig = mp->no_autoconfig == 1;
1072  no_onlink = mp->no_onlink == 1;
1073 
1074  rv = ip6_neighbor_ra_prefix (vm, ntohl (mp->sw_if_index),
1075  (ip6_address_t *) mp->address,
1076  mp->address_length, use_default,
1077  ntohl (mp->val_lifetime),
1078  ntohl (mp->pref_lifetime), no_advertise,
1079  off_link, no_autoconfig, no_onlink, is_no);
1080 
1082  REPLY_MACRO (VL_API_SW_INTERFACE_IP6ND_RA_PREFIX_REPLY);
1083 }
1084 
1085 static void
1088 {
1089  vlib_main_t *vm = vlib_get_main ();
1091  vnet_main_t *vnm = vnet_get_main ();
1092  int rv = 0;
1093  clib_error_t *error;
1094 
1095  vnm->api_errno = 0;
1096 
1097  VALIDATE_SW_IF_INDEX (mp);
1098 
1099  error =
1100  (mp->enable == 1) ? enable_ip6_interface (vm,
1101  ntohl (mp->sw_if_index)) :
1102  disable_ip6_interface (vm, ntohl (mp->sw_if_index));
1103 
1104  if (error)
1105  {
1106  clib_error_report (error);
1107  rv = VNET_API_ERROR_UNSPECIFIED;
1108  }
1109  else
1110  {
1111  rv = vnm->api_errno;
1112  }
1113 
1115 
1116  REPLY_MACRO (VL_API_SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY);
1117 }
1118 
1119 static void
1122 {
1123  vlib_main_t *vm = vlib_get_main ();
1125  int rv = 0;
1126  clib_error_t *error;
1127  vnet_main_t *vnm = vnet_get_main ();
1128 
1129  vnm->api_errno = 0;
1130 
1131  VALIDATE_SW_IF_INDEX (mp);
1132 
1133  error = set_ip6_link_local_address (vm,
1134  ntohl (mp->sw_if_index),
1135  (ip6_address_t *) mp->address,
1136  mp->address_length);
1137  if (error)
1138  {
1139  clib_error_report (error);
1140  rv = VNET_API_ERROR_UNSPECIFIED;
1141  }
1142  else
1143  {
1144  rv = vnm->api_errno;
1145  }
1146 
1148 
1149  REPLY_MACRO (VL_API_SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY);
1150 }
1151 
1152 
1153 #define vl_msg_name_crc_list
1154 #include <vnet/ip/ip.api.h>
1155 #undef vl_msg_name_crc_list
1156 
1157 static void
1159 {
1160 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1161  foreach_vl_msg_name_crc_ip;
1162 #undef _
1163 }
1164 
1165 static clib_error_t *
1167 {
1168  api_main_t *am = &api_main;
1169 
1170 #define _(N,n) \
1171  vl_msg_api_set_handlers(VL_API_##N, #n, \
1172  vl_api_##n##_t_handler, \
1173  vl_noop_handler, \
1174  vl_api_##n##_t_endian, \
1175  vl_api_##n##_t_print, \
1176  sizeof(vl_api_##n##_t), 1);
1178 #undef _
1179 
1180  /*
1181  * Set up the (msg_name, crc, message-id) table
1182  */
1184 
1185  return 0;
1186 }
1187 
1189 
1190 /*
1191  * fd.io coding-style-patch-verification: ON
1192  *
1193  * Local Variables:
1194  * eval: (c-set-style "gnu")
1195  * End:
1196  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:396
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
Definition: lookup.h:460
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:154
#define VNET_SW_INTERFACE_FLAG_UNNUMBERED
Definition: interface.h:535
u32 fib_entry_get_fib_index(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1443
fib_protocol_t frp_proto
The protocol of the address below.
Definition: fib_types.h:290
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:299
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
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
A representation of a fib path for fib_path_encode to convey the information to the caller...
Definition: fib_types.h:335
int vnet_set_ip4_flow_hash(u32 table_id, flow_hash_config_t flow_hash_config)
Definition: ip4_forward.c:3065
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:69
A representation of a path as described by a route producer.
Definition: fib_types.h:285
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:462
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
vnet_interface_main_t interface_main
Definition: vnet.h:57
IP FIB table response.
Definition: ip.api:62
The table that stores ALL routes learned by the DP.
Definition: ip6.h:109
u8 as_u8[16]
Definition: ip6_packet.h:48
void fib_entry_get_prefix(fib_node_index_t fib_entry_index, fib_prefix_t *pfx)
Definition: fib_entry.c:1433
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:677
static void vl_api_ip6_fib_details_t_endian(vl_api_ip6_fib_details_t *mp)
Definition: ip_api.c:315
#define NULL
Definition: clib.h:55
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)
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:521
ip6_neighbor_t * ip6_neighbors_entries(u32 sw_if_index)
Definition: ip6_neighbor.c:715
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:482
#define IP_NULL_DPO_ACTION_NUM
Definition: ip_null_dpo.h:48
static void vl_api_ip6_fib_details_t_print(vl_api_ip6_fib_details_t *mp)
Definition: ip_api.c:321
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
ip_lookup_main_t lookup_main
Definition: ip4.h:97
IPv6 router advertisement config request.
Definition: ip.api:213
#define clib_error_report(e)
Definition: error.h:125
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, u32 *fib_index, u32 *next_hop_fib_index)
Definition: ip_api.c:655
static void api_ip6_fib_table_put_entries(clib_bihash_kv_24_8_t *kvp, void *arg)
Definition: ip_api.c:397
Dump IP6 fib table.
Definition: ip.api:75
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
api_main_t api_main
Definition: api_shared.c:39
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:348
u32 frp_sw_if_index
The interface.
Definition: fib_types.h:311
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:399
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
Definition: vec.h:270
static BVT(clib_bihash)
Definition: adj_nbr.c:26
Recursion constraint of via a host prefix.
Definition: fib_types.h:261
Aggregrate type for a prefix.
Definition: fib_types.h:145
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:941
static int ip6_add_del_route_t_handler(vl_api_ip_add_del_route_t *mp)
Definition: ip_api.c:772
#define clib_warning(format, args...)
Definition: error.h:59
IPv6 interface enable / disable request.
Definition: ip.api:291
enum fib_route_path_flags_t_ fib_route_path_flags_t
Path flags from the control plane.
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:948
u16 fp_len
The mask length.
Definition: fib_types.h:149
int fib_entry_cmp_for_sort(void *i1, void *i2)
Definition: fib_entry.c:1388
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:1447
Definition: fib_entry.h:216
vnet_api_error_t api_errno
Definition: vnet.h:77
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)
Definition: ip6_neighbor.c:509
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:138
Definition: fib_entry.h:220
static void send_ip_address_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, u8 *ip, u16 prefix_length, u8 is_ipv6, u32 context)
Definition: ip_api.c:865
static void vl_api_ip_fib_details_t_endian(vl_api_ip_fib_details_t *mp)
Definition: ip_api.c:184
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:168
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:142
ip4_address_t ip4_address
Definition: arp_packet.h:146
u8 ethernet_address[6]
Definition: arp_packet.h:148
static void vl_api_sw_interface_ip6nd_ra_prefix_t_handler(vl_api_sw_interface_ip6nd_ra_prefix_t *mp)
Definition: ip_api.c:1058
clib_error_t * set_ip6_link_local_address(vlib_main_t *vm, u32 sw_if_index, ip6_address_t *address, u8 address_length)
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:565
vl_api_fib_path_t path[count]
Definition: ip.api:95
IPv6 router advertisement prefix config response.
Definition: ip.api:279
#define REPLY_MACRO(t)
Recursion constraint of via an attahced prefix.
Definition: fib_types.h:265
u32 index
Definition: ip6.h:72
fib_node_index_t * entries
Definition: ip_api.c:393
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:1087
static void vl_api_set_ip_flow_hash_t_handler(vl_api_set_ip_flow_hash_t *mp)
Definition: ip_api.c:1013
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)
void stats_dsunlock(void)
#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
Set the ip flow hash config for a fib request.
Definition: ip.api:172
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:327
void * vl_msg_api_alloc(int nbytes)
u32 ft_table_id
Table ID (hash key) for this FIB.
Definition: fib_table.h:56
#define IP6_NEIGHBOR_FLAG_STATIC
Definition: ip6_neighbor.h:36
#define MPLS_LABEL_INVALID
Definition: mpls_types.h:33
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:300
void copy_fib_next_hop(fib_route_path_encode_t *api_rpath, void *fp_arg)
Definition: ip_api.c:152
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:808
Definition: ip6.h:66
u32 frp_weight
[un]equal cost path weight
Definition: fib_types.h:320
IPv6 interface enable / disable response.
Definition: ip.api:303
#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:196
#define ETHERNET_ARP_IP4_ENTRY_FLAG_STATIC
Definition: arp_packet.h:151
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:28
Reply for IP Neighbor add / delete request.
Definition: ip.api:154
static void set_ip6_flow_hash(vl_api_set_ip_flow_hash_t *mp)
Definition: ip_api.c:982
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:211
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:154
u32 sw_if_index
Definition: ip.api:45
clib_error_t * enable_ip6_interface(vlib_main_t *vm, u32 sw_if_index)
struct _vnet_classify_main vnet_classify_main_t
Definition: vnet_classify.h:69
#define foreach_flow_hash_bit
Definition: lookup.h:149
int vnet_arp_set_ip4_over_ethernet(vnet_main_t *vnm, u32 sw_if_index, void *a_arg, int is_static)
Definition: arp.c:1791
IP neighbor add / del request.
Definition: ip.api:136
IPv6 router advertisement config response.
Definition: ip.api:237
unsigned int u32
Definition: types.h:88
ip6_address_t ip6_address
Definition: ip6_neighbor.h:26
ip6_main_t ip6_main
Definition: ip6_forward.c:2828
ip_lookup_main_t lookup_main
Definition: ip6.h:135
static void vl_api_ip_neighbor_details_t_handler(vl_api_ip_neighbor_details_t *mp)
Definition: ip_api.c:98
static int ip4_add_del_route_t_handler(vl_api_ip_add_del_route_t *mp)
Definition: ip_api.c:713
FIB path.
Definition: ip.api:43
Reply for add / del route request.
Definition: ip.api:394
IPv6 router advertisement prefix config request.
Definition: ip.api:258
IPv4 main type.
Definition: ip4.h:95
static void set_ip4_flow_hash(vl_api_set_ip_flow_hash_t *mp)
Definition: ip_api.c:993
fib_route_path_flags_t frp_flags
flags on the path
Definition: fib_types.h:324
static void vl_api_ip_fib_details_t_handler(vl_api_ip_fib_details_t *mp)
Definition: ip_api.c:178
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:964
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:220
From the control plane API.
Definition: fib_entry.h:58
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:327
void stats_dslock_with_hint(int hint, int tag)
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:646
static clib_error_t * ip_api_hookup(vlib_main_t *vm)
Definition: ip_api.c:1166
u32 flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
Definition: lookup.h:160
static void vl_api_ip_fib_dump_t_handler(vl_api_ip_fib_dump_t *mp)
Definition: ip_api.c:260
ip6_fib_table_instance_t ip6_table[IP6_FIB_NUM_TABLES]
The two FIB tables; fwding and non-fwding.
Definition: ip6.h:133
IP neighboors dump response.
Definition: ip.api:117
void fib_entry_encode(fib_node_index_t fib_entry_index, fib_route_path_encode_t **api_rpaths)
Definition: fib_entry.c:1423
static void vl_api_ip6_fib_details_t_handler(vl_api_ip6_fib_details_t *mp)
Definition: ip_api.c:309
mpls_label_t frp_local_label
The MPLS local Label to reursively resolve through.
Definition: fib_types.h:305
Add / del route request.
Definition: ip.api:360
static void setup_message_id_table(api_main_t *am)
Definition: ip_api.c:1158
unsigned short u16
Definition: types.h:57
static void vl_api_ip_fib_details_t_print(vl_api_ip_fib_details_t *mp)
Definition: ip_api.c:190
ip6_fib_t v6
Definition: fib_table.h:39
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:154
ip6_neighbor_key_t key
Definition: ip6_neighbor.h:33
static void send_ip_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, u32 sw_if_index, u32 context)
Definition: ip_api.c:849
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:920
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:606
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
Definition: dpo.h:165
u32 next_hop_out_label_stack[next_hop_n_out_labels]
Definition: ip.api:387
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
static void vl_api_sw_interface_ip6nd_ra_config_t_handler(vl_api_sw_interface_ip6nd_ra_config_t *mp)
Definition: ip_api.c:1023
u32 client_index
Definition: ip.api:424
u16 flags
Definition: arp_packet.h:150
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_classify, u32 classify_table_index, u8 is_resolve_host, u8 is_resolve_attached, 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:513
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1099
IP6 FIB table response.
Definition: ip.api:88
struct fib_table_t_ * fibs
Vector of FIBs.
Definition: ip4.h:100
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
Definition: dpo.c:191
#define vec_foreach(var, vec)
Vector iterator.
fib_route_path_t rpath
Definition: fib_types.h:336
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:1121
static void vl_api_ip_address_dump_t_handler(vl_api_ip_address_dump_t *mp)
Definition: ip_api.c:891
ethernet_arp_ip4_entry_t * ip4_neighbor_entries(u32 sw_if_index)
Definition: arp.c:1288
static void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
Definition: lookup.h:453
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:77
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:408
struct apt_ip6_fib_show_ctx_t_ api_ip6_fib_show_ctx_t
clib_error_t * disable_ip6_interface(vlib_main_t *vm, u32 sw_if_index)
vpe_api_main_t vpe_api_main
Definition: api.c:324
void vl_api_ip_add_del_route_t_handler(vl_api_ip_add_del_route_t *mp)
Definition: ip_api.c:830
struct fib_table_t_ * fibs
Definition: ip6.h:138
Definition: dpo.h:96
u8 link_layer_address[8]
Definition: ip6_neighbor.h:34
#define foreach_ip_api_msg
Definition: ip_api.c:55
const ip46_address_t zero_addr
Definition: lookup.c:351
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:443
#define VALIDATE_SW_IF_INDEX(mp)
A protocol Independent FIB table.
Definition: fib_table.h:29
Definition: arp_packet.h:143
Set the ip flow hash config for a fib response.
Definition: ip.api:190
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:104
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:109