rename session_direction to flow_direction

This commit is contained in:
luwenpeng
2024-05-09 14:57:12 +08:00
parent 37d12ebcfc
commit cc380d9271
21 changed files with 610 additions and 556 deletions

View File

@@ -1,4 +1,5 @@
#include <errno.h>
#include <assert.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/prctl.h>
@@ -19,23 +20,27 @@ static void update_session_stat(struct session *sess, struct packet *pkt)
{
enum session_stat stat_pkt;
enum session_stat stat_byte;
enum session_direction dir = session_get_current_direction(sess);
enum flow_direction dir = session_get_flow_direction(sess);
int is_ctrl = packet_is_ctrl(pkt);
if (packet_need_drop(pkt))
switch (packet_get_action(pkt))
{
case PACKET_ACTION_DROP:
stat_pkt = is_ctrl ? STAT_CTRL_PKTS_DROP : STAT_RAW_PKTS_DROP;
stat_byte = is_ctrl ? STAT_CTRL_BYTES_DROP : STAT_RAW_BYTES_DROP;
}
else
{
break;
case PACKET_ACTION_FORWARD:
break;
stat_pkt = is_ctrl ? STAT_CTRL_PKTS_TX : STAT_RAW_PKTS_TX;
stat_byte = is_ctrl ? STAT_CTRL_BYTES_TX : STAT_RAW_BYTES_TX;
default:
assert(0);
break;
}
session_inc_stat(sess, dir, stat_pkt, 1);
session_inc_stat(sess, dir, stat_byte, packet_get_len(pkt));
session_set_current_packet(sess, NULL);
session_set_current_direction(sess, SESSION_DIRECTION_NONE);
session_set_flow_direction(sess, FLOW_DIRECTION_NONE);
}
}
@@ -167,11 +172,15 @@ static void *work_thread(void *arg)
goto fast_path;
}
}
if (packet_get_session_id(pkt) == 0)
{
packet_set_session_id(pkt, session_get_id(sess));
}
plugin_manager_dispatch_session(plug_mgr, sess, pkt);
fast_path:
update_session_stat(sess, pkt);
if (packet_need_drop(pkt))
if (packet_get_action(pkt) == PACKET_ACTION_DROP)
{
if (pkt == defraged_pkt)
{