|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
66 }) ip4_mapt_pseudo_header_t;
82 ip6->dst_address.as_u64[0] =
84 ip6->dst_address.as_u64[1] =
103 ip6->src_address.as_u64[0] =
105 ip6->src_address.as_u64[1] =
140 pi0 = to_next[0] =
from[0];
145 error0 = MAP_ERROR_NONE;
159 if (ctx0.recv_port == 0)
164 error0 = MAP_ERROR_ICMP;
173 error0 = MAP_ERROR_ICMP;
194 map_t.map_domain_index, 1,
203 to_next, n_left_to_next, pi0,
208 return frame->n_vectors;
216 ip4_mapt_pseudo_header_t * pheader)
220 ip6_frag_hdr_t *frag;
226 sizeof (*
ip4) -
sizeof (*frag) -
233 (
ip4->protocol == IP_PROTOCOL_ICMP) ? IP_PROTOCOL_ICMP6 :
ip4->protocol;
236 frag->fragment_offset_and_more =
239 (
ip4->flags_and_fragment_offset) &
242 ip6->ip_version_traffic_class_and_flow_label =
243 clib_host_to_net_u32 ((6 << 28) + (
ip4->tos << 20));
244 ip6->payload_length =
245 clib_host_to_net_u16 (clib_net_to_host_u16 (
ip4->length) -
246 sizeof (*
ip4) +
sizeof (*frag));
247 ip6->hop_limit =
ip4->ttl;
248 ip6->protocol = IP_PROTOCOL_IPV6_FRAGMENTATION;
250 ip6->dst_address.as_u64[0] = pheader->daddr.as_u64[0];
251 ip6->dst_address.as_u64[1] = pheader->daddr.as_u64[1];
252 ip6->src_address.as_u64[0] = pheader->saddr.as_u64[0];
253 ip6->src_address.as_u64[1] = pheader->saddr.as_u64[1];
277 ip4_mapt_pseudo_header_t *pheader0;
281 pi0 = to_next[0] =
from[0];
295 p0->
error = error_node->
errors[MAP_ERROR_FRAGMENT_DROPPED];
315 to_next, n_left_to_next, pi0,
320 return frame->n_vectors;
334 ip6_frag_hdr_t *frag;
340 if (
ip4->protocol == IP_PROTOCOL_UDP)
352 u16 udp_len = clib_host_to_net_u16 (
ip4->length) -
sizeof (*ip4);
366 csum = tcp->checksum;
370 checksum = &tcp->checksum;
373 old_src.
as_u32 =
ip4->src_address.as_u32;
374 old_dst.
as_u32 =
ip4->dst_address.as_u32;
382 sizeof (*
ip4) -
sizeof (*ip6) -
396 ip6->ip_version_traffic_class_and_flow_label =
397 clib_host_to_net_u32 ((6 << 28) + (
ip4->tos << 20));
399 ip6->hop_limit =
ip4->ttl;
400 ip6->protocol =
ip4->protocol;
403 frag->next_hdr =
ip6->protocol;
404 frag->identification = frag_id;
407 ip6->protocol = IP_PROTOCOL_IPV6_FRAGMENTATION;
411 ip6->dst_address.as_u64[0] = pheader->daddr.as_u64[0];
412 ip6->dst_address.as_u64[1] = pheader->daddr.as_u64[1];
413 ip6->src_address.as_u64[0] = pheader->saddr.as_u64[0];
414 ip6->src_address.as_u64[1] = pheader->saddr.as_u64[1];
447 ip4_mapt_pseudo_header_t *pheader0;
450 pi0 = to_next[0] =
from[0];
485 to_next, n_left_to_next, pi0,
491 return frame->n_vectors;
508 *dst_port0 = l4_dst_port;
509 *error0 = (*dst_port0 == -1) ? MAP_ERROR_FRAGMENT_MEMORY : *error0;
516 *error0 = ip4_len0 < 40 ? MAP_ERROR_MALFORMED : *error0;
517 *dst_port0 = l4_dst_port;
523 *error0 = ip4_len0 < 28 ? MAP_ERROR_MALFORMED : *error0;
524 *dst_port0 = l4_dst_port;
526 else if (ip40->
protocol == IP_PROTOCOL_ICMP)
531 else if (((icmp46_header_t *)
u8_ptr_add (ip40,
sizeof (*ip40)))->
type
533 || ((icmp46_header_t *)
535 sizeof (*ip40)))->
type == ICMP4_echo_request)
536 *dst_port0 = l4_dst_port;
540 *error0 = MAP_ERROR_BAD_PROTOCOL;
570 ip4_mapt_pseudo_header_t *pheader0;
572 pi0 = to_next[0] =
from[0];
577 error0 = MAP_ERROR_NONE;
584 ip4_len0 = clib_host_to_net_u16 (ip40->
length);
588 error0 = MAP_ERROR_UNKNOWN;
606 ICMP4_time_exceeded_ttl_exceeded_in_transit,
608 p0->
error = error_node->
errors[MAP_ERROR_TIME_EXCEEDED];
627 ICMP4_destination_unreachable_fragmentation_needed_and_dont_fragment_set,
637 &next0, l4_dst_port);
641 && (clib_net_to_host_u16 (dst_port0) <
644 error0 = MAP_ERROR_SEC_CHECK;
654 pheader0->daddr.as_u64[0] =
656 pheader0->daddr.as_u64[1] =
665 map_t.map_domain_index, 1,
679 to_next, n_left_to_next, pi0,
684 return frame->n_vectors;
689 .arc_name =
"ip4-unicast",
690 .node_name =
"ip4-map-t",
697 .name =
"ip4-map-t-fragmented",
698 .vector_size =
sizeof(
u32),
702 .n_errors = MAP_N_ERROR,
703 .error_counters = map_error_counters,
718 .name =
"ip4-map-t-icmp",
719 .vector_size =
sizeof(
u32),
723 .n_errors = MAP_N_ERROR,
724 .error_counters = map_error_counters,
739 .name =
"ip4-map-t-tcp-udp",
740 .vector_size =
sizeof(
u32),
744 .n_errors = MAP_N_ERROR,
745 .error_counters = map_error_counters,
761 .vector_size =
sizeof(
u32),
765 .n_errors = MAP_N_ERROR,
766 .error_counters = map_error_counters,
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
static uword ip4_map_t(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define IP4_HEADER_FLAG_DONT_FRAGMENT
#define u8_ptr_add(ptr, index)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
vlib_node_registration_t ip4_map_t_tcp_udp_node
(constructor) VLIB_REGISTER_NODE (ip4_map_t_tcp_udp_node)
nat44_ei_hairpin_src_next_t next_index
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
@ IP4_MAPT_ICMP_NEXT_IP6_REWRITE
@ IP4_MAPT_FRAGMENTED_N_NEXT
struct _tcp_header tcp_header_t
@ VLIB_NODE_TYPE_INTERNAL
vlib_main_t vlib_node_runtime_t * node
@ IP4_MAPT_TCP_UDP_N_NEXT
#define ip6_frag_hdr_offset_and_more(offset, more)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static_always_inline void ip4_map_t_classify(vlib_buffer_t *p0, map_domain_t *d0, ip4_header_t *ip40, u16 ip4_len0, i32 *dst_port0, u8 *error0, ip4_mapt_next_t *next0, u16 l4_dst_port)
static void map_add_trace(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b, u32 map_domain_index, u16 port)
@ IP4_MAPT_NEXT_MAPT_FRAGMENTED
vlib_node_registration_t ip4_map_t_node
(constructor) VLIB_REGISTER_NODE (ip4_map_t_node)
typedef CLIB_PACKED(struct { ip6_address_t daddr;ip6_address_t saddr;u8 unused[28];})
@ IP4_MAPT_ICMP_NEXT_IP6_LOOKUP
static u16 ip4_get_port(ip4_header_t *ip, u8 sender)
Get TCP/UDP port number or ICMP id from IPv4 packet.
static_always_inline void map_mss_clamping(tcp_header_t *tcp, ip_csum_t *sum, u16 mss_clamping)
vlib_error_t * errors
Vector of errors for this node.
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
vlib_error_t error
Error code for buffers to be enqueued to error handler.
@ IP4_MAPT_TCP_UDP_NEXT_IP6_REWRITE
static ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
@ IP4_MAPT_NEXT_MAPT_ICMP
static_always_inline void vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static u16 ip4_get_fragment_offset(const ip4_header_t *i)
@ IP4_MAPT_NEXT_MAPT_TCP_UDP
@ IP4_MAPT_ICMP_NEXT_IP6_FRAG
#define static_always_inline
static uword ip4_map_t_tcp_udp(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
@ IP4_MAPT_TCP_UDP_NEXT_IP6_LOOKUP
@ IP4_MAPT_TCP_UDP_NEXT_IP6_FRAG
static_always_inline map_domain_t * ip4_map_get_domain(ip4_address_t *addr, u32 *map_domain_index, u8 *error)
vlib_combined_counter_main_t * domain_counters
static uword ip4_map_t_icmp(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static uword ip4_map_t_fragmented(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static int map_ip4_to_ip6_fragmented(vlib_buffer_t *p, ip4_mapt_pseudo_header_t *pheader)
vnet_feature_config_main_t * cm
@ IP4_MAPT_FRAGMENTED_NEXT_IP6_LOOKUP
static int icmp_to_icmp6(vlib_buffer_t *p, ip4_to_ip6_set_fn_t fn, void *ctx, ip4_to_ip6_set_fn_t inner_fn, void *inner_ctx)
Translate ICMP4 packet to ICMP6.
struct _vlib_node_registration vlib_node_registration_t
static int ip4_to_ip6_set_inner_icmp_cb(vlib_buffer_t *b, ip4_header_t *ip4, ip6_header_t *ip6, void *arg)
#define IP6_FRAG_NODE_NAME
u16 current_length
Nbytes between current data and the end of this buffer.
static_always_inline void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
static int ip4_to_ip6_set_icmp_cb(vlib_buffer_t *b, ip4_header_t *ip4, ip6_header_t *ip6, void *arg)
ip4_mapt_fragmented_next_t
@ IP4_MAPT_NEXT_ICMP_ERROR
static ip_csum_t ip_csum_sub_even(ip_csum_t c, ip_csum_t x)
@ IP4_MAPT_FRAGMENTED_NEXT_IP6_REWRITE
#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.
@ IP4_MAPT_FRAGMENTED_NEXT_IP6_FRAG
@ IP_FRAG_NEXT_IP6_LOOKUP
@ IP4_MAPT_ICMP_NEXT_DROP
A collection of combined counters.
static int map_ip4_to_ip6_tcp_udp(vlib_buffer_t *p, ip4_mapt_pseudo_header_t *pheader)
vlib_put_next_frame(vm, node, next_index, 0)
static ip_csum_t ip_csum_with_carry(ip_csum_t sum, ip_csum_t x)
static_always_inline u64 map_get_sfx_net(map_domain_t *d, u32 addr, u16 port)
static_always_inline bool ip4_map_ip6_lookup_bypass(vlib_buffer_t *p0, ip4_header_t *ip)
@ IP4_MAPT_FRAGMENTED_NEXT_DROP
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
vlib_node_registration_t ip4_map_t_icmp_node
(constructor) VLIB_REGISTER_NODE (ip4_map_t_icmp_node)
#define VNET_FEATURES(...)
vlib_node_registration_t ip4_map_t_fragmented_node
(constructor) VLIB_REGISTER_NODE (ip4_map_t_fragmented_node)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
IPv4 to IPv6 translation.
static_always_inline u64 map_get_pfx_net(map_domain_t *d, u32 addr, u16 port)
#define u16_net_add(u, val)
static_always_inline void ip4_map_t_embedded_address(map_domain_t *d, ip6_address_t *ip6, const ip4_address_t *ip4)
static ip_csum_t ip_csum_add_even(ip_csum_t c, ip_csum_t x)
#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)
@ IP4_MAPT_TCP_UDP_NEXT_DROP
#define IP4_HEADER_FLAG_MORE_FRAGMENTS
VNET_FEATURE_INIT(ip4_map_t_feature, static)
vl_api_fib_path_type_t type
vlib_increment_combined_counter(ccm, ti, sw_if_index, n_buffers, n_bytes)
u8 * format_map_trace(u8 *s, va_list *args)
static void * ip4_next_header(ip4_header_t *i)
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,...)