Refactor the session manager using session transformation 2D array & Update test case
This commit is contained in:
@@ -23,59 +23,69 @@ struct session_manager_options
|
||||
uint8_t udp_overload_evict_old_sess; // 1: evict old session, 0: bypass new session
|
||||
|
||||
// TCP timeout
|
||||
uint64_t tcp_timeout_init; // seconds, Range: 1-60
|
||||
uint64_t tcp_timeout_handshake; // seconds, Range: 1-60
|
||||
uint64_t tcp_timeout_data; // seconds, Range: 1-15,999,999
|
||||
uint64_t tcp_timeout_half_closed; // seconds, Range: 1-604,800
|
||||
uint64_t tcp_timeout_time_wait; // seconds, Range: 1-600
|
||||
uint64_t tcp_timeout_discard; // seconds, Range: 1-15,999,999
|
||||
uint64_t tcp_timeout_init; // ms, Range: 1-60,000
|
||||
uint64_t tcp_timeout_handshake; // ms, Range: 1-60,000
|
||||
uint64_t tcp_timeout_data; // ms, Range: 1-15,999,999,000
|
||||
uint64_t tcp_timeout_half_closed; // ms, Range: 1-604,800,000
|
||||
uint64_t tcp_timeout_time_wait; // ms, Range: 1-600,000
|
||||
uint64_t tcp_timeout_discard; // ms, Range: 1-15,999,999,000
|
||||
|
||||
// UDP timeout
|
||||
uint64_t udp_timeout_data; // seconds, Range: 1-15,999,999
|
||||
uint64_t udp_timeout_data; // ms, Range: 1-15,999,999,000
|
||||
|
||||
// duplicate packet filter
|
||||
uint8_t duplicated_packet_filter_enable;
|
||||
uint32_t duplicated_packet_filter_capacity;
|
||||
uint32_t duplicated_packet_filter_timeout; // seconds, Range: 1-60
|
||||
uint32_t duplicated_packet_filter_timeout; // ms, Range: 1-60,000
|
||||
double duplicated_packet_filter_error_rate;
|
||||
|
||||
// evicted session filter
|
||||
uint8_t evicted_session_filter_enable;
|
||||
uint32_t evicted_session_filter_capacity;
|
||||
uint32_t evicted_session_filter_timeout; // seconds, Range: 1-60
|
||||
uint32_t evicted_session_filter_timeout; // ms, Range: 1-60,000
|
||||
double evicted_session_filter_error_rate;
|
||||
};
|
||||
|
||||
struct session_stat
|
||||
{
|
||||
uint64_t nr_sess_used;
|
||||
uint64_t nr_sess_init;
|
||||
uint64_t nr_sess_opening;
|
||||
uint64_t nr_sess_active;
|
||||
uint64_t nr_sess_closing;
|
||||
uint64_t nr_sess_closed;
|
||||
|
||||
uint64_t nr_new_sess_evicted;
|
||||
uint64_t nr_old_sess_evicted;
|
||||
};
|
||||
|
||||
struct packet_stat
|
||||
{
|
||||
uint64_t nr_pkts;
|
||||
uint64_t nr_bytes;
|
||||
};
|
||||
|
||||
struct session_manager_stat
|
||||
{
|
||||
uint64_t tcp_sess_num;
|
||||
uint64_t tcp_opening_sess_num;
|
||||
uint64_t tcp_active_sess_num;
|
||||
uint64_t tcp_closing_sess_num;
|
||||
struct packet_stat dup_pkt;
|
||||
struct packet_stat evc_pkt;
|
||||
|
||||
uint64_t udp_sess_num;
|
||||
uint64_t udp_opening_sess_num;
|
||||
uint64_t udp_active_sess_num;
|
||||
uint64_t udp_closing_sess_num;
|
||||
|
||||
uint64_t tcp_overload_evict_old_sess_num;
|
||||
uint64_t tcp_overload_evict_new_sess_num;
|
||||
uint64_t udp_overload_evict_old_sess_num;
|
||||
uint64_t udp_overload_evict_new_sess_num;
|
||||
struct session_stat tcp_sess;
|
||||
struct session_stat udp_sess;
|
||||
};
|
||||
|
||||
struct session_manager;
|
||||
struct session_manager *session_manager_new(struct session_manager_options *opts);
|
||||
struct session_manager *session_manager_new(struct session_manager_options *opts, uint64_t now);
|
||||
void session_manager_free(struct session_manager *mgr);
|
||||
|
||||
struct session *session_manager_new_session(struct session_manager *mgr, const struct packet *pkt);
|
||||
struct session *session_manager_new_session(struct session_manager *mgr, const struct packet *pkt, uint64_t now);
|
||||
void session_manager_free_session(struct session_manager *mgr, struct session *sess);
|
||||
|
||||
struct session *session_manager_lookup_session(struct session_manager *mgr, const struct packet *pkt);
|
||||
int session_manager_update_session(struct session_manager *mgr, struct session *sess, const struct packet *pkt);
|
||||
int session_manager_update_session(struct session_manager *mgr, struct session *sess, const struct packet *pkt, uint64_t now);
|
||||
|
||||
// return session need free by session_manager_free_session()
|
||||
struct session *session_manager_get_expired_session(struct session_manager *mgr);
|
||||
struct session *session_manager_get_expired_session(struct session_manager *mgr, uint64_t now);
|
||||
struct session *session_manager_get_evicted_session(struct session_manager *mgr);
|
||||
|
||||
// return 0: have already timeout session
|
||||
|
||||
Reference in New Issue
Block a user