|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
16 #include <netinet/in.h>
40 void *format_addr_func;
63 return (
format (s,
"l3 %U -> %U %U | sess id %d thread id %d epoch %04x",
64 format_addr_func, paddr0,
65 format_addr_func, paddr1,
87 if (!
am->fa_sessions_hash_is_initialized)
91 for (wk = 0; wk <
vec_len (
am->per_worker_data); wk++)
101 am->fa_conn_table_max_entries);
105 clib_bihash_init_40_8 (&
am->fa_ip6_sessions_hash,
106 "ACL plugin FA IPv6 session bihash",
107 am->fa_conn_table_hash_num_buckets,
108 am->fa_conn_table_hash_memory_size);
109 clib_bihash_set_kvp_format_fn_40_8 (&
am->fa_ip6_sessions_hash,
112 clib_bihash_init_16_8 (&
am->fa_ip4_sessions_hash,
113 "ACL plugin FA IPv4 session bihash",
114 am->fa_conn_table_hash_num_buckets,
115 am->fa_conn_table_hash_memory_size);
116 clib_bihash_set_kvp_format_fn_16_8 (&
am->fa_ip4_sessions_hash,
119 am->fa_sessions_hash_is_initialized = 1;
131 u64 timeout =
am->vlib_main->clib_time.clocks_per_second / 1000;
155 return (timeout_time <
now)
170 int total_expired = 0;
196 int n_pending_swipes = 0;
200 while (n_expired < am->fa_max_deleted_sessions_per_interval)
208 if (
am->trace_sessions > 3)
211 "acl_fa_check_idle_sessions: expire session %d in list %d on thread %d",
229 if (n_pending_swipes == 0)
244 u64 sess_timeout_time =
246 int timeout_passed = (
now >= sess_timeout_time);
247 int clearing_interface =
249 if (
am->trace_sessions > 3)
252 "acl_fa_check_idle_sessions: now %lu sess_timeout_time %lu",
253 "i8i8",
now, sess_timeout_time);
255 "acl_fa_check_idle_sessions: session %d sw_if_index %d timeout_passed %d clearing_interface %d",
258 (
u32) timeout_passed,
259 (
u32) clearing_interface);
261 if (timeout_passed || clearing_interface)
265 if (
am->trace_sessions > 3)
268 "acl_fa_check_idle_sessions: deleted session %d sw_if_index %d",
278 if (
am->trace_sessions > 3)
281 "acl_fa_check_idle_sessions: session %d sw_if_index %d marked as deleted, put to purgatory",
290 if (
am->trace_sessions > 3)
293 "acl_fa_check_idle_sessions: restart timer for session %d sw_if_index %d",
320 "acl_fa_check_idle_sessions: done, total sessions expired: %d",
321 "i4", (
u32) total_expired);
322 return (total_expired);
333 #define foreach_acl_fa_cleaner_error \
334 _(UNKNOWN_EVENT, "unknown event received") \
339 #define _(sym,str) ACL_FA_CLEANER_ERROR_##sym,
346 #define _(sym,string) string,
368 "send_one_worker_interrupt: send interrupt to worker %u",
378 u32 target_session,
u32 request_type)
386 (((
u64) request_type) << 32) | target_session);
438 "acl_fa_worker_conn_cleaner interrupt: now %lu",
461 "acl_fa_worker_conn_cleaner: now %lu, someone tried to call clear but one of the bitmaps are empty",
467 #ifdef FA_NODE_VERBOSE_DEBUG
469 (
"WORKER-CLEAR: (before and) swiping sw-if-index bitmap: %U, my serviced bitmap %U",
482 "acl_fa_worker_conn_cleaner: now %lu, clearing done, nothing to do",
489 #ifdef FA_NODE_VERBOSE_DEBUG
491 (
"WORKER-CLEAR: swiping sw-if-index bitmap: %U, my serviced bitmap %U",
496 "acl_fa_worker_conn_cleaner: swiping until %lu",
506 "acl_fa_worker_conn_cleaner: checked %d sessions (clear_in_process: %d)",
507 "i4i4", (
u32) num_expired,
517 "acl_fa_worker_conn_cleaner: now %lu, clearing done - all done",
523 "acl_fa_worker_conn_cleaner: now %lu, more work to do - requesting interrupt",
546 "acl_fa_worker_conn_cleaner: now %lu, interrupt needed: %u, interrupt unwanted: %u",
565 for (
i = 0;
i < n_threads;
i++)
581 u64 max_timer_wait_interval = cpu_cps / 2;
582 uword event_type, *event_data = 0;
585 am->fa_current_cleaner_timer_wait_interval = max_timer_wait_interval;
587 am->fa_interrupt_generation = 1;
591 next_expire =
now +
am->fa_current_cleaner_timer_wait_interval;
592 int has_pending_conns = 0;
618 "acl_fa_session_cleaner_process: now %lu, worker: %u tt: %u",
619 "i8i2i2",
now,
ti, tt);
621 "acl_fa_session_cleaner_process: head expiry: %lu, is earlier than curr next expire: %lu",
622 "i8i8", head_expiry, next_expire);
623 next_expire = head_expiry;
627 has_pending_conns = 1;
633 if (!has_pending_conns && (0 ==
am->fa_total_enabled_count))
635 am->fa_cleaner_cnt_wait_without_timeout++;
637 "acl_conn_cleaner: now %lu entering wait without timeout",
644 f64 timeout = ((
i64) next_expire - (
i64)
now) / cpu_cps;
652 am->fa_cleaner_cnt_wait_with_timeout++;
654 "acl_conn_cleaner: now %lu entering wait with timeout %.6f sec",
655 "i8f8",
now, timeout);
671 uword *clear_sw_if_index_bitmap = 0;
676 "acl_fa_session_cleaner_process: now %lu, received ACL_FA_CLEANER_DELETE_BY_SW_IF_INDEX",
680 am->fa_cleaner_cnt_delete_by_sw_index++;
682 "acl_fa_session_cleaner_process: ACL_FA_CLEANER_DELETE_BY_SW_IF_INDEX %u",
683 "i4", *sw_if_index0);
684 if (*sw_if_index0 == ~0)
691 (
am->vnet_main->interface_main.sw_interfaces,
694 clear_sw_if_index_bitmap =
701 (
"ACL_FA_CLEANER_DELETE_BY_SW_IF_INDEX bitmap: %U, clear_all: %u",
710 "ACL_FA_NODE_CLEAN: waiting previous cleaning cycle to finish on %u",
712 (
u32) (pw0 -
am->per_worker_data));
717 (pw0 -
am->per_worker_data));
723 (
"ERROR-BUG! Could not initiate cleaning on worker because another cleanup in progress");
739 (
"ACL_FA_CLEANER: thread %u, pending clear bitmap: %U",
749 acl_log_info (
"CLEANER mains len: %u per-worker len: %d",
759 "ACL_FA_NODE_CLEAN: waiting for my cleaning cycle to finish on %u",
761 (
u32) (pw0 -
am->per_worker_data));
766 (pw0 -
am->per_worker_data));
773 am->fa_cleaner_cnt_delete_by_sw_index_ok++;
776 #ifdef FA_NODE_VERBOSE_DEBUG
777 clib_warning (
"ACL plugin connection cleaner: unknown event %u",
783 ACL_FA_CLEANER_ERROR_UNKNOWN_EVENT, 1);
784 am->fa_cleaner_cnt_unknown_event++;
791 _vec_len (event_data) = 0;
797 int need_more_wait = 0;
798 int max_wait_cycles = 100;
814 while (need_more_wait && (--max_wait_cycles > 0));
816 int interrupts_needed = 0;
817 int interrupts_unwanted = 0;
828 interrupts_unwanted++;
832 if (interrupts_needed)
835 am->fa_current_cleaner_timer_wait_interval /= 2;
837 am->fa_current_cleaner_timer_wait_interval += 1;
839 else if (interrupts_unwanted)
842 if (
am->fa_current_cleaner_timer_wait_interval <
843 max_timer_wait_interval)
844 am->fa_current_cleaner_timer_wait_interval +=
845 cpu_cps *
am->fa_cleaner_wait_time_increment;
847 am->fa_cleaner_cnt_event_cycles++;
848 am->fa_interrupt_generation++;
862 am->fa_total_enabled_count++;
870 am->fa_total_enabled_count--;
883 am->fa_in_acl_on_sw_if_index =
897 am->fa_out_acl_on_sw_if_index =
904 #ifdef FA_NODE_VERBOSE_DEBUG
905 clib_warning (
"ENABLE-DISABLE: clean the connections on interface %d",
920 if (
am->fa_sessions_hash_is_initialized)
923 format_bihash_40_8, &
am->fa_ip6_sessions_hash,
927 format_bihash_16_8, &
am->fa_ip4_sessions_hash,
933 "\nSession lookup hash table is not allocated.\n\n");
942 .name =
"acl-plugin-fa-worker-cleaner-process",
944 .state = VLIB_NODE_STATE_INTERRUPT,
950 .name =
"acl-plugin-fa-cleaner-process",
#define elog_acl_maybe_trace_X2(am, acl_elog_trace_format_label, acl_elog_trace_format_args, acl_elog_val1, acl_elog_val2)
fa_session_t * fa_sessions_pool
#define acl_log_info(...)
void show_fa_sessions_hash(vlib_main_t *vm, u32 verbose)
static u64 acl_fa_get_list_head_expiry_time(acl_main_t *am, acl_fa_per_worker_data_t *pw, u64 now, u16 thread_index, int timeout_type)
static_always_inline u8 * format_ip46_session_bihash_kv(u8 *s, va_list *args, int is_ip6)
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
static u64 fa_session_get_timeout(acl_main_t *am, fa_session_t *sess)
ip4_address_t ip4_addr[2]
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
clib_spinlock_t pending_session_change_request_lock
static_always_inline u8 * format_fa_session_l4_key(u8 *s, va_list *args)
static char * acl_fa_cleaner_error_strings[]
static int acl_fa_check_idle_sessions(acl_main_t *am, u16 thread_index, u64 now)
u64 * fa_conn_list_head_expiry_time
@ ACL_FA_CLEANER_RESCHEDULE
static uword acl_fa_session_cleaner_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
uword * serviced_sw_if_index_bitmap
@ ACL_FA_CLEANER_DELETE_BY_SW_IF_INDEX
static int purgatory_has_connections(vlib_main_t *vm, acl_main_t *am, int thread_index)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static int acl_fa_restart_timer_for_session(acl_main_t *am, u64 now, fa_full_session_id_t sess_id)
u64 sent_session_change_requests
static void acl_fa_conn_list_add_session(acl_main_t *am, fa_full_session_id_t sess_id, u64 now)
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
u64 cnt_session_timer_restarted
void acl_fa_enable_disable(u32 sw_if_index, int is_input, int enable_disable)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
#define elog_acl_maybe_trace_X3(am, acl_elog_trace_format_label, acl_elog_trace_format_args, acl_elog_val1, acl_elog_val2, acl_elog_val3)
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,...
int interrupt_is_unwanted
#define pool_init_fixed(pool, max_elts)
initialize a fixed-size, preallocated pool
clib_bihash_kv_16_8_t kv_16_8
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static int acl_fa_ifc_has_in_acl(acl_main_t *am, int sw_if_index0)
static vlib_node_registration_t acl_fa_session_cleaner_process_node
(constructor) VLIB_REGISTER_NODE (acl_fa_session_cleaner_process_node)
static vlib_node_registration_t acl_fa_worker_session_cleaner_process_node
(constructor) VLIB_REGISTER_NODE (acl_fa_worker_session_cleaner_process_node)
#define foreach_acl_fa_cleaner_error
#define static_always_inline
static int acl_fa_conn_time_to_check(acl_main_t *am, acl_fa_per_worker_data_t *pw, u64 now, u16 thread_index, u32 session_index)
static int acl_fa_two_stage_delete_session(acl_main_t *am, u32 sw_if_index, fa_full_session_id_t sess_id, u64 now)
#define clib_bitmap_free(v)
Free a bitmap.
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
#define FA_SESSION_BOGUS_INDEX
#define CLIB_MEMORY_BARRIER()
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap.
static void send_interrupts_to_workers(vlib_main_t *vm, acl_main_t *am)
struct _vlib_node_registration vlib_node_registration_t
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static_always_inline uword os_get_thread_index(void)
static u8 * format_ip4_session_bihash_kv(u8 *s, va_list *args)
static u8 * format_ip6_session_bihash_kv(u8 *s, va_list *args)
static uword * clib_bitmap_and(uword *ai, uword *bi)
Logical operator across two bitmaps.
static uword acl_fa_worker_conn_cleaner_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
#define elog_acl_maybe_trace_X4(am, acl_elog_trace_format_label, acl_elog_trace_format_args, acl_elog_val1, acl_elog_val2, acl_elog_val3, acl_elog_val4)
u64 cnt_already_deleted_sessions
static fa_session_t * get_session_ptr(acl_main_t *am, u16 thread_index, u32 session_index)
static int acl_fa_conn_list_delete_session(acl_main_t *am, fa_full_session_id_t sess_id, u64 now)
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
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
static u64 fa_session_get_list_timeout(acl_main_t *am, fa_session_t *sess)
static void vlib_node_set_interrupt_pending(vlib_main_t *vm, u32 node_index)
@ ACL_FA_REQ_SESS_RESCHEDULE
static void acl_fa_verify_init_sessions(acl_main_t *am)
#define vec_foreach(var, vec)
Vector iterator.
static vlib_main_t * vlib_get_main_by_index(u32 thread_index)
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)
void aclp_post_session_change_request(acl_main_t *am, u32 target_thread, u32 target_session, u32 request_type)
ip6_address_t ip6_addr[2]
static u32 vlib_get_n_threads()
u64 * pending_session_change_requests
vnet_interface_output_runtime_t * rt
#define clib_warning(format, args...)
__clib_export u8 * format_bitmap_hex(u8 *s, va_list *args)
Format a bitmap as a string of hex bytes.
uword * pending_clear_sw_if_index_bitmap
static int acl_fa_ifc_has_out_acl(acl_main_t *am, int sw_if_index0)
void aclp_swap_wip_and_pending_session_change_requests(acl_main_t *am, u32 target_thread)
#define clib_bitmap_zero(v)
Clear a bitmap.
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
#define elog_acl_maybe_trace_X1(am, acl_elog_trace_format_label, acl_elog_trace_format_args, acl_elog_val1)
static u64 clib_cpu_time_now(void)
u64 rcvd_session_change_requests
clib_bihash_kv_40_8_t kv_40_8
vl_api_interface_index_t sw_if_index
static clib_mem_heap_t * clib_mem_set_heap(clib_mem_heap_t *heap)
u64 * wip_session_change_requests
static uword clib_bitmap_is_zero(uword *ai)
predicate function; is an entire bitmap empty?
static void send_one_worker_interrupt(vlib_main_t *vm, acl_main_t *am, int thread_index)
#define clib_bitmap_dup(v)
Duplicate a bitmap.
#define VLIB_REGISTER_NODE(x,...)