|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
31 #define MSEC_PER_SEC 1000
32 #define IP4_SV_REASS_TIMEOUT_DEFAULT_MS 100
33 #define IP4_SV_REASS_EXPIRE_WALK_INTERVAL_DEFAULT_MS 10000 // 10 seconds default
34 #define IP4_SV_REASS_MAX_REASSEMBLIES_DEFAULT 1024
35 #define IP4_SV_REASS_MAX_REASSEMBLY_LENGTH_DEFAULT 3
36 #define IP4_SV_REASS_HT_LOAD_FACTOR (0.75)
164 #ifndef CLIB_MARCH_VARIANT
210 s =
format (s,
"[cached]");
214 format (s,
"[finish, ip proto=%u, src_port=%u, dst_port=%u]",
220 format (s,
"[forward, ip proto=%u, src_port=%u, dst_port=%u]",
225 s =
format (s,
"[not-fragmented]");
242 b->
flags &= ~VLIB_BUFFER_IS_TRACED;
259 printf (
"%.*s\n",
vec_len (s), s);
273 clib_bihash_add_del_16_8 (&rm->
hash, &kv, 0);
290 if (
rt->lru_first == reass -
rt->pool)
294 if (
rt->lru_last == reass -
rt->pool)
317 if (!clib_bihash_search_16_8 (&rm->
hash, &kv->
kv, &kv->
kv))
353 if (~0 !=
rt->lru_last)
360 if (~0 ==
rt->lru_first)
362 rt->lru_first =
rt->lru_last = reass -
rt->pool;
371 if (clib_bihash_add_del_16_8 (&rm->
hash, &kv->
kv, 1))
388 if (0 == fragment_first)
395 if (IP_PROTOCOL_TCP == reass->
ip_proto)
401 else if (IP_PROTOCOL_ICMP == reass->
ip_proto)
404 ((icmp46_header_t *) (ip0 + 1))->
type;
434 bool is_output_feature,
bool is_custom)
477 (is_output_feature ? 1 : 0) *
479 ip.save_rewrite_length);
482 (is_output_feature ? 1 : 0) *
484 ip.save_rewrite_length);
504 next0 = is_custom ?
vnet_buffer (b0)->ip.reass.next_index :
507 vnet_buffer (b0)->ip.reass.is_non_first_fragment = 0;
509 if (IP_PROTOCOL_TCP == ip0->
protocol)
511 vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
518 else if (IP_PROTOCOL_ICMP == ip0->
protocol)
520 vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
521 ((icmp46_header_t *) (ip0 + 1))->
type;
539 next1 = is_custom ?
vnet_buffer (b1)->ip.reass.next_index :
542 vnet_buffer (b1)->ip.reass.is_non_first_fragment = 0;
544 if (IP_PROTOCOL_TCP == ip1->
protocol)
546 vnet_buffer (b1)->ip.reass.icmp_type_or_tcp_flags =
553 else if (IP_PROTOCOL_ICMP == ip1->
protocol)
555 vnet_buffer (b1)->ip.reass.icmp_type_or_tcp_flags =
556 ((icmp46_header_t *) (ip1 + 1))->
type;
584 (is_output_feature ? 1 : 0) *
586 ip.save_rewrite_length);
609 vnet_buffer (b0)->ip.reass.is_non_first_fragment = 0;
611 if (IP_PROTOCOL_TCP == ip0->
protocol)
613 vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
620 else if (IP_PROTOCOL_ICMP == ip0->
protocol)
622 vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
623 ((icmp46_header_t *) (ip0 + 1))->
type;
659 u32 error0 = IP4_ERROR_NONE;
666 (is_output_feature ? 1 : 0) *
668 ip.save_rewrite_length);
680 vnet_buffer (b0)->ip.reass.is_non_first_fragment = 0;
682 if (IP_PROTOCOL_TCP == ip0->
protocol)
684 vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
691 else if (IP_PROTOCOL_ICMP == ip0->
protocol)
693 vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
694 ((icmp46_header_t *) (ip0 + 1))->
type;
711 const u32 fragment_length =
713 const u32 fragment_last = fragment_first + fragment_length - 1;
714 if (fragment_first > fragment_last || fragment_first + fragment_length > UINT16_MAX - 20 || (fragment_length < 8 &&
ip4_get_fragment_more (ip0)))
717 error0 = IP4_ERROR_REASS_MALFORMED_PACKET;
746 error0 = IP4_ERROR_REASS_LIMIT_REACHED;
751 if (reass->is_complete)
763 vnet_buffer (b0)->ip.reass.ip_proto = reass->ip_proto;
764 vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
765 reass->icmp_type_or_tcp_flags;
767 reass->tcp_ack_number;
769 reass->tcp_seq_number;
770 vnet_buffer (b0)->ip.reass.l4_src_port = reass->l4_src_port;
771 vnet_buffer (b0)->ip.reass.l4_dst_port = reass->l4_dst_port;
792 IP4_ERROR_REASS_FRAGMENT_CHAIN_TOO_LONG,
799 IP4_ERROR_REASS_FRAGMENT_CHAIN_TOO_LONG,
805 if (reass->is_complete)
810 u32 bi0 =
vec_elt (reass->cached_buffers, idx);
814 (is_output_feature ? 1 : 0) *
816 ip.save_rewrite_length);
826 if (0 == n_left_to_next)
838 vnet_buffer (b0)->ip.reass.ip_proto = reass->ip_proto;
839 vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
840 reass->icmp_type_or_tcp_flags;
842 reass->tcp_ack_number;
844 reass->tcp_seq_number;
845 vnet_buffer (b0)->ip.reass.l4_src_port = reass->l4_src_port;
846 vnet_buffer (b0)->ip.reass.l4_dst_port = reass->l4_dst_port;
856 to_next, n_left_to_next, bi0,
859 _vec_len (reass->cached_buffers) = 0;
867 if (is_feature && IP4_ERROR_NONE == error0)
873 to_next, n_left_to_next,
886 return frame->n_vectors;
890 #define _(sym, string) string,
906 .name =
"ip4-sv-reassembly",
907 .vector_size =
sizeof (
u32),
933 .name =
"ip4-sv-reassembly-feature",
934 .vector_size =
sizeof (
u32),
950 .arc_name =
"ip4-unicast",
951 .node_name =
"ip4-sv-reassembly-feature",
969 .name =
"ip4-sv-reassembly-output-feature",
970 .vector_size =
sizeof (
u32),
986 .arc_name =
"ip4-output",
987 .node_name =
"ip4-sv-reassembly-output-feature",
995 .name =
"ip4-sv-reassembly-custom-next",
996 .vector_size =
sizeof (
u32),
1020 #ifndef CLIB_MARCH_VARIANT
1030 for (
i = 0;
i < 31;
i++)
1031 if ((1 <<
i) >= nbuckets)
1047 clib_bihash_16_8_t *new_hash;
1050 #ifndef CLIB_MARCH_VARIANT
1055 if (clib_bihash_add_del_16_8 (
ctx->new_hash, kv, 1))
1059 return (BIHASH_WALK_CONTINUE);
1064 u32 max_reassembly_length,
1065 u32 expire_walk_interval_ms)
1076 u32 max_reassembly_length,
u32 expire_walk_interval_ms)
1080 max_reassembly_length, expire_walk_interval_ms);
1087 clib_bihash_16_8_t new_hash;
1091 ctx.new_hash = &new_hash;
1092 clib_bihash_init_16_8 (&new_hash,
"ip4-dr", new_nbuckets,
1093 new_nbuckets * 1024);
1098 clib_bihash_free_16_8 (&new_hash);
1114 u32 * max_reassembly_length,
u32 * expire_walk_interval_ms)
1140 rt->lru_first =
rt->lru_last = ~0;
1153 clib_bihash_init_16_8 (&rm->
hash,
"ip4-dr", nbuckets, nbuckets * 1024);
1177 uword event_type, *event_data = 0;
1201 int *pool_indexes_to_free = NULL;
1236 _vec_len (event_data) = 0;
1247 .name =
"ip4-sv-reassembly-expire-walk",
1261 "xx_id: %u, src: %U, dst: %U, frag_id: %u, proto: %u",
1263 &
key->dst, clib_net_to_host_u16 (
key->frag_id),
key->proto);
1273 s =
format (s,
"ID: %lu, key: %U trace_op_counter: %u\n",
1286 s =
format (s,
" #%03u: bi: %u, ", counter, bi);
1290 while (
b->
flags & VLIB_BUFFER_NEXT_PRESENT);
1305 bool details =
false;
1311 u32 sum_reass_n = 0;
1327 sum_reass_n +=
rt->reass_n;
1332 (
long unsigned) sum_reass_n);
1334 "Maximum configured concurrent shallow virtual IP4 reassemblies per worker-thread: %lu\n",
1337 "Maximum configured amount of fragments per shallow "
1338 "virtual IP4 reassembly: %lu\n",
1341 "Maximum configured shallow virtual IP4 reassembly timeout: %lums\n",
1344 "Maximum configured shallow virtual IP4 reassembly expire walk interval: %lums\n",
1351 .path =
"show ip4-sv-reassembly",
1352 .short_help =
"show ip4-sv-reassembly [details]",
1357 #ifndef CLIB_MARCH_VARIANT
1367 #define foreach_ip4_sv_reass_handoff_error \
1368 _(CONGESTION_DROP, "congestion drop")
1373 #define _(sym,str) IP4_SV_REASSEMBLY_HANDOFF_ERROR_##sym,
1380 #define _(sym,string) string,
1399 format (s,
"ip4-sv-reassembly-handoff: next-worker %d",
1422 ti = thread_indices;
1432 && (
b[0]->
flags & VLIB_BUFFER_IS_TRACED)))
1444 thread_indices,
frame->n_vectors, 1);
1448 IP4_SV_REASSEMBLY_HANDOFF_ERROR_CONGESTION_DROP,
1449 frame->n_vectors - n_enq);
1450 return frame->n_vectors;
1464 .name =
"ip4-sv-reassembly-handoff",
1465 .vector_size =
sizeof (
u32),
1493 .name =
"ip4-sv-reass-feature-hoff",
1494 .vector_size =
sizeof (
u32),
1507 #ifndef CLIB_MARCH_VARIANT
1519 "ip4-sv-reassembly-feature",
1530 "ip4-sv-reassembly-feature",
1555 "ip4-sv-reassembly-output-feature",
1566 "ip4-sv-reassembly-output-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.
vlib_node_registration_t ip4_sv_reass_node_feature
(constructor) VLIB_REGISTER_NODE (ip4_sv_reass_node_feature)
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
static u32 vlib_num_workers()
static void ip4_sv_reass_add_trace(vlib_main_t *vm, vlib_node_runtime_t *node, ip4_sv_reass_main_t *rm, ip4_sv_reass_t *reass, u32 bi, ip4_sv_reass_trace_operation_e action, u32 ip_proto, u16 l4_src_port, u16 l4_dst_port)
#define IP4_SV_REASS_MAX_REASSEMBLIES_DEFAULT
uword ip4_sv_reass_custom_register_next_node(uword node_index)
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
#define u8_ptr_add(ptr, index)
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)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
#define IP4_SV_REASS_MAX_REASSEMBLY_LENGTH_DEFAULT
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
nat44_ei_hairpin_src_next_t next_index
static vlib_cli_command_t show_ip4_sv_reass_cmd
(constructor) VLIB_CLI_COMMAND (show_ip4_sv_reass_cmd)
ip4_main_t ip4_main
Global ip4 main structure.
@ IP4_SV_REASSEMBLY_NEXT_INPUT
vlib_node_registration_t ip4_sv_reass_feature_handoff_node
(constructor) VLIB_REGISTER_NODE (ip4_sv_reass_feature_handoff_node)
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.
static clib_error_t * show_ip4_reass(vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED(vlib_cli_command_t *lmd))
static u8 * format_ip4_sv_reass_handoff_trace(u8 *s, va_list *args)
struct _tcp_header tcp_header_t
vlib_get_buffers(vm, from, b, n_left_from)
u8 icmp_type_or_tcp_flags
vlib_main_t vlib_node_runtime_t * node
u32 fq_index
Worker handoff.
static char * ip4_sv_reass_handoff_error_strings[]
@ IP4_SV_REASSEMBLY_N_NEXT
vnet_api_error_t ip4_sv_reass_get(u32 *timeout_ms, u32 *max_reassemblies, u32 *max_reassembly_length, u32 *expire_walk_interval_ms)
get ip4 reassembly configuration
static void ip4_sv_reass_set_params(u32 timeout_ms, u32 max_reassemblies, u32 max_reassembly_length, u32 expire_walk_interval_ms)
static int ip4_get_fragment_offset_bytes(const ip4_header_t *i)
#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.
@ IP4_SV_REASSEMBLY_HANDOFF_N_ERROR
@ IP4_SV_REASS_RC_TOO_MANY_FRAGMENTS
u32 * output_feature_use_refcount_per_intf
vlib_buffer_enqueue_to_next(vm, node, from,(u16 *) nexts, frame->n_vectors)
int ip4_sv_reass_output_enable_disable_with_refcnt(u32 sw_if_index, int is_enable)
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
vnet_api_error_t ip4_sv_reass_set(u32 timeout_ms, u32 max_reassemblies, u32 max_reassembly_length, u32 expire_walk_interval_ms)
set ip4 reassembly configuration
u32 vlib_frame_queue_main_init(u32 node_index, u32 frame_queue_nelts)
#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.
#define IP4_SV_REASS_EXPIRE_WALK_INTERVAL_DEFAULT_MS
static void ip4_sv_reass_init(ip4_sv_reass_t *reass)
static u16 ip4_get_port(ip4_header_t *ip, u8 sender)
Get TCP/UDP port number or ICMP id from IPv4 packet.
#define CLIB_PREFETCH(addr, size, type)
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
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 u8 * format_ip4_sv_reass(u8 *s, va_list *args)
vlib_node_registration_t ip4_sv_reass_node_output_feature
(constructor) VLIB_REGISTER_NODE (ip4_sv_reass_node_output_feature)
static u8 * format_ip4_sv_reass_trace(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.
IPv4 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
u32 * feature_use_refcount_per_intf
ip4_sv_reass_trace_operation_e
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)
#define foreach_ip4_sv_reass_handoff_error
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
__clib_export void clib_bihash_copied(void *dst, void *src)
static void ip4_sv_reass_free(vlib_main_t *vm, ip4_sv_reass_main_t *rm, ip4_sv_reass_per_thread_t *rt, ip4_sv_reass_t *reass)
vlib_node_registration_t ip4_sv_reass_node
(constructor) VLIB_REGISTER_NODE (ip4_sv_reass_node)
#define IP4_SV_REASS_TIMEOUT_DEFAULT_MS
static uword ip4_sv_reass_walk_expired(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
#define vec_foreach_index(var, v)
Iterate over vector indices.
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
@ IP4_SV_REASSEMBLY_NEXT_HANDOFF
static clib_error_t * ip4_sv_reass_init_function(vlib_main_t *vm)
sll srl srl sll sra u16x4 i
static uword ip4_sv_reass_handoff_node_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, bool is_feature)
#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)
#define VLIB_CLI_COMMAND(x,...)
#define CLIB_CACHE_LINE_BYTES
struct _vlib_node_registration vlib_node_registration_t
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
ip4_sv_reass_trace_operation_e action
u32 expire_walk_interval_ms
static u16 ip4_get_fragment_more(const ip4_header_t *i)
vlib_node_registration_t ip4_sv_reass_expire_node
(constructor) VLIB_REGISTER_NODE (ip4_sv_reass_expire_node)
#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.
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
#define pool_foreach_index(i, v)
u32 ip4_sv_reass_expire_node_idx
vlib_trace_header_t ** trace_buffer_pool
static ip4_sv_reass_rc_t ip4_sv_reass_update(vlib_main_t *vm, vlib_node_runtime_t *node, ip4_sv_reass_main_t *rm, ip4_sv_reass_per_thread_t *rt, ip4_header_t *ip0, ip4_sv_reass_t *reass, u32 bi0)
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...
vlib_node_registration_t ip4_sv_reass_handoff_node
(constructor) VLIB_REGISTER_NODE (ip4_sv_reass_handoff_node)
description fragment has unexpected format
vlib_put_next_frame(vm, node, next_index, 0)
#define VLIB_INIT_FUNCTION(x)
static char * ip4_sv_reass_error_strings[]
VNET_FEATURE_INIT(ip4_sv_reass_feature)
static u32 ip4_sv_reass_get_nbuckets()
ip4_sv_reass_main_t ip4_sv_reass_main
static u8 * format_ip4_sv_reass_key(u8 *s, va_list *args)
#define vec_foreach(var, vec)
Vector iterator.
ip4_sv_reass_per_thread_t * per_thread_data
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
static ip4_sv_reass_t * ip4_sv_reass_find_or_create(vlib_main_t *vm, ip4_sv_reass_main_t *rm, ip4_sv_reass_per_thread_t *rt, ip4_sv_reass_kv_t *kv, u8 *do_handoff)
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)
#define foreach_ip4_error
static u32 slow_path(nat44_ei_main_t *nm, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t i2o_addr, u16 i2o_port, u32 rx_fib_index0, nat_protocol_t nat_proto, nat44_ei_session_t **sessionp, vlib_node_runtime_t *node, u32 next0, u32 thread_index, f64 now)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define IP4_SV_REASS_HT_LOAD_FACTOR
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static vlib_main_t * vlib_get_main(void)
#define VNET_FEATURES(...)
static int ip4_rehash_cb(clib_bihash_kv_16_8_t *kv, void *_ctx)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vnet_interface_output_runtime_t * rt
@ IP4_SV_REASSEMBLY_NEXT_DROP
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
IPv4 to IPv6 translation.
#define clib_warning(format, args...)
#define pool_alloc(P, N)
Allocate N more free elements to pool (unspecified alignment).
u16 nexts[VLIB_FRAME_SIZE]
static int ip4_header_bytes(const ip4_header_t *i)
ip4_sv_reass_handoff_error_t
@ IP4_EVENT_CONFIG_CHANGED
static f64 vlib_time_now(vlib_main_t *vm)
vlib_trace_main_t trace_main
@ IP4_SV_REASS_RC_UNSUPP_IP_PROTO
static u32 vlib_buffer_get_trace_index(vlib_buffer_t *b)
Extract the trace (pool) index from a trace handle.
static uword ip4_sv_reass_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, bool is_feature, bool is_output_feature, bool is_custom)
vl_api_mac_event_action_t action
vl_api_interface_index_t sw_if_index
int ip4_sv_reass_enable_disable_with_refcnt(u32 sw_if_index, int is_enable)
#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).
vlib_node_registration_t ip4_sv_reass_custom_node
(constructor) VLIB_REGISTER_NODE (ip4_sv_reass_custom_node)
vnet_api_error_t ip4_sv_reass_enable_disable(u32 sw_if_index, u8 enable_disable)
vl_api_fib_path_type_t type
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,...)
vl_api_wireguard_peer_flags_t flags