|
FD.io VPP
v21.06-3-gbb25fbf28
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]");
235 b->
flags &= ~VLIB_BUFFER_IS_TRACED;
252 printf (
"%.*s\n",
vec_len (s), s);
269 clib_bihash_add_del_48_8 (&rm->
hash, &kv, 0);
286 if (
rt->lru_first == reass -
rt->pool)
290 if (
rt->lru_last == reass -
rt->pool)
315 if (!clib_bihash_search_48_8 (&rm->
hash, &kv->
kv, &kv->
kv))
352 if (~0 !=
rt->lru_last)
359 if (~0 ==
rt->lru_first)
361 rt->lru_first =
rt->lru_last = reass -
rt->pool;
374 if (clib_bihash_add_del_48_8 (&rm->
hash, &kv->
kv, 1))
387 ip6_frag_hdr_t * frag_hdr)
391 fvnb->
ip.reass.ip6_frag_hdr_offset =
395 fvnb->
ip.reass.ip6_frag_hdr_offset == 0 ||
401 u32 fragment_first = fvnb->
ip.reass.fragment_first =
403 u32 fragment_length =
405 (fvnb->
ip.reass.ip6_frag_hdr_offset +
sizeof (*frag_hdr));
406 u32 fragment_last = fvnb->
ip.reass.fragment_last =
407 fragment_first + fragment_length - 1;
408 fvnb->
ip.reass.range_first = fragment_first;
409 fvnb->
ip.reass.range_last = fragment_last;
410 fvnb->
ip.reass.next_range_bi = ~0;
411 if (0 == fragment_first)
449 ip6_frag_hdr_t * frag_hdr)
451 ip6_ext_header_t *
tmp = (ip6_ext_header_t *) frag_hdr;
456 if (IP_PROTOCOL_IP6_NONXT ==
tmp->next_hdr)
459 ICMP6_parameter_problem_first_fragment_has_incomplete_header_chain,
461 b->
error =
node->errors[IP6_ERROR_REASS_MISSING_UPPER];
472 ip6_frag_hdr_t * frag_hdr)
477 u32 fragment_length =
479 (vnb->
ip.reass.ip6_frag_hdr_offset +
sizeof (*frag_hdr));
480 if (more_fragments && 0 != fragment_length % 8)
483 ICMP6_parameter_problem_erroneous_header_field,
484 (
u8 *) &
ip->payload_length - (
u8 *)
ip);
494 ip6_frag_hdr_t * frag_hdr)
498 u32 fragment_length =
500 (vnb->
ip.reass.ip6_frag_hdr_offset +
sizeof (*frag_hdr));
501 if (fragment_first + fragment_length > 65535)
505 ICMP6_parameter_problem_erroneous_header_field,
506 (
u8 *) & frag_hdr->fragment_offset_and_more
536 u32 error0 = IP6_ERROR_NONE;
543 ip6_frag_hdr_t *frag_hdr = NULL;
544 ip6_ext_header_t *prev_hdr;
549 IP_PROTOCOL_IPV6_FRAGMENTATION,
564 error0 = IP6_ERROR_REASS_UNSUPP_IP_PROTO;
569 vnet_buffer (b0)->ip.reass.is_non_first_fragment = 0;
584 (
u8 *) frag_hdr - (
u8 *) ip0;
589 (
node, b0, frag_hdr))
614 (
u64) frag_hdr->identification;
632 error0 = IP6_ERROR_REASS_LIMIT_REACHED;
637 if (reass->is_complete)
641 vnet_buffer (b0)->ip.reass.ip_proto = reass->ip_proto;
642 vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
643 reass->icmp_type_or_tcp_flags;
645 reass->tcp_ack_number;
647 reass->tcp_seq_number;
648 vnet_buffer (b0)->ip.reass.l4_src_port = reass->l4_src_port;
649 vnet_buffer (b0)->ip.reass.l4_dst_port = reass->l4_dst_port;
663 (
vm,
node, rm,
rt, reass, bi0, frag_hdr))
670 IP6_ERROR_REASS_FRAGMENT_CHAIN_TOO_LONG,
677 IP6_ERROR_REASS_UNSUPP_IP_PROTO,
684 IP6_ERROR_REASS_INTERNAL_ERROR, 1);
690 if (reass->is_complete)
695 u32 bi0 =
vec_elt (reass->cached_buffers, idx);
696 if (0 == n_left_to_next)
716 vnet_buffer (b0)->ip.reass.ip_proto = reass->ip_proto;
717 vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
718 reass->icmp_type_or_tcp_flags;
720 reass->tcp_ack_number;
722 reass->tcp_seq_number;
723 vnet_buffer (b0)->ip.reass.l4_src_port = reass->l4_src_port;
724 vnet_buffer (b0)->ip.reass.l4_dst_port = reass->l4_dst_port;
734 to_next, n_left_to_next, bi0,
737 _vec_len (reass->cached_buffers) = 0;
745 if (is_feature && IP6_ERROR_NONE == error0)
751 n_left_to_next, bi0, next0);
756 to_next[0] = icmp_bi;
760 n_left_to_next, icmp_bi,
773 return frame->n_vectors;
777 #define _(sym, string) string,
791 .name =
"ip6-sv-reassembly",
792 .vector_size =
sizeof (
u32),
816 .name =
"ip6-sv-reassembly-feature",
817 .vector_size =
sizeof (
u32),
834 .arc_name =
"ip6-unicast",
835 .node_name =
"ip6-sv-reassembly-feature",
841 #ifndef CLIB_MARCH_VARIANT
851 for (
i = 0;
i < 31;
i++)
852 if ((1 <<
i) >= nbuckets)
865 #ifndef CLIB_MARCH_VARIANT
869 clib_bihash_48_8_t *new_hash;
876 if (clib_bihash_add_del_48_8 (
ctx->new_hash, kv, 1))
880 return (BIHASH_WALK_CONTINUE);
885 u32 max_reassembly_length,
886 u32 expire_walk_interval_ms)
897 u32 max_reassembly_length,
u32 expire_walk_interval_ms)
901 max_reassembly_length, expire_walk_interval_ms);
908 clib_bihash_48_8_t new_hash;
912 ctx.new_hash = &new_hash;
913 clib_bihash_init_48_8 (&new_hash,
"ip6-sv-reass", new_nbuckets,
914 new_nbuckets * 1024);
919 clib_bihash_free_48_8 (&new_hash);
935 u32 * max_reassembly_length,
u32 * expire_walk_interval_ms)
961 rt->lru_first =
rt->lru_last = ~0;
974 clib_bihash_init_48_8 (&rm->
hash,
"ip6-sv-reass", nbuckets,
1004 uword event_type, *event_data = 0;
1027 int *pool_indexes_to_free = NULL;
1062 _vec_len (event_data) = 0;
1074 .name =
"ip6-sv-reassembly-expire-walk",
1086 s =
format (s,
"xx_id: %u, src: %U, dst: %U, frag_id: %u, proto: %u",
1088 &
key->dst, clib_net_to_host_u16 (
key->frag_id),
key->proto);
1098 s =
format (s,
"ID: %lu, key: %U, trace_op_counter: %u\n",
1110 s =
format (s,
" #%03u: bi: %u\n", counter, bi);
1114 while (
b->
flags & VLIB_BUFFER_NEXT_PRESENT);
1128 bool details =
false;
1134 u32 sum_reass_n = 0;
1135 u64 sum_buffers_n = 0;
1151 sum_reass_n +=
rt->reass_n;
1156 (
long unsigned) sum_reass_n);
1158 "Maximum configured concurrent shallow virtual IP6 reassemblies per worker-thread: %lu\n",
1161 "Maximum configured amount of fragments per shallow "
1162 "virtual IP6 reassembly: %lu\n",
1165 "Maximum configured shallow virtual IP6 reassembly timeout: %lums\n",
1168 "Maximum configured shallow virtual IP6 reassembly expire walk interval: %lums\n",
1171 (
long unsigned) sum_buffers_n);
1177 .path =
"show ip6-sv-reassembly",
1178 .short_help =
"show ip6-sv-reassembly [details]",
1183 #ifndef CLIB_MARCH_VARIANT
1192 #define foreach_ip6_sv_reassembly_handoff_error \
1193 _(CONGESTION_DROP, "congestion drop")
1198 #define _(sym,str) IP6_SV_REASSEMBLY_HANDOFF_ERROR_##sym,
1205 #define _(sym,string) string,
1224 format (s,
"ip6-sv-reassembly-handoff: next-worker %d",
1247 ti = thread_indices;
1257 && (
b[0]->
flags & VLIB_BUFFER_IS_TRACED)))
1269 thread_indices,
frame->n_vectors, 1);
1273 IP6_SV_REASSEMBLY_HANDOFF_ERROR_CONGESTION_DROP,
1274 frame->n_vectors - n_enq);
1275 return frame->n_vectors;
1288 .name =
"ip6-sv-reassembly-handoff",
1289 .vector_size =
sizeof (
u32),
1311 .name =
"ip6-sv-reass-feature-hoff",
1312 .vector_size =
sizeof (
u32),
1325 #ifndef CLIB_MARCH_VARIANT
1337 "ip6-sv-reassembly-feature",
1347 "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 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_per_thread_t *rt, ip6_sv_reass_t *reass, u32 bi0, ip6_frag_hdr_t *frag_hdr)
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
vnet_api_error_t ip6_sv_reass_enable_disable(u32 sw_if_index, u8 enable_disable)
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.
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 ip6_sv_reass_t * ip6_sv_reass_find_or_create(vlib_main_t *vm, vlib_node_runtime_t *node, ip6_sv_reass_main_t *rm, ip6_sv_reass_per_thread_t *rt, ip6_sv_reass_kv_t *kv, u32 *icmp_bi, u8 *do_handoff)
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)
#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)
sll srl srl sll sra u16x4 i
static bool ip6_sv_reass_verify_fragment_multiple_8(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b, ip6_frag_hdr_t *frag_hdr)
static bool ip6_sv_reass_verify_packet_size_lt_64k(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b, ip6_frag_hdr_t *frag_hdr)
#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 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)
static uword ip6_sv_reass_walk_expired(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
#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 void ip6_sv_reass_add_trace(vlib_main_t *vm, vlib_node_runtime_t *node, ip6_sv_reass_main_t *rm, 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)
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
VLIB buffer representation.
#define VLIB_REGISTER_NODE(x,...)
u8 icmp_type_or_tcp_flags
@ IP6_SV_REASSEMBLY_NEXT_HANDOFF