|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
38 se = &
ccm->server_ids[
i];
57 client_duid.hardware_type = clib_host_to_net_u16 (1);
78 "setting DHCPv6 DUID link-layer address to random value");
90 #define foreach_dhcpv6_client \
91 _(DROP, "error-drop") \
92 _(LOOKUP, "ip6-lookup")
96 #define _(sym,str) DHCPV6_CLIENT_NEXT_##sym,
116 s =
format (s,
"nothing");
145 dhcpv6_option_t *option;
150 u32 next0 = DHCPV6_CLIENT_NEXT_DROP;
155 u8 client_id_present = 0;
173 u32 dhcpv6_ip6_payload_offset =
174 (
u8 *) dhcpv60 - ((
u8 *) ip0 +
sizeof (*ip0));
177 dhcpv6_ip6_payload_offset -
sizeof (*dhcpv60);
183 ia_na_client_state = 0;
193 (dhcpv60->
xid[0] << 16) + (dhcpv60->
xid[1] << 8) +
195 if (ia_na_client_state && ia_na_client_state->
transaction_id == xid)
197 else if (pd_client_state && pd_client_state->
transaction_id == xid)
202 (
"Received DHCPv6 message with wrong Transaction ID");
214 option = (dhcpv6_option_t *) (dhcpv60 + 1);
215 while (options_length > 0)
218 clib_net_to_host_u16 (option->length) +
222 (
"remaining payload length < option length (%d < %d)",
224 clib_net_to_host_u16 (option->length) +
228 u16 oo = clib_net_to_host_u16 (option->option);
229 if (oo == DHCPV6_OPTION_IA_NA || oo == DHCPV6_OPTION_IA_PD)
231 u8 discard_option = 0;
232 dhcpv6_ia_header_t *ia_header = (
void *) option;
233 iaid = clib_net_to_host_u32 (ia_header->iaid);
234 u32 T1 = clib_net_to_host_u32 (ia_header->t1);
235 u32 T2 = clib_net_to_host_u32 (ia_header->t2);
238 if (T1 != 0 && T2 != 0 && T1 > T2)
245 dhcpv6_option_t *inner_option =
246 (
void *) ia_header->data;
247 u16 inner_options_length =
248 clib_net_to_host_u16 (option->length) -
249 (
sizeof (*ia_header) -
sizeof (dhcpv6_option_t));
250 while (inner_options_length > 0)
253 clib_net_to_host_u16 (inner_option->option);
256 else if (inner_oo == DHCPV6_OPTION_IAADDR)
258 dhcpv6_ia_opt_addr_t *iaaddr =
259 (
void *) inner_option;
263 &addresses[n_addresses];
265 clib_net_to_host_u32 (iaaddr->preferred);
267 clib_net_to_host_u32 (iaaddr->valid);
268 address_info->
address = iaaddr->addr;
270 else if (inner_oo == DHCPV6_OPTION_IAPREFIX)
272 dhcpv6_ia_opt_pd_t *iaprefix =
273 (
void *) inner_option;
277 &prefixes[n_prefixes];
279 clib_net_to_host_u32 (iaprefix->preferred);
281 clib_net_to_host_u32 (iaprefix->valid);
283 prefix_info->
prefix = iaprefix->addr;
285 else if (inner_oo == DHCPV6_OPTION_STATUS_CODE)
287 dhcpv6_status_code_t *sc =
288 (
void *) inner_option;
290 clib_net_to_host_u16 (sc->status_code);
292 inner_options_length -=
293 sizeof (*inner_option) +
294 clib_net_to_host_u16 (inner_option->length);
296 (
void *) ((
u8 *) inner_option +
297 sizeof (*inner_option) +
299 (inner_option->length));
302 else if (oo == DHCPV6_OPTION_CLIENTID)
304 if (client_id_present)
307 (
"Duplicate Client ID in received DHVPv6 message");
312 u16 len = clib_net_to_host_u16 (option->length);
313 client_id_present = 1;
315 0 != memcmp (option->data,
320 (
"Unrecognized client DUID inside received DHVPv6 message");
325 else if (oo == DHCPV6_OPTION_SERVERID)
330 (
"Duplicate Server ID in received DHVPv6 message");
335 u16 ol = clib_net_to_host_u16 (option->length);
339 (
"Server DUID (without type code) is longer than 128 octets");
349 else if (oo == DHCPV6_OPTION_PREFERENCE)
353 else if (oo == DHCPV6_OPTION_STATUS_CODE)
355 dhcpv6_status_code_t *sc = (
void *) option;
357 clib_net_to_host_u16 (sc->status_code);
360 sizeof (*option) + clib_net_to_host_u16 (option->length);
362 (
void *) ((
u8 *) option +
sizeof (*option) +
363 clib_net_to_host_u16 (option->length));
366 if (!client_id_present)
369 (
"Missing Client ID in received DHVPv6 message");
375 (
"Missing Server ID in received DHVPv6 message");
385 r.n_addresses =
vec_len (addresses);
386 r.addresses = addresses;
396 r.prefixes = prefixes;
418 to_next, n_left_to_next,
425 return frame->n_vectors;
431 .name =
"dhcpv6-client",
432 .vector_size =
sizeof (
u32),
438 #define _(s,n) [DHCPV6_CLIENT_NEXT_##s] = n,
vnet_interface_main_t * im
dhcp6_pd_client_state_t * client_state_by_sw_if_index
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
#define clib_memcpy(d, s, n)
nat44_ei_hairpin_src_next_t next_index
static uword dhcpv6_client_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
vlib_main_t vlib_node_runtime_t * node
u32 server_index_get_or_create(u8 *data, u16 len)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static u8 * format_dhcpv6_client_trace(u8 *s, va_list *args)
vnet_hw_interface_t * hw_interfaces
vlib_combined_counter_main_t * ccm
dhcp6_ia_na_client_main_t dhcp6_ia_na_client_main
vnet_hw_if_output_node_runtime_t * r
static u32 random_u32(u32 *seed)
32-bit random number generator
#define pool_foreach(VAR, POOL)
Iterate through pool.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void generate_client_duid(void)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define CLIENT_DUID_LENGTH
vnet_main_t * vnet_get_main(void)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
sll srl srl sll sra u16x4 i
void udp_unregister_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u8 is_ip4)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
struct _vlib_node_registration vlib_node_registration_t
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
#define foreach_dhcpv6_client
#define vec_free(V)
Free vector's memory (no header).
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
ethernet_main_t ethernet_main
description fragment has unexpected format
vlib_put_next_frame(vm, node, next_index, 0)
dhcp6_ia_na_client_state_t * client_state_by_sw_if_index
void dhcp6_clients_enable_disable(u8 enable)
dhcpv6_duid_ll_string_t client_duid
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
int dhcp6_pd_publish_report(prefix_report_t *r)
static vlib_main_t * vlib_get_main(void)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define DHCPV6_CLIENT_IAID
#define clib_warning(format, args...)
int dhcp6_publish_report(address_report_t *r)
dhcp6_pd_client_main_t dhcp6_pd_client_main
static vlib_node_registration_t dhcpv6_client_node
(constructor) VLIB_REGISTER_NODE (dhcpv6_client_node)
dhcp6_client_common_main_t dhcp6_client_common_main
vl_api_interface_index_t sw_if_index
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
ethernet_interface_address_t address
struct dhcpv6_client_trace_t_ dhcpv6_client_trace_t
per-packet trace data
vnet_interface_main_t interface_main
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
VLIB buffer representation.
#define VLIB_REGISTER_NODE(x,...)
static uword random_default_seed(void)
Default random seed (unix/linux user-mode)