feat(plugin manager integration): packet and session exdata&mq

This commit is contained in:
yangwei
2024-08-06 20:37:59 +08:00
committed by luwenpeng
parent ee69595720
commit 6786372449
27 changed files with 3438 additions and 508 deletions

View File

@@ -101,6 +101,7 @@ static inline void free_evicted_sessions(struct session_manager *sess_mgr, uint6
if (sess)
{
plugin_ctx = session_get_user_data(sess);
plugin_manager_on_session_closing(sess);
plugin_manager_session_runtime_free((struct plugin_manager_runtime *)plugin_ctx);
session_manager_free_session(sess_mgr, sess);
}
@@ -121,6 +122,7 @@ static inline void free_expired_sessions(struct session_manager *sess_mgr, uint6
if (sess)
{
plugin_ctx = session_get_user_data(sess);
plugin_manager_on_session_closing(sess);
plugin_manager_session_runtime_free((struct plugin_manager_runtime *)plugin_ctx);
session_manager_free_session(sess_mgr, sess);
}
@@ -164,6 +166,11 @@ static void *work_thread(void *arg)
memset(packets, 0, sizeof(packets));
for(int i=0; i<RX_BURST_MAX; i++)
{
packet_set_user_data(&packets[i], (void *)plug_mgr);
}
snprintf(thd_name, sizeof(thd_name), "stellar:%d", thr_idx);
prctl(PR_SET_NAME, (unsigned long long)thd_name, NULL, NULL, NULL);
@@ -200,7 +207,7 @@ static void *work_thread(void *arg)
defraged_pkt = NULL;
pkt = &packets[i];
plugin_manager_on_packet(plug_mgr, pkt);
plugin_manager_on_packet_ingress(plug_mgr, pkt);
if (packet_is_fragment(pkt))
{
defraged_pkt = ip_reassembly_packet(ip_reass, pkt, now_ms);
@@ -211,10 +218,12 @@ static void *work_thread(void *arg)
else
{
pkt = defraged_pkt;
plugin_manager_on_packet(plug_mgr, pkt);
plugin_manager_on_packet_ingress(plug_mgr, pkt);
plugin_manager_on_packet_egress(plug_mgr, pkt);
}
}
pkt = &packets[i];
sess = session_manager_lookup_session_by_packet(sess_mgr, pkt);
if (sess == NULL)
{
@@ -241,6 +250,8 @@ static void *work_thread(void *arg)
fast_path:
plugin_manager_on_session_egress(sess, pkt);
plugin_manager_on_packet_egress(plug_mgr, pkt);
if (sess && session_get_current_state(sess) == SESSION_STATE_DISCARD)
{
packet_set_action(pkt, PACKET_ACTION_DROP);
@@ -567,4 +578,9 @@ void stellar_send_crafted_packet(struct stellar *st, struct packet *pkt)
{
packet_io_inject(packet_io, thr_idx, pkt, 1);
}
}
int stellar_get_worker_thread_num(struct stellar *st)
{
return st->config.pkt_io_opts.nr_threads;
}