FD.io VPP  v19.04-6-g6f05f72
Vector Packet Processing
dhcp6_pd_client_cp.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <vnet/vnet.h>
17 #include <vlibmemory/api.h>
18 #include <vnet/vnet_msg_enum.h>
19 #include <vnet/dhcp/dhcp6_packet.h>
21 #include <vnet/ip/ip.h>
22 #include <vnet/ip/ip6.h>
23 #include <float.h>
24 #include <math.h>
25 #include <string.h>
26 
27 #define vl_typedefs /* define message structures */
28 #include <vnet/vnet_all_api_h.h>
29 #undef vl_typedefs
30 
31 #define vl_endianfun /* define message structures */
32 #include <vnet/vnet_all_api_h.h>
33 #undef vl_endianfun
34 
36 
37 #define foreach_dhcp6_pd_client_cp_msg \
38 _(DHCP6_PD_CLIENT_ENABLE_DISABLE, dhcp6_pd_client_enable_disable) \
39 _(IP6_ADD_DEL_ADDRESS_USING_PREFIX, ip6_add_del_address_using_prefix)
40 
41 #define vl_api_dhcp6_pd_client_enable_disable_t_print vl_noop_handler
42 #define vl_api_ip6_add_del_address_using_prefix_t_print vl_noop_handler
43 
44 typedef struct
45 {
47  uword opaque_data; // used by prefix publisher
54 
55 typedef struct
56 {
57  u8 enabled;
59  u32 server_index;
60  u32 T1;
61  u32 T2;
62  f64 T1_due_time;
63  f64 T2_due_time;
65  u8 rebinding;
67 
68 typedef struct
69 {
74 
75  /* convenience */
81 
83 
84 typedef struct
85 {
89 
91 
92 typedef struct
93 {
94  /* config */
99 
100  /* state */
103 
104 typedef struct
105 {
109 
111 
112 enum
113 {
116 };
117 
120 {
122 
123  if (prefix_group_index >=
125  return ~0;
126 
127  return apm->active_prefix_index_by_prefix_group_index[prefix_group_index];
128 }
129 
132  u32 prefix_index)
133 {
135  static const u32 empty = ~0;
136 
137  ASSERT (prefix_group_index != ~0);
138 
139  if (prefix_index == ~0
140  && prefix_group_index >=
142  return;
143 
145  prefix_group_index, empty);
146  apm->active_prefix_index_by_prefix_group_index[prefix_group_index] =
147  prefix_index;
148 }
149 
152 {
155  u32 prefix_index;
156 
157  prefix_index = prefix_info - pm->prefix_pool;
158  return clib_bitmap_get (rm->prefix_ownership_bitmap, prefix_index);
159 }
160 
163 {
166  u32 prefix_index;
167 
168  prefix_index = prefix_info - pm->prefix_pool;
170  clib_bitmap_set (rm->prefix_ownership_bitmap, prefix_index, value);
171 }
172 
173 static void
175 
176 static void
177 notify_prefix_add_del (u32 prefix_index, u8 is_add)
178 {
179  // TODO: use registries
180  cp_ip6_address_prefix_add_del_handler (prefix_index, is_add);
181 }
182 
183 static void
185  u8 msg_type, prefix_info_t * prefix_list,
186  u8 start)
187 {
191  u32 i;
192 
193  ASSERT (sw_if_index < vec_len (rm->client_state_by_sw_if_index) &&
194  rm->client_state_by_sw_if_index[sw_if_index].enabled);
195  client_state_t *client_state =
197 
198  params.sw_if_index = sw_if_index;
199  params.server_index = server_index;
200  params.msg_type = msg_type;
201  if (start)
202  {
203  if (msg_type == DHCPV6_MSG_SOLICIT)
204  {
205  params.irt = 1;
206  params.mrt = 120;
207  }
208  else if (msg_type == DHCPV6_MSG_REQUEST)
209  {
210  params.irt = 1;
211  params.mrt = 30;
212  params.mrc = 10;
213  }
214  else if (msg_type == DHCPV6_MSG_RENEW)
215  {
216  params.irt = 10;
217  params.mrt = 600;
218  f64 current_time = vlib_time_now (rm->vlib_main);
219  i32 diff_time = client_state->T2 - current_time;
220  if (diff_time < 0)
221  diff_time = 0;
222  params.mrd = diff_time;
223  }
224  else if (msg_type == DHCPV6_MSG_REBIND)
225  {
226  params.irt = 10;
227  params.mrt = 600;
228  f64 current_time = vlib_time_now (rm->vlib_main);
229  i32 diff_time = rm->max_valid_due_time - current_time;
230  if (diff_time < 0)
231  diff_time = 0;
232  params.mrd = diff_time;
233  }
234  else if (msg_type == DHCPV6_MSG_RELEASE)
235  {
236  params.mrc = 1;
237  }
238  }
239 
240  params.T1 = 0;
241  params.T2 = 0;
242  if (vec_len (prefix_list) != 0)
243  vec_validate (prefixes, vec_len (prefix_list) - 1);
244  for (i = 0; i < vec_len (prefix_list); i++)
245  {
246  prefix_info_t *prefix = &prefix_list[i];
247  pref = &prefixes[i];
248  pref->valid_lt = prefix->valid_lt;
249  pref->preferred_lt = prefix->preferred_lt;
250  pref->prefix = prefix->prefix;
251  pref->prefix_length = prefix->prefix_length;
252  }
253  params.prefixes = prefixes;
254 
255  dhcp6_pd_send_client_message (rm->vlib_main, sw_if_index, !start, &params);
256 
257  vec_free (params.prefixes);
258 }
259 
260 static void interrupt_process (void);
261 
262 static u32
264 {
266  clib_error_t *rv;
267 
268  rv = enable_ip6_interface (rm->vlib_main, sw_if_index);
269 
270  return rv != 0;
271 }
272 
273 static u8
275 {
276  if (len >= 64)
277  {
278  if (prefix1->as_u64[0] != prefix2->as_u64[0])
279  return 0;
280  if (len == 64)
281  return 1;
282  return clib_net_to_host_u64 (prefix1->as_u64[1]) >> (128 - len) ==
283  clib_net_to_host_u64 (prefix2->as_u64[1]) >> (128 - len);
284  }
285  return clib_net_to_host_u64 (prefix1->as_u64[0]) >> (64 - len) ==
286  clib_net_to_host_u64 (prefix2->as_u64[0]) >> (64 - len);
287 }
288 
289 static clib_error_t *
291 {
294  vlib_main_t *vm = rm->vlib_main;
295  client_state_t *client_state;
298  u32 n_prefixes;
299  vl_api_dhcp6_pd_prefix_info_t *api_prefix;
300  u32 inner_status_code;
301  u32 status_code;
302  u32 server_index;
303  f64 current_time;
304  clib_error_t *error = 0;
305  u32 i;
306 
307  current_time = vlib_time_now (vm);
308 
309  sw_if_index = ntohl (mp->sw_if_index);
310 
311  if (sw_if_index >= vec_len (rm->client_state_by_sw_if_index))
312  return 0;
313 
314  client_state = &rm->client_state_by_sw_if_index[sw_if_index];
315 
316  if (!client_state->enabled)
317  return 0;
318 
319  server_index = ntohl (mp->server_index);
320 
321  n_prefixes = ntohl (mp->n_prefixes);
322 
323  inner_status_code = ntohs (mp->inner_status_code);
324  status_code = ntohs (mp->status_code);
325 
326  if (mp->msg_type == DHCPV6_MSG_ADVERTISE
327  && client_state->server_index == ~0)
328  {
329  prefix_info_t *prefix_list = 0, *prefix_info;
330  u8 prefix_length;
331 
332  if (inner_status_code == DHCPV6_STATUS_NOPREFIX_AVAIL)
333  {
335  ("Advertise message arrived with NoPrefixAvail status code");
336  return 0;
337  }
338 
339  if (n_prefixes > 0)
340  vec_validate (prefix_list, n_prefixes - 1);
341  for (i = 0; i < n_prefixes; i++)
342  {
343  api_prefix = &mp->prefixes[i];
344  prefix = (ip6_address_t *) api_prefix->prefix;
345  prefix_length = api_prefix->prefix_length;
346 
347  prefix_info = &prefix_list[i];
348  prefix_info->prefix = *prefix;
349  prefix_info->prefix_length = prefix_length;
350  prefix_info->preferred_lt = 0;
351  prefix_info->valid_lt = 0;
352  }
353 
354  client_state->server_index = server_index;
355 
356  send_client_message_start_stop (sw_if_index, server_index,
357  DHCPV6_MSG_REQUEST, prefix_list, 1);
358  vec_free (prefix_list);
359  }
360 
361  if (mp->msg_type != DHCPV6_MSG_REPLY)
362  return 0;
363 
364  if (!client_state->rebinding && client_state->server_index != server_index)
365  {
366  clib_warning ("Reply message arrived with Server ID different "
367  "from that in Request or Renew message");
368  return 0;
369  }
370 
371  if (inner_status_code == DHCPV6_STATUS_NOPREFIX_AVAIL)
372  {
373  clib_warning ("Reply message arrived with NoPrefixAvail status code");
374  if (n_prefixes > 0)
375  {
377  ("Invalid Reply message arrived: It contains NoPrefixAvail "
378  "status code but also contains prefixes");
379  return 0;
380  }
381  }
382 
383  if (status_code == DHCPV6_STATUS_UNSPEC_FAIL)
384  {
385  clib_warning ("Reply message arrived with UnspecFail status code");
386  return 0;
387  }
388 
389  send_client_message_start_stop (sw_if_index, server_index,
390  mp->msg_type, 0, 0);
391 
392  for (i = 0; i < n_prefixes; i++)
393  {
394  prefix_info_t *prefix_info = 0;
395  u8 prefix_length;
396  u32 valid_time;
397  u32 preferred_time;
398 
399  api_prefix = &mp->prefixes[i];
400 
401  prefix = (ip6_address_t *) api_prefix->prefix;
402  prefix_length = api_prefix->prefix_length;
403 
405  continue;
406 
407  valid_time = ntohl (api_prefix->valid_time);
408  preferred_time = ntohl (api_prefix->preferred_time);
409  prefix_length = api_prefix->prefix_length;
410 
411  if (preferred_time > valid_time)
412  continue;
413 
414  u8 address_prefix_present = 0;
415  /* *INDENT-OFF* */
416  pool_foreach (prefix_info, pm->prefix_pool,
417  ({
418  if (is_dhcpv6_pd_prefix (prefix_info) &&
419  prefix_info->opaque_data == sw_if_index &&
420  prefix_info->prefix_length == prefix_length &&
421  ip6_prefixes_equal (&prefix_info->prefix, prefix, prefix_length))
422  {
423  address_prefix_present = 1;
424  goto prefix_pool_foreach_out;
425  }
426  }));
427  /* *INDENT-ON* */
428  prefix_pool_foreach_out:
429 
430  if (address_prefix_present)
431  {
432  prefix_info->preferred_lt = preferred_time;
433  prefix_info->valid_lt = valid_time;
434  prefix_info->due_time = current_time + valid_time;
435  if (prefix_info->due_time > rm->max_valid_due_time)
436  rm->max_valid_due_time = prefix_info->due_time;
437  continue;
438  }
439 
440  if (valid_time == 0)
441  continue;
442 
443  pool_get (pm->prefix_pool, prefix_info);
444  prefix_info->prefix_group_index = client_state->prefix_group_index;
445  set_is_dhcpv6_pd_prefix (prefix_info, 1);
446  prefix_info->opaque_data = sw_if_index;
447  prefix_info->prefix_length = prefix_length;
448  prefix_info->prefix = *prefix;
449  prefix_info->preferred_lt = preferred_time;
450  prefix_info->valid_lt = valid_time;
451  prefix_info->due_time = current_time + valid_time;
452  if (prefix_info->due_time > rm->max_valid_due_time)
453  rm->max_valid_due_time = prefix_info->due_time;
455 
456  u32 prefix_index = prefix_info - pm->prefix_pool;
457  notify_prefix_add_del (prefix_index, 1);
458  }
459 
460  client_state->server_index = server_index;
461  client_state->T1 = ntohl (mp->T1);
462  client_state->T2 = ntohl (mp->T2);
463  if (client_state->T1 != 0)
464  client_state->T1_due_time = current_time + client_state->T1;
465  if (client_state->T2 != 0)
466  client_state->T2_due_time = current_time + client_state->T2;
467  client_state->rebinding = 0;
468 
470 
471  return error;
472 }
473 
474 static prefix_info_t *
476 {
478  prefix_info_t *prefix_info, *prefix_list = 0;;
479 
480  /* *INDENT-OFF* */
481  pool_foreach (prefix_info, pm->prefix_pool,
482  ({
483  if (is_dhcpv6_pd_prefix (prefix_info) &&
484  prefix_info->opaque_data == sw_if_index)
485  {
486  u32 pos = vec_len (prefix_list);
487  vec_validate (prefix_list, pos);
488  clib_memcpy (&prefix_list[pos], prefix_info, sizeof (*prefix_info));
489  }
490  }));
491  /* *INDENT-ON* */
492 
493  return prefix_list;
494 }
495 
497 
498 static uword
500  vlib_frame_t * f)
501 {
504  prefix_info_t *prefix_info;
505  client_state_t *client_state;
506  f64 sleep_time = 1e9;
507  f64 current_time;
508  f64 due_time;
509  uword event_type;
510  uword *event_data = 0;
511  int i;
512 
513  while (1)
514  {
515  vlib_process_wait_for_event_or_clock (vm, sleep_time);
516  event_type = vlib_process_get_events (vm, &event_data);
517  vec_reset_length (event_data);
518 
519  if (event_type == DHCPV6_PD_EVENT_DISABLE)
520  {
521  vlib_node_set_state (vm, rm->node_index, VLIB_NODE_STATE_DISABLED);
522  sleep_time = 1e9;
523  continue;
524  }
525 
526  current_time = vlib_time_now (vm);
527  do
528  {
529  due_time = current_time + 1e9;
530  /* *INDENT-OFF* */
531  pool_foreach (prefix_info, pm->prefix_pool,
532  ({
533  if (is_dhcpv6_pd_prefix (prefix_info))
534  {
535  if (prefix_info->due_time > current_time)
536  {
537  if (prefix_info->due_time < due_time)
538  due_time = prefix_info->due_time;
539  }
540  else
541  {
542  u32 prefix_index = prefix_info - pm->prefix_pool;
543  notify_prefix_add_del (prefix_index, 0);
544  u32 sw_if_index = prefix_info->opaque_data;
545  set_is_dhcpv6_pd_prefix (prefix_info, 0);
546  pool_put (pm->prefix_pool, prefix_info);
547  client_state = &rm->client_state_by_sw_if_index[sw_if_index];
548  if (--client_state->prefix_count == 0)
549  {
550  client_state->rebinding = 0;
551  client_state->server_index = ~0;
552  send_client_message_start_stop (sw_if_index, ~0,
553  DHCPV6_MSG_SOLICIT,
554  0, 1);
555  }
556  }
557  }
558  }));
559  /* *INDENT-ON* */
560  for (i = 0; i < vec_len (rm->client_state_by_sw_if_index); i++)
561  {
563  if (cs->enabled && cs->server_index != ~0)
564  {
565  if (cs->T2_due_time > current_time)
566  {
567  if (cs->T2_due_time < due_time)
568  due_time = cs->T2_due_time;
569  if (cs->T1_due_time > current_time)
570  {
571  if (cs->T1_due_time < due_time)
572  due_time = cs->T1_due_time;
573  }
574  else
575  {
576  cs->T1_due_time = DBL_MAX;
577  prefix_info_t *prefix_list;
578  prefix_list = create_prefix_list (i);
581  prefix_list, 1);
582  vec_free (prefix_list);
583  }
584  }
585  else
586  {
587  cs->T2_due_time = DBL_MAX;
588  prefix_info_t *prefix_list;
589  prefix_list = create_prefix_list (i);
590  cs->rebinding = 1;
593  prefix_list, 1);
594  vec_free (prefix_list);
595  }
596  }
597  }
598  current_time = vlib_time_now (vm);
599  }
600  while (due_time < current_time);
601 
602  sleep_time = due_time - current_time;
603  }
604 
605  return 0;
606 }
607 
608 /* *INDENT-OFF* */
610  .function = dhcp6_pd_client_cp_process,
611  .type = VLIB_NODE_TYPE_PROCESS,
612  .name = "dhcp6-pd-client-cp-process",
613 };
614 /* *INDENT-ON* */
615 
616 static void
618 {
620  vlib_main_t *vm = rm->vlib_main;
621 
624 }
625 
626 static void
628 {
630  vlib_main_t *vm = rm->vlib_main;
631 
634 }
635 
636 static void
638 {
640  vlib_main_t *vm = rm->vlib_main;
641  vlib_node_t *node;
642 
643  node = vec_elt (vm->node_main.nodes, rm->node_index);
644 
645  vlib_node_set_state (vm, rm->node_index, VLIB_NODE_STATE_POLLING);
646  vlib_start_process (vm, node->runtime_index);
647 }
648 
649 static u32
650 cp_ip6_construct_address (ip6_address_info_t * address_info, u32 prefix_index,
651  ip6_address_t * r_addr)
652 {
655  u64 mask, addr0, pref;
656 
657  addr0 = clib_net_to_host_u64 (address_info->address.as_u64[0]);
658  prefix = &pm->prefix_pool[prefix_index];
659  if (prefix->prefix_length > 64)
660  {
661  clib_warning ("Prefix length is bigger that 64 bits");
662  return 1;
663  }
664  mask = ((u64) 1 << (64 - prefix->prefix_length)) - 1;
665  addr0 &= mask;
666  pref = clib_host_to_net_u64 (prefix->prefix.as_u64[0]);
667  pref &= ~mask;
668  addr0 |= pref;
669  r_addr->as_u64[0] = clib_host_to_net_u64 (addr0);
670  r_addr->as_u64[1] = address_info->address.as_u64[1];
671 
672  return 0;
673 }
674 
675 static void
677 {
679  u32 prefix_index;
681  clib_error_t *error;
682 
683  if (address_info->prefix_group_index != ~0)
684  prefix_index =
686  (address_info->prefix_group_index);
687  else
688  prefix_index = ~0;
689 
690  if (is_add && !address_info->configured_in_data_plane)
691  {
692  if (prefix_index != ~0)
693  {
694  if (cp_ip6_construct_address (address_info, prefix_index, &addr) !=
695  0)
696  return;
697  error =
698  ip6_add_del_interface_address (vm, address_info->sw_if_index,
699  &addr, address_info->prefix_length,
700  0 /* add */ );
701  if (error)
702  clib_warning ("Failed adding IPv6 address: %U",
703  format_clib_error, error);
704  else
705  address_info->configured_in_data_plane = 1;
706  }
707  else
708  {
709  if (address_info->prefix_group_index == ~0)
710  {
711  error =
712  ip6_add_del_interface_address (vm, address_info->sw_if_index,
713  &address_info->address,
714  address_info->prefix_length,
715  0 /* add */ );
716  if (error)
717  clib_warning ("Failed adding IPv6 address: %U",
718  format_clib_error, error);
719  else
720  address_info->configured_in_data_plane = 1;
721  }
722  }
723  }
724  else if (!is_add && address_info->configured_in_data_plane)
725  {
726  if (prefix_index == ~0)
727  {
728  if (address_info->prefix_group_index == ~0)
729  {
730  error =
731  ip6_add_del_interface_address (vm, address_info->sw_if_index,
732  &address_info->address,
733  address_info->prefix_length,
734  1 /* del */ );
735  if (error)
736  clib_warning ("Failed deleting IPv6 address: %U",
737  format_clib_error, error);
738  address_info->configured_in_data_plane = 0;
739  }
740  else
741  clib_warning ("Deleting address with prefix "
742  "but active prefix index is not set");
743  }
744  else
745  {
746  if (cp_ip6_construct_address (address_info, prefix_index, &addr) !=
747  0)
748  return;
749  error =
750  ip6_add_del_interface_address (vm, address_info->sw_if_index,
751  &addr, address_info->prefix_length,
752  1 /* del */ );
753  if (error)
754  clib_warning ("Failed deleting IPv6 address: %U",
755  format_clib_error, error);
756  address_info->configured_in_data_plane = 0;
757  }
758  }
759 }
760 
761 static u32
763  u32 ignore_prefix_index)
764 {
766  prefix_info_t *prefix_info;
767 
768  /* *INDENT-OFF* */
769  pool_foreach (prefix_info, pm->prefix_pool,
770  ({
771  if (prefix_info->prefix_group_index == prefix_group_index &&
772  prefix_info - pm->prefix_pool != ignore_prefix_index)
773  return prefix_info - pm->prefix_pool;
774  }));
775  /* *INDENT-ON* */
776  return ~0;
777 }
778 
779 static void
781 {
784  ip6_address_info_t *address_info;
786  u32 new_prefix_index;
787  u32 prefix_group_index;
788  u32 i;
789 
790  prefix = &pm->prefix_pool[prefix_index];
791  prefix_group_index = prefix->prefix_group_index;
792 
793  if (is_add)
794  {
796  (prefix_group_index) == ~0)
797  {
799  (prefix_group_index, prefix_index);
800  for (i = 0; i < vec_len (apm->addresses); i++)
801  {
802  address_info = &apm->addresses[i];
803  if (address_info->prefix_group_index == prefix_group_index)
804  cp_ip6_address_add_del_now (address_info, 1 /* add */ );
805  }
806  }
807  }
808  else
809  {
811  (prefix_group_index) == prefix_index)
812  {
813  for (i = 0; i < vec_len (apm->addresses); i++)
814  {
815  address_info = &apm->addresses[i];
816  if (address_info->prefix_group_index == prefix_group_index)
817  cp_ip6_address_add_del_now (address_info, 0 /* del */ );
818  }
820  (prefix_group_index, ~0);
821  new_prefix_index =
822  cp_ip6_address_find_new_active_prefix (prefix_group_index,
823  prefix_index);
824  if (new_prefix_index != ~0)
825  {
827  (prefix_group_index, new_prefix_index);
828  for (i = 0; i < vec_len (apm->addresses); i++)
829  {
830  address_info = &apm->addresses[i];
831  if (address_info->prefix_group_index == prefix_group_index)
832  cp_ip6_address_add_del_now (address_info, 1 /* add */ );
833  }
834  }
835  }
836  }
837 }
838 
839 static u32
841 {
843  u32 free_index = ~0;
844  u8 *name_dup;
845  u32 i;
846 
847  for (i = 0; i < vec_len (pm->prefix_group_name_by_index); i++)
848  {
849  if (pm->prefix_group_name_by_index[i] == 0)
850  free_index = i;
851  else if (0 ==
852  strcmp ((const char *) pm->prefix_group_name_by_index[i],
853  (const char *) name))
854  return i;
855  }
856  if (!create)
857  return ~0;
858  name_dup = (u8 *) strdup ((const char *) name);
859  if (free_index != ~0)
860  {
861  pm->prefix_group_name_by_index[free_index] = name_dup;
862  return free_index;
863  }
864  else
865  {
866  vec_add1 (pm->prefix_group_name_by_index, name_dup);
867  return vec_len (pm->prefix_group_name_by_index) - 1;
868  }
869 }
870 
871 static int
872 cp_ip6_address_add_del (u32 sw_if_index, const u8 * prefix_group,
873  ip6_address_t address, u8 prefix_length, u8 is_add)
874 {
875 
877  vnet_main_t *vnm = vnet_get_main ();
878  ip6_address_info_t *address_info;
879  u32 prefix_group_index;
880  u32 n;
881 
882  if (!vnet_sw_interface_is_api_valid (vnm, sw_if_index))
883  {
884  clib_warning ("Invalid sw_if_index");
885  return VNET_API_ERROR_INVALID_VALUE;
886  }
887 
888  if (prefix_group != 0 && prefix_group[0] != '\0')
889  {
890  if (strnlen ((const char *) prefix_group, 64) == 64)
891  return VNET_API_ERROR_INVALID_VALUE;
892 
893  prefix_group_index = prefix_group_find_or_create (prefix_group, 1);
894  }
895  else
896  prefix_group_index = ~0;
897 
898  n = vec_len (apm->addresses);
899 
900  vec_foreach (address_info, apm->addresses)
901  {
902  if (address_info->sw_if_index == sw_if_index &&
903  address_info->prefix_group_index == prefix_group_index &&
904  address_info->prefix_length == prefix_length &&
905  0 == memcmp (&address_info->address, &address, 16))
906  {
907  if (is_add)
908  return VNET_API_ERROR_DUPLICATE_IF_ADDRESS;
909  cp_ip6_address_add_del_now (address_info, 0 /* del */ );
910  *address_info = apm->addresses[n - 1];
911  _vec_len (apm->addresses) = n - 1;
912  return 0;
913  }
914  }
915 
916  if (!is_add)
917  return VNET_API_ERROR_ADDRESS_NOT_FOUND_FOR_INTERFACE;
918 
919  vec_validate (apm->addresses, n);
920  address_info = &apm->addresses[n];
921  address_info->sw_if_index = sw_if_index;
922  address_info->prefix_group_index = prefix_group_index;
923  address_info->address = address;
924  address_info->prefix_length = prefix_length;
925  cp_ip6_address_add_del_now (address_info, 1 /* add */ );
926 
927  return 0;
928 }
929 
930 static void
933 {
934  vl_api_ip6_add_del_address_using_prefix_reply_t *rmp;
937  u8 prefix_length;
938  int rv = 0;
939 
941 
942  sw_if_index = ntohl (mp->sw_if_index);
943 
944  memcpy (address.as_u8, mp->address, 16);
945  prefix_length = mp->prefix_length;
946 
947  rv =
948  cp_ip6_address_add_del (sw_if_index, mp->prefix_group, address,
949  prefix_length, mp->is_add);
950 
952 
953  REPLY_MACRO (VL_API_SW_INTERFACE_SET_TABLE_REPLY);
954 }
955 
956 static clib_error_t *
958  unformat_input_t * input,
959  vlib_cli_command_t * cmd)
960 {
961  vnet_main_t *vnm = vnet_get_main ();
962  clib_error_t *error = 0;
963  u32 sw_if_index = ~0;
964  u8 *prefix_group = 0;
966  u32 prefix_length;
967  u8 address_set = 0;
968  u8 add = 1;
969  unformat_input_t _line_input, *line_input = &_line_input;
970 
971  if (!unformat_user (input, unformat_line_input, line_input))
972  return 0;
973 
974  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
975  {
976  if (unformat
977  (line_input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index));
978  else if (unformat (line_input, "prefix group %s", &prefix_group));
979  else
980  if (unformat (line_input, "%U/%d", unformat_ip6_address,
981  &address, &prefix_length))
982  address_set = 1;
983  else if (unformat (line_input, "del"))
984  add = 0;
985  else
986  {
987  error = clib_error_return (0, "unexpected input `%U'",
988  format_unformat_error, line_input);
989  unformat_free (line_input);
990  goto done;
991  }
992  }
993 
994  unformat_free (line_input);
995 
996  if (sw_if_index == ~0)
997  error = clib_error_return (0, "Missing sw_if_index");
998  else if (address_set == 0)
999  error = clib_error_return (0, "Missing address");
1000  else
1001  {
1003  (sw_if_index, prefix_group, address, prefix_length, add) != 0)
1004  error = clib_error_return (0, "Error adding or removing address");
1005  }
1006 
1007 done:
1008  return error;
1009 }
1010 
1011 /*?
1012  * This command is used to add/delete IPv6 address
1013  * potentially using available prefix from specified prefix group
1014  *
1015  * @cliexpar
1016  * @parblock
1017  * Example of how to add IPv6 address:
1018  * @cliexcmd{set ip6 address GigabitEthernet2/0/0
1019  * prefix group my-prefix-group ::7/64}
1020  * Example of how to delete IPv6 address:
1021  * @cliexcmd{set ip6 address GigabitEthernet2/0/0
1022  * prefix group my-prefix-group ::7/64 del}
1023  * @endparblock
1024 ?*/
1025 /* *INDENT-OFF* */
1027  .path = "set ip6 address",
1028  .short_help = "set ip6 address <interface> [prefix group <string>] "
1029  "<address> [del]",
1031 };
1032 /* *INDENT-ON* */
1033 
1034 static clib_error_t *
1036  unformat_input_t * input,
1037  vlib_cli_command_t * cmd)
1038 {
1041  ip6_address_info_t *address_info;
1042  const u8 *prefix_group;
1043  clib_error_t *error = 0;
1044  int i;
1045 
1046  for (i = 0; i < vec_len (apm->addresses); i++)
1047  {
1048  address_info = &apm->addresses[i];
1049  if (address_info->prefix_group_index == ~0)
1050  prefix_group = (const u8 *) "NONE";
1051  else
1052  prefix_group =
1054  vlib_cli_output (vm,
1055  "sw_if_index: %u, prefix_group: %s, address: %U/%d",
1056  address_info->sw_if_index, prefix_group,
1057  format_ip6_address, &address_info->address,
1058  address_info->prefix_length);
1059  }
1060 
1061  return error;
1062 }
1063 
1064 /* *INDENT-OFF* */
1066  .path = "show ip6 addresses",
1067  .short_help = "show ip6 addresses",
1069 };
1070 /* *INDENT-ON* */
1071 
1072 static clib_error_t *
1074  unformat_input_t * input,
1075  vlib_cli_command_t * cmd)
1076 {
1078  clib_error_t *error = 0;
1079  prefix_info_t *prefix_info;
1080  const u8 *prefix_group;
1081  f64 current_time = vlib_time_now (vm);
1082 
1083  /* *INDENT-OFF* */
1084  pool_foreach (prefix_info, pm->prefix_pool,
1085  ({
1086  prefix_group =
1087  pm->prefix_group_name_by_index[prefix_info->prefix_group_index];
1088  vlib_cli_output (vm, "opaque_data: %lu, prefix: %U/%d, prefix group: %s, "
1089  "preferred lifetime: %u, valid lifetime: %u "
1090  "(%f remaining)",
1091  prefix_info->opaque_data, format_ip6_address,
1092  &prefix_info->prefix, prefix_info->prefix_length,
1093  prefix_group,
1094  prefix_info->preferred_lt, prefix_info->valid_lt,
1095  prefix_info->due_time - current_time);
1096  }));
1097  /* *INDENT-ON* */
1098 
1099  return error;
1100 }
1101 
1102 /* *INDENT-OFF* */
1104  .path = "show ip6 prefixes",
1105  .short_help = "show ip6 prefixes",
1107 };
1108 /* *INDENT-ON* */
1109 
1110 static clib_error_t *
1112  unformat_input_t * input,
1113  vlib_cli_command_t * cmd)
1114 {
1117  clib_error_t *error = 0;
1118  client_state_t *cs;
1119  f64 current_time = vlib_time_now (vm);
1120  const u8 *prefix_group;
1121  char buf1[256];
1122  char buf2[256];
1123  const char *rebinding;
1124  u32 i;
1125 
1126  for (i = 0; i < vec_len (rm->client_state_by_sw_if_index); i++)
1127  {
1128  cs = &rm->client_state_by_sw_if_index[i];
1129  if (cs->enabled)
1130  {
1131  if (cs->T1_due_time != DBL_MAX && cs->T1_due_time > current_time)
1132  {
1133  sprintf (buf1, "%u remaining",
1134  (u32) round (cs->T1_due_time - current_time));
1135  }
1136  else
1137  sprintf (buf1, "timeout");
1138  if (cs->T2_due_time != DBL_MAX && cs->T2_due_time > current_time)
1139  sprintf (buf2, "%u remaining",
1140  (u32) round (cs->T2_due_time - current_time));
1141  else
1142  sprintf (buf2, "timeout");
1143  if (cs->rebinding)
1144  rebinding = ", REBINDING";
1145  else
1146  rebinding = "";
1147  prefix_group =
1149  if (cs->T1)
1150  vlib_cli_output (vm,
1151  "sw_if_index: %u, prefix group: %s, T1: %u (%s), "
1152  "T2: %u (%s), server index: %d%s", i,
1153  prefix_group, cs->T1, buf1, cs->T2, buf2,
1154  cs->server_index, rebinding);
1155  else
1156  vlib_cli_output (vm, "sw_if_index: %u, prefix group: %s%s", i,
1157  prefix_group, rebinding);
1158  }
1159  }
1160 
1161  return error;
1162 }
1163 
1164 /* *INDENT-OFF* */
1166  .path = "show ip6 pd clients",
1167  .short_help = "show ip6 pd clients",
1169 };
1170 /* *INDENT-ON* */
1171 
1172 static int
1174  u8 enable)
1175 {
1178  vnet_main_t *vnm = rm->vnet_main;
1179  client_state_t *client_state;
1180  static client_state_t empty_config = {
1181  0
1182  };
1183  prefix_info_t *prefix_info;
1184  prefix_info_t *prefix_list = 0;
1185  u32 prefix_group_index;
1186 
1187  if (!vnet_sw_interface_is_api_valid (vnm, sw_if_index))
1188  {
1189  clib_warning ("Invalid sw_if_index");
1190  return VNET_API_ERROR_INVALID_VALUE;
1191  }
1192 
1194  empty_config);
1195  client_state = &rm->client_state_by_sw_if_index[sw_if_index];
1196 
1197  u8 old_enabled = client_state->enabled;
1198 
1199  if (enable)
1200  {
1201  if (strnlen ((const char *) prefix_group, 64) == 64
1202  || prefix_group[0] == '\0')
1203  return VNET_API_ERROR_INVALID_VALUE;
1204  prefix_group_index =
1205  prefix_group_find_or_create (prefix_group, !old_enabled);
1206  if (old_enabled
1207  && prefix_group_index != client_state->prefix_group_index)
1208  return VNET_API_ERROR_INVALID_VALUE;
1209  }
1210 
1211  if (!old_enabled && enable)
1212  {
1213  client_state->enabled = 1;
1214  client_state->prefix_group_index = prefix_group_index;
1215  ASSERT (client_state->prefix_group_index != ~0);
1216  client_state->server_index = ~0;
1217 
1218  rm->n_clients++;
1219  if (rm->n_clients == 1)
1220  {
1221  enable_process ();
1223  }
1224 
1225  ip6_enable (sw_if_index);
1227  0, 1);
1228  }
1229  else if (old_enabled && !enable)
1230  {
1231  send_client_message_start_stop (sw_if_index, ~0, ~0, 0, 0);
1232 
1233  rm->n_clients--;
1234  if (rm->n_clients == 0)
1235  {
1237  disable_process ();
1238  }
1239 
1240  vec_validate (prefix_list, 0);
1241 
1242  /* *INDENT-OFF* */
1243  pool_foreach (prefix_info, pm->prefix_pool,
1244  ({
1245  if (is_dhcpv6_pd_prefix (prefix_info) &&
1246  prefix_info->opaque_data == sw_if_index)
1247  {
1248  ASSERT (sw_if_index < vec_len (rm->client_state_by_sw_if_index) &&
1249  rm->client_state_by_sw_if_index[sw_if_index].enabled);
1250  client_state_t *client_state =
1251  &rm->client_state_by_sw_if_index[sw_if_index];
1252  prefix_list[0] = *prefix_info;
1253  send_client_message_start_stop (sw_if_index,
1254  client_state->server_index,
1255  DHCPV6_MSG_RELEASE, prefix_list,
1256  1);
1257  u32 prefix_index = prefix_info - pm->prefix_pool;
1258  notify_prefix_add_del (prefix_index, 0);
1259  set_is_dhcpv6_pd_prefix (prefix_info, 0);
1260  pool_put (pm->prefix_pool, prefix_info);
1261  }
1262  }));
1263  /* *INDENT-ON* */
1264 
1265  vec_free (prefix_list);
1266 
1267  clib_memset (client_state, 0, sizeof (*client_state));
1268  }
1269 
1270  return 0;
1271 }
1272 
1273 static clib_error_t *
1275  vm,
1277  * input, vlib_cli_command_t * cmd)
1278 {
1280  vnet_main_t *vnm = rm->vnet_main;
1281  clib_error_t *error = 0;
1282  u8 *prefix_group = 0;
1283  u32 sw_if_index = ~0;
1284  u8 enable = 1;
1285  unformat_input_t _line_input, *line_input = &_line_input;
1286 
1287  if (!unformat_user (input, unformat_line_input, line_input))
1288  return 0;
1289 
1290  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1291  {
1292  if (unformat
1293  (line_input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
1294  ;
1295  else if (unformat (line_input, "prefix group %s", &prefix_group));
1296  else if (unformat (line_input, "disable"))
1297  enable = 0;
1298  else
1299  {
1300  error = clib_error_return (0, "unexpected input `%U'",
1301  format_unformat_error, line_input);
1302  goto done;
1303  }
1304  }
1305 
1306  if (prefix_group == 0 && enable)
1307  error = clib_error_return (0, "Prefix group must be set when enabling");
1308  else if (sw_if_index != ~0)
1309  {
1310  if (dhcp6_pd_client_enable_disable (sw_if_index, prefix_group, enable)
1311  != 0)
1312  error = clib_error_return (0, "Invalid sw_if_index or prefix group");
1313  }
1314  else
1315  error = clib_error_return (0, "Missing sw_if_index");
1316 
1317 done:
1318  vec_free (prefix_group);
1319  unformat_free (line_input);
1320 
1321  return error;
1322 }
1323 
1324 /*?
1325  * This command is used to enable/disable DHCPv6 PD client
1326  * on particular interface.
1327  *
1328  * @cliexpar
1329  * @parblock
1330  * Example of how to enable DHCPv6 PD client:
1331  * @cliexcmd{dhcp6 pd client GigabitEthernet2/0/0 prefix group my-pd-group}
1332  * Example of how to disable DHCPv6 PD client:
1333  * @cliexcmd{dhcp6 pd client GigabitEthernet2/0/0 disable}
1334  * @endparblock
1335 ?*/
1336 /* *INDENT-OFF* */
1338  .path = "dhcp6 pd client",
1339  .short_help = "dhcp6 pd client <interface> (prefix group <string> | disable)",
1341 };
1342 /* *INDENT-ON* */
1343 
1344 static void
1347 {
1348  vl_api_dhcp6_pd_client_enable_disable_reply_t *rmp;
1349  u32 sw_if_index;
1350  int rv = 0;
1351 
1352  VALIDATE_SW_IF_INDEX (mp);
1353 
1354  sw_if_index = ntohl (mp->sw_if_index);
1355 
1356  rv =
1357  dhcp6_pd_client_enable_disable (sw_if_index, mp->prefix_group,
1358  mp->enable);
1359 
1361 
1362  REPLY_MACRO (VL_API_SW_INTERFACE_SET_TABLE_REPLY);
1363 }
1364 
1365 #define vl_msg_name_crc_list
1366 #include <vnet/dhcp/dhcp6_pd_client_cp.api.h>
1367 #undef vl_msg_name_crc_list
1368 
1369 static void
1371 {
1372 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1373  foreach_vl_msg_name_crc_dhcp6_pd_client_cp;
1374 #undef _
1375 }
1376 
1377 static clib_error_t *
1379 {
1381  api_main_t *am = &api_main;
1382 
1383  rm->vlib_main = vm;
1384  rm->vnet_main = vnet_get_main ();
1385  rm->api_main = am;
1387 
1388 #define _(N,n) \
1389  vl_msg_api_set_handlers(VL_API_##N, #n, \
1390  vl_api_##n##_t_handler, \
1391  vl_noop_handler, \
1392  vl_api_##n##_t_endian, \
1393  vl_api_##n##_t_print, \
1394  sizeof(vl_api_##n##_t), 0/* do NOT trace! */);
1396 #undef _
1397 
1398  /*
1399  * Set up the (msg_name, crc, message-id) table
1400  */
1402 
1403  return 0;
1404 }
1405 
1407 
1408 /*
1409  * fd.io coding-style-patch-verification: ON
1410  *
1411  * Local Variables:
1412  * eval: (c-set-style "gnu")
1413  * End:
1414  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
u32 sw_if_index
Definition: ipsec_gre.api:37
typedef address
Definition: ip_types.api:30
u8 * format_clib_error(u8 *s, va_list *va)
Definition: error.c:191
static void notify_prefix_add_del(u32 prefix_index, u8 is_add)
vlib_node_registration_t dhcp6_pd_client_cp_process_node
(constructor) VLIB_REGISTER_NODE (dhcp6_pd_client_cp_process_node)
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
Definition: node_funcs.h:703
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
vl_api_dhcp6_pd_prefix_info_t prefixes[n_prefixes]
Definition: dhcp.api:413
static void cp_ip6_address_prefix_add_del_handler(u32 prefix_index, u8 is_add)
Optimized string handling code, including c11-compliant "safe C library" variants.
ip6_address_t prefix
static u32 cp_ip6_address_find_new_active_prefix(u32 prefix_group_index, u32 ignore_prefix_index)
u8 as_u8[16]
Definition: ip6_packet.h:48
u64 as_u64[2]
Definition: ip6_packet.h:51
unsigned long u64
Definition: types.h:89
static_always_inline u8 is_dhcpv6_pd_prefix(prefix_info_t *prefix_info)
static void send_client_message_start_stop(u32 sw_if_index, u32 server_index, u8 msg_type, prefix_info_t *prefix_list, u8 start)
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:255
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
Enable/disable DHCPv6 PD client on interface.
dhcp6_pd_send_client_message_params_prefix_t * prefixes
int i
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
Definition: bitmap.h:167
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:983
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
void dhcp6_pd_send_client_message(vlib_main_t *vm, u32 sw_if_index, u8 stop, dhcp6_pd_send_client_message_params_t *params)
static void setup_message_id_table(api_main_t *am)
unformat_function_t unformat_vnet_sw_interface
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:236
vhost_vring_addr_t addr
Definition: vhost_user.h:121
static vlib_cli_command_t ip6_pd_clients_show_command
(constructor) VLIB_CLI_COMMAND (ip6_pd_clients_show_command)
unsigned char u8
Definition: types.h:56
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
double f64
Definition: types.h:142
static ip6_address_with_prefix_main_t ip6_address_with_prefix_main
const u8 ** prefix_group_name_by_index
static void cp_ip6_address_add_del_now(ip6_address_info_t *address_info, u8 is_add)
#define static_always_inline
Definition: clib.h:99
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:493
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:163
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
Definition: node_funcs.h:546
vlib_node_t ** nodes
Definition: node.h:698
#define clib_error_return(e, args...)
Definition: error.h:99
static clib_error_t * dhcp6_pd_client_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t()*input, vlib_cli_command_t *cmd)
unsigned int u32
Definition: types.h:88
static_always_inline void active_prefix_index_by_prefix_group_index_set(u32 prefix_group_index, u32 prefix_index)
unformat_function_t unformat_line_input
Definition: format.h:282
static u32 ip6_enable(u32 sw_if_index)
static vlib_cli_command_t ip6_address_add_del_command
(constructor) VLIB_CLI_COMMAND (ip6_address_add_del_command)
VNET_DHCP6_PD_REPLY_EVENT_FUNCTION(dhcp6_pd_reply_event_handler)
Struct representing DHCPv6 PD prefix.
Definition: dhcp.api:230
static int cp_ip6_address_add_del(u32 sw_if_index, const u8 *prefix_group, ip6_address_t address, u8 prefix_length, u8 is_add)
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:964
struct _unformat_input_t unformat_input_t
#define REPLY_MACRO(t)
static int dhcp6_pd_client_enable_disable(u32 sw_if_index, const u8 *prefix_group, u8 enable)
u8 name[64]
Definition: memclnt.api:152
static void interrupt_process(void)
static void disable_process(void)
u8 len
Definition: ip_types.api:49
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:202
unformat_function_t unformat_ip6_address
Definition: format.h:91
#define BAD_SW_IF_INDEX_LABEL
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
#define UNFORMAT_END_OF_INPUT
Definition: format.h:144
u32 runtime_index
Definition: node.h:282
static clib_error_t * cp_ip6_prefixes_show_command_function(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * ip6_pd_clients_show_command_function(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
format_function_t format_ip6_address
Definition: format.h:93
vlib_main_t * vm
Definition: buffer.c:312
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
static prefix_info_t * create_prefix_list(u32 sw_if_index)
#define clib_warning(format, args...)
Definition: error.h:59
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
Definition: bitmap.h:197
clib_error_t * enable_ip6_interface(vlib_main_t *vm, u32 sw_if_index)
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:155
signed int i32
Definition: types.h:77
#define ASSERT(truth)
static u32 cp_ip6_construct_address(ip6_address_info_t *address_info, u32 prefix_index, ip6_address_t *r_addr)
u8 is_add
Definition: ipsec_gre.api:36
static_always_inline u32 active_prefix_index_by_prefix_group_index_get(u32 prefix_group_index)
static u8 ip6_prefixes_equal(ip6_address_t *prefix1, ip6_address_t *prefix2, u8 len)
Tell client about a DHCPv6 PD server reply event.
Definition: dhcp.api:400
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
Definition: node_funcs.h:148
static uword ip6_address_is_link_local_unicast(const ip6_address_t *a)
Definition: ip6_packet.h:328
static clib_error_t * dhcp6_pd_reply_event_handler(vl_api_dhcp6_pd_reply_event_t *mp)
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
#define vec_elt(v, i)
Get vector value at index i.
static dhcp6_pd_client_cp_main_t dhcp6_pd_client_cp_main
prefix_info_t * prefix_pool
static_always_inline void set_is_dhcpv6_pd_prefix(prefix_info_t *prefix_info, u8 value)
static uword vnet_sw_interface_is_api_valid(vnet_main_t *vnm, u32 sw_if_index)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static clib_error_t * cp_ip6_addresses_show_command_function(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_node_main_t node_main
Definition: main.h:135
static clib_error_t * dhcp_pd_client_cp_init(vlib_main_t *vm)
u64 uword
Definition: types.h:112
static void unformat_free(unformat_input_t *i)
Definition: format.h:162
static uword dhcp6_pd_client_cp_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
typedef prefix
Definition: ip_types.api:35
static u32 prefix_group_find_or_create(const u8 *name, u8 create)
void dhcp6_clients_enable_disable(u8 enable)
static vlib_cli_command_t ip6_prefixes_show_command
(constructor) VLIB_CLI_COMMAND (ip6_prefixes_show_command)
Add/delete IPv6 address optionally using available prefix.
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
uword clib_bitmap_t
Definition: bitmap.h:50
clib_bitmap_t * prefix_ownership_bitmap
static void vl_api_dhcp6_pd_client_enable_disable_t_handler(vl_api_dhcp6_pd_client_enable_disable_t *mp)
#define vec_foreach(var, vec)
Vector iterator.
clib_error_t * ip6_add_del_interface_address(vlib_main_t *vm, u32 sw_if_index, ip6_address_t *address, u32 address_length, u32 is_del)
Definition: ip6_forward.c:197
static void vl_api_ip6_add_del_address_using_prefix_t_handler(vl_api_ip6_add_del_address_using_prefix_t *mp)
static vlib_cli_command_t dhcp6_pd_client_enable_disable_command
(constructor) VLIB_CLI_COMMAND (dhcp6_pd_client_enable_disable_command)
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
Definition: vec.h:486
void vlib_start_process(vlib_main_t *vm, uword process_index)
Definition: main.c:1584
static void enable_process(void)
api_main_t api_main
Definition: api_shared.c:35
static ip6_prefix_main_t ip6_prefix_main
#define foreach_dhcp6_pd_client_cp_msg
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:725
static vlib_cli_command_t ip6_addresses_show_command
(constructor) VLIB_CLI_COMMAND (ip6_addresses_show_command)
static clib_error_t * cp_ip6_address_add_del_command_function(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:170
#define VALIDATE_SW_IF_INDEX(mp)
client_state_t * client_state_by_sw_if_index