refactor: move evicted_session_filter to session dir

This commit is contained in:
luwenpeng
2024-08-16 11:18:16 +08:00
parent f4d437d58b
commit da891dffa7
9 changed files with 52 additions and 66 deletions

View File

@@ -14,9 +14,9 @@
#include "session_pool.h"
#include "session_table.h"
#include "session_timer.h"
#include "session_filter.h"
#include "session_manager.h"
#include "session_transition.h"
#include "evicted_session_filter.h"
#include "duplicated_packet_filter.h"
#define SESSION_LOG_ERROR(format, ...) LOG_ERROR("session", format, ##__VA_ARGS__)
@@ -31,7 +31,7 @@ struct session_manager
struct session_table *udp_sess_table;
struct duplicated_packet_filter *dup_pkt_filter;
struct evicted_session_filter *evicte_sess_filter;
struct session_filter *evicte_sess_filter;
struct session_manager_stat stat;
struct session_manager_options opts;
@@ -479,7 +479,7 @@ static int udp_overload_bypass(struct session_manager *mgr, const struct tuple6
static int evicted_session_bypass(struct session_manager *mgr, const struct tuple6 *key)
{
if (mgr->opts.evicted_session_filter_enable && evicted_session_filter_lookup(mgr->evicte_sess_filter, key, mgr->now_ms))
if (mgr->opts.evicted_session_filter_enable && session_filter_lookup(mgr->evicte_sess_filter, key, mgr->now_ms))
{
mgr->stat.udp_pkts_evctd_bypass++;
return 1;
@@ -639,7 +639,7 @@ static void session_manager_evicte_session(struct session_manager *mgr, struct s
session_table_del(mgr->udp_sess_table, sess);
if (mgr->opts.evicted_session_filter_enable)
{
evicted_session_filter_add(mgr->evicte_sess_filter, session_get_tuple6(sess), mgr->now_ms);
session_filter_add(mgr->evicte_sess_filter, session_get_tuple6(sess), mgr->now_ms);
}
SESS_MGR_STAT_UPDATE(&mgr->stat, curr_state, next_state, udp);
mgr->stat.udp_sess_evicted++;
@@ -908,9 +908,9 @@ struct session_manager *session_manager_new(struct session_manager_options *opts
}
if (mgr->opts.evicted_session_filter_enable)
{
mgr->evicte_sess_filter = evicted_session_filter_new(mgr->opts.evicted_session_filter_capacity,
mgr->opts.evicted_session_filter_timeout,
mgr->opts.evicted_session_filter_error_rate, now_ms);
mgr->evicte_sess_filter = session_filter_new(mgr->opts.evicted_session_filter_capacity,
mgr->opts.evicted_session_filter_timeout,
mgr->opts.evicted_session_filter_error_rate, now_ms);
if (mgr->evicte_sess_filter == NULL)
{
goto error;
@@ -962,7 +962,7 @@ void session_manager_free(struct session_manager *mgr)
}
if (mgr->opts.evicted_session_filter_enable)
{
evicted_session_filter_free(mgr->evicte_sess_filter);
session_filter_free(mgr->evicte_sess_filter);
}
if (mgr->opts.duplicated_packet_filter_enable)
{