perf: 优化通过四元组查询流表的实现(查表前先根据端口预判是否需要翻转四元组)

This commit is contained in:
luwenpeng
2023-11-28 16:36:58 +08:00
parent 699be92862
commit 95abad41b5
4 changed files with 167 additions and 154 deletions

View File

@@ -50,15 +50,15 @@ TEST(STREAM_TABLE, SEARCH_BY_ID)
EXPECT_TRUE(session_table_count(table) == 2);
// TEST Search By Session ID
struct session_node *node = NULL;
node = session_table_search_by_id(table, 1);
EXPECT_TRUE(node != nullptr);
EXPECT_STREQ((const char *)node->value, "HELLO");
node = session_table_search_by_id(table, 2);
EXPECT_TRUE(node != nullptr);
EXPECT_STREQ((const char *)node->value, "WORLD");
node = session_table_search_by_id(table, 3);
EXPECT_TRUE(node == nullptr);
char *val = NULL;
val = (char *)session_table_search_by_id(table, 1);
EXPECT_TRUE(val != nullptr);
EXPECT_STREQ((const char *)val, "HELLO");
val = (char *)session_table_search_by_id(table, 2);
EXPECT_TRUE(val != nullptr);
EXPECT_STREQ((const char *)val, "WORLD");
val = (char *)session_table_search_by_id(table, 3);
EXPECT_TRUE(val == nullptr);
// TEST Destory
session_table_destory(table);
@@ -85,15 +85,15 @@ TEST(STREAM_TABLE, SEARCH_BY_ADDR)
EXPECT_TRUE(session_table_count(table) == 2);
// TEST Search By Session Addr
struct session_node *node = NULL;
node = session_table_search_by_addr(table, &addr1);
EXPECT_TRUE(node != nullptr);
EXPECT_STREQ((const char *)node->value, "HELLO");
node = session_table_search_by_addr(table, &addr2);
EXPECT_TRUE(node != nullptr);
EXPECT_STREQ((const char *)node->value, "WORLD");
node = session_table_search_by_addr(table, &addr3);
EXPECT_TRUE(node == nullptr);
char *val = NULL;
val = (char *)session_table_search_by_addr(table, &addr1);
EXPECT_TRUE(val != nullptr);
EXPECT_STREQ((const char *)val, "HELLO");
val = (char *)session_table_search_by_addr(table, &addr2);
EXPECT_TRUE(val != nullptr);
EXPECT_STREQ((const char *)val, "WORLD");
val = (char *)session_table_search_by_addr(table, &addr3);
EXPECT_TRUE(val == nullptr);
// TEST Destory
session_table_destory(table);
@@ -122,13 +122,13 @@ TEST(STREAM_TABLE, SEARCH_BY_REVERSE_ADDR)
EXPECT_TRUE(session_table_count(table) == 2);
// TEST Search By Session Reverse Addr
struct session_node *node = NULL;
node = session_table_search_by_addr(table, &addr1_reverse);
EXPECT_TRUE(node != nullptr);
EXPECT_STREQ((const char *)node->value, "HELLO");
node = session_table_search_by_addr(table, &addr2_reverse);
EXPECT_TRUE(node != nullptr);
EXPECT_STREQ((const char *)node->value, "WORLD");
char *val = NULL;
val = (char *)session_table_search_by_addr(table, &addr1_reverse);
EXPECT_TRUE(val != nullptr);
EXPECT_STREQ((const char *)val, "HELLO");
val = (char *)session_table_search_by_addr(table, &addr2_reverse);
EXPECT_TRUE(val != nullptr);
EXPECT_STREQ((const char *)val, "WORLD");
// TEST Destory
session_table_destory(table);