FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
dhcp6_ia_na_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 <dhcp/dhcp6_packet.h>
21 #include <vnet/ip/ip.h>
22 #include <vnet/ip/ip6.h>
23 #include <vnet/ip/ip6_link.h>
24 #include <float.h>
25 #include <math.h>
26 
27 typedef struct
28 {
30  ip6_address_t address;
35 
36 typedef struct
37 {
47 
48 typedef struct
49 {
54 
55  /* convenience */
61 
63 
64 enum
65 {
68 };
69 
70 static void
72  u8 msg_type, address_info_t * address_list,
73  u8 start)
74 {
76  dhcp6_send_client_message_params_t params = { 0, };
78  u32 i;
79 
82  client_state_t *client_state =
84 
85  params.sw_if_index = sw_if_index;
86  params.server_index = server_index;
87  params.msg_type = msg_type;
88  if (start)
89  {
90  if (msg_type == DHCPV6_MSG_SOLICIT)
91  {
92  params.irt = 1;
93  params.mrt = 120;
94  }
95  else if (msg_type == DHCPV6_MSG_REQUEST)
96  {
97  params.irt = 1;
98  params.mrt = 30;
99  params.mrc = 10;
100  }
101  else if (msg_type == DHCPV6_MSG_RENEW)
102  {
103  params.irt = 10;
104  params.mrt = 600;
105  f64 current_time = vlib_time_now (rm->vlib_main);
106  i32 diff_time = client_state->T2 - current_time;
107  if (diff_time < 0)
108  diff_time = 0;
109  params.mrd = diff_time;
110  }
111  else if (msg_type == DHCPV6_MSG_REBIND)
112  {
113  params.irt = 10;
114  params.mrt = 600;
115  f64 current_time = vlib_time_now (rm->vlib_main);
116  i32 diff_time = rm->max_valid_due_time - current_time;
117  if (diff_time < 0)
118  diff_time = 0;
119  params.mrd = diff_time;
120  }
121  else if (msg_type == DHCPV6_MSG_RELEASE)
122  {
123  params.mrc = 1;
124  }
125  }
126 
127  params.T1 = 0;
128  params.T2 = 0;
129  if (vec_len (address_list) != 0)
130  vec_validate (addresses, vec_len (address_list) - 1);
131  for (i = 0; i < vec_len (address_list); i++)
132  {
133  address_info_t *address = &address_list[i];
134  addr = &addresses[i];
135  addr->valid_lt = address->valid_lt;
136  addr->preferred_lt = address->preferred_lt;
137  addr->address = address->address;
138  }
139  params.addresses = addresses;
140 
141  dhcp6_send_client_message (rm->vlib_main, sw_if_index, !start, &params);
142 
143  vec_free (params.addresses);
144 }
145 
146 static void interrupt_process (void);
147 
148 static u8
149 ip6_addresses_equal (ip6_address_t * address1, ip6_address_t * address2)
150 {
151  if (address1->as_u64[0] != address2->as_u64[0])
152  return 0;
153  return address1->as_u64[1] == address2->as_u64[1];
154 }
155 
156 static clib_error_t *
158 {
160  vlib_main_t *vm = rm->vlib_main;
161  client_state_t *client_state;
162  ip6_address_t *address;
164  u32 n_addresses;
165  vl_api_dhcp6_address_info_t *api_address;
166  u32 inner_status_code;
167  u32 status_code;
168  u32 server_index;
169  f64 current_time;
170  clib_error_t *error = 0;
171  u32 i;
172 
173  current_time = vlib_time_now (vm);
174 
175  sw_if_index = ntohl (mp->sw_if_index);
176 
178  return 0;
179 
180  client_state = &rm->client_state_by_sw_if_index[sw_if_index];
181 
182  if (!client_state->enabled)
183  return 0;
184 
185  server_index = ntohl (mp->server_index);
186 
187  n_addresses = ntohl (mp->n_addresses);
188 
189  inner_status_code = ntohs (mp->inner_status_code);
190  status_code = ntohs (mp->status_code);
191 
193  && client_state->server_index == ~0)
194  {
195  address_info_t *address_list = 0, *address_info;
196 
197  if (inner_status_code == DHCPV6_STATUS_NOADDRS_AVAIL)
198  {
200  ("Advertise message arrived with NoAddrsAvail status code");
201  return 0;
202  }
203 
204  if (n_addresses > 0)
205  vec_validate (address_list, n_addresses - 1);
206  for (i = 0; i < n_addresses; i++)
207  {
208  api_address = &mp->addresses[i];
209  address = (ip6_address_t *) api_address->address;
210 
211  address_info = &address_list[i];
212  address_info->address = *address;
213  address_info->preferred_lt = 0;
214  address_info->valid_lt = 0;
215  }
216 
217  client_state->server_index = server_index;
218 
220  DHCPV6_MSG_REQUEST, address_list, 1);
221  vec_free (address_list);
222  }
223 
224  if (mp->msg_type != DHCPV6_MSG_API_REPLY)
225  return 0;
226 
227  if (!client_state->rebinding && client_state->server_index != server_index)
228  {
229  clib_warning ("Reply message arrived with Server ID different "
230  "from that in Request or Renew message");
231  return 0;
232  }
233 
234  if (inner_status_code == DHCPV6_STATUS_NOADDRS_AVAIL)
235  {
236  clib_warning ("Reply message arrived with NoAddrsAvail status code");
237  if (n_addresses > 0)
238  {
240  ("Invalid Reply message arrived: It contains NoAddrsAvail "
241  "status code but also contains addresses");
242  return 0;
243  }
244  }
245 
246  if (status_code == DHCPV6_STATUS_UNSPEC_FAIL)
247  {
248  clib_warning ("Reply message arrived with UnspecFail status code");
249  return 0;
250  }
251 
253  mp->msg_type, 0, 0);
254 
255  for (i = 0; i < n_addresses; i++)
256  {
257  address_info_t *address_info = 0;
258  u32 valid_time;
260 
261  api_address = &mp->addresses[i];
262 
263  address = (ip6_address_t *) api_address->address;
264 
266  continue;
267 
268  valid_time = ntohl (api_address->valid_time);
269  preferred_time = ntohl (api_address->preferred_time);
270 
272  continue;
273 
274  u8 address_already_present = 0;
275  /* *INDENT-OFF* */
276  pool_foreach (address_info, rm->address_pool)
277  {
278  if (address_info->sw_if_index != sw_if_index)
279  ;
280  else if (!ip6_addresses_equal (&address_info->address, address))
281  ;
282  else
283  {
284  address_already_present = 1;
285  goto address_pool_foreach_out;
286  }
287  }
288  /* *INDENT-ON* */
289  address_pool_foreach_out:
290 
291  if (address_already_present)
292  {
293  address_info->preferred_lt = preferred_time;
294  address_info->valid_lt = valid_time;
295  address_info->due_time = current_time;
296  /* Renew the lease at the preferred time, if non-zero */
297  address_info->due_time += (preferred_time > 0) ?
299 
300  if (address_info->due_time > rm->max_valid_due_time)
301  rm->max_valid_due_time = address_info->due_time;
302  continue;
303  }
304 
305  if (valid_time == 0)
306  continue;
307 
308  pool_get (rm->address_pool, address_info);
309  address_info->sw_if_index = sw_if_index;
310  address_info->address = *address;
311  address_info->preferred_lt = preferred_time;
312  address_info->valid_lt = valid_time;
313  address_info->due_time = current_time;
314  /* Renew the lease at the preferred time, if non-zero */
315  address_info->due_time += (preferred_time > 0) ?
317 
318  if (address_info->due_time > rm->max_valid_due_time)
319  rm->max_valid_due_time = address_info->due_time;
321 
323  &address_info->address, 64, 0);
324  if (error)
325  clib_warning ("Failed to add interface address");
326  }
327 
328  client_state->server_index = server_index;
329  client_state->T1 = ntohl (mp->T1);
330  client_state->T2 = ntohl (mp->T2);
331  if (client_state->T1 != 0)
332  client_state->T1_due_time = current_time + client_state->T1;
333  if (client_state->T2 != 0)
334  client_state->T2_due_time = current_time + client_state->T2;
335  client_state->rebinding = 0;
336 
338 
339  return error;
340 }
341 
342 static address_info_t *
344 {
346  address_info_t *address_info, *address_list = 0;;
347 
348  /* *INDENT-OFF* */
349  pool_foreach (address_info, rm->address_pool)
350  {
351  if (address_info->sw_if_index == sw_if_index)
352  {
353  u32 pos = vec_len (address_list);
354  vec_validate (address_list, pos);
355  clib_memcpy (&address_list[pos], address_info, sizeof (*address_info));
356  }
357  }
358  /* *INDENT-ON* */
359 
360  return address_list;
361 }
362 
364 
365 static uword
367  vlib_frame_t * f)
368 {
370  address_info_t *address_info;
371  client_state_t *client_state;
372  f64 sleep_time = 1e9;
374  f64 current_time;
375  f64 due_time;
376  uword event_type;
377  uword *event_data = 0;
378  int i;
379 
380  while (1)
381  {
383  event_type = vlib_process_get_events (vm, &event_data);
384  vec_reset_length (event_data);
385 
386  if (event_type == RD_CP_EVENT_DISABLE)
387  {
388  vlib_node_set_state (vm, rm->node_index, VLIB_NODE_STATE_DISABLED);
389  sleep_time = 1e9;
390  continue;
391  }
392 
393  current_time = vlib_time_now (vm);
394  do
395  {
396  due_time = current_time + 1e9;
397  /* *INDENT-OFF* */
398  pool_foreach (address_info, rm->address_pool)
399  {
400  if (address_info->due_time > current_time)
401  {
402  if (address_info->due_time < due_time)
403  due_time = address_info->due_time;
404  }
405  else
406  {
407  u32 sw_if_index = address_info->sw_if_index;
409  &address_info->address,
410  64, 1);
411  if (error)
412  clib_warning ("Failed to delete interface address");
413  pool_put (rm->address_pool, address_info);
414  /* make sure ip6 stays enabled */
416  client_state = &rm->client_state_by_sw_if_index[sw_if_index];
417  if (--client_state->address_count == 0)
418  {
419  client_state->rebinding = 0;
420  client_state->server_index = ~0;
423  0, 1);
424  }
425  }
426  }
427  /* *INDENT-ON* */
428  for (i = 0; i < vec_len (rm->client_state_by_sw_if_index); i++)
429  {
431  if (cs->enabled && cs->server_index != ~0)
432  {
433  if (cs->T2_due_time > current_time)
434  {
435  if (cs->T2_due_time < due_time)
436  due_time = cs->T2_due_time;
437  if (cs->T1_due_time > current_time)
438  {
439  if (cs->T1_due_time < due_time)
440  due_time = cs->T1_due_time;
441  }
442  else
443  {
444  cs->T1_due_time = DBL_MAX;
445  address_info_t *address_list;
446  address_list = create_address_list (i);
447  cs->rebinding = 1;
450  address_list, 1);
451  vec_free (address_list);
452  }
453  }
454  else
455  {
456  cs->T2_due_time = DBL_MAX;
457  address_info_t *address_list;
458  address_list = create_address_list (i);
459  cs->rebinding = 1;
462  address_list, 1);
463  vec_free (address_list);
464  }
465  }
466  }
467  current_time = vlib_time_now (vm);
468  }
469  while (due_time < current_time);
470 
471  sleep_time = due_time - current_time;
472  }
473 
474  return 0;
475 }
476 
477 /* *INDENT-OFF* */
479  .function = dhcp6_client_cp_process,
480  .type = VLIB_NODE_TYPE_PROCESS,
481  .name = "dhcp6-client-cp-process",
482 };
483 /* *INDENT-ON* */
484 
485 static void
487 {
489  vlib_main_t *vm = rm->vlib_main;
490 
493 }
494 
495 static void
497 {
499  vlib_main_t *vm = rm->vlib_main;
500 
503 }
504 
505 static void
507 {
509  vlib_main_t *vm = rm->vlib_main;
510  vlib_node_t *node;
511 
513 
514  vlib_node_set_state (vm, rm->node_index, VLIB_NODE_STATE_POLLING);
515  vlib_start_process (vm, node->runtime_index);
516 }
517 
518 static clib_error_t *
520  unformat_input_t * input,
521  vlib_cli_command_t * cmd)
522 {
524  clib_error_t *error = 0;
525  address_info_t *address_info;
526  f64 current_time = vlib_time_now (vm);
527 
528  /* *INDENT-OFF* */
529  pool_foreach (address_info, dm->address_pool)
530  {
531  vlib_cli_output (vm, "address: %U, "
532  "preferred lifetime: %u, valid lifetime: %u "
533  "(%f remaining)",
534  format_ip6_address, &address_info->address,
535  address_info->preferred_lt, address_info->valid_lt,
536  address_info->due_time - current_time);
537  }
538  /* *INDENT-ON* */
539 
540  return error;
541 }
542 
543 /* *INDENT-OFF* */
545  .path = "show dhcp6 addresses",
546  .short_help = "show dhcp6 addresses",
548 };
549 /* *INDENT-ON* */
550 
551 static clib_error_t *
553  unformat_input_t * input,
554  vlib_cli_command_t * cmd)
555 {
557  clib_error_t *error = 0;
558  client_state_t *cs;
559  f64 current_time = vlib_time_now (vm);
560  u8 *buf1 = 0;
561  u8 *buf2 = 0;
562  const char *rebinding;
563  u32 i;
564 
565  for (i = 0; i < vec_len (rm->client_state_by_sw_if_index); i++)
566  {
567  cs = &rm->client_state_by_sw_if_index[i];
568  if (cs->enabled)
569  {
570  vec_reset_length (buf1);
571  vec_reset_length (buf2);
572  if (cs->T1_due_time != DBL_MAX && cs->T1_due_time > current_time)
573  {
574  buf1 = format (buf1, "%u remaining",
575  (u32) round (cs->T1_due_time - current_time));
576  }
577  else
578  buf1 = format (buf1, "timeout");
579  if (cs->T2_due_time != DBL_MAX && cs->T2_due_time > current_time)
580  buf2 = format (buf2, "%u remaining",
581  (u32) round (cs->T2_due_time - current_time));
582  else
583  buf2 = format (buf2, "timeout");
584  if (cs->rebinding)
585  rebinding = ", REBINDING";
586  else
587  rebinding = "";
588  if (cs->T1)
590  "sw_if_index: %u, T1: %u (%v), "
591  "T2: %u (%v), server index: %d%s", i,
592  cs->T1, buf1, cs->T2, buf2,
593  cs->server_index, rebinding);
594  else
595  vlib_cli_output (vm, "sw_if_index: %u%s", i, rebinding);
596  }
597  }
598 
599  vec_free (buf1);
600  vec_free (buf2);
601 
602  return error;
603 }
604 
605 /* *INDENT-OFF* */
607  .path = "show dhcp6 clients",
608  .short_help = "show dhcp6 clients",
610 };
611 /* *INDENT-ON* */
612 
613 int
615 {
617  vnet_main_t *vnm = rm->vnet_main;
618  vlib_main_t *vm = rm->vlib_main;
619  client_state_t *client_state;
620  client_state_t empty_config = { 0 };
621  address_info_t *address_info;
623 
625  {
626  clib_warning ("Invalid sw_if_index");
627  return 1;
628  }
629 
631  empty_config);
632  client_state = &rm->client_state_by_sw_if_index[sw_if_index];
633 
634  u8 old_enabled = client_state->enabled;
635  if (enable)
636  client_state->enabled = 1;
637  client_state->server_index = ~0;
638 
639  if (!old_enabled && enable)
640  {
641  rm->n_clients++;
642  if (rm->n_clients == 1)
643  {
644  enable_process ();
646  }
647 
650  0, 1);
651  }
652  else if (old_enabled && !enable)
653  {
655 
656  rm->n_clients--;
657  if (rm->n_clients == 0)
658  {
660  disable_process ();
661  }
662 
663  /* *INDENT-OFF* */
664  pool_foreach (address_info, rm->address_pool)
665  {
666  if (address_info->sw_if_index == sw_if_index)
667  {
670  client_state_t *client_state =
673  client_state->server_index,
674  DHCPV6_MSG_RELEASE, address_info,
675  1);
677  &address_info->address,
678  64, 1);
679  if (error)
680  clib_warning ("Failed to delete interface address");
681  pool_put (rm->address_pool, address_info);
682  }
683  }
684  /* *INDENT-ON* */
685  }
686 
687  if (!enable)
688  client_state->enabled = 0;
689 
690  return 0;
691 }
692 
693 static clib_error_t *
695  unformat_input_t * input,
696  vlib_cli_command_t * cmd)
697 {
699  vnet_main_t *vnm = rm->vnet_main;
700  clib_error_t *error = 0;
701  u32 sw_if_index = ~0;
702  u8 enable = 1;
703  unformat_input_t _line_input, *line_input = &_line_input;
704 
705  if (!unformat_user (input, unformat_line_input, line_input))
706  return 0;
707 
708  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
709  {
710  if (unformat
711  (line_input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
712  ;
713  else if (unformat (line_input, "disable"))
714  enable = 0;
715  else
716  {
717  error = clib_error_return (0, "unexpected input `%U'",
718  format_unformat_error, line_input);
719  goto done;
720  }
721  }
722 
723  unformat_free (line_input);
724 
725  if (sw_if_index != ~0)
726  {
727  if (dhcp6_client_enable_disable (sw_if_index, enable) != 0)
728  error = clib_error_return (0, "Invalid sw_if_index");
729  }
730  else
731  error = clib_error_return (0, "Missing sw_if_index");
732 
733 done:
734  return error;
735 }
736 
737 /*?
738  * This command is used to enable/disable DHCPv6 client
739  * on particular interface.
740  *
741  * @cliexpar
742  * @parblock
743  * Example of how to enable DHCPv6 client:
744  * @cliexcmd{dhcp6 client GigabitEthernet2/0/0}
745  * Example of how to disable DHCPv6 client:
746  * @cliexcmd{dhcp6 client GigabitEthernet2/0/0 disable}
747  * @endparblock
748 ?*/
749 /* *INDENT-OFF* */
751  .path = "dhcp6 client",
752  .short_help = "dhcp6 client <interface> [disable]",
754 };
755 /* *INDENT-ON* */
756 
757 static clib_error_t *
759 {
761 
762  rm->vlib_main = vm;
763  rm->vnet_main = vnet_get_main ();
764  rm->api_main = vlibapi_get_main ();
766 
767  return NULL;
768 }
769 
771 
772 /*
773  * fd.io coding-style-patch-verification: ON
774  *
775  * Local Variables:
776  * eval: (c-set-style "gnu")
777  * End:
778  */
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
ip6_address_is_link_local_unicast
static uword ip6_address_is_link_local_unicast(const ip6_address_t *a)
Definition: ip6_packet.h:253
dhcp_ia_na_client_cp_init
static clib_error_t * dhcp_ia_na_client_cp_init(vlib_main_t *vm)
Definition: dhcp6_ia_na_client_cp.c:758
DHCPV6_MSG_API_REPLY
@ DHCPV6_MSG_API_REPLY
Definition: dhcp.api:43
RD_CP_EVENT_INTERRUPT
@ RD_CP_EVENT_INTERRUPT
Definition: dhcp6_ia_na_client_cp.c:66
DHCPV6_MSG_REBIND
@ DHCPV6_MSG_REBIND
Definition: dhcp6_packet.h:41
api.h
unformat_user
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
dhcp6_client_enable_disable_command_fn
static clib_error_t * dhcp6_client_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: dhcp6_ia_na_client_cp.c:694
client_state_t::T1
u32 T1
Definition: dhcp6_ia_na_client_cp.c:40
dhcp6_client_cp_main
static dhcp6_client_cp_main_t dhcp6_client_cp_main
Definition: dhcp6_ia_na_client_cp.c:62
enable_process
static void enable_process(void)
Definition: dhcp6_ia_na_client_cp.c:506
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
create_address_list
static address_info_t * create_address_list(u32 sw_if_index)
Definition: dhcp6_ia_na_client_cp.c:343
vl_api_dhcp6_reply_event_t::n_addresses
u32 n_addresses
Definition: dhcp.api:471
VNET_DHCP6_REPLY_EVENT_FUNCTION
VNET_DHCP6_REPLY_EVENT_FUNCTION(dhcp6_reply_event_handler)
f
vlib_frame_t * f
Definition: interface_output.c:1080
dhcp6_client_cp_main_t::max_valid_due_time
f64 max_valid_due_time
Definition: dhcp6_ia_na_client_cp.c:53
unformat_line_input
unformat_function_t unformat_line_input
Definition: format.h:275
vlib_node_set_state
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:175
dhcp6_send_client_message_params_t::sw_if_index
u32 sw_if_index
Definition: dhcp6_ia_na_client_dp.h:32
preferred_time
u32 preferred_time
Definition: dhcp.api:313
DHCPV6_STATUS_NOADDRS_AVAIL
@ DHCPV6_STATUS_NOADDRS_AVAIL
Definition: dhcp6_packet.h:97
dhcp6_client_enable_disable
int dhcp6_client_enable_disable(u32 sw_if_index, u8 enable)
Definition: dhcp6_ia_na_client_cp.c:614
dhcp6_send_client_message_params_t::msg_type
u8 msg_type
Definition: dhcp6_ia_na_client_dp.h:38
dhcp6_send_client_message_params_t::mrd
u32 mrd
Definition: dhcp6_ia_na_client_dp.h:37
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
vl_api_dhcp6_reply_event_t::msg_type
vl_api_dhcpv6_msg_type_t msg_type
Definition: dhcp.api:465
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
client_state_t::server_index
u32 server_index
Definition: dhcp6_ia_na_client_cp.c:39
vlib_cli_command_t::path
char * path
Definition: cli.h:96
dhcp6_client_cp_main_t::n_clients
u32 n_clients
Definition: dhcp6_ia_na_client_cp.c:52
dhcp6_client_cp_main_t::node_index
u32 node_index
Definition: dhcp6_ia_na_client_cp.c:59
vl_api_dhcp6_reply_event_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: dhcp.api:463
vlib_main_t::node_main
vlib_node_main_t node_main
Definition: main.h:171
valid_time
u32 valid_time
Definition: dhcp.api:312
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
client_state_t::address_count
u32 address_count
Definition: dhcp6_ia_na_client_cp.c:44
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vl_api_dhcp6_reply_event_t::status_code
u16 status_code
Definition: dhcp.api:469
vl_api_dhcp6_reply_event_t::T2
u32 T2
Definition: dhcp.api:467
unformat_input_t
struct _unformat_input_t unformat_input_t
addr
vhost_vring_addr_t addr
Definition: vhost_user.h:130
vlib_frame_t
Definition: node.h:372
vlib_process_signal_event
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:1019
vlib_start_process
void vlib_start_process(vlib_main_t *vm, uword process_index)
Definition: main.c:1416
dhcp6_client_cp_main_t::address_pool
address_info_t * address_pool
Definition: dhcp6_ia_na_client_cp.c:50
error
Definition: cJSON.c:88
i32
signed int i32
Definition: types.h:77
DHCPV6_MSG_RELEASE
@ DHCPV6_MSG_RELEASE
Definition: dhcp6_packet.h:43
dhcp6_send_client_message_params_t::addresses
dhcp6_send_client_message_params_address_t * addresses
Definition: dhcp6_ia_na_client_dp.h:41
vnet_sw_interface_is_api_valid
static uword vnet_sw_interface_is_api_valid(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:285
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
interrupt_process
static void interrupt_process(void)
Definition: dhcp6_ia_na_client_cp.c:486
dhcp6_send_client_message_params_t::T2
u32 T2
Definition: dhcp6_ia_na_client_dp.h:40
vec_elt
#define vec_elt(v, i)
Get vector value at index i.
Definition: vec_bootstrap.h:210
vlib_process_get_events
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:583
dhcp6_clients_show_command_function
static clib_error_t * dhcp6_clients_show_command_function(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: dhcp6_ia_na_client_cp.c:552
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
address_info_t
Definition: dhcp6_ia_na_client_cp.c:27
ip6_add_del_interface_address
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:297
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
unformat_free
static void unformat_free(unformat_input_t *i)
Definition: format.h:155
math.h
client_state_t::T2_due_time
f64 T2_due_time
Definition: dhcp6_ia_na_client_cp.c:43
vl_api_dhcp6_reply_event_t::server_index
u32 server_index
Definition: dhcp.api:464
dhcp6_send_client_message_params_address_t
Definition: dhcp6_ia_na_client_dp.h:23
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
vnet_msg_enum.h
vl_api_dhcp6_reply_event_t
Tell client about a DHCPv6 server reply event.
Definition: dhcp.api:459
address_info_t::due_time
f64 due_time
Definition: dhcp6_ia_na_client_cp.c:33
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
dhcp6_client_cp_main_t::vlib_main
vlib_main_t * vlib_main
Definition: dhcp6_ia_na_client_cp.c:56
dhcp6_client_cp_main_t
Definition: dhcp6_ia_na_client_cp.c:48
uword
u64 uword
Definition: types.h:112
if
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
dhcp6_ia_na_client_dp.h
dhcp6_reply_event_handler
static clib_error_t * dhcp6_reply_event_handler(vl_api_dhcp6_reply_event_t *mp)
Definition: dhcp6_ia_na_client_cp.c:157
dhcp6_send_client_message_params_t::mrt
u32 mrt
Definition: dhcp6_ia_na_client_dp.h:35
vlibapi_get_main
static api_main_t * vlibapi_get_main(void)
Definition: api_common.h:390
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
f64
double f64
Definition: types.h:142
format_unformat_error
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
pool_get
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:255
DHCPV6_MSG_RENEW
@ DHCPV6_MSG_RENEW
Definition: dhcp6_packet.h:40
address_info_t::preferred_lt
u32 preferred_lt
Definition: dhcp6_ia_na_client_cp.c:31
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
address
manual_print typedef address
Definition: ip_types.api:96
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
client_state_t::T2
u32 T2
Definition: dhcp6_ia_na_client_cp.c:41
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
dhcp6_addresses_show_command_function
static clib_error_t * dhcp6_addresses_show_command_function(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: dhcp6_ia_na_client_cp.c:519
dhcp6_send_client_message
void dhcp6_send_client_message(vlib_main_t *vm, u32 sw_if_index, u8 stop, dhcp6_send_client_message_params_t *params)
Definition: dhcp6_ia_na_client_dp.c:358
api_main_t
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:228
dhcp6_client_cp_main_t::api_main
api_main_t * api_main
Definition: dhcp6_ia_na_client_cp.c:58
dhcp6_client_cp_main_t::vnet_main
vnet_main_t * vnet_main
Definition: dhcp6_ia_na_client_cp.c:57
dhcp6_send_client_message_params_t
Definition: dhcp6_ia_na_client_dp.h:30
address_info_t::address
ip6_address_t address
Definition: dhcp6_ia_na_client_cp.c:30
disable_process
static void disable_process(void)
Definition: dhcp6_ia_na_client_cp.c:496
vnet_main_t
Definition: vnet.h:76
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
vl_api_dhcp6_reply_event_t::inner_status_code
u16 inner_status_code
Definition: dhcp.api:468
dhcp6_addresses_show_command
static vlib_cli_command_t dhcp6_addresses_show_command
(constructor) VLIB_CLI_COMMAND (dhcp6_addresses_show_command)
Definition: dhcp6_ia_na_client_cp.c:544
unformat_vnet_sw_interface
unformat_function_t unformat_vnet_sw_interface
Definition: interface_funcs.h:459
vlib_process_wait_for_event_or_clock
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:755
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
vec_validate_init_empty
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header,...
Definition: vec.h:570
client_state_t::enabled
u8 enabled
Definition: dhcp6_ia_na_client_cp.c:38
ip.h
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
dhcp6_clients_enable_disable
void dhcp6_clients_enable_disable(u8 enable)
Definition: dhcp6_client_common_dp.c:448
VLIB_NODE_TYPE_PROCESS
@ VLIB_NODE_TYPE_PROCESS
Definition: node.h:84
vl_api_dhcp6_reply_event_t::addresses
vl_api_dhcp6_address_info_t addresses[n_addresses]
Definition: dhcp.api:472
RD_CP_EVENT_DISABLE
@ RD_CP_EVENT_DISABLE
Definition: dhcp6_ia_na_client_cp.c:67
vl_api_dhcp6_reply_event_t::T1
u32 T1
Definition: dhcp.api:466
dhcp6_client_cp_process_node
vlib_node_registration_t dhcp6_client_cp_process_node
(constructor) VLIB_REGISTER_NODE (dhcp6_client_cp_process_node)
Definition: dhcp6_ia_na_client_cp.c:478
vlib_main_t
Definition: main.h:102
vlib_node_t
Definition: node.h:247
dhcp6_send_client_message_params_t::irt
u32 irt
Definition: dhcp6_ia_na_client_dp.h:34
u8
unsigned char u8
Definition: types.h:56
DHCPV6_MSG_SOLICIT
@ DHCPV6_MSG_SOLICIT
Definition: dhcp6_packet.h:36
clib_error_t
Definition: clib_error.h:21
rt
vnet_interface_output_runtime_t * rt
Definition: interface_output.c:399
address_info_t::sw_if_index
u32 sw_if_index
Definition: dhcp6_ia_na_client_cp.c:29
DHCPV6_STATUS_UNSPEC_FAIL
@ DHCPV6_STATUS_UNSPEC_FAIL
Definition: dhcp6_packet.h:96
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
format_ip6_address
format_function_t format_ip6_address
Definition: format.h:91
dhcp6_packet.h
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
DHCPV6_MSG_API_ADVERTISE
@ DHCPV6_MSG_API_ADVERTISE
Definition: dhcp.api:38
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:325
client_state_t::T1_due_time
f64 T1_due_time
Definition: dhcp6_ia_na_client_cp.c:42
dhcp6_client_cp_main_t::client_state_by_sw_if_index
client_state_t * client_state_by_sw_if_index
Definition: dhcp6_ia_na_client_cp.c:51
vnet.h
ip6_addresses_equal
static u8 ip6_addresses_equal(ip6_address_t *address1, ip6_address_t *address2)
Definition: dhcp6_ia_na_client_cp.c:149
vlib_node_runtime_t
Definition: node.h:454
vlib_node_main_t::nodes
vlib_node_t ** nodes
Definition: node.h:668
vlib_cli_command_t
Definition: cli.h:92
address_info_t::valid_lt
u32 valid_lt
Definition: dhcp6_ia_na_client_cp.c:32
client_state_t
Definition: dhcp6_ia_na_client_cp.c:36
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
ip6.h
dhcp6_send_client_message_params_t::T1
u32 T1
Definition: dhcp6_ia_na_client_dp.h:39
dhcp6_send_client_message_params_t::server_index
u32 server_index
Definition: dhcp6_ia_na_client_dp.h:33
send_client_message_start_stop
static void send_client_message_start_stop(u32 sw_if_index, u32 server_index, u8 msg_type, address_info_t *address_list, u8 start)
Definition: dhcp6_ia_na_client_cp.c:71
client_state_t::rebinding
u8 rebinding
Definition: dhcp6_ia_na_client_cp.c:45
dhcp6_client_cp_process
static uword dhcp6_client_cp_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: dhcp6_ia_na_client_cp.c:366
DHCPV6_MSG_REQUEST
@ DHCPV6_MSG_REQUEST
Definition: dhcp6_packet.h:38
dhcp6_client_enable_disable_command
static vlib_cli_command_t dhcp6_client_enable_disable_command
(constructor) VLIB_CLI_COMMAND (dhcp6_client_enable_disable_command)
Definition: dhcp6_ia_na_client_cp.c:750
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
dhcp6_send_client_message_params_t::mrc
u32 mrc
Definition: dhcp6_ia_na_client_dp.h:36
dhcp6_clients_show_command
static vlib_cli_command_t dhcp6_clients_show_command
(constructor) VLIB_CLI_COMMAND (dhcp6_clients_show_command)
Definition: dhcp6_ia_na_client_cp.c:606
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169