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