5 #include "bihash_40_8.h"
7 #define TCP_FLAG_FIN 0x01
8 #define TCP_FLAG_SYN 0x02
9 #define TCP_FLAG_RST 0x04
10 #define TCP_FLAG_PUSH 0x08
11 #define TCP_FLAG_ACK 0x10
12 #define TCP_FLAG_URG 0x20
13 #define TCP_FLAG_ECE 0x40
14 #define TCP_FLAG_CWR 0x80
15 #define TCP_FLAGS_RSTFINACKSYN (TCP_FLAG_RST + TCP_FLAG_FIN + TCP_FLAG_SYN + TCP_FLAG_ACK)
16 #define TCP_FLAGS_ACKSYN (TCP_FLAG_SYN + TCP_FLAG_ACK)
18 #define ACL_FA_CONN_TABLE_DEFAULT_HASH_NUM_BUCKETS (64 * 1024)
19 #define ACL_FA_CONN_TABLE_DEFAULT_HASH_MEMORY_SIZE (1<<30)
20 #define ACL_FA_CONN_TABLE_DEFAULT_MAX_ENTRIES 1000000
29 u8 is_nonfirst_fragment:1;
41 } fa_session_l4_key_t;
45 ip46_address_t addr[2];
46 fa_session_l4_key_t l4;
47 /* This field should align with u64 value in bihash_40_8 keyvalue struct */
50 clib_bihash_kv_40_8_t kv;
55 fa_5tuple_t info; /* (5+1)*8 = 48 bytes */
56 u64 last_active_time; /* +8 bytes = 56 */
57 u32 sw_if_index; /* +4 bytes = 60 */
61 } tcp_flags_seen; ; /* +2 bytes = 62 */
62 u16 thread_index; /* +2 bytes = 64 */
63 u64 link_enqueue_time; /* 8 byte = 8 */
64 u32 link_prev_idx; /* +4 bytes = 12 */
65 u32 link_next_idx; /* +4 bytes = 16 */
66 u8 link_list_id; /* +1 bytes = 17 */
67 u8 reserved1[7]; /* +7 bytes = 24 */
68 u64 reserved2[5]; /* +5*8 bytes = 64 */
72 /* This structure is used to fill in the u64 value
73 in the per-sw-if-index hash table */
83 } fa_full_session_id_t;
86 * A few compile-time constraints on the size and the layout of the union, to ensure
87 * it makes sense both for bihash and for us.
90 #define CT_ASSERT_EQUAL(name, x,y) typedef int assert_ ## name ## _compile_time_assertion_failed[((x) == (y))-1]
91 CT_ASSERT_EQUAL(fa_l3_key_size_is_40, offsetof(fa_5tuple_t, pkt), offsetof(clib_bihash_kv_40_8_t, value));
92 CT_ASSERT_EQUAL(fa_l4_key_t_is_8, sizeof(fa_session_l4_key_t), sizeof(u64));
93 CT_ASSERT_EQUAL(fa_packet_info_t_is_8, sizeof(fa_packet_info_t), sizeof(u64));
94 CT_ASSERT_EQUAL(fa_l3_kv_size_is_48, sizeof(fa_5tuple_t), sizeof(clib_bihash_kv_40_8_t));
96 /* Let's try to fit within two cachelines */
97 CT_ASSERT_EQUAL(fa_session_t_size_is_128, sizeof(fa_session_t), 128);
99 /* Session ID MUST be the same as u64 */
100 CT_ASSERT_EQUAL(fa_full_session_id_size_is_64, sizeof(fa_full_session_id_t), sizeof(u64));
101 #undef CT_ASSERT_EQUAL
104 /* The pool of sessions managed by this worker */
105 fa_session_t *fa_sessions_pool;
106 /* per-worker ACL_N_TIMEOUTS of conn lists */
107 u32 *fa_conn_list_head;
108 u32 *fa_conn_list_tail;
109 /* Vector of expired connections retrieved from lists */
111 /* the earliest next expiry time */
112 u64 next_expiry_time;
113 /* if not zero, look at all the elements until their enqueue timestamp is after below one */
114 u64 requeue_until_time;
115 /* Current time between the checks */
116 u64 current_time_wait_interval;
117 /* Counter of how many sessions we did delete */
118 u64 cnt_deleted_sessions;
119 /* Counter of already deleted sessions being deleted - should not increment unless a bug */
120 u64 cnt_already_deleted_sessions;
121 /* Number of times we requeued a session to a head of the list */
122 u64 cnt_session_timer_restarted;
123 /* swipe up to this enqueue time, rather than following the timeouts */
125 /* bitmap of sw_if_index serviced by this worker */
126 uword *serviced_sw_if_index_bitmap;
127 /* bitmap of sw_if_indices to clear. set by main thread, cleared by worker */
128 uword *pending_clear_sw_if_index_bitmap;
129 /* atomic, indicates that the swipe-deletion of connections is in progress */
130 u32 clear_in_process;
131 /* Interrupt is pending from main thread */
132 int interrupt_is_pending;
134 * Interrupt node on the worker thread sets this if it knows there is
135 * more work to do, but it has to finish to avoid hogging the
138 int interrupt_is_needed;
140 * Set to indicate that the interrupt node wants to get less interrupts
141 * because there is not enough work for the current rate.
143 int interrupt_is_unwanted;
144 } acl_fa_per_worker_data_t;
155 ACL_FA_CLEANER_RESCHEDULE = 1,
156 ACL_FA_CLEANER_DELETE_BY_SW_IF_INDEX,
157 } acl_fa_cleaner_process_event_e;
159 void acl_fa_enable_disable(u32 sw_if_index, int is_input, int enable_disable);