FD.io VPP  v19.08.3-2-gbabecb413
Vector Packet Processing
dhcp6_ia_na_client_dp.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 <vlib/vlib.h>
17 #include <vnet/dhcp/dhcp6_packet.h>
18 #include <vnet/dhcp/dhcp_proxy.h>
19 #include <vnet/mfib/mfib_table.h>
20 #include <vnet/mfib/ip6_mfib.h>
21 #include <vnet/fib/fib.h>
22 #include <vnet/adj/adj_mcast.h>
23 #include <vnet/ip/ip6_neighbor.h>
24 #include <vlibapi/api_common.h>
25 #include <vlibmemory/api.h>
28 
29 #include <vnet/vnet_msg_enum.h>
30 
31 #define vl_typedefs /* define message structures */
32 #include <vnet/vnet_all_api_h.h>
33 #undef vl_typedefs
34 
35 #define vl_endianfun /* define message structures */
36 #include <vnet/vnet_all_api_h.h>
37 #undef vl_endianfun
38 
39 /* instantiate all the print functions we know about */
40 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
41 #define vl_printfun
42 #include <vnet/vnet_all_api_h.h>
43 #undef vl_printfun
44 
46 
49 
50 static void
52 {
55  uword ni = cm->publisher_node;
56  uword et = cm->publisher_et;
57 
58  if (ni == (uword) ~ 0)
59  return;
60  address_report_t *q =
61  vlib_process_signal_event_data (vm, ni, et, 1, sizeof *q);
62 
63  *q = *r;
64 }
65 
66 int
68 {
69  void vl_api_rpc_call_main_thread (void *fp, u8 * data, u32 data_length);
70  vl_api_rpc_call_main_thread (signal_report, (u8 *) r, sizeof *r);
71  return 0;
72 }
73 
74 void
75 dhcp6_set_publisher_node (uword node_index, uword event_type)
76 {
78  cm->publisher_node = node_index;
79  cm->publisher_et = event_type;
80 }
81 
82 static void
84  dhcp6_ia_na_client_state_t * client_state)
85 {
86  u32 bi0;
87 
88  client_state->keep_sending_client_message = 0;
89  vec_free (client_state->params.addresses);
90  if (client_state->buffer)
91  {
92  bi0 = vlib_get_buffer_index (vm, client_state->buffer);
93  vlib_buffer_free (vm, &bi0, 1);
94  client_state->buffer = 0;
95  adj_unlock (client_state->adj_index);
96  client_state->adj_index = ~0;
97  }
98 }
99 
100 static vlib_buffer_t *
102  dhcp6_ia_na_client_state_t * client_state,
103  u32 type)
104 {
106  vlib_buffer_t *b;
107  u32 bi;
108  ip6_header_t *ip;
109  udp_header_t *udp;
110  dhcpv6_header_t *dhcp;
111  ip6_address_t src_addr;
112  u32 dhcp_opt_len = 0;
113  client_state->transaction_start = vlib_time_now (vm);
114  u32 n_addresses;
115  u32 i;
116 
117  /* Get a link-local address */
118  src_addr = ip6_neighbor_get_link_local_address (sw_if_index);
119 
120  if (src_addr.as_u8[0] != 0xfe)
121  {
122  clib_warning ("Could not find source address to send DHCPv6 packet");
123  return NULL;
124  }
125 
126  if (vlib_buffer_alloc (vm, &bi, 1) != 1)
127  {
128  clib_warning ("Buffer allocation failed");
129  return NULL;
130  }
131 
132  b = vlib_get_buffer (vm, bi);
133  vnet_buffer (b)->sw_if_index[VLIB_RX] = sw_if_index;
134  vnet_buffer (b)->sw_if_index[VLIB_TX] = sw_if_index;
137  sw_if_index);
138  vnet_buffer (b)->ip.adj_index[VLIB_TX] = client_state->adj_index;
139  b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
140 
142  udp = (udp_header_t *) (ip + 1);
143  dhcp = (dhcpv6_header_t *) (udp + 1);
144 
145  ip->src_address = src_addr;
146  ip->hop_limit = 255;
148  clib_host_to_net_u32 (0x6 << 28);
149  ip->payload_length = 0;
150  ip->protocol = IP_PROTOCOL_UDP;
151 
152  udp->src_port = clib_host_to_net_u16 (DHCPV6_CLIENT_PORT);
153  udp->dst_port = clib_host_to_net_u16 (DHCPV6_SERVER_PORT);
154  udp->checksum = 0;
155  udp->length = 0;
156 
157  dhcp->msg_type = type;
158  dhcp->xid[0] = (client_state->transaction_id & 0x00ff0000) >> 16;
159  dhcp->xid[1] = (client_state->transaction_id & 0x0000ff00) >> 8;
160  dhcp->xid[2] = (client_state->transaction_id & 0x000000ff) >> 0;
161 
162  void *d = (void *) dhcp->data;
163  dhcpv6_option_t *duid;
164  dhcpv6_elapsed_t *elapsed;
165  dhcpv6_ia_header_t *ia_hdr;
166  dhcpv6_ia_opt_addr_t *opt_addr;
167  if (type == DHCPV6_MSG_SOLICIT || type == DHCPV6_MSG_REQUEST ||
168  type == DHCPV6_MSG_RENEW || type == DHCPV6_MSG_REBIND ||
169  type == DHCPV6_MSG_RELEASE)
170  {
171  duid = (dhcpv6_option_t *) d;
172  duid->option = clib_host_to_net_u16 (DHCPV6_OPTION_CLIENTID);
173  duid->length = clib_host_to_net_u16 (CLIENT_DUID_LENGTH);
175  d += sizeof (*duid) + CLIENT_DUID_LENGTH;
176 
177  if (client_state->params.server_index != ~0)
178  {
179  server_id_t *se =
180  &ccm->server_ids[client_state->params.server_index];
181 
182  duid = (dhcpv6_option_t *) d;
183  duid->option = clib_host_to_net_u16 (DHCPV6_OPTION_SERVERID);
184  duid->length = clib_host_to_net_u16 (se->len);
185  clib_memcpy (duid + 1, se->data, se->len);
186  d += sizeof (*duid) + se->len;
187  }
188 
189  elapsed = (dhcpv6_elapsed_t *) d;
190  elapsed->opt.option = clib_host_to_net_u16 (DHCPV6_OPTION_ELAPSED_TIME);
191  elapsed->opt.length =
192  clib_host_to_net_u16 (sizeof (*elapsed) - sizeof (elapsed->opt));
193  elapsed->elapsed_10ms = 0;
194  client_state->elapsed_pos =
195  (char *) &elapsed->elapsed_10ms -
196  (char *) vlib_buffer_get_current (b);
197  d += sizeof (*elapsed);
198 
199  ia_hdr = (dhcpv6_ia_header_t *) d;
200  ia_hdr->opt.option = clib_host_to_net_u16 (DHCPV6_OPTION_IA_NA);
201  ia_hdr->iaid = clib_host_to_net_u32 (DHCPV6_CLIENT_IAID);
202  ia_hdr->t1 = clib_host_to_net_u32 (client_state->params.T1);
203  ia_hdr->t2 = clib_host_to_net_u32 (client_state->params.T2);
204  d += sizeof (*ia_hdr);
205 
206  n_addresses = vec_len (client_state->params.addresses);
207 
208  ia_hdr->opt.length =
209  clib_host_to_net_u16 (sizeof (*ia_hdr) +
210  n_addresses * sizeof (*opt_addr) -
211  sizeof (ia_hdr->opt));
212 
213  for (i = 0; i < n_addresses; i++)
214  {
216  &client_state->params.addresses[i];
217  opt_addr = (dhcpv6_ia_opt_addr_t *) d;
218  opt_addr->opt.option = clib_host_to_net_u16 (DHCPV6_OPTION_IAADDR);
219  opt_addr->opt.length =
220  clib_host_to_net_u16 (sizeof (*opt_addr) -
221  sizeof (opt_addr->opt));
222  opt_addr->addr = addr->address;
223  opt_addr->valid = clib_host_to_net_u32 (addr->valid_lt);
224  opt_addr->preferred = clib_host_to_net_u32 (addr->preferred_lt);
225  d += sizeof (*opt_addr);
226  }
227  }
228  else
229  {
230  clib_warning ("State not implemented");
231  }
232 
233  dhcp_opt_len = ((u8 *) d) - dhcp->data;
234  udp->length =
235  clib_host_to_net_u16 (sizeof (*udp) + sizeof (*dhcp) + dhcp_opt_len);
236  ip->payload_length = udp->length;
237  b->current_length =
238  sizeof (*ip) + sizeof (*udp) + sizeof (*dhcp) + dhcp_opt_len;
239 
241 
242  return b;
243 }
244 
245 static inline u8
247  dhcp6_ia_na_client_state_t * client_state,
248  f64 current_time, f64 * due_time)
249 {
250  vlib_buffer_t *p0;
251  vlib_frame_t *f;
252  u32 *to_next;
253  u32 next_index;
254  vlib_buffer_t *c0;
255  ip6_header_t *ip;
256  udp_header_t *udp;
257  u32 ci0;
258  int bogus_length = 0;
259 
261 
262  f64 now = vlib_time_now (vm);
263 
264  if (!client_state->keep_sending_client_message)
265  return false;
266 
267  params = &client_state->params;
268 
269  if (client_state->due_time > current_time)
270  {
271  *due_time = client_state->due_time;
272  return true;
273  }
274 
275  p0 = client_state->buffer;
276 
277  next_index = ip6_rewrite_mcast_node.index;
278 
279  c0 = vlib_buffer_copy (vm, p0);
280  if (c0 == NULL)
281  return client_state->keep_sending_client_message;
282 
283  ci0 = vlib_get_buffer_index (vm, c0);
284 
286  udp = (udp_header_t *) (ip + 1);
287 
288  u16 *elapsed_field = (u16 *) ((void *) ip + client_state->elapsed_pos);
289  *elapsed_field =
290  clib_host_to_net_u16 ((u16)
291  ((now - client_state->transaction_start) * 100));
292 
293  udp->checksum = 0;
294  udp->checksum =
295  ip6_tcp_udp_icmp_compute_checksum (vm, 0, ip, &bogus_length);
296 
297  f = vlib_get_frame_to_node (vm, next_index);
298  to_next = vlib_frame_vector_args (f);
299  to_next[0] = ci0;
300  f->n_vectors = 1;
301  vlib_put_frame_to_node (vm, next_index, f);
302 
303  if (params->mrc != 0 && --client_state->n_left == 0)
304  stop_sending_client_message (vm, client_state);
305  else
306  {
307  client_state->sleep_interval =
308  (2 + random_f64_from_to (-0.1, 0.1)) * client_state->sleep_interval;
309  if (client_state->sleep_interval > params->mrt)
310  client_state->sleep_interval =
311  (1 + random_f64_from_to (-0.1, 0.1)) * params->mrt;
312 
313  client_state->due_time = current_time + client_state->sleep_interval;
314 
315  if (params->mrd != 0
316  && current_time > client_state->start_time + params->mrd)
317  stop_sending_client_message (vm, client_state);
318  else
319  *due_time = client_state->due_time;
320  }
321 
322  return client_state->keep_sending_client_message;
323 }
324 
325 static uword
327  vlib_node_runtime_t * rt,
328  vlib_frame_t * f0)
329 {
331  dhcp6_ia_na_client_state_t *client_state;
332  uword *event_data = 0;
333  f64 sleep_time = 1e9;
334  f64 current_time;
335  f64 due_time;
336  f64 dt = 0;
337  int i;
338 
339  while (true)
340  {
341  vlib_process_wait_for_event_or_clock (vm, sleep_time);
342  vlib_process_get_events (vm, &event_data);
343  vec_reset_length (event_data);
344 
345  current_time = vlib_time_now (vm);
346  do
347  {
348  due_time = current_time + 1e9;
349  for (i = 0; i < vec_len (cm->client_state_by_sw_if_index); i++)
350  {
351  client_state = &cm->client_state_by_sw_if_index[i];
352  if (!client_state->entry_valid)
353  continue;
355  (vm, client_state, current_time, &dt) && (dt < due_time))
356  due_time = dt;
357  }
358  current_time = vlib_time_now (vm);
359  }
360  while (due_time < current_time);
361 
362  sleep_time = due_time - current_time;
363  }
364 
365  return 0;
366 }
367 
368 /* *INDENT-OFF* */
371  .type = VLIB_NODE_TYPE_PROCESS,
372  .name = "send-dhcp6-client-message-process",
373 };
374 /* *INDENT-ON* */
375 
376 void
379 {
381  dhcp6_ia_na_client_state_t *client_state = 0;
382  dhcp6_ia_na_client_state_t empty_state = { 0, };
383 
384  ASSERT (~0 != sw_if_index);
385 
387  empty_state);
388  client_state = &cm->client_state_by_sw_if_index[sw_if_index];
389  if (!client_state->entry_valid)
390  {
391  client_state->entry_valid = 1;
392  client_state->adj_index = ~0;
393  }
394 
395  stop_sending_client_message (vm, client_state);
396 
397  if (!stop)
398  {
399  client_state->keep_sending_client_message = 1;
400  vec_free (client_state->params.addresses);
401  client_state->params = *params;
402  client_state->params.addresses = vec_dup (params->addresses);
403  client_state->n_left = params->mrc;
404  client_state->start_time = vlib_time_now (vm);
405  client_state->sleep_interval =
406  (1 + random_f64_from_to (-0.1, 0.1)) * params->irt;
407  client_state->due_time = 0; /* send first packet ASAP */
408  client_state->transaction_id = random_u32 (&cm->seed) & 0x00ffffff;
409  client_state->buffer =
410  create_buffer_for_client_message (vm, sw_if_index, client_state,
411  params->msg_type);
412  if (!client_state->buffer)
413  client_state->keep_sending_client_message = 0;
414  else
417  1, 0);
418  }
419 }
420 
421 void
424 {
425  vl_api_dhcp6_send_client_message_reply_t *rmp;
428  u32 n_addresses;
429  u32 i;
430  int rv = 0;
431 
433 
435  REPLY_MACRO (VL_API_DHCP6_SEND_CLIENT_MESSAGE_REPLY);
436 
437  if (rv != 0)
438  return;
439 
440  params.sw_if_index = ntohl (mp->sw_if_index);
441  params.server_index = ntohl (mp->server_index);
442  params.irt = ntohl (mp->irt);
443  params.mrt = ntohl (mp->mrt);
444  params.mrc = ntohl (mp->mrc);
445  params.mrd = ntohl (mp->mrd);
446  params.msg_type = mp->msg_type;
447  params.T1 = ntohl (mp->T1);
448  params.T2 = ntohl (mp->T2);
449  n_addresses = ntohl (mp->n_addresses);
450  params.addresses = 0;
451  if (n_addresses > 0)
452  vec_validate (params.addresses, n_addresses - 1);
453  for (i = 0; i < n_addresses; i++)
454  {
457  addr->preferred_lt = ntohl (ai->preferred_time);
458  addr->valid_lt = ntohl (ai->valid_time);
459  memcpy (addr->address.as_u8, ai->address, 16);
460  }
461 
462  dhcp6_send_client_message (vm, ntohl (mp->sw_if_index), mp->stop, &params);
463 }
464 
465 clib_error_t *
467  _vnet_dhcp6_reply_event_function_list_elt_t
468  * elt)
469 {
470  clib_error_t *error = 0;
471 
472  while (elt)
473  {
474  error = elt->fp (data);
475  if (error)
476  return error;
477  elt = elt->next_dhcp6_reply_event_function;
478  }
479 
480  return error;
481 }
482 
483 static uword
485  vlib_frame_t * f)
486 {
487  /* These cross the longjmp boundary (vlib_process_wait_for_event)
488  * and need to be volatile - to prevent them from being optimized into
489  * a register - which could change during suspension */
490 
491  while (1)
492  {
494  uword event_type = DHCP6_DP_REPLY_REPORT;
495  void *event_data = vlib_process_get_event_data (vm, &event_type);
496 
497  int i;
498  if (event_type == DHCP6_DP_REPLY_REPORT)
499  {
500  address_report_t *events = event_data;
501  for (i = 0; i < vec_len (events); i++)
502  {
503  u32 event_size =
504  sizeof (vl_api_dhcp6_reply_event_t) +
505  vec_len (events[i].addresses) *
507  vl_api_dhcp6_reply_event_t *event = clib_mem_alloc (event_size);
508  clib_memset (event, 0, event_size);
509 
510  event->sw_if_index = htonl (events[i].body.sw_if_index);
511  event->server_index = htonl (events[i].body.server_index);
512  event->msg_type = events[i].body.msg_type;
513  event->T1 = htonl (events[i].body.T1);
514  event->T2 = htonl (events[i].body.T2);
515  event->inner_status_code =
516  htons (events[i].body.inner_status_code);
517  event->status_code = htons (events[i].body.status_code);
518  event->preference = events[i].body.preference;
519 
520  event->n_addresses = htonl (vec_len (events[i].addresses));
522  (typeof (address)) event->addresses;
523  u32 j;
524  for (j = 0; j < vec_len (events[i].addresses); j++)
525  {
526  dhcp6_address_info_t *info = &events[i].addresses[j];
527  memcpy (address->address, &info->address, 16);
528  address->valid_time = htonl (info->valid_time);
529  address->preferred_time = htonl (info->preferred_time);
530  address++;
531  }
532  vec_free (events[i].addresses);
533 
537 
539  /* *INDENT-OFF* */
540  pool_foreach(reg, vpe_api_main.dhcp6_reply_events_registrations,
541  ({
542  vl_api_registration_t *vl_reg;
543  vl_reg =
544  vl_api_client_index_to_registration (reg->client_index);
545  if (vl_reg && vl_api_can_send_msg (vl_reg))
546  {
547  vl_api_dhcp6_reply_event_t *msg =
548  vl_msg_api_alloc (event_size);
549  clib_memcpy (msg, event, event_size);
550  msg->_vl_msg_id = htons (VL_API_DHCP6_REPLY_EVENT);
551  msg->client_index = reg->client_index;
552  msg->pid = reg->client_pid;
553  vl_api_send_msg (vl_reg, (u8 *) msg);
554  }
555  }));
556  /* *INDENT-ON* */
557 
558  clib_mem_free (event);
559  }
560  }
561  vlib_process_put_event_data (vm, event_data);
562  }
563 
564  return 0;
565 }
566 
567 /* *INDENT-OFF* */
569  .function = dhcp6_reply_process,
570  .type = VLIB_NODE_TYPE_PROCESS,
571  .name = "dhcp6-reply-publisher-process",
572 };
573 /* *INDENT-ON* */
574 
575 void
578 {
580  vl_api_want_dhcp6_reply_events_reply_t *rmp;
581  int rv = 0;
582 
583  uword *p =
584  hash_get (am->dhcp6_reply_events_registration_hash, mp->client_index);
586  if (p)
587  {
588  if (mp->enable_disable)
589  {
590  clib_warning ("pid %d: already enabled...", ntohl (mp->pid));
591  rv = VNET_API_ERROR_INVALID_REGISTRATION;
592  goto reply;
593  }
594  else
595  {
596  rp = pool_elt_at_index (am->dhcp6_reply_events_registrations, p[0]);
597  pool_put (am->dhcp6_reply_events_registrations, rp);
598  hash_unset (am->dhcp6_reply_events_registration_hash,
599  mp->client_index);
600  if (pool_elts (am->dhcp6_reply_events_registrations) == 0)
602  goto reply;
603  }
604  }
605  if (mp->enable_disable == 0)
606  {
607  clib_warning ("pid %d: already disabled...", ntohl (mp->pid));
608  rv = VNET_API_ERROR_INVALID_REGISTRATION;
609  goto reply;
610  }
611  pool_get (am->dhcp6_reply_events_registrations, rp);
612  rp->client_index = mp->client_index;
613  rp->client_pid = ntohl (mp->pid);
614  hash_set (am->dhcp6_reply_events_registration_hash, rp->client_index,
615  rp - am->dhcp6_reply_events_registrations);
618 
619 reply:
620  REPLY_MACRO (VL_API_WANT_DHCP6_REPLY_EVENTS_REPLY);
621 }
622 
623 static clib_error_t *
625 {
627 
628  cm->vlib_main = vm;
629  cm->vnet_main = vnet_get_main ();
630 
631  cm->publisher_node = ~0;
632 
633  cm->seed = 0xdeaccabe;
634 
635  return 0;
636 }
637 
639 
640 /*
641  * fd.io coding-style-patch-verification: ON
642  *
643  * Local Variables:
644  * eval: (c-set-style "gnu")
645  * End:
646  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:124
static void signal_report(address_report_t *r)
typedef address
Definition: ip_types.api:83
#define hash_set(h, key, value)
Definition: hash.h:255
static vlib_buffer_t * create_buffer_for_client_message(vlib_main_t *vm, u32 sw_if_index, dhcp6_ia_na_client_state_t *client_state, u32 type)
static clib_error_t * dhcp6_client_init(vlib_main_t *vm)
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:673
#define hash_unset(h, key)
Definition: hash.h:261
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
Definition: buffer_funcs.h:865
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
Definition: node_funcs.h:593
static void stop_sending_client_message(vlib_main_t *vm, dhcp6_ia_na_client_state_t *client_state)
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
u8 as_u8[16]
Definition: ip6_packet.h:48
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:279
_vnet_dhcp6_reply_event_function_list_elt_t * functions
void vl_api_want_dhcp6_reply_events_t_handler(vl_api_want_dhcp6_reply_events_t *mp)
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:113
vlib_node_registration_t dhcp6_reply_process_node
(constructor) VLIB_REGISTER_NODE (dhcp6_reply_process_node)
for(i=1;i<=collision_buckets;i++)
int i
#define DHCPV6_CLIENT_PORT
Definition: dhcp6_packet.h:26
u8 data[128]
Definition: ipsec.api:251
#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:147
ip6_address_t src_address
Definition: ip6_packet.h:383
unsigned char u8
Definition: types.h:56
static vlib_buffer_t * vlib_buffer_copy(vlib_main_t *vm, vlib_buffer_t *b)
Definition: buffer_funcs.h:964
void dhcp6_set_publisher_node(uword node_index, uword event_type)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
double f64
Definition: types.h:142
#define clib_memcpy(d, s, n)
Definition: string.h:180
vlib_node_registration_t ip6_rewrite_mcast_node
(constructor) VLIB_REGISTER_NODE (ip6_rewrite_mcast_node)
Definition: ip6_forward.c:2244
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:493
vl_api_interface_index_t sw_if_index
Definition: gre.api:50
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:173
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:516
Send DHCPv6 client message of specified type.
Definition: dhcp.api:273
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
Definition: main.c:185
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
Definition: vlib_api.c:608
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
Definition: adj.c:347
unsigned int u32
Definition: types.h:88
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
Definition: buffer_funcs.h:257
vl_api_fib_path_type_t type
Definition: fib_types.api:123
vnet_crypto_main_t * cm
Definition: quic_crypto.c:41
#define hash_get(h, key)
Definition: hash.h:249
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:514
dhcp6_ia_na_client_main_t dhcp6_ia_na_client_main
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:934
unsigned short u16
Definition: types.h:57
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
Definition: main.c:194
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:229
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:286
#define vec_dup(V)
Return copy of vector (no header, no alignment)
Definition: vec.h:375
static void * vlib_process_signal_event_data(vlib_main_t *vm, uword node_index, uword type_opaque, uword n_data_elts, uword n_data_elt_bytes)
Definition: node_funcs.h:828
#define REPLY_MACRO(t)
dhcp6_ia_na_client_state_t * client_state_by_sw_if_index
dhcpv6_duid_ll_string_t client_duid
dhcp6_ia_na_client_public_main_t dhcp6_ia_na_client_public_main
#define CLIENT_DUID_LENGTH
#define BAD_SW_IF_INDEX_LABEL
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
u16 n_vectors
Definition: node.h:397
#define DHCPV6_CLIENT_IAID
vlib_main_t * vm
Definition: buffer.c:323
dhcp6_send_client_message_params_address_t * addresses
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
#define clib_warning(format, args...)
Definition: error.h:59
void vl_api_dhcp6_send_client_message_t_handler(vl_api_dhcp6_send_client_message_t *mp)
u16 ip6_tcp_udp_icmp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip6_header_t *ip0, int *bogus_lengthp)
Definition: ip6_forward.c:1010
#define ASSERT(truth)
Struct representing DHCPv6 address.
Definition: dhcp.api:231
dhcp6_send_client_message_params_t params
static void clib_mem_free(void *p)
Definition: mem.h:226
void dhcp6_send_client_message(vlib_main_t *vm, u32 sw_if_index, u8 stop, dhcp6_send_client_message_params_t *params)
static void * clib_mem_alloc(uword size)
Definition: mem.h:153
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
dhcp6_client_common_main_t dhcp6_client_common_main
Tell client about a DHCPv6 server reply event.
Definition: dhcp.api:383
ip6_address_t ip6_neighbor_get_link_local_address(u32 sw_if_index)
Definition: ip6_neighbor.c:242
u32 ip_version_traffic_class_and_flow_label
Definition: ip6_packet.h:370
Definition: defs.h:47
u16 payload_length
Definition: ip6_packet.h:374
static void * vlib_process_get_event_data(vlib_main_t *vm, uword *return_event_type_opaque)
Definition: node_funcs.h:463
vl_api_address_t ip
Definition: l2.api:489
clib_error_t * call_dhcp6_reply_event_callbacks(void *data, _vnet_dhcp6_reply_event_function_list_elt_t *elt)
static uword dhcp6_reply_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
int dhcp6_publish_report(address_report_t *r)
VLIB buffer representation.
Definition: buffer.h:102
u64 uword
Definition: types.h:112
dhcp6_address_info_t * addresses
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:244
vl_api_dhcp6_address_info_t addresses[n_addresses]
Definition: dhcp.api:288
static vlib_node_registration_t send_dhcp6_client_message_process_node
(constructor) VLIB_REGISTER_NODE (send_dhcp6_client_message_process_node)
static u8 check_send_client_message(vlib_main_t *vm, dhcp6_ia_na_client_state_t *client_state, f64 current_time, f64 *due_time)
Register for DHCPv6 reply events.
Definition: dhcp.api:346
#define DHCPV6_SERVER_PORT
Definition: dhcp6_packet.h:27
static uword send_dhcp6_client_message_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f0)
#define vnet_buffer(b)
Definition: buffer.h:365
static u32 random_u32(u32 *seed)
32-bit random number generator
Definition: random.h:69
static void vlib_process_put_event_data(vlib_main_t *vm, void *event_data)
Definition: node_funcs.h:500
adj_index_t adj_mcast_add_or_lock(fib_protocol_t proto, vnet_link_t link_type, u32 sw_if_index)
Mcast Adjacency.
Definition: adj_mcast.c:51
dhcp6_report_common_t body
static const ip6_address_t all_dhcp6_relay_agents_and_servers
#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
vpe_api_main_t vpe_api_main
Definition: interface_api.c:49
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
Definition: buffer_funcs.h:612
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:85
Definition: defs.h:46
ip6_address_t dst_address
Definition: ip6_packet.h:383
#define VALIDATE_SW_IF_INDEX(mp)
static_always_inline f64 random_f64_from_to(f64 from, f64 to)
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128