|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
24 #define dhcp_proxy_error(n,s) s,
26 #undef dhcp_proxy_error
29 #define foreach_dhcp_proxy_to_server_input_next \
30 _ (DROP, "error-drop") \
31 _ (LOOKUP, "ip4-lookup") \
32 _ (SEND_TO_CLIENT, "dhcp-proxy-to-client")
36 #define _(s,n) DHCP_PROXY_TO_SERVER_INPUT_NEXT_##s,
56 #define VPP_DHCP_OPTION82_SUB1_SIZE 6
57 #define VPP_DHCP_OPTION82_SUB5_SIZE 6
58 #define VPP_DHCP_OPTION82_VSS_SIZE 12
59 #define VPP_DHCP_OPTION82_SIZE (VPP_DHCP_OPTION82_SUB1_SIZE + \
60 VPP_DHCP_OPTION82_SUB5_SIZE + \
61 VPP_DHCP_OPTION82_VSS_SIZE +3)
74 s =
format (s,
"DHCP proxy: sent to server %U\n",
77 s =
format (s,
"DHCP proxy: broadcast to client from %U\n",
83 s =
format (s,
" original_sw_if_index: %d, sw_if_index: %d\n",
95 u32 max_header_bytes = va_arg (*args,
u32);
98 header_bytes =
sizeof (
h[0]);
99 if (max_header_bytes != 0 && header_bytes > max_header_bytes)
100 return format (s,
"dhcp header truncated");
102 s =
format (s,
"DHCP Proxy");
116 u32 pkts_to_server = 0, pkts_to_client = 0, pkts_no_server = 0;
117 u32 pkts_no_interface_address = 0;
118 u32 pkts_too_big = 0;
141 u32 original_sw_if_index = 0;
168 clib_net_to_host_u16 (UDP_DST_PORT_dhcp_to_server))
171 next0 = DHCP_PROXY_TO_SERVER_INPUT_NEXT_SEND_TO_CLIENT;
178 fib_index =
im->fib_index_by_sw_if_index[rx_sw_if_index];
183 error0 = DHCP_PROXY_ERROR_NO_SERVER;
184 next0 = DHCP_PROXY_TO_SERVER_INPUT_NEXT_DROP;
191 error0 = DHCP_PROXY_ERROR_PKT_TOO_BIG;
192 next0 = DHCP_PROXY_TO_SERVER_INPUT_NEXT_DROP;
199 if ((b0->
flags & VLIB_BUFFER_NEXT_PRESENT) != 0 ||
202 error0 = DHCP_PROXY_ERROR_PKT_TOO_BIG;
203 next0 = DHCP_PROXY_TO_SERVER_INPUT_NEXT_DROP;
277 error0 = DHCP_PROXY_ERROR_NO_INTERFACE_ADDRESS;
278 next0 = DHCP_PROXY_TO_SERVER_INPUT_NEXT_DROP;
279 pkts_no_interface_address++;
289 *o_ifid = clib_host_to_net_u32 (original_sw_if_index);
303 id_len =
sizeof (vss->
vpn_id);
315 o->
data[13] = id_len + 1;
317 o->
data[15 + id_len] = 152;
318 o->
data[16 + id_len] = 0;
328 new_l0 = clib_net_to_host_u16 (old_l0);
330 new_l0 = clib_host_to_net_u16 (new_l0);
338 new_l0 = clib_net_to_host_u16 (u0->
length);
340 u0->
length = clib_host_to_net_u16 (new_l0);
346 DHCP_PROXY_ERROR_OPTION_82_ERROR, 1);
349 next0 = DHCP_PROXY_TO_SERVER_INPUT_NEXT_LOOKUP;
370 DHCP_PROXY_ERROR_ALLOC_FAIL, 1);
392 to_next, n_left_to_next,
404 if (next0 == DHCP_PROXY_TO_SERVER_INPUT_NEXT_LOOKUP)
418 to_next, n_left_to_next);
431 if (next0 == DHCP_PROXY_TO_SERVER_INPUT_NEXT_LOOKUP)
444 to_next, n_left_to_next,
451 DHCP_PROXY_ERROR_RELAY_TO_CLIENT,
454 DHCP_PROXY_ERROR_RELAY_TO_SERVER,
457 DHCP_PROXY_ERROR_NO_SERVER, pkts_no_server);
459 DHCP_PROXY_ERROR_NO_INTERFACE_ADDRESS,
460 pkts_no_interface_address);
462 DHCP_PROXY_ERROR_PKT_TOO_BIG, pkts_too_big);
469 .name =
"dhcp-proxy-to-server",
471 .vector_size =
sizeof (
u32),
478 #define _(s,n) [DHCP_PROXY_TO_SERVER_INPUT_NEXT_##s] = n,
486 .unformat_buffer = unformat_dhcp_proxy_header,
533 u32 inner_vlan = (
u32) ~ 0;
534 u32 outer_vlan = (
u32) ~ 0;
540 u32 original_sw_if_index = (
u32) ~ 0;
546 bi0 = to_next[0] =
from[0];
568 error0 = DHCP_PROXY_ERROR_FOR_US;
575 if ((b0->
flags & VLIB_BUFFER_NEXT_PRESENT) != 0 || !
rv)
577 error0 = DHCP_PROXY_ERROR_PKT_TOO_BIG;
606 (sub->
data[1] << 16) |
607 (sub->
data[2] << 8) |
617 else if (sub->
option == 151 &&
624 if (vss_ctrl && vss_exist)
627 DHCP_PROXY_ERROR_OPTION_82_VSS_NOT_PROCESSED, 1);
635 error0 = DHCP_PROXY_ERROR_NO_OPTION_82;
646 if (relay_addr.
as_u32 == 0)
648 error0 = DHCP_PROXY_ERROR_BAD_OPTION_82_ADDR;
654 error0 = DHCP_PROXY_ERROR_BAD_OPTION_82_ITF;
663 error0 = DHCP_PROXY_ERROR_NO_SERVER;
675 error0 = DHCP_PROXY_ERROR_BAD_SVR_FIB_OR_ADDRESS;
689 error0 = DHCP_PROXY_ERROR_NO_INTERFACE_ADDRESS;
695 error0 = DHCP_PROXY_ERROR_BAD_YIADDR;
700 u0->
dst_port = clib_net_to_host_u16 (UDP_DST_PORT_dhcp_to_client);
745 && outer_vlan != (
u32) ~ 0)
748 clib_net_to_host_u16 (0x88a8) : clib_net_to_host_u16 (0x8100);
749 u32 *vlan_tag = (
u32 *) (mac0 + 1);
750 *vlan_tag = clib_host_to_net_u32 (outer_vlan);
751 if (inner_vlan != (
u32) ~ 0)
753 u32 *inner_vlan_tag = (
u32 *) (vlan_tag + 1);
754 *inner_vlan_tag = clib_host_to_net_u32 (inner_vlan);
759 mac0->
type = clib_net_to_host_u16 (0x0800);
777 to_next, n_left_to_next,
789 .name =
"dhcp-proxy-to-client",
791 .vector_size =
sizeof (
u32),
798 .unformat_buffer = unformat_dhcp_proxy_header,
848 u32 rx_table_id,
u32 server_table_id,
int is_del)
850 u32 rx_fib_index = 0;
855 .fp_addr.ip4.as_u32 = 0xffffffff,
860 return VNET_API_ERROR_INVALID_DST_ADDRESS;
863 return VNET_API_ERROR_INVALID_SRC_ADDRESS;
874 addr, server_table_id))
885 rx_fib_index, server_table_id))
903 ip46_address_t server_addr,
src_addr;
904 u32 server_table_id = 0, rx_table_id = 0;
906 int set_src = 0, set_server = 0;
908 clib_memset (&server_addr, 0,
sizeof (server_addr));
916 else if (
unformat (input,
"server-fib-id %d", &server_table_id))
918 else if (
unformat (input,
"rx-fib-id %d", &rx_table_id))
920 else if (
unformat (input,
"src-address %U",
929 if (is_del || (set_server && set_src))
934 server_table_id, is_del);
940 case VNET_API_ERROR_INVALID_DST_ADDRESS:
943 case VNET_API_ERROR_INVALID_SRC_ADDRESS:
946 case VNET_API_ERROR_NO_SUCH_ENTRY:
948 (0,
"Fib id %d: no per-fib DHCP server configured", rx_table_id);
961 .path =
"set dhcp proxy",
962 .short_help =
"set dhcp proxy [del] server <ip-addr> src-address <ip-addr> [server-fib-id <n>] [rx-fib-id <n>]",
976 s =
format (s,
"%=14s%=16s%s",
"RX FIB",
"Src Address",
977 "Servers FIB,Address");
983 s =
format (s,
"%=14u%=16U",
1022 .path =
"show dhcp proxy",
1023 .short_help =
"Display dhcp proxy server info",
1033 u32 oui = 0, fib_id = 0, tbl_id = ~0;
1034 u8 *vpn_ascii_id = 0;
1038 if (
unformat (input,
"table %d", &tbl_id))
1040 else if (
unformat (input,
"oui %d", &oui))
1042 else if (
unformat (input,
"vpn-id %d", &fib_id))
1044 else if (
unformat (input,
"vpn-ascii-id %s", &vpn_ascii_id))
1056 vpn_ascii_id, oui, fib_id, is_del);
1061 case VNET_API_ERROR_NO_SUCH_ENTRY:
1063 "option 82 vss for table %d not found in in pool.",
1073 .path =
"set dhcp option-82 vss",
1074 .short_help =
"set dhcp option-82 vss [del] table <table id> [oui <n> vpn-id <n> | vpn-ascii-id <text>]",
1090 .path =
"show dhcp vss",
1091 .short_help =
"show dhcp VSS",
1114 swif->unnumbered_sw_if_index : sw_if_index0;
1119 "source IP address");
1127 "No IPv4 address configured on",
1139 .path =
"show dhcp option-82-address interface",
1140 .short_help =
"show dhcp option-82-address interface <interface>",
@ DHCP_PROXY_TO_SERVER_INPUT_N_NEXT
vnet_interface_main_t * im
static u8 * format_dhcp_proxy_header_with_length(u8 *s, va_list *args)
u8 vss_type
VSS type as defined in RFC 6607: 0 for NVT ASCII VPN Identifier 1 for RFC 2685 VPN-ID of 7 octects - ...
vnet_sw_interface_type_t type
A representation of a single DHCP Server within a given VRF config.
static dhcp_proxy_t * dhcp_get_proxy(dhcp_proxy_main_t *dm, u32 rx_fib_index, fib_protocol_t proto)
Get the DHCP proxy server data for the FIB index.
static vlib_buffer_t * vlib_buffer_copy(vlib_main_t *vm, vlib_buffer_t *b)
#define clib_memcpy(d, s, n)
nat44_ei_hairpin_src_next_t next_index
ip4_main_t ip4_main
Global ip4 main structure.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
u8 * vpn_ascii_id
Type 0 ASCII VPN Identifier.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static clib_error_t * dhcp4_proxy_show_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static vlib_node_registration_t dhcp_proxy_to_client_node
(constructor) VLIB_REGISTER_NODE (dhcp_proxy_to_client_node)
void dhcp_maybe_register_udp_ports(dhcp_port_reg_flags_t ports)
Register the dhcp client and/or server ports, if not already done.
vlib_node_registration_t error_drop_node
(constructor) VLIB_REGISTER_NODE (error_drop_node)
vlib_main_t vlib_node_runtime_t * node
@ VNET_SW_INTERFACE_TYPE_SUB
#define clib_error_return(e, args...)
int dhcp_proxy_set_vss(fib_protocol_t proto, u32 tbl_id, u8 vss_type, u8 *vpn_ascii_id, u32 oui, u32 vpn_index, u8 is_del)
Configure/set a new VSS info.
dhcp_proxy_to_server_input_next_t
A DHCP proxy representation fpr per-client VRF config.
u16 fp_len
The mask length.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static u8 * format_dhcp4_proxy_server(u8 *s, va_list *args)
int dhcp_proxy_server_del(fib_protocol_t proto, u32 rx_fib_index, ip46_address_t *addr, u32 server_table_id)
Delete a DHCP proxy config.
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
The Virtual Sub-net Selection information for a given RX FIB.
vlib_main_t vlib_node_runtime_t vlib_frame_t * from_frame
dhcp_proxy_main_t dhcp_proxy_main
Shard 4/6 instance of DHCP main.
static uword dhcp_proxy_to_server_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
Collection of global DHCP proxy data.
static dhcp_vss_t * dhcp_get_vss_info(dhcp_proxy_main_t *dm, u32 rx_fib_index, fib_protocol_t proto)
Get the VSS data for the FIB index.
#define VPP_DHCP_OPTION82_SIZE
static ethernet_main_t * vnet_get_ethernet_main(void)
struct vnet_sub_interface_t::@368 eth
ethernet_interface_t * interfaces
void fib_table_entry_special_remove(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Remove a 'special' entry from the FIB.
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
u8 * format_dhcp_header(u8 *s, va_list *args)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
@ DHCP_PACKET_OPTION_MSG_TYPE
static clib_error_t * dhcp_vss_show_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
ip4_address_t trace_ip4_address
vnet_main_t * vnet_get_main(void)
vl_api_mac_address_t src_addr
static vlib_cli_command_t dhcp_proxy_vss_command
(constructor) VLIB_CLI_COMMAND (dhcp_proxy_vss_command)
u32 fib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id, fib_source_t src)
Get the index of the FIB for a Table-ID.
static vlib_cli_command_t dhcp_proxy_address_show_command
(constructor) VLIB_CLI_COMMAND (dhcp_proxy_address_show_command)
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
f64 end
end of the time range
#define foreach_dhcp_proxy_to_server_input_next
u32 rx_fib_index
The FIB index (not the external Table-ID) in which the client is resides.
int dhcp4_proxy_set_server(ip46_address_t *addr, ip46_address_t *src_addr, u32 rx_table_id, u32 server_table_id, int is_del)
u32 server_fib_index
The FIB index (not the external Table-ID) in which the server is reachable.
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
static clib_error_t * dhcp4_proxy_set_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static ip4_fib_t * ip4_fib_get(u32 index)
Get the FIB at the given index.
@ VNET_SW_INTERFACE_FLAG_UNNUMBERED
#define VLIB_CLI_COMMAND(x,...)
static u32 vlib_buffer_chain_linearize(vlib_main_t *vm, vlib_buffer_t *b)
void dhcp_proxy_walk(fib_protocol_t proto, dhcp_proxy_walk_fn_t fn, void *ctx)
Walk/Visit each DHCP proxy server.
static u8 * format_dhcp_proxy_trace(u8 *s, va_list *args)
struct _vlib_node_registration vlib_node_registration_t
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
u16 current_length
Nbytes between current data and the end of this buffer.
static u32 vlib_buffer_space_left_at_end(vlib_main_t *vm, vlib_buffer_t *b)
ip46_address_t dhcp_server
The address of the DHCP server to which to relay the client's messages.
static clib_error_t * dhcp_option_82_address_show_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 error_drop_node_index
static char * dhcp_proxy_error_strings[]
static u8 ip46_address_is_zero(const ip46_address_t *ip46)
struct vnet_sub_interface_t::@368::@369::@371 flags
static vlib_cli_command_t dhcp_proxy_show_command
(constructor) VLIB_CLI_COMMAND (dhcp_proxy_show_command)
#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.
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
static clib_error_t * dhcp4_proxy_init(vlib_main_t *vm)
u8 vpn_id[7]
Type 1 VPN-ID.
int dhcp_client_for_us(u32 bi, vlib_buffer_t *b, ip4_header_t *ip, udp_header_t *udp, dhcp_header_t *dhcp)
format_function_t format_vnet_sw_if_index_name
unformat_function_t unformat_vnet_sw_interface
description fragment has unexpected format
static u8 * vlib_buffer_get_tail(vlib_buffer_t *b)
Get pointer to the end of buffer's data.
vlib_put_next_frame(vm, node, next_index, 0)
format_function_t format_ip46_address
void fib_table_lock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Release a reference counting lock on the table.
static vlib_node_registration_t dhcp_proxy_to_server_node
(constructor) VLIB_REGISTER_NODE (dhcp_proxy_to_server_node)
#define VLIB_INIT_FUNCTION(x)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define vec_foreach(var, vec)
Vector iterator.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define ip_csum_update(sum, old, new, type, field)
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
static vlib_cli_command_t dhcp_proxy_vss_show_command
(constructor) VLIB_CLI_COMMAND (dhcp_proxy_vss_show_command)
void fib_table_unlock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Take a reference counting lock on the table.
void dhcp_vss_walk(fib_protocol_t proto, dhcp_vss_walk_fn_t fn, void *ctx)
Walk/Visit each DHCP proxy VSS.
dhcp_server_t * dhcp_servers
The set of DHCP servers to which messages are relayed.
static uword dhcp_proxy_to_client_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
ip46_address_t dhcp_src_address
The source address to use in relayed messaes.
ip4_address_t * ip4_interface_first_address(ip4_main_t *im, u32 sw_if_index, ip_interface_address_t **result_ia)
static vlib_cli_command_t dhcp_proxy_set_command
(constructor) VLIB_CLI_COMMAND (dhcp_proxy_set_command)
int dhcp_vss_show_walk(dhcp_vss_t *vss, u32 rx_table_id, void *ctx)
Show (on CLI) a VSS config during a show walk.
fib_node_index_t fib_table_entry_special_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags)
Add a 'special' entry to the FIB.
vl_api_address_union_t src_address
int dhcp_proxy_server_add(fib_protocol_t proto, ip46_address_t *addr, ip46_address_t *src_address, u32 rx_fib_index, u32 server_table_id)
Add a new DHCP proxy server configuration.
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).
static u16 ip_csum_fold(ip_csum_t c)
ethernet_interface_address_t address
Aggregate type for a prefix.
static clib_error_t * dhcp_option_82_vss_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u8 packet_data[2 *sizeof(dhcp_header_t)]
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
VLIB buffer representation.
static int dhcp4_proxy_show_walk(dhcp_proxy_t *server, void *ctx)
#define VLIB_REGISTER_NODE(x,...)