|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
30 #define MSEC_PER_SEC 1000
31 #define IP6_SV_REASS_TIMEOUT_DEFAULT_MS 100
32 #define IP6_SV_REASS_EXPIRE_WALK_INTERVAL_DEFAULT_MS 10000 // 10 seconds default
33 #define IP6_SV_REASS_MAX_REASSEMBLIES_DEFAULT 1024
34 #define IP6_SV_REASS_MAX_REASSEMBLY_LENGTH_DEFAULT 3
35 #define IP6_SV_REASS_HT_LOAD_FACTOR (0.75)
158 #ifndef CLIB_MARCH_VARIANT
202 s =
format (s,
"[cached]");
206 format (s,
"[finish, ip proto=%u, src_port=%u, dst_port=%u]",
212 format (s,
"[forward, ip proto=%u, src_port=%u, dst_port=%u]",
217 s =
format (s,
"[not-fragmented]");
234 b->
flags &= ~VLIB_BUFFER_IS_TRACED;
251 printf (
"%.*s\n",
vec_len (s), s);
268 clib_bihash_add_del_48_8 (&rm->
hash, &kv, 0);
285 if (
rt->lru_first == reass -
rt->pool)
289 if (
rt->lru_last == reass -
rt->pool)
312 if (!clib_bihash_search_48_8 (&rm->
hash, &kv->
kv, &kv->
kv))
349 if (~0 !=
rt->lru_last)
356 if (~0 ==
rt->lru_first)
358 rt->lru_first =
rt->lru_last = reass -
rt->pool;
371 if (clib_bihash_add_del_48_8 (&rm->
hash, &kv->
kv, 1))
383 ip6_frag_hdr_t *frag_hdr)
387 fvnb->
ip.reass.ip6_frag_hdr_offset =
391 fvnb->
ip.reass.ip6_frag_hdr_offset == 0 ||
397 u32 fragment_first = fvnb->
ip.reass.fragment_first =
399 u32 fragment_length =
401 (fvnb->
ip.reass.ip6_frag_hdr_offset +
sizeof (*frag_hdr));
402 u32 fragment_last = fvnb->
ip.reass.fragment_last =
403 fragment_first + fragment_length - 1;
404 fvnb->
ip.reass.range_first = fragment_first;
405 fvnb->
ip.reass.range_last = fragment_last;
406 fvnb->
ip.reass.next_range_bi = ~0;
407 if (0 == fragment_first)
445 ip6_frag_hdr_t * frag_hdr)
447 ip6_ext_header_t *
tmp = (ip6_ext_header_t *) frag_hdr;
452 if (IP_PROTOCOL_IP6_NONXT ==
tmp->next_hdr)
455 ICMP6_parameter_problem_first_fragment_has_incomplete_header_chain,
457 b->
error =
node->errors[IP6_ERROR_REASS_MISSING_UPPER];
467 ip6_frag_hdr_t * frag_hdr)
472 u32 fragment_length =
474 (vnb->
ip.reass.ip6_frag_hdr_offset +
sizeof (*frag_hdr));
475 if (more_fragments && 0 != fragment_length % 8)
478 ICMP6_parameter_problem_erroneous_header_field,
479 (
u8 *) &
ip->payload_length - (
u8 *)
ip);
488 ip6_frag_hdr_t * frag_hdr)
492 u32 fragment_length =
494 (vnb->
ip.reass.ip6_frag_hdr_offset +
sizeof (*frag_hdr));
495 if (fragment_first + fragment_length > 65535)
499 ICMP6_parameter_problem_erroneous_header_field,
500 (
u8 *) & frag_hdr->fragment_offset_and_more
530 u32 error0 = IP6_ERROR_NONE;
536 ip6_frag_hdr_t *frag_hdr = NULL;
537 ip6_ext_header_t *prev_hdr;
542 IP_PROTOCOL_IPV6_FRAGMENTATION,
557 error0 = IP6_ERROR_REASS_UNSUPP_IP_PROTO;
562 vnet_buffer (b0)->ip.reass.is_non_first_fragment = 0;
575 (
u8 *) frag_hdr - (
u8 *) ip0;
580 (
node, b0, frag_hdr))
603 (
u64) frag_hdr->identification;
620 error0 = IP6_ERROR_REASS_LIMIT_REACHED;
625 if (reass->is_complete)
629 vnet_buffer (b0)->ip.reass.ip_proto = reass->ip_proto;
630 vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
631 reass->icmp_type_or_tcp_flags;
633 reass->tcp_ack_number;
635 reass->tcp_seq_number;
636 vnet_buffer (b0)->ip.reass.l4_src_port = reass->l4_src_port;
637 vnet_buffer (b0)->ip.reass.l4_dst_port = reass->l4_dst_port;
643 reass->ip_proto, reass->l4_src_port, reass->l4_dst_port);
655 IP6_ERROR_REASS_FRAGMENT_CHAIN_TOO_LONG,
662 IP6_ERROR_REASS_UNSUPP_IP_PROTO,
669 IP6_ERROR_REASS_INTERNAL_ERROR, 1);
675 if (reass->is_complete)
680 u32 bi0 =
vec_elt (reass->cached_buffers, idx);
681 if (0 == n_left_to_next)
701 vnet_buffer (b0)->ip.reass.ip_proto = reass->ip_proto;
702 vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
703 reass->icmp_type_or_tcp_flags;
705 reass->tcp_ack_number;
707 reass->tcp_seq_number;
708 vnet_buffer (b0)->ip.reass.l4_src_port = reass->l4_src_port;
709 vnet_buffer (b0)->ip.reass.l4_dst_port = reass->l4_dst_port;
714 reass->ip_proto, reass->l4_src_port, reass->l4_dst_port);
717 to_next, n_left_to_next, bi0,
720 _vec_len (reass->cached_buffers) = 0;
728 if (is_feature && IP6_ERROR_NONE == error0)
734 n_left_to_next, bi0, next0);
745 return frame->n_vectors;
749 #define _(sym, string) string,
763 .name =
"ip6-sv-reassembly",
764 .vector_size =
sizeof (
u32),
788 .name =
"ip6-sv-reassembly-feature",
789 .vector_size =
sizeof (
u32),
806 .arc_name =
"ip6-unicast",
807 .node_name =
"ip6-sv-reassembly-feature",
813 #ifndef CLIB_MARCH_VARIANT
823 for (
i = 0;
i < 31;
i++)
824 if ((1 <<
i) >= nbuckets)
837 #ifndef CLIB_MARCH_VARIANT
841 clib_bihash_48_8_t *new_hash;
848 if (clib_bihash_add_del_48_8 (
ctx->new_hash, kv, 1))
852 return (BIHASH_WALK_CONTINUE);
857 u32 max_reassembly_length,
858 u32 expire_walk_interval_ms)
869 u32 max_reassembly_length,
u32 expire_walk_interval_ms)
873 max_reassembly_length, expire_walk_interval_ms);
880 clib_bihash_48_8_t new_hash;
884 ctx.new_hash = &new_hash;
885 clib_bihash_init_48_8 (&new_hash,
"ip6-sv-reass", new_nbuckets,
886 new_nbuckets * 1024);
891 clib_bihash_free_48_8 (&new_hash);
907 u32 * max_reassembly_length,
u32 * expire_walk_interval_ms)
933 rt->lru_first =
rt->lru_last = ~0;
946 clib_bihash_init_48_8 (&rm->
hash,
"ip6-sv-reass", nbuckets,
977 uword event_type, *event_data = 0;
1001 int *pool_indexes_to_free = NULL;
1036 _vec_len (event_data) = 0;
1048 .name =
"ip6-sv-reassembly-expire-walk",
1060 s =
format (s,
"xx_id: %u, src: %U, dst: %U, frag_id: %u, proto: %u",
1062 &
key->dst, clib_net_to_host_u16 (
key->frag_id),
key->proto);
1072 s =
format (s,
"ID: %lu, key: %U, trace_op_counter: %u\n",
1084 s =
format (s,
" #%03u: bi: %u\n", counter, bi);
1088 while (
b->
flags & VLIB_BUFFER_NEXT_PRESENT);
1102 bool details =
false;
1108 u32 sum_reass_n = 0;
1109 u64 sum_buffers_n = 0;
1125 sum_reass_n +=
rt->reass_n;
1130 (
long unsigned) sum_reass_n);
1132 "Maximum configured concurrent shallow virtual IP6 reassemblies per worker-thread: %lu\n",
1135 "Maximum configured amount of fragments per shallow "
1136 "virtual IP6 reassembly: %lu\n",
1139 "Maximum configured shallow virtual IP6 reassembly timeout: %lums\n",
1142 "Maximum configured shallow virtual IP6 reassembly expire walk interval: %lums\n",
1145 (
long unsigned) sum_buffers_n);
1151 .path =
"show ip6-sv-reassembly",
1152 .short_help =
"show ip6-sv-reassembly [details]",
1157 #ifndef CLIB_MARCH_VARIANT
1166 #define foreach_ip6_sv_reassembly_handoff_error \
1167 _(CONGESTION_DROP, "congestion drop")
1172 #define _(sym,str) IP6_SV_REASSEMBLY_HANDOFF_ERROR_##sym,
1179 #define _(sym,string) string,
1198 format (s,
"ip6-sv-reassembly-handoff: next-worker %d",
1221 ti = thread_indices;
1231 && (
b[0]->
flags & VLIB_BUFFER_IS_TRACED)))
1243 thread_indices,
frame->n_vectors, 1);
1247 IP6_SV_REASSEMBLY_HANDOFF_ERROR_CONGESTION_DROP,
1248 frame->n_vectors - n_enq);
1249 return frame->n_vectors;
1262 .name =
"ip6-sv-reassembly-handoff",
1263 .vector_size =
sizeof (
u32),
1285 .name =
"ip6-sv-reass-feature-hoff",
1286 .vector_size =
sizeof (
u32),
1299 #ifndef CLIB_MARCH_VARIANT
1311 "ip6-sv-reassembly-feature",
1321 "ip6-sv-reassembly-feature",
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static void clib_spinlock_init(clib_spinlock_t *p)
u32 next_buffer
Next buffer for this linked-list of buffers.
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
#define ip6_frag_hdr_more(hdr)
static u32 vlib_num_workers()
static vlib_cli_command_t show_ip6_sv_reassembly_cmd
(constructor) VLIB_CLI_COMMAND (show_ip6_sv_reassembly_cmd)
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
vnet_api_error_t ip6_sv_reass_set(u32 timeout_ms, u32 max_reassemblies, u32 max_reassembly_length, u32 expire_walk_interval_ms)
set ip6 reassembly configuration
u32 fq_index
Worker handoff.
static_always_inline u32 vlib_buffer_enqueue_to_thread(vlib_main_t *vm, vlib_node_runtime_t *node, u32 frame_queue_index, u32 *buffer_indices, u16 *thread_indices, u32 n_packets, int drop_on_congestion)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
void icmp6_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
#define IP6_SV_REASS_TIMEOUT_DEFAULT_MS
nat44_ei_hairpin_src_next_t next_index
u32 expire_walk_interval_ms
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
#define IP6_SV_REASS_EXPIRE_WALK_INTERVAL_DEFAULT_MS
static u8 * format_ip6_sv_reass_trace(u8 *s, va_list *args)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static bool ip6_sv_reass_verify_upper_layer_present(vlib_node_runtime_t *node, vlib_buffer_t *b, ip6_frag_hdr_t *frag_hdr)
vlib_get_buffers(vm, from, b, n_left_from)
@ IP6_SV_REASS_RC_INTERNAL_ERROR
vlib_main_t vlib_node_runtime_t * node
static bool ip6_sv_reass_verify_packet_size_lt_64k(vlib_main_t *vm, vlib_buffer_t *b, ip6_frag_hdr_t *frag_hdr)
vnet_api_error_t ip6_sv_reass_enable_disable(u32 sw_if_index, u8 enable_disable)
static ip6_sv_reass_rc_t ip6_sv_reass_update(vlib_main_t *vm, vlib_node_runtime_t *node, ip6_sv_reass_main_t *rm, ip6_sv_reass_t *reass, u32 bi0, ip6_frag_hdr_t *frag_hdr)
vlib_node_registration_t ip6_sv_reassembly_handoff_node
(constructor) VLIB_REGISTER_NODE (ip6_sv_reassembly_handoff_node)
static uword ip6_sv_reassembly_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, bool is_feature)
#define vlib_call_init_function(vm, x)
#define pool_put(P, E)
Free an object E in pool P.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static void ip6_sv_reass_add_trace(vlib_main_t *vm, vlib_node_runtime_t *node, ip6_sv_reass_t *reass, u32 bi, ip6_sv_reass_trace_operation_e action, u32 ip_proto, u16 l4_src_port, u16 l4_dst_port)
vnet_api_error_t ip6_sv_reass_get(u32 *timeout_ms, u32 *max_reassemblies, u32 *max_reassembly_length, u32 *expire_walk_interval_ms)
get ip6 reassembly configuration
ip6_sv_reass_per_thread_t * per_thread_data
static uword ip6_sv_reassembly_handoff_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, bool is_feature)
int ip6_sv_reass_enable_disable_with_refcnt(u32 sw_if_index, int is_enable)
ip6_sv_reass_main_t ip6_sv_reass_main
vlib_node_registration_t ip6_sv_reass_node
(constructor) VLIB_REGISTER_NODE (ip6_sv_reass_node)
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
u32 * feature_use_refcount_per_intf
#define IP6_SV_REASS_MAX_REASSEMBLIES_DEFAULT
u32 vlib_frame_queue_main_init(u32 node_index, u32 frame_queue_nelts)
struct vnet_buffer_opaque_t::@157::@159 ip
#define IP6_SV_REASS_MAX_REASSEMBLY_LENGTH_DEFAULT
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
#define vec_elt(v, i)
Get vector value at index i.
vlib_node_registration_t ip6_sv_reass_expire_node
(constructor) VLIB_REGISTER_NODE (ip6_sv_reass_expire_node)
static u8 * format_ip6_sv_reassembly_handoff_trace(u8 *s, va_list *args)
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type,...
#define pool_foreach(VAR, POOL)
Iterate through pool.
static void ip6_sv_reass_init(ip6_sv_reass_t *reass)
vlib_node_registration_t ip6_sv_reassembly_feature_handoff_node
(constructor) VLIB_REGISTER_NODE (ip6_sv_reassembly_feature_handoff_node)
static uword ip6_sv_reass_walk_expired(vlib_main_t *vm, CLIB_UNUSED(vlib_node_runtime_t *node), CLIB_UNUSED(vlib_frame_t *f))
#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.
@ IP6_SV_REASS_RC_UNSUPP_IP_PROTO
IPv6 shallow virtual reassembly.
#define VLIB_NODE_FN(node)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
vnet_main_t * vnet_get_main(void)
#define VLIB_NODE_FLAG_TRACE
@ IP6_EVENT_CONFIG_CHANGED
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_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
static void * ip6_ext_header_find(vlib_main_t *vm, vlib_buffer_t *b, ip6_header_t *ip6_header, u8 header_type, ip6_ext_header_t **prev_ext_header)
__clib_export void clib_bihash_copied(void *dst, void *src)
static u32 ip6_sv_reass_get_nbuckets()
@ IP6_SV_REASS_RC_TOO_MANY_FRAGMENTS
#define vec_foreach_index(var, v)
Iterate over vector indices.
ip6_sv_reassembly_handoff_error_t
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#define ip6_frag_hdr_offset(hdr)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
u32 * fib_index_by_sw_if_index
#define VLIB_CLI_COMMAND(x,...)
IPv6 to IPv4 translation.
#define foreach_ip6_sv_reassembly_handoff_error
ip6_sv_reass_trace_operation_e action
@ IP6_SV_REASSEMBLY_NEXT_ICMP_ERROR
vlib_node_registration_t ip6_sv_reass_node_feature
(constructor) VLIB_REGISTER_NODE (ip6_sv_reass_node_feature)
clib_error_t * ip_main_init(vlib_main_t *vm)
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 u8 * format_ip6_sv_reass(u8 *s, va_list *args)
@ IP6_SV_REASSEMBLY_NEXT_DROP
static ip6_sv_reass_t * ip6_sv_reass_find_or_create(vlib_main_t *vm, ip6_sv_reass_main_t *rm, ip6_sv_reass_per_thread_t *rt, ip6_sv_reass_kv_t *kv, u8 *do_handoff)
static void ip6_sv_reass_set_params(u32 timeout_ms, u32 max_reassemblies, u32 max_reassembly_length, u32 expire_walk_interval_ms)
ip6_sv_reass_trace_operation_e
#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.
static char * ip6_sv_reassembly_error_strings[]
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
#define pool_foreach_index(i, v)
static void ip6_sv_reass_free(vlib_main_t *vm, ip6_sv_reass_main_t *rm, ip6_sv_reass_per_thread_t *rt, ip6_sv_reass_t *reass)
vlib_trace_header_t ** trace_buffer_pool
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
description fragment has unexpected format
vlib_put_next_frame(vm, node, next_index, 0)
static u8 ip6_ext_hdr(u8 nexthdr)
#define VLIB_INIT_FUNCTION(x)
static clib_error_t * ip6_sv_reass_init_function(vlib_main_t *vm)
@ IP6_SV_REASSEMBLY_HANDOFF_N_ERROR
#define IP6_SV_REASS_HT_LOAD_FACTOR
static u8 * format_ip6_sv_reass_key(u8 *s, va_list *args)
#define vec_foreach(var, vec)
Vector iterator.
u32 ip6_sv_reass_expire_node_idx
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
static u16 ip6_get_port(vlib_main_t *vm, vlib_buffer_t *b, ip6_header_t *ip6, u16 buffer_len, u8 *ip_protocol, u16 *src_port, u16 *dst_port, u8 *icmp_type_or_tcp_flags, u32 *tcp_ack_number, u32 *tcp_seq_number)
Get L4 information like port number or ICMP id from IPv6 packet.
#define ip6_frag_hdr_offset_bytes(hdr)
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)
#define VNET_FEATURES(...)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vnet_interface_output_runtime_t * rt
@ IP6_SV_REASSEMBLY_NEXT_INPUT
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
@ IP6_SV_REASSEMBLY_N_NEXT
#define clib_warning(format, args...)
#define pool_alloc(P, N)
Allocate N more free elements to pool (unspecified alignment).
static int ip6_rehash_cb(clib_bihash_kv_48_8_t *kv, void *_ctx)
static f64 vlib_time_now(vlib_main_t *vm)
vlib_trace_main_t trace_main
static void * ip6_ext_next_header(ip6_ext_header_t *ext_hdr)
static clib_error_t * show_ip6_sv_reass(vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED(vlib_cli_command_t *lmd))
static u32 vlib_buffer_get_trace_index(vlib_buffer_t *b)
Extract the trace (pool) index from a trace handle.
static char * ip6_sv_reassembly_handoff_error_strings[]
vl_api_mac_event_action_t action
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).
VNET_FEATURE_INIT(ip6_sv_reassembly_feature)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
#define foreach_ip6_error
static bool ip6_sv_reass_verify_fragment_multiple_8(vlib_main_t *vm, vlib_buffer_t *b, ip6_frag_hdr_t *frag_hdr)
VLIB buffer representation.
#define VLIB_REGISTER_NODE(x,...)
u8 icmp_type_or_tcp_flags
@ IP6_SV_REASSEMBLY_NEXT_HANDOFF