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