reactor packet I/O & duplicated packet filter & evicted session filter
This commit is contained in:
@@ -1,7 +1,3 @@
|
||||
###############################################################################
|
||||
# session manager
|
||||
###############################################################################
|
||||
|
||||
add_library(session_manager
|
||||
session.cpp
|
||||
session_pool.cpp
|
||||
@@ -11,6 +7,6 @@ add_library(session_manager
|
||||
session_manager.cpp
|
||||
)
|
||||
target_include_directories(session_manager PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||
target_link_libraries(session_manager timeout dupkt_filter eviction_filter log id_generator)
|
||||
target_link_libraries(session_manager timeout duplicated_packet_filter evicted_session_filter log id_generator timestamp)
|
||||
|
||||
add_subdirectory(test)
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "session_private.h"
|
||||
#include "packet_utils.h"
|
||||
|
||||
#define EX_KEY_MAX_LEN 64
|
||||
|
||||
@@ -506,6 +505,8 @@ const char *session_state_to_str(enum session_state state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case SESSION_STATE_INIT:
|
||||
return "init";
|
||||
case SESSION_STATE_OPENING:
|
||||
return "opening";
|
||||
case SESSION_STATE_ACTIVE:
|
||||
|
||||
@@ -37,10 +37,12 @@ enum udp_state
|
||||
|
||||
enum session_state
|
||||
{
|
||||
SESSION_STATE_OPENING = 0x1,
|
||||
SESSION_STATE_ACTIVE = 0x2,
|
||||
SESSION_STATE_CLOSING = 0x3,
|
||||
SESSION_STATE_CLOSED = 0x4,
|
||||
SESSION_STATE_INIT = 0,
|
||||
SESSION_STATE_OPENING = 1,
|
||||
SESSION_STATE_ACTIVE = 2,
|
||||
SESSION_STATE_CLOSING = 3,
|
||||
SESSION_STATE_CLOSED = 4,
|
||||
SESSION_STATE_MAX = 5,
|
||||
};
|
||||
|
||||
enum session_type
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "stellar.h"
|
||||
#include "timestamp.h"
|
||||
#include "session_private.h"
|
||||
#include "session_pool.h"
|
||||
@@ -10,9 +11,8 @@
|
||||
#include "session_manager.h"
|
||||
#include "tcp_utils.h"
|
||||
#include "udp_utils.h"
|
||||
#include "packet_utils.h"
|
||||
#include "dupkt_filter.h"
|
||||
#include "eviction_filter.h"
|
||||
#include "duplicated_packet_filter.h"
|
||||
#include "evicted_session_filter.h"
|
||||
#include "id_generator.h"
|
||||
|
||||
struct session_manager
|
||||
@@ -23,8 +23,8 @@ struct session_manager
|
||||
struct session_timer *sess_timer;
|
||||
struct session_queue *sess_evicted_queue;
|
||||
|
||||
struct dupkt_filter *tcp_dupkt_filter;
|
||||
struct eviction_filter *udp_eviction_filter;
|
||||
struct duplicated_packet_filter *tcp_dup_pkt_filter;
|
||||
struct evicted_session_filter *udp_evc_sess_filter;
|
||||
|
||||
struct session_manager_options opts;
|
||||
|
||||
@@ -58,6 +58,95 @@ struct session_manager
|
||||
uint64_t npkts_hit_udp_evicted; // fast forward
|
||||
};
|
||||
|
||||
enum packet_flag
|
||||
{
|
||||
NONE = 0,
|
||||
TCP_SYN = 1 << 0,
|
||||
TCP_SYN_ACK = 1 << 1,
|
||||
TCP_FIN = 1 << 2,
|
||||
TCP_RST = 1 << 3,
|
||||
TCP_DATA = 1 << 4,
|
||||
UDP_DATA = 1 << 5,
|
||||
TIMEOUT = 1 << 6,
|
||||
};
|
||||
|
||||
struct session_finite_state_machine
|
||||
{
|
||||
int flag_mask;
|
||||
int next_state;
|
||||
} sess_fsm[SESSION_STATE_MAX][8];
|
||||
|
||||
void session_finite_state_machine_init()
|
||||
{
|
||||
// SESSION_STATE_INIT -> SESSION_STATE_OPENING
|
||||
// SESSION_STATE_INIT -> SESSION_STATE_INIT
|
||||
|
||||
sess_fsm[SESSION_STATE_INIT][0].flag_mask = TCP_SYN | TCP_SYN_ACK | UDP_DATA;
|
||||
sess_fsm[SESSION_STATE_INIT][0].next_state = SESSION_STATE_OPENING;
|
||||
|
||||
sess_fsm[SESSION_STATE_INIT][1].flag_mask = NONE;
|
||||
sess_fsm[SESSION_STATE_INIT][1].next_state = SESSION_STATE_INIT;
|
||||
|
||||
// SESSION_STATE_OPENING -> SESSION_STATE_ACTIVE
|
||||
// SESSION_STATE_OPENING -> SESSION_STATE_CLOSING
|
||||
// SESSION_STATE_OPENING -> SESSION_STATE_CLOSED
|
||||
// SESSION_STATE_OPENING -> SESSION_STATE_OPENING
|
||||
|
||||
sess_fsm[SESSION_STATE_OPENING][0].flag_mask = TCP_DATA | UDP_DATA;
|
||||
sess_fsm[SESSION_STATE_OPENING][0].next_state = SESSION_STATE_ACTIVE;
|
||||
|
||||
sess_fsm[SESSION_STATE_OPENING][1].flag_mask = TCP_FIN | TCP_RST;
|
||||
sess_fsm[SESSION_STATE_OPENING][1].next_state = SESSION_STATE_CLOSING;
|
||||
|
||||
sess_fsm[SESSION_STATE_OPENING][2].flag_mask = TIMEOUT;
|
||||
sess_fsm[SESSION_STATE_OPENING][2].next_state = SESSION_STATE_CLOSED;
|
||||
|
||||
sess_fsm[SESSION_STATE_OPENING][3].flag_mask = NONE;
|
||||
sess_fsm[SESSION_STATE_OPENING][3].next_state = SESSION_STATE_OPENING;
|
||||
|
||||
// SESSION_STATE_ACTIVE -> SESSION_STATE_CLOSING
|
||||
// SESSION_STATE_ACTIVE -> SESSION_STATE_ACTIVE
|
||||
|
||||
sess_fsm[SESSION_STATE_ACTIVE][0].flag_mask = TCP_FIN | TCP_RST | TIMEOUT;
|
||||
sess_fsm[SESSION_STATE_ACTIVE][0].next_state = SESSION_STATE_CLOSING;
|
||||
|
||||
sess_fsm[SESSION_STATE_ACTIVE][1].flag_mask = NONE;
|
||||
sess_fsm[SESSION_STATE_ACTIVE][1].next_state = SESSION_STATE_ACTIVE;
|
||||
|
||||
// SESSION_STATE_CLOSING -> SESSION_STATE_CLOSED
|
||||
// SESSION_STATE_CLOSING -> SESSION_STATE_CLOSING
|
||||
|
||||
sess_fsm[SESSION_STATE_CLOSING][0].flag_mask = TIMEOUT;
|
||||
sess_fsm[SESSION_STATE_CLOSING][0].next_state = SESSION_STATE_CLOSED;
|
||||
|
||||
sess_fsm[SESSION_STATE_CLOSING][1].flag_mask = NONE;
|
||||
sess_fsm[SESSION_STATE_CLOSING][1].next_state = SESSION_STATE_CLOSING;
|
||||
|
||||
// SESSION_STATE_CLOSED -> SESSION_STATE_INIT
|
||||
}
|
||||
|
||||
int session_finite_state_machine_run(enum session_state curr_state, int input_pkt_flag)
|
||||
{
|
||||
struct session_finite_state_machine *list = sess_fsm[curr_state];
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int mask = list[i].flag_mask;
|
||||
if (mask & input_pkt_flag)
|
||||
{
|
||||
return list[i].next_state;
|
||||
}
|
||||
|
||||
if (mask == NONE)
|
||||
{
|
||||
return list[i].next_state;
|
||||
}
|
||||
}
|
||||
|
||||
assert(0);
|
||||
|
||||
return curr_state;
|
||||
}
|
||||
|
||||
static inline void tcp_init_timeout_cb(struct session *sess, void *arg);
|
||||
static inline void tcp_handshake_timeout_cb(struct session *sess, void *arg);
|
||||
static inline void tcp_data_timeout_cb(struct session *sess, void *arg);
|
||||
@@ -66,14 +155,13 @@ static inline void tcp_time_wait_timeout_cb(struct session *sess, void *arg);
|
||||
static inline void udp_data_timeout_cb(struct session *sess, void *arg);
|
||||
|
||||
static inline int session_manager_check_options(struct session_manager_options *opts);
|
||||
static inline uint64_t session_manager_alloc_session_id(void);
|
||||
static inline int session_manager_update_tcp_filter(struct session_manager *mgr, struct session *sess, const struct packet *pkt, enum session_dir curr_dir);
|
||||
|
||||
static inline enum session_dir judge_direction_by_tuple6(const struct tuple6 *key);
|
||||
static inline enum session_dir judge_direction_by_session(const struct session *sess, const struct tuple6 *key);
|
||||
|
||||
static inline void session_update_tcp_state(struct session *sess, const struct layer_record *tcp_layer, enum session_dir curr_dir);
|
||||
static inline void session_update_udp_state(struct session *sess, const struct layer_record *udp_layer, enum session_dir curr_dir);
|
||||
static inline void session_update_tcp_state(struct session *sess, const struct layer *tcp_layer, enum session_dir curr_dir);
|
||||
static inline void session_update_udp_state(struct session *sess, const struct layer *udp_layer, enum session_dir curr_dir);
|
||||
|
||||
static inline void session_manager_update_session_state(struct session_manager *mgr, struct session *sess, enum session_state state);
|
||||
static inline void session_manager_update_session_timer(struct session_manager *mgr, struct session *sess, session_expire_cb expire_cb, uint64_t timeout_sec);
|
||||
@@ -251,52 +339,52 @@ static inline int session_manager_check_options(struct session_manager_options *
|
||||
return -1;
|
||||
}
|
||||
|
||||
// TCP duplicate packet filter opts
|
||||
if (opts->tcp_dupkt_filter_enable != 0 && opts->tcp_dupkt_filter_enable != 1)
|
||||
// duplicate packet filter opts
|
||||
if (opts->duplicated_packet_filter_enable != 0 && opts->duplicated_packet_filter_enable != 1)
|
||||
{
|
||||
SESSION_LOG_ERROR("invalid tcp dupkt filter enable, support range: 0-1");
|
||||
SESSION_LOG_ERROR("invalid duplicate packet filter enable, support range: 0-1");
|
||||
return -1;
|
||||
}
|
||||
if (opts->tcp_dupkt_filter_enable)
|
||||
if (opts->duplicated_packet_filter_enable)
|
||||
{
|
||||
if (opts->tcp_dupkt_filter_capacity == 0)
|
||||
if (opts->duplicated_packet_filter_capacity == 0)
|
||||
{
|
||||
SESSION_LOG_ERROR("invalid tcp dupkt filter capacity");
|
||||
SESSION_LOG_ERROR("invalid duplicate packet filter capacity");
|
||||
return -1;
|
||||
}
|
||||
if (opts->tcp_dupkt_filter_timeout < 1 || opts->tcp_dupkt_filter_timeout > 60)
|
||||
if (opts->duplicated_packet_filter_timeout < 1 || opts->duplicated_packet_filter_timeout > 60)
|
||||
{
|
||||
SESSION_LOG_ERROR("invalid tcp dupkt filter timeout, support range: 1-60");
|
||||
SESSION_LOG_ERROR("invalid duplicate packet filter timeout, support range: 1-60");
|
||||
return -1;
|
||||
}
|
||||
if (opts->tcp_dupkt_filter_error_rate < 0 || opts->tcp_dupkt_filter_error_rate > 1)
|
||||
if (opts->duplicated_packet_filter_error_rate < 0 || opts->duplicated_packet_filter_error_rate > 1)
|
||||
{
|
||||
SESSION_LOG_ERROR("invalid tcp dupkt filter error rate, support range: 0-1");
|
||||
SESSION_LOG_ERROR("invalid duplicate packet filter error rate, support range: 0-1");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// UDP eviction filter opts
|
||||
if (opts->udp_eviction_filter_enable != 0 && opts->udp_eviction_filter_enable != 1)
|
||||
// eviction filter opts
|
||||
if (opts->evicted_session_filter_enable != 0 && opts->evicted_session_filter_enable != 1)
|
||||
{
|
||||
SESSION_LOG_ERROR("invalid udp eviction filter enable, support range: 0-1");
|
||||
SESSION_LOG_ERROR("invalid eviction filter enable, support range: 0-1");
|
||||
return -1;
|
||||
}
|
||||
if (opts->udp_eviction_filter_enable)
|
||||
if (opts->evicted_session_filter_enable)
|
||||
{
|
||||
if (opts->udp_eviction_filter_capacity == 0)
|
||||
if (opts->evicted_session_filter_capacity == 0)
|
||||
{
|
||||
SESSION_LOG_ERROR("invalid udp eviction filter capacity");
|
||||
SESSION_LOG_ERROR("invalid eviction filter capacity");
|
||||
return -1;
|
||||
}
|
||||
if (opts->udp_eviction_filter_timeout < 1 || opts->udp_eviction_filter_timeout > 60)
|
||||
if (opts->evicted_session_filter_timeout < 1 || opts->evicted_session_filter_timeout > 60)
|
||||
{
|
||||
SESSION_LOG_ERROR("invalid udp eviction filter timeout, support range: 1-60");
|
||||
SESSION_LOG_ERROR("invalid eviction filter timeout, support range: 1-60");
|
||||
return -1;
|
||||
}
|
||||
if (opts->udp_eviction_filter_error_rate < 0 || opts->udp_eviction_filter_error_rate > 1)
|
||||
if (opts->evicted_session_filter_error_rate < 0 || opts->evicted_session_filter_error_rate > 1)
|
||||
{
|
||||
SESSION_LOG_ERROR("invalid udp eviction filter error rate, support range: 0-1");
|
||||
SESSION_LOG_ERROR("invalid eviction filter error rate, support range: 0-1");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -304,11 +392,6 @@ static inline int session_manager_check_options(struct session_manager_options *
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline uint64_t session_manager_alloc_session_id(void)
|
||||
{
|
||||
return id_generator_get();
|
||||
}
|
||||
|
||||
// return 1: duplicate packet
|
||||
// return 0: not duplicate packet
|
||||
static inline int session_manager_update_tcp_filter(struct session_manager *mgr, struct session *sess, const struct packet *pkt, enum session_dir curr_dir)
|
||||
@@ -338,13 +421,13 @@ static inline int session_manager_update_tcp_filter(struct session_manager *mgr,
|
||||
}
|
||||
|
||||
dupkt_fitler:
|
||||
if (dupkt_filter_lookup(mgr->tcp_dupkt_filter, pkt))
|
||||
if (duplicated_packet_filter_lookup(mgr->tcp_dup_pkt_filter, pkt, timestamp_get_sec()))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dupkt_filter_add(mgr->tcp_dupkt_filter, pkt);
|
||||
duplicated_packet_filter_add(mgr->tcp_dup_pkt_filter, pkt, timestamp_get_sec());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -383,7 +466,7 @@ static inline enum session_dir judge_direction_by_session(const struct session *
|
||||
}
|
||||
}
|
||||
|
||||
static inline void session_update_tcp_state(struct session *sess, const struct layer_record *tcp_layer, enum session_dir curr_dir)
|
||||
static inline void session_update_tcp_state(struct session *sess, const struct layer *tcp_layer, enum session_dir curr_dir)
|
||||
{
|
||||
const struct tcphdr *hdr = (const struct tcphdr *)tcp_layer->hdr_ptr;
|
||||
uint64_t state = session_get_tcp_state(sess);
|
||||
@@ -442,7 +525,7 @@ static inline void session_update_tcp_state(struct session *sess, const struct l
|
||||
session_set_tcp_state(sess, (enum tcp_state)state);
|
||||
}
|
||||
|
||||
static inline void session_update_udp_state(struct session *sess, const struct layer_record *udp_layer, enum session_dir curr_dir)
|
||||
static inline void session_update_udp_state(struct session *sess, const struct layer *udp_layer, enum session_dir curr_dir)
|
||||
{
|
||||
uint64_t state = session_get_udp_state(sess);
|
||||
if (curr_dir == SESSION_DIR_C2S)
|
||||
@@ -589,7 +672,6 @@ static inline void session_manager_update_session_timer(struct session_manager *
|
||||
static inline void session_manager_update_session_base(struct session_manager *mgr, struct session *sess, const struct tuple6 *key, enum session_dir curr_dir)
|
||||
{
|
||||
session_init(sess);
|
||||
session_set_id(sess, session_manager_alloc_session_id());
|
||||
session_set_key(sess, key);
|
||||
session_set_key_dir(sess, curr_dir);
|
||||
if (key->ip_proto == IPPROTO_UDP)
|
||||
@@ -643,7 +725,7 @@ static inline void session_manager_update_udp_to_closing(struct session_manager
|
||||
{
|
||||
session_manager_update_session_state(mgr, sess, SESSION_STATE_CLOSING);
|
||||
session_timer_del_session(mgr->sess_timer, sess);
|
||||
eviction_filter_add(mgr->udp_eviction_filter, session_get0_1st_pkt(sess));
|
||||
evicted_session_filter_add(mgr->udp_evc_sess_filter, session_get0_key(sess), timestamp_get_sec());
|
||||
}
|
||||
|
||||
static inline void session_manager_update_tcp_to_opening(struct session_manager *mgr, struct session *sess, int opening_by_syn)
|
||||
@@ -791,7 +873,7 @@ static inline void session_manager_handle_tcp_on_closing(struct session_manager
|
||||
|
||||
static inline struct session *session_manager_new_tcp_session(struct session_manager *mgr, const struct packet *pkt, const struct tuple6 *key)
|
||||
{
|
||||
const struct layer_record *tcp_layer = packet_get_innermost_layer(pkt, LAYER_TYPE_TCP);
|
||||
const struct layer *tcp_layer = packet_get_innermost_layer(pkt, LAYER_TYPE_TCP);
|
||||
if (tcp_layer == NULL)
|
||||
{
|
||||
mgr->npkts_miss_l4_proto++;
|
||||
@@ -805,7 +887,7 @@ static inline struct session *session_manager_new_tcp_session(struct session_man
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (mgr->tcp_sess_num >= mgr->opts.max_tcp_session_num - 1)
|
||||
if (mgr->tcp_sess_num >= mgr->opts.max_tcp_session_num - RX_BURST_MAX - 1)
|
||||
{
|
||||
if (mgr->opts.tcp_overload_evict_old_sess)
|
||||
{
|
||||
@@ -828,7 +910,7 @@ static inline struct session *session_manager_new_tcp_session(struct session_man
|
||||
}
|
||||
}
|
||||
|
||||
struct session *sess = session_pool_alloc(mgr->sess_pool);
|
||||
struct session *sess = session_pool_pop(mgr->sess_pool);
|
||||
assert(sess);
|
||||
|
||||
enum session_dir curr_dir = tcp_hdr_get_ack_flag(hdr) ? SESSION_DIR_S2C : SESSION_DIR_C2S;
|
||||
@@ -843,20 +925,20 @@ static inline struct session *session_manager_new_tcp_session(struct session_man
|
||||
|
||||
session_manager_update_tcp_to_opening(mgr, sess, curr_dir == SESSION_DIR_C2S);
|
||||
session_table_add_session(mgr->tcp_sess_table, key, sess);
|
||||
dupkt_filter_add(mgr->tcp_dupkt_filter, pkt);
|
||||
duplicated_packet_filter_add(mgr->tcp_dup_pkt_filter, pkt, timestamp_get_sec());
|
||||
|
||||
return sess;
|
||||
}
|
||||
|
||||
static inline struct session *session_manager_new_udp_session(struct session_manager *mgr, const struct packet *pkt, const struct tuple6 *key)
|
||||
{
|
||||
if (eviction_filter_lookup(mgr->udp_eviction_filter, pkt))
|
||||
if (evicted_session_filter_lookup(mgr->udp_evc_sess_filter, key, timestamp_get_sec()))
|
||||
{
|
||||
mgr->npkts_hit_udp_evicted++;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (mgr->udp_sess_num >= mgr->opts.max_udp_session_num - 1)
|
||||
if (mgr->udp_sess_num >= mgr->opts.max_udp_session_num - RX_BURST_MAX - 1)
|
||||
{
|
||||
if (mgr->opts.udp_overload_evict_old_sess)
|
||||
{
|
||||
@@ -879,7 +961,7 @@ static inline struct session *session_manager_new_udp_session(struct session_man
|
||||
}
|
||||
}
|
||||
|
||||
struct session *sess = session_pool_alloc(mgr->sess_pool);
|
||||
struct session *sess = session_pool_pop(mgr->sess_pool);
|
||||
assert(sess);
|
||||
|
||||
enum session_dir curr_dir = judge_direction_by_tuple6(key);
|
||||
@@ -907,7 +989,7 @@ static inline int session_manager_update_tcp_session(struct session_manager *mgr
|
||||
return -1;
|
||||
}
|
||||
|
||||
const struct layer_record *tcp_layer = packet_get_innermost_layer(pkt, LAYER_TYPE_TCP);
|
||||
const struct layer *tcp_layer = packet_get_innermost_layer(pkt, LAYER_TYPE_TCP);
|
||||
if (tcp_layer == NULL)
|
||||
{
|
||||
mgr->npkts_miss_l4_proto++;
|
||||
@@ -930,6 +1012,9 @@ static inline int session_manager_update_tcp_session(struct session_manager *mgr
|
||||
|
||||
switch (sess_state)
|
||||
{
|
||||
case SESSION_STATE_INIT:
|
||||
assert(0);
|
||||
break;
|
||||
case SESSION_STATE_OPENING:
|
||||
session_manager_handle_tcp_on_opening(mgr, sess, tcp_old_state, tcp_curr_state);
|
||||
break;
|
||||
@@ -965,6 +1050,9 @@ static inline int session_manager_update_udp_session(struct session_manager *mgr
|
||||
|
||||
switch (sess_state)
|
||||
{
|
||||
case SESSION_STATE_INIT:
|
||||
assert(0);
|
||||
break;
|
||||
case SESSION_STATE_OPENING:
|
||||
session_manager_update_udp_to_active(mgr, sess);
|
||||
break;
|
||||
@@ -977,6 +1065,8 @@ static inline int session_manager_update_udp_session(struct session_manager *mgr
|
||||
case SESSION_STATE_CLOSED:
|
||||
assert(0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -991,7 +1081,7 @@ static inline void session_manager_evicte_session(struct session_manager *mgr, s
|
||||
|
||||
if (session_get_type(sess) == SESSION_TYPE_UDP)
|
||||
{
|
||||
eviction_filter_add(mgr->udp_eviction_filter, session_get0_1st_pkt(sess));
|
||||
evicted_session_filter_add(mgr->udp_evc_sess_filter, session_get0_key(sess), timestamp_get_sec());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1013,6 +1103,19 @@ struct session_manager *session_manager_new(struct session_manager_options *opts
|
||||
}
|
||||
|
||||
memcpy(&mgr->opts, opts, sizeof(struct session_manager_options));
|
||||
struct duplicated_packet_filter_options dup_pkt_opts = {
|
||||
.enable = mgr->opts.duplicated_packet_filter_enable,
|
||||
.capacity = mgr->opts.duplicated_packet_filter_capacity,
|
||||
.timeout_sec = mgr->opts.duplicated_packet_filter_timeout,
|
||||
.error_rate = mgr->opts.duplicated_packet_filter_error_rate,
|
||||
};
|
||||
struct evicted_session_filter_options evc_sess_opts = {
|
||||
.enable = mgr->opts.evicted_session_filter_enable,
|
||||
.capacity = mgr->opts.evicted_session_filter_capacity,
|
||||
.timeout_sec = mgr->opts.evicted_session_filter_timeout,
|
||||
.error_rate = mgr->opts.evicted_session_filter_error_rate,
|
||||
};
|
||||
|
||||
mgr->sess_pool = session_pool_new(mgr->opts.max_tcp_session_num + mgr->opts.max_udp_session_num);
|
||||
if (mgr->sess_pool == NULL)
|
||||
{
|
||||
@@ -1043,14 +1146,14 @@ struct session_manager *session_manager_new(struct session_manager_options *opts
|
||||
goto error;
|
||||
}
|
||||
|
||||
mgr->tcp_dupkt_filter = dupkt_filter_new(mgr->opts.tcp_dupkt_filter_enable, mgr->opts.tcp_dupkt_filter_capacity, mgr->opts.tcp_dupkt_filter_error_rate, mgr->opts.tcp_dupkt_filter_timeout);
|
||||
if (mgr->tcp_dupkt_filter == NULL)
|
||||
mgr->tcp_dup_pkt_filter = duplicated_packet_filter_new(&dup_pkt_opts, timestamp_get_sec());
|
||||
if (mgr->tcp_dup_pkt_filter == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
mgr->udp_eviction_filter = eviction_filter_new(mgr->opts.udp_eviction_filter_enable, mgr->opts.udp_eviction_filter_capacity, mgr->opts.udp_eviction_filter_error_rate, mgr->opts.udp_eviction_filter_timeout);
|
||||
if (mgr->udp_eviction_filter == NULL)
|
||||
mgr->udp_evc_sess_filter = evicted_session_filter_new(&evc_sess_opts, timestamp_get_sec());
|
||||
if (mgr->udp_evc_sess_filter == NULL)
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
@@ -1085,8 +1188,8 @@ void session_manager_free(struct session_manager *mgr)
|
||||
session_manager_free_session(mgr, sess);
|
||||
}
|
||||
|
||||
eviction_filter_free(mgr->udp_eviction_filter);
|
||||
dupkt_filter_free(mgr->tcp_dupkt_filter);
|
||||
evicted_session_filter_free(mgr->udp_evc_sess_filter);
|
||||
duplicated_packet_filter_free(mgr->tcp_dup_pkt_filter);
|
||||
session_queue_free(mgr->sess_evicted_queue);
|
||||
session_timer_free(mgr->sess_timer);
|
||||
session_table_free(mgr->udp_sess_table);
|
||||
@@ -1173,7 +1276,7 @@ void session_manager_free_session(struct session_manager *mgr, struct session *s
|
||||
session_set0_cur_pkt(sess, NULL);
|
||||
session_set_cur_dir(sess, SESSION_DIR_NONE);
|
||||
session_free(sess);
|
||||
session_pool_free(mgr->sess_pool, sess);
|
||||
session_pool_push(mgr->sess_pool, sess);
|
||||
sess = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,17 +33,17 @@ struct session_manager_options
|
||||
// UDP timeout
|
||||
uint64_t udp_timeout_data; // seconds, Range: 1-15,999,999
|
||||
|
||||
// TCP duplicate packet filter
|
||||
uint8_t tcp_dupkt_filter_enable;
|
||||
uint64_t tcp_dupkt_filter_capacity;
|
||||
uint64_t tcp_dupkt_filter_timeout; // seconds, Range: 1-60
|
||||
double tcp_dupkt_filter_error_rate;
|
||||
// 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
|
||||
double duplicated_packet_filter_error_rate;
|
||||
|
||||
// UDP eviction filter
|
||||
uint8_t udp_eviction_filter_enable;
|
||||
uint64_t udp_eviction_filter_capacity;
|
||||
uint64_t udp_eviction_filter_timeout; // seconds, Range: 1-60
|
||||
double udp_eviction_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
|
||||
double evicted_session_filter_error_rate;
|
||||
};
|
||||
|
||||
struct session_manager;
|
||||
|
||||
@@ -36,7 +36,7 @@ void session_pool_free(struct session_pool *pool)
|
||||
}
|
||||
}
|
||||
|
||||
struct session *session_pool_alloc(struct session_pool *pool)
|
||||
struct session *session_pool_pop(struct session_pool *pool)
|
||||
{
|
||||
if (pool == NULL)
|
||||
{
|
||||
@@ -56,7 +56,7 @@ struct session *session_pool_alloc(struct session_pool *pool)
|
||||
return sess;
|
||||
}
|
||||
|
||||
void session_pool_free(struct session_pool *pool, struct session *sess)
|
||||
void session_pool_push(struct session_pool *pool, struct session *sess)
|
||||
{
|
||||
if (pool == NULL || sess == NULL)
|
||||
{
|
||||
|
||||
@@ -12,8 +12,8 @@ struct session_pool;
|
||||
struct session_pool *session_pool_new(uint64_t count);
|
||||
void session_pool_free(struct session_pool *pool);
|
||||
|
||||
struct session *session_pool_alloc(struct session_pool *pool);
|
||||
void session_pool_free(struct session_pool *pool, struct session *sess);
|
||||
struct session *session_pool_pop(struct session_pool *pool);
|
||||
void session_pool_push(struct session_pool *pool, struct session *sess);
|
||||
uint64_t session_pool_get_count(struct session_pool *pool);
|
||||
|
||||
#ifdef __cpluscplus
|
||||
|
||||
@@ -34,7 +34,7 @@ TEST(TCP_DUPKT_FILTER_ENABLE, SYN_DUP)
|
||||
char tcp_pkt_c2s_syn_retransmission[1500] = {0};
|
||||
memcpy(tcp_pkt_c2s_syn_retransmission, tcp_pkt1_c2s_syn, sizeof(tcp_pkt1_c2s_syn));
|
||||
packet_parse(&pkt, (const char *)tcp_pkt_c2s_syn_retransmission, sizeof(tcp_pkt1_c2s_syn));
|
||||
const struct layer_record *ipv4_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_IPV4);
|
||||
const struct layer *ipv4_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_IPV4);
|
||||
EXPECT_TRUE(ipv4_layer);
|
||||
struct ip *hdr = (struct ip *)ipv4_layer->hdr_ptr;
|
||||
ipv4_hdr_set_ipid(hdr, 0x1234);
|
||||
@@ -86,7 +86,7 @@ TEST(TCP_DUPKT_FILTER_ENABLE, S2C_DUP)
|
||||
char tcp_pkt_s2c_synack_retransmission[1500] = {0};
|
||||
memcpy(tcp_pkt_s2c_synack_retransmission, tcp_pkt2_s2c_syn_ack, sizeof(tcp_pkt2_s2c_syn_ack));
|
||||
packet_parse(&pkt, (const char *)tcp_pkt_s2c_synack_retransmission, sizeof(tcp_pkt2_s2c_syn_ack));
|
||||
const struct layer_record *ipv4_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_IPV4);
|
||||
const struct layer *ipv4_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_IPV4);
|
||||
EXPECT_TRUE(ipv4_layer);
|
||||
struct ip *hdr = (struct ip *)ipv4_layer->hdr_ptr;
|
||||
ipv4_hdr_set_ipid(hdr, 0x1234);
|
||||
@@ -110,7 +110,7 @@ TEST(TCP_DUPKT_FILTER_ENABLE, SKIP_FILTER)
|
||||
struct packet pkt;
|
||||
struct session *sess = NULL;
|
||||
struct session_manager *mgr = NULL;
|
||||
const struct layer_record *ipv4_layer;
|
||||
const struct layer *ipv4_layer;
|
||||
struct ip *hdr;
|
||||
char tcp_pkt_c2s_syn_retransmission[1500] = {0};
|
||||
|
||||
@@ -209,7 +209,7 @@ TEST(TCP_DUPKT_FILTER_DISABLE, C2S_DUPKT)
|
||||
char tcp_pkt_c2s_syn_retransmission[1500] = {0};
|
||||
memcpy(tcp_pkt_c2s_syn_retransmission, tcp_pkt1_c2s_syn, sizeof(tcp_pkt1_c2s_syn));
|
||||
packet_parse(&pkt, (const char *)tcp_pkt_c2s_syn_retransmission, sizeof(tcp_pkt1_c2s_syn));
|
||||
const struct layer_record *ipv4_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_IPV4);
|
||||
const struct layer *ipv4_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_IPV4);
|
||||
EXPECT_TRUE(ipv4_layer);
|
||||
struct ip *hdr = (struct ip *)ipv4_layer->hdr_ptr;
|
||||
ipv4_hdr_set_ipid(hdr, 0x1234);
|
||||
@@ -264,7 +264,7 @@ TEST(TCP_DUPKT_FILTER_DISABLE, S2C_DUP)
|
||||
char tcp_pkt_s2c_synack_retransmission[1500] = {0};
|
||||
memcpy(tcp_pkt_s2c_synack_retransmission, tcp_pkt2_s2c_syn_ack, sizeof(tcp_pkt2_s2c_syn_ack));
|
||||
packet_parse(&pkt, (const char *)tcp_pkt_s2c_synack_retransmission, sizeof(tcp_pkt2_s2c_syn_ack));
|
||||
const struct layer_record *ipv4_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_IPV4);
|
||||
const struct layer *ipv4_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_IPV4);
|
||||
EXPECT_TRUE(ipv4_layer);
|
||||
struct ip *hdr = (struct ip *)ipv4_layer->hdr_ptr;
|
||||
ipv4_hdr_set_ipid(hdr, 0x1234);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
static void overwrite_ipv4_saddr(struct packet *pkt, uint32_t saddr)
|
||||
{
|
||||
const struct layer_record *ipv4_layer = packet_get_innermost_layer(pkt, LAYER_TYPE_IPV4);
|
||||
const struct layer *ipv4_layer = packet_get_innermost_layer(pkt, LAYER_TYPE_IPV4);
|
||||
EXPECT_TRUE(ipv4_layer);
|
||||
struct ip *hdr = (struct ip *)ipv4_layer->hdr_ptr;
|
||||
ipv4_hdr_set_src_addr(hdr, saddr);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
static void overwrite_ipv4_saddr(struct packet *pkt, uint32_t saddr)
|
||||
{
|
||||
const struct layer_record *ipv4_layer = packet_get_innermost_layer(pkt, LAYER_TYPE_IPV4);
|
||||
const struct layer *ipv4_layer = packet_get_innermost_layer(pkt, LAYER_TYPE_IPV4);
|
||||
EXPECT_TRUE(ipv4_layer);
|
||||
struct ip *hdr = (struct ip *)ipv4_layer->hdr_ptr;
|
||||
ipv4_hdr_set_src_addr(hdr, saddr);
|
||||
|
||||
@@ -14,42 +14,42 @@ TEST(SESSION_POOL, POP_PUSH)
|
||||
EXPECT_TRUE(sess_pool != NULL);
|
||||
EXPECT_TRUE(session_pool_get_count(sess_pool) == 3);
|
||||
|
||||
sess1 = session_pool_alloc(sess_pool);
|
||||
sess1 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess1 != NULL);
|
||||
EXPECT_TRUE(session_pool_get_count(sess_pool) == 2);
|
||||
sess2 = session_pool_alloc(sess_pool);
|
||||
sess2 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess2 != NULL);
|
||||
EXPECT_TRUE(session_pool_get_count(sess_pool) == 1);
|
||||
sess3 = session_pool_alloc(sess_pool);
|
||||
sess3 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess3 != NULL);
|
||||
EXPECT_TRUE(session_pool_get_count(sess_pool) == 0);
|
||||
sess4 = session_pool_alloc(sess_pool);
|
||||
sess4 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess4 == NULL);
|
||||
|
||||
session_pool_free(sess_pool, sess1);
|
||||
session_pool_push(sess_pool, sess1);
|
||||
EXPECT_TRUE(session_pool_get_count(sess_pool) == 1);
|
||||
session_pool_free(sess_pool, sess2);
|
||||
session_pool_push(sess_pool, sess2);
|
||||
EXPECT_TRUE(session_pool_get_count(sess_pool) == 2);
|
||||
session_pool_free(sess_pool, sess3);
|
||||
session_pool_push(sess_pool, sess3);
|
||||
EXPECT_TRUE(session_pool_get_count(sess_pool) == 3);
|
||||
|
||||
sess1 = session_pool_alloc(sess_pool);
|
||||
sess1 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess1 != NULL);
|
||||
EXPECT_TRUE(session_pool_get_count(sess_pool) == 2);
|
||||
sess2 = session_pool_alloc(sess_pool);
|
||||
sess2 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess2 != NULL);
|
||||
EXPECT_TRUE(session_pool_get_count(sess_pool) == 1);
|
||||
sess3 = session_pool_alloc(sess_pool);
|
||||
sess3 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess3 != NULL);
|
||||
EXPECT_TRUE(session_pool_get_count(sess_pool) == 0);
|
||||
sess4 = session_pool_alloc(sess_pool);
|
||||
sess4 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess4 == NULL);
|
||||
|
||||
session_pool_free(sess_pool, sess1);
|
||||
session_pool_push(sess_pool, sess1);
|
||||
EXPECT_TRUE(session_pool_get_count(sess_pool) == 1);
|
||||
session_pool_free(sess_pool, sess2);
|
||||
session_pool_push(sess_pool, sess2);
|
||||
EXPECT_TRUE(session_pool_get_count(sess_pool) == 2);
|
||||
session_pool_free(sess_pool, sess3);
|
||||
session_pool_push(sess_pool, sess3);
|
||||
EXPECT_TRUE(session_pool_get_count(sess_pool) == 3);
|
||||
|
||||
session_pool_free(sess_pool);
|
||||
|
||||
@@ -41,7 +41,7 @@ static void session_free_callback(struct session *sess, void *arg)
|
||||
if (sess)
|
||||
{
|
||||
struct session_pool *sess_pool = (struct session_pool *)arg;
|
||||
session_pool_free(sess_pool, sess);
|
||||
session_pool_push(sess_pool, sess);
|
||||
sess = NULL;
|
||||
}
|
||||
}
|
||||
@@ -74,17 +74,17 @@ TEST(SESSION_TABLE, OP_SESSION)
|
||||
session_table_set_freecb(sess_table, session_free_callback, sess_pool);
|
||||
|
||||
// Add
|
||||
sess1 = session_pool_alloc(sess_pool);
|
||||
sess1 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess1 != NULL);
|
||||
session_set_id(sess1, 1);
|
||||
session_set_key(sess1, &tuple_1);
|
||||
|
||||
sess2 = session_pool_alloc(sess_pool);
|
||||
sess2 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess2 != NULL);
|
||||
session_set_id(sess2, 2);
|
||||
session_set_key(sess2, &tuple_2);
|
||||
|
||||
sess3 = session_pool_alloc(sess_pool);
|
||||
sess3 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess3 != NULL);
|
||||
session_set_id(sess3, 3);
|
||||
session_set_key(sess3, &tuple_3);
|
||||
@@ -150,7 +150,7 @@ TEST(SESSION_TABLE, FIND_OLDEST_NEWEST)
|
||||
EXPECT_TRUE(session_table_find_least_recently_unused_session(sess_table) == NULL);
|
||||
EXPECT_TRUE(session_table_find_least_recently_used_session(sess_table) == NULL);
|
||||
|
||||
sess1 = session_pool_alloc(sess_pool);
|
||||
sess1 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess1 != NULL);
|
||||
session_set_id(sess1, 1);
|
||||
session_set_key(sess1, &tuple_1);
|
||||
@@ -158,7 +158,7 @@ TEST(SESSION_TABLE, FIND_OLDEST_NEWEST)
|
||||
EXPECT_TRUE(session_table_find_least_recently_unused_session(sess_table) == sess1);
|
||||
EXPECT_TRUE(session_table_find_least_recently_used_session(sess_table) == sess1);
|
||||
|
||||
sess2 = session_pool_alloc(sess_pool);
|
||||
sess2 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess2 != NULL);
|
||||
session_set_id(sess2, 2);
|
||||
session_set_key(sess2, &tuple_2);
|
||||
@@ -166,7 +166,7 @@ TEST(SESSION_TABLE, FIND_OLDEST_NEWEST)
|
||||
EXPECT_TRUE(session_table_find_least_recently_unused_session(sess_table) == sess1);
|
||||
EXPECT_TRUE(session_table_find_least_recently_used_session(sess_table) == sess2);
|
||||
|
||||
sess3 = session_pool_alloc(sess_pool);
|
||||
sess3 = session_pool_pop(sess_pool);
|
||||
EXPECT_TRUE(sess3 != NULL);
|
||||
session_set_id(sess3, 3);
|
||||
session_set_key(sess3, &tuple_3);
|
||||
|
||||
@@ -193,7 +193,7 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_C2S_RST)
|
||||
char tcp_pkt_c2s_rst[1500] = {0};
|
||||
memcpy(tcp_pkt_c2s_rst, tcp_pkt9_c2s_fin, sizeof(tcp_pkt9_c2s_fin));
|
||||
packet_parse(&pkt, (const char *)tcp_pkt_c2s_rst, sizeof(tcp_pkt9_c2s_fin));
|
||||
const struct layer_record *tcp_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_TCP);
|
||||
const struct layer *tcp_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_TCP);
|
||||
EXPECT_TRUE(tcp_layer);
|
||||
struct tcphdr *hdr = (struct tcphdr *)tcp_layer->hdr_ptr;
|
||||
tcp_hdr_set_flags(hdr, 0);
|
||||
@@ -257,7 +257,7 @@ TEST(TCP_ACTIVE_TO_CLOSING, BY_S2C_RST)
|
||||
char tcp_pkt_s2c_rst[1500] = {0};
|
||||
memcpy(tcp_pkt_s2c_rst, tcp_pkt10_s2c_fin, sizeof(tcp_pkt10_s2c_fin));
|
||||
packet_parse(&pkt, (const char *)tcp_pkt_s2c_rst, sizeof(tcp_pkt10_s2c_fin));
|
||||
const struct layer_record *tcp_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_TCP);
|
||||
const struct layer *tcp_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_TCP);
|
||||
EXPECT_TRUE(tcp_layer);
|
||||
struct tcphdr *hdr = (struct tcphdr *)tcp_layer->hdr_ptr;
|
||||
tcp_hdr_set_flags(hdr, 0);
|
||||
|
||||
@@ -385,7 +385,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYN_RETRANSMISSION)
|
||||
char tcp_pkt_c2s_syn_retransmission[1500] = {0};
|
||||
memcpy(tcp_pkt_c2s_syn_retransmission, tcp_pkt1_c2s_syn, sizeof(tcp_pkt1_c2s_syn));
|
||||
packet_parse(&pkt, (const char *)tcp_pkt_c2s_syn_retransmission, sizeof(tcp_pkt1_c2s_syn));
|
||||
const struct layer_record *ipv4_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_IPV4);
|
||||
const struct layer *ipv4_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_IPV4);
|
||||
EXPECT_TRUE(ipv4_layer);
|
||||
struct ip *hdr = (struct ip *)ipv4_layer->hdr_ptr;
|
||||
ipv4_hdr_set_ipid(hdr, 0x1234);
|
||||
@@ -483,7 +483,7 @@ TEST(TCP_INIT_TO_OPENING, BY_SYNACK_RETRANSMISSION)
|
||||
char tcp_pkt_s2c_synack_retransmission[1500] = {0};
|
||||
memcpy(tcp_pkt_s2c_synack_retransmission, tcp_pkt2_s2c_syn_ack, sizeof(tcp_pkt2_s2c_syn_ack));
|
||||
packet_parse(&pkt, (const char *)tcp_pkt_s2c_synack_retransmission, sizeof(tcp_pkt2_s2c_syn_ack));
|
||||
const struct layer_record *ipv4_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_IPV4);
|
||||
const struct layer *ipv4_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_IPV4);
|
||||
EXPECT_TRUE(ipv4_layer);
|
||||
struct ip *hdr = (struct ip *)ipv4_layer->hdr_ptr;
|
||||
ipv4_hdr_set_ipid(hdr, 0x1234);
|
||||
|
||||
@@ -159,7 +159,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_C2S_RST)
|
||||
char tcp_pkt_c2s_rst[1500] = {0};
|
||||
memcpy(tcp_pkt_c2s_rst, tcp_pkt9_c2s_fin, sizeof(tcp_pkt9_c2s_fin));
|
||||
packet_parse(&pkt, (const char *)tcp_pkt_c2s_rst, sizeof(tcp_pkt9_c2s_fin));
|
||||
const struct layer_record *tcp_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_TCP);
|
||||
const struct layer *tcp_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_TCP);
|
||||
EXPECT_TRUE(tcp_layer);
|
||||
struct tcphdr *hdr = (struct tcphdr *)tcp_layer->hdr_ptr;
|
||||
tcp_hdr_set_flags(hdr, 0);
|
||||
@@ -223,7 +223,7 @@ TEST(TCP_OPENING_TO_CLOSING, BY_S2C_RST)
|
||||
char tcp_pkt_s2c_rst[1500] = {0};
|
||||
memcpy(tcp_pkt_s2c_rst, tcp_pkt10_s2c_fin, sizeof(tcp_pkt10_s2c_fin));
|
||||
packet_parse(&pkt, (const char *)tcp_pkt_s2c_rst, sizeof(tcp_pkt10_s2c_fin));
|
||||
const struct layer_record *tcp_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_TCP);
|
||||
const struct layer *tcp_layer = packet_get_innermost_layer(&pkt, LAYER_TYPE_TCP);
|
||||
EXPECT_TRUE(tcp_layer);
|
||||
struct tcphdr *hdr = (struct tcphdr *)tcp_layer->hdr_ptr;
|
||||
tcp_hdr_set_flags(hdr, 0);
|
||||
|
||||
@@ -35,17 +35,17 @@ struct session_manager_options opts = {
|
||||
// udp timeout
|
||||
.udp_timeout_data = 2,
|
||||
|
||||
// tcp duplicate packet filter
|
||||
.tcp_dupkt_filter_enable = 1,
|
||||
.tcp_dupkt_filter_capacity = 1000,
|
||||
.tcp_dupkt_filter_timeout = 10,
|
||||
.tcp_dupkt_filter_error_rate = 0.0001,
|
||||
// duplicate packet filter
|
||||
.duplicated_packet_filter_enable = 1,
|
||||
.duplicated_packet_filter_capacity = 1000,
|
||||
.duplicated_packet_filter_timeout = 10,
|
||||
.duplicated_packet_filter_error_rate = 0.0001,
|
||||
|
||||
// udp eviction filter
|
||||
.udp_eviction_filter_enable = 1,
|
||||
.udp_eviction_filter_capacity = 1000,
|
||||
.udp_eviction_filter_timeout = 10,
|
||||
.udp_eviction_filter_error_rate = 0.0001,
|
||||
// evicted session filter
|
||||
.evicted_session_filter_enable = 1,
|
||||
.evicted_session_filter_capacity = 1000,
|
||||
.evicted_session_filter_timeout = 10,
|
||||
.evicted_session_filter_error_rate = 0.0001,
|
||||
};
|
||||
|
||||
__attribute__((unused)) static void __session_dispatch(struct session *sess)
|
||||
|
||||
Reference in New Issue
Block a user